mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	Merge branch 'hidpi'
This commit is contained in:
		
						commit
						425713b837
					
				
					 14 changed files with 134 additions and 40 deletions
				
			
		| 
						 | 
					@ -70,6 +70,8 @@ void handle_tablet_tool_axis(struct libinput_event *event,
 | 
				
			||||||
		wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_WHEEL;
 | 
							wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_WHEEL;
 | 
				
			||||||
		wlr_event.wheel_delta = libinput_event_tablet_tool_get_wheel_delta(tevent);
 | 
							wlr_event.wheel_delta = libinput_event_tablet_tool_get_wheel_delta(tevent);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						wlr_log(L_DEBUG, "Tablet tool axis event %d @ %f,%f",
 | 
				
			||||||
 | 
								wlr_event.updated_axes, wlr_event.x_mm, wlr_event.y_mm);
 | 
				
			||||||
	wl_signal_emit(&wlr_dev->tablet_tool->events.axis, &wlr_event);
 | 
						wl_signal_emit(&wlr_dev->tablet_tool->events.axis, &wlr_event);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -249,7 +249,7 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) {
 | 
				
			||||||
	wlr_output_init(&output->wlr_output, &backend->backend, &output_impl);
 | 
						wlr_output_init(&output->wlr_output, &backend->backend, &output_impl);
 | 
				
			||||||
	struct wlr_output *wlr_output = &output->wlr_output;
 | 
						struct wlr_output *wlr_output = &output->wlr_output;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wlr_output_update_size(wlr_output, 640, 480);
 | 
						wlr_output_update_size(wlr_output, 1280, 720);
 | 
				
			||||||
	strncpy(wlr_output->make, "wayland", sizeof(wlr_output->make));
 | 
						strncpy(wlr_output->make, "wayland", sizeof(wlr_output->make));
 | 
				
			||||||
	strncpy(wlr_output->model, "wayland", sizeof(wlr_output->model));
 | 
						strncpy(wlr_output->model, "wayland", sizeof(wlr_output->model));
 | 
				
			||||||
	snprintf(wlr_output->name, sizeof(wlr_output->name), "WL-%d",
 | 
						snprintf(wlr_output->name, sizeof(wlr_output->name), "WL-%d",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,6 +8,7 @@ struct output_config {
 | 
				
			||||||
	char *name;
 | 
						char *name;
 | 
				
			||||||
	enum wl_output_transform transform;
 | 
						enum wl_output_transform transform;
 | 
				
			||||||
	int x, y;
 | 
						int x, y;
 | 
				
			||||||
 | 
						int scale;
 | 
				
			||||||
	struct wl_list link;
 | 
						struct wl_list link;
 | 
				
			||||||
	struct {
 | 
						struct {
 | 
				
			||||||
		int width, height;
 | 
							int width, height;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -71,7 +71,7 @@ struct roots_view {
 | 
				
			||||||
	// configure event from the xdg_shell
 | 
						// configure event from the xdg_shell
 | 
				
			||||||
	// If not then this should follow the typical type/impl pattern we use
 | 
						// If not then this should follow the typical type/impl pattern we use
 | 
				
			||||||
	// elsewhere
 | 
						// elsewhere
 | 
				
			||||||
	void (*get_size)(struct roots_view *view, struct wlr_box *box);
 | 
						void (*get_size)(const struct roots_view *view, struct wlr_box *box);
 | 
				
			||||||
	void (*activate)(struct roots_view *view, bool active);
 | 
						void (*activate)(struct roots_view *view, bool active);
 | 
				
			||||||
	void (*move)(struct roots_view *view, double x, double y);
 | 
						void (*move)(struct roots_view *view, double x, double y);
 | 
				
			||||||
	void (*resize)(struct roots_view *view, uint32_t width, uint32_t height);
 | 
						void (*resize)(struct roots_view *view, uint32_t width, uint32_t height);
 | 
				
			||||||
| 
						 | 
					@ -80,7 +80,7 @@ struct roots_view {
 | 
				
			||||||
	void (*close)(struct roots_view *view);
 | 
						void (*close)(struct roots_view *view);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void view_get_size(struct roots_view *view, struct wlr_box *box);
 | 
					void view_get_size(const struct roots_view *view, struct wlr_box *box);
 | 
				
			||||||
void view_activate(struct roots_view *view, bool active);
 | 
					void view_activate(struct roots_view *view, bool active);
 | 
				
			||||||
void view_move(struct roots_view *view, double x, double y);
 | 
					void view_move(struct roots_view *view, double x, double y);
 | 
				
			||||||
void view_resize(struct roots_view *view, uint32_t width, uint32_t height);
 | 
					void view_resize(struct roots_view *view, uint32_t width, uint32_t height);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,7 +14,7 @@ struct wlr_output_mode {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct wlr_output_cursor {
 | 
					struct wlr_output_cursor {
 | 
				
			||||||
	struct wlr_output *output;
 | 
						struct wlr_output *output;
 | 
				
			||||||
	int32_t x, y;
 | 
						double x, y;
 | 
				
			||||||
	bool enabled;
 | 
						bool enabled;
 | 
				
			||||||
	uint32_t width, height;
 | 
						uint32_t width, height;
 | 
				
			||||||
	int32_t hotspot_x, hotspot_y;
 | 
						int32_t hotspot_x, hotspot_y;
 | 
				
			||||||
| 
						 | 
					@ -95,7 +95,8 @@ bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor,
 | 
				
			||||||
	int32_t hotspot_x, int32_t hotspot_y);
 | 
						int32_t hotspot_x, int32_t hotspot_y);
 | 
				
			||||||
void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor,
 | 
					void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor,
 | 
				
			||||||
	struct wlr_surface *surface, int32_t hotspot_x, int32_t hotspot_y);
 | 
						struct wlr_surface *surface, int32_t hotspot_x, int32_t hotspot_y);
 | 
				
			||||||
bool wlr_output_cursor_move(struct wlr_output_cursor *cursor, int x, int y);
 | 
					bool wlr_output_cursor_move(struct wlr_output_cursor *cursor,
 | 
				
			||||||
 | 
						double x, double y);
 | 
				
			||||||
void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor);
 | 
					void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,10 +1,10 @@
 | 
				
			||||||
#ifndef WLR_TYPES_WLR_SURFACE_H
 | 
					#ifndef WLR_TYPES_WLR_SURFACE_H
 | 
				
			||||||
#define WLR_TYPES_WLR_SURFACE_H
 | 
					#define WLR_TYPES_WLR_SURFACE_H
 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <wayland-server.h>
 | 
					#include <wayland-server.h>
 | 
				
			||||||
#include <pixman.h>
 | 
					#include <pixman.h>
 | 
				
			||||||
#include <stdint.h>
 | 
					#include <stdint.h>
 | 
				
			||||||
#include <stdbool.h>
 | 
					#include <stdbool.h>
 | 
				
			||||||
 | 
					#include <wlr/types/wlr_output.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct wlr_frame_callback {
 | 
					struct wlr_frame_callback {
 | 
				
			||||||
	struct wl_resource *resource;
 | 
						struct wl_resource *resource;
 | 
				
			||||||
| 
						 | 
					@ -135,4 +135,11 @@ struct wlr_surface *wlr_surface_get_main_surface(struct wlr_surface *surface);
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct wlr_subsurface *wlr_surface_subsurface_at(struct wlr_surface *surface,
 | 
					struct wlr_subsurface *wlr_surface_subsurface_at(struct wlr_surface *surface,
 | 
				
			||||||
		double sx, double sy, double *sub_x, double *sub_y);
 | 
							double sx, double sy, double *sub_x, double *sub_y);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void wlr_surface_send_enter(struct wlr_surface *surface,
 | 
				
			||||||
 | 
							struct wlr_output *output);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void wlr_surface_send_leave(struct wlr_surface *surface,
 | 
				
			||||||
 | 
							struct wlr_output *output);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -220,6 +220,7 @@ static int config_ini_handler(void *user, const char *section, const char *name,
 | 
				
			||||||
			oc = calloc(1, sizeof(struct output_config));
 | 
								oc = calloc(1, sizeof(struct output_config));
 | 
				
			||||||
			oc->name = strdup(output_name);
 | 
								oc->name = strdup(output_name);
 | 
				
			||||||
			oc->transform = WL_OUTPUT_TRANSFORM_NORMAL;
 | 
								oc->transform = WL_OUTPUT_TRANSFORM_NORMAL;
 | 
				
			||||||
 | 
								oc->scale = 1;
 | 
				
			||||||
			wl_list_insert(&config->outputs, &oc->link);
 | 
								wl_list_insert(&config->outputs, &oc->link);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -227,6 +228,9 @@ static int config_ini_handler(void *user, const char *section, const char *name,
 | 
				
			||||||
			oc->x = strtol(value, NULL, 10);
 | 
								oc->x = strtol(value, NULL, 10);
 | 
				
			||||||
		} else if (strcmp(name, "y") == 0) {
 | 
							} else if (strcmp(name, "y") == 0) {
 | 
				
			||||||
			oc->y = strtol(value, NULL, 10);
 | 
								oc->y = strtol(value, NULL, 10);
 | 
				
			||||||
 | 
							} else if (strcmp(name, "scale") == 0) {
 | 
				
			||||||
 | 
								oc->scale = strtol(value, NULL, 10);
 | 
				
			||||||
 | 
								assert(oc->scale >= 1);
 | 
				
			||||||
		} else if (strcmp(name, "rotate") == 0) {
 | 
							} else if (strcmp(name, "rotate") == 0) {
 | 
				
			||||||
			if (strcmp(value, "normal") == 0) {
 | 
								if (strcmp(value, "normal") == 0) {
 | 
				
			||||||
				oc->transform = WL_OUTPUT_TRANSFORM_NORMAL;
 | 
									oc->transform = WL_OUTPUT_TRANSFORM_NORMAL;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -383,11 +383,20 @@ static void handle_touch_motion(struct wl_listener *listener, void *data) {
 | 
				
			||||||
static void handle_tool_axis(struct wl_listener *listener, void *data) {
 | 
					static void handle_tool_axis(struct wl_listener *listener, void *data) {
 | 
				
			||||||
	struct roots_input *input = wl_container_of(listener, input, cursor_tool_axis);
 | 
						struct roots_input *input = wl_container_of(listener, input, cursor_tool_axis);
 | 
				
			||||||
	struct wlr_event_tablet_tool_axis *event = data;
 | 
						struct wlr_event_tablet_tool_axis *event = data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X) &&
 | 
						if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X) &&
 | 
				
			||||||
			(event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) {
 | 
								(event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) {
 | 
				
			||||||
		wlr_cursor_warp_absolute(input->cursor, event->device,
 | 
							wlr_cursor_warp_absolute(input->cursor, event->device,
 | 
				
			||||||
			event->x_mm / event->width_mm, event->y_mm / event->height_mm);
 | 
								event->x_mm / event->width_mm, event->y_mm / event->height_mm);
 | 
				
			||||||
		cursor_update_position(input, event->time_msec);
 | 
							cursor_update_position(input, event->time_msec);
 | 
				
			||||||
 | 
						} else if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X)) {
 | 
				
			||||||
 | 
							wlr_cursor_warp_absolute(input->cursor, event->device,
 | 
				
			||||||
 | 
								event->x_mm / event->width_mm, -1);
 | 
				
			||||||
 | 
							cursor_update_position(input, event->time_msec);
 | 
				
			||||||
 | 
						} else if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) {
 | 
				
			||||||
 | 
							wlr_cursor_warp_absolute(input->cursor, event->device,
 | 
				
			||||||
 | 
								-1, event->y_mm / event->height_mm);
 | 
				
			||||||
 | 
							cursor_update_position(input, event->time_msec);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,14 +35,49 @@ void view_destroy(struct roots_view *view) {
 | 
				
			||||||
	free(view);
 | 
						free(view);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void view_get_size(struct roots_view *view, struct wlr_box *box) {
 | 
					void view_get_size(const struct roots_view *view, struct wlr_box *box) {
 | 
				
			||||||
	if (view->get_size) {
 | 
						if (view->get_size) {
 | 
				
			||||||
		view->get_size(view, box);
 | 
							view->get_size(view, box);
 | 
				
			||||||
		return;
 | 
						} else {
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	box->x = box->y = 0;
 | 
					 | 
				
			||||||
		box->width = view->wlr_surface->current->width;
 | 
							box->width = view->wlr_surface->current->width;
 | 
				
			||||||
		box->height = view->wlr_surface->current->height;
 | 
							box->height = view->wlr_surface->current->height;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						box->x = view->x;
 | 
				
			||||||
 | 
						box->y = view->y;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void view_update_output(const struct roots_view *view,
 | 
				
			||||||
 | 
							const struct wlr_box *before) {
 | 
				
			||||||
 | 
						struct roots_desktop *desktop = view->desktop;
 | 
				
			||||||
 | 
						struct roots_output *output;
 | 
				
			||||||
 | 
						struct wlr_box box;
 | 
				
			||||||
 | 
						view_get_size(view, &box);
 | 
				
			||||||
 | 
						wl_list_for_each(output, &desktop->outputs, link) {
 | 
				
			||||||
 | 
							bool intersected = before->x != -1 && wlr_output_layout_intersects(
 | 
				
			||||||
 | 
									desktop->layout, output->wlr_output,
 | 
				
			||||||
 | 
									before->x, before->y, before->x + before->width,
 | 
				
			||||||
 | 
									before->y + before->height);
 | 
				
			||||||
 | 
							bool intersects = wlr_output_layout_intersects(
 | 
				
			||||||
 | 
									desktop->layout, output->wlr_output,
 | 
				
			||||||
 | 
									view->x, view->y, view->x + box.width, view->y + box.height);
 | 
				
			||||||
 | 
							if (intersected && !intersects) {
 | 
				
			||||||
 | 
								wlr_surface_send_leave(view->wlr_surface, output->wlr_output);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if (!intersected && intersects) {
 | 
				
			||||||
 | 
								wlr_surface_send_enter(view->wlr_surface, output->wlr_output);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void view_move(struct roots_view *view, double x, double y) {
 | 
				
			||||||
 | 
						struct wlr_box before;
 | 
				
			||||||
 | 
						view_get_size(view, &before);
 | 
				
			||||||
 | 
						if (view->move) {
 | 
				
			||||||
 | 
							view->move(view, x, y);
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							view->x = x;
 | 
				
			||||||
 | 
							view->y = y;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void view_activate(struct roots_view *view, bool activate) {
 | 
					void view_activate(struct roots_view *view, bool activate) {
 | 
				
			||||||
| 
						 | 
					@ -51,20 +86,13 @@ void view_activate(struct roots_view *view, bool activate) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void view_move(struct roots_view *view, double x, double y) {
 | 
					 | 
				
			||||||
	if (view->move) {
 | 
					 | 
				
			||||||
		view->move(view, x, y);
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	view->x = x;
 | 
					 | 
				
			||||||
	view->y = y;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void view_resize(struct roots_view *view, uint32_t width, uint32_t height) {
 | 
					void view_resize(struct roots_view *view, uint32_t width, uint32_t height) {
 | 
				
			||||||
 | 
						struct wlr_box before;
 | 
				
			||||||
 | 
						view_get_size(view, &before);
 | 
				
			||||||
	if (view->resize) {
 | 
						if (view->resize) {
 | 
				
			||||||
		view->resize(view, width, height);
 | 
							view->resize(view, width, height);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						view_update_output(view, &before);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void view_move_resize(struct roots_view *view, double x, double y,
 | 
					void view_move_resize(struct roots_view *view, double x, double y,
 | 
				
			||||||
| 
						 | 
					@ -85,8 +113,8 @@ void view_close(struct roots_view *view) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool view_center(struct roots_view *view) {
 | 
					bool view_center(struct roots_view *view) {
 | 
				
			||||||
	struct wlr_box size;
 | 
						struct wlr_box box;
 | 
				
			||||||
	view_get_size(view, &size);
 | 
						view_get_size(view, &box);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct roots_desktop *desktop = view->desktop;
 | 
						struct roots_desktop *desktop = view->desktop;
 | 
				
			||||||
	struct wlr_cursor *cursor = desktop->server->input->cursor;
 | 
						struct wlr_cursor *cursor = desktop->server->input->cursor;
 | 
				
			||||||
| 
						 | 
					@ -109,19 +137,20 @@ bool view_center(struct roots_view *view) {
 | 
				
			||||||
	int width, height;
 | 
						int width, height;
 | 
				
			||||||
	wlr_output_effective_resolution(output, &width, &height);
 | 
						wlr_output_effective_resolution(output, &width, &height);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	double view_x = (double)(width - size.width) / 2 + l_output->x;
 | 
						double view_x = (double)(width - box.width) / 2 + l_output->x;
 | 
				
			||||||
	double view_y = (double)(height - size.height) / 2 + l_output->y;
 | 
						double view_y = (double)(height - box.height) / 2 + l_output->y;
 | 
				
			||||||
 | 
					 | 
				
			||||||
	view_move(view, view_x, view_y);
 | 
						view_move(view, view_x, view_y);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return true;
 | 
						return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void view_setup(struct roots_view *view) {
 | 
					void view_setup(struct roots_view *view) {
 | 
				
			||||||
	view_center(view);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	struct roots_input *input = view->desktop->server->input;
 | 
						struct roots_input *input = view->desktop->server->input;
 | 
				
			||||||
 | 
						view_center(view);
 | 
				
			||||||
	set_view_focus(input, view->desktop, view);
 | 
						set_view_focus(input, view->desktop, view);
 | 
				
			||||||
 | 
						struct wlr_box before;
 | 
				
			||||||
 | 
						view_get_size(view, &before);
 | 
				
			||||||
 | 
						view_update_output(view, &before);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void view_teardown(struct roots_view *view) {
 | 
					void view_teardown(struct roots_view *view) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,10 +20,13 @@ static void render_surface(struct wlr_surface *surface,
 | 
				
			||||||
		struct roots_desktop *desktop, struct wlr_output *wlr_output,
 | 
							struct roots_desktop *desktop, struct wlr_output *wlr_output,
 | 
				
			||||||
		struct timespec *when, double lx, double ly, float rotation) {
 | 
							struct timespec *when, double lx, double ly, float rotation) {
 | 
				
			||||||
	if (surface->texture->valid) {
 | 
						if (surface->texture->valid) {
 | 
				
			||||||
		int width = surface->current->buffer_width;
 | 
							float scale_factor = (float)wlr_output->scale / surface->current->scale;
 | 
				
			||||||
		int height = surface->current->buffer_height;
 | 
							int width = surface->current->buffer_width * scale_factor;
 | 
				
			||||||
 | 
							int height = surface->current->buffer_height * scale_factor;
 | 
				
			||||||
		double ox = lx, oy = ly;
 | 
							double ox = lx, oy = ly;
 | 
				
			||||||
		wlr_output_layout_output_coords(desktop->layout, wlr_output, &ox, &oy);
 | 
							wlr_output_layout_output_coords(desktop->layout, wlr_output, &ox, &oy);
 | 
				
			||||||
 | 
							ox *= wlr_output->scale;
 | 
				
			||||||
 | 
							oy *= wlr_output->scale;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (wlr_output_layout_intersects(desktop->layout, wlr_output,
 | 
							if (wlr_output_layout_intersects(desktop->layout, wlr_output,
 | 
				
			||||||
				lx, ly, lx + width, ly + height)) {
 | 
									lx, ly, lx + width, ly + height)) {
 | 
				
			||||||
| 
						 | 
					@ -32,15 +35,22 @@ static void render_surface(struct wlr_surface *surface,
 | 
				
			||||||
			float translate_origin[16];
 | 
								float translate_origin[16];
 | 
				
			||||||
			wlr_matrix_translate(&translate_origin,
 | 
								wlr_matrix_translate(&translate_origin,
 | 
				
			||||||
				(int)ox + width / 2, (int)oy + height / 2, 0);
 | 
									(int)ox + width / 2, (int)oy + height / 2, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			float rotate[16];
 | 
								float rotate[16];
 | 
				
			||||||
			wlr_matrix_rotate(&rotate, rotation);
 | 
								wlr_matrix_rotate(&rotate, rotation);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			float translate_center[16];
 | 
								float translate_center[16];
 | 
				
			||||||
			wlr_matrix_translate(&translate_center, -width / 2, -height / 2, 0);
 | 
								wlr_matrix_translate(&translate_center, -width / 2, -height / 2, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								float scale[16];
 | 
				
			||||||
 | 
								wlr_matrix_scale(&scale, width, height, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			float transform[16];
 | 
								float transform[16];
 | 
				
			||||||
			wlr_matrix_mul(&translate_origin, &rotate, &transform);
 | 
								wlr_matrix_mul(&translate_origin, &rotate, &transform);
 | 
				
			||||||
			wlr_matrix_mul(&transform, &translate_center, &transform);
 | 
								wlr_matrix_mul(&transform, &translate_center, &transform);
 | 
				
			||||||
			wlr_surface_get_matrix(surface, &matrix,
 | 
								wlr_matrix_mul(&transform, &scale, &transform);
 | 
				
			||||||
					&wlr_output->transform_matrix, &transform);
 | 
								wlr_matrix_mul(&wlr_output->transform_matrix, &transform, &matrix);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			wlr_render_with_matrix(desktop->server->renderer,
 | 
								wlr_render_with_matrix(desktop->server->renderer,
 | 
				
			||||||
					surface->texture, &matrix);
 | 
										surface->texture, &matrix);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -217,6 +227,7 @@ void output_add_notify(struct wl_listener *listener, void *data) {
 | 
				
			||||||
		if (output_config->mode.width) {
 | 
							if (output_config->mode.width) {
 | 
				
			||||||
			set_mode(wlr_output, output_config);
 | 
								set_mode(wlr_output, output_config);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							wlr_output->scale = output_config->scale;
 | 
				
			||||||
		wlr_output_transform(wlr_output, output_config->transform);
 | 
							wlr_output_transform(wlr_output, output_config->transform);
 | 
				
			||||||
		wlr_output_layout_add(desktop->layout,
 | 
							wlr_output_layout_add(desktop->layout,
 | 
				
			||||||
				wlr_output, output_config->x, output_config->y);
 | 
									wlr_output, output_config->x, output_config->y);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,7 +10,7 @@
 | 
				
			||||||
#include "rootston/server.h"
 | 
					#include "rootston/server.h"
 | 
				
			||||||
#include "rootston/input.h"
 | 
					#include "rootston/input.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void get_size(struct roots_view *view, struct wlr_box *box) {
 | 
					static void get_size(const struct roots_view *view, struct wlr_box *box) {
 | 
				
			||||||
	assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
 | 
						assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
 | 
				
			||||||
	struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6;
 | 
						struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6;
 | 
				
			||||||
	// TODO: surf->geometry can be NULL
 | 
						// TODO: surf->geometry can be NULL
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -261,8 +261,8 @@ void wlr_cursor_warp_absolute(struct wlr_cursor *cur,
 | 
				
			||||||
		mapping = wlr_output_layout_get_box(cur->state->layout, NULL);
 | 
							mapping = wlr_output_layout_get_box(cur->state->layout, NULL);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	double x = mapping->width * x_mm + mapping->x;
 | 
						double x = x_mm > 0 ? mapping->width * x_mm + mapping->x : cur->x;
 | 
				
			||||||
	double y = mapping->height * y_mm + mapping->y;
 | 
						double y = y_mm > 0 ? mapping->height * y_mm + mapping->y : cur->y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wlr_cursor_warp_unchecked(cur, x, y);
 | 
						wlr_cursor_warp_unchecked(cur, x, y);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -231,7 +231,6 @@ void wlr_output_destroy(struct wlr_output *output) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void wlr_output_effective_resolution(struct wlr_output *output,
 | 
					void wlr_output_effective_resolution(struct wlr_output *output,
 | 
				
			||||||
		int *width, int *height) {
 | 
							int *width, int *height) {
 | 
				
			||||||
	// TODO: Scale factor
 | 
					 | 
				
			||||||
	if (output->transform % 2 == 1) {
 | 
						if (output->transform % 2 == 1) {
 | 
				
			||||||
		*width = output->height;
 | 
							*width = output->height;
 | 
				
			||||||
		*height = output->width;
 | 
							*height = output->width;
 | 
				
			||||||
| 
						 | 
					@ -239,6 +238,8 @@ void wlr_output_effective_resolution(struct wlr_output *output,
 | 
				
			||||||
		*width = output->width;
 | 
							*width = output->width;
 | 
				
			||||||
		*height = output->height;
 | 
							*height = output->height;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						*width /= output->scale;
 | 
				
			||||||
 | 
						*height /= output->scale;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void wlr_output_make_current(struct wlr_output *output) {
 | 
					void wlr_output_make_current(struct wlr_output *output) {
 | 
				
			||||||
| 
						 | 
					@ -269,6 +270,8 @@ static void output_cursor_render(struct wlr_output_cursor *cursor) {
 | 
				
			||||||
	output_box.x = output_box.y = 0;
 | 
						output_box.x = output_box.y = 0;
 | 
				
			||||||
	wlr_output_effective_resolution(cursor->output, &output_box.width,
 | 
						wlr_output_effective_resolution(cursor->output, &output_box.width,
 | 
				
			||||||
		&output_box.height);
 | 
							&output_box.height);
 | 
				
			||||||
 | 
						output_box.width *= cursor->output->scale;
 | 
				
			||||||
 | 
						output_box.height *= cursor->output->scale;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct wlr_box cursor_box;
 | 
						struct wlr_box cursor_box;
 | 
				
			||||||
	output_cursor_get_box(cursor, &cursor_box);
 | 
						output_cursor_get_box(cursor, &cursor_box);
 | 
				
			||||||
| 
						 | 
					@ -471,7 +474,10 @@ void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool wlr_output_cursor_move(struct wlr_output_cursor *cursor, int x, int y) {
 | 
					bool wlr_output_cursor_move(struct wlr_output_cursor *cursor,
 | 
				
			||||||
 | 
							double x, double y) {
 | 
				
			||||||
 | 
						x *= cursor->output->scale;
 | 
				
			||||||
 | 
						y *= cursor->output->scale;
 | 
				
			||||||
	cursor->x = x;
 | 
						cursor->x = x;
 | 
				
			||||||
	cursor->y = y;
 | 
						cursor->y = y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -483,7 +489,7 @@ bool wlr_output_cursor_move(struct wlr_output_cursor *cursor, int x, int y) {
 | 
				
			||||||
	if (!cursor->output->impl->move_cursor) {
 | 
						if (!cursor->output->impl->move_cursor) {
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return cursor->output->impl->move_cursor(cursor->output, x, y);
 | 
						return cursor->output->impl->move_cursor(cursor->output, (int)x, (int)y);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct wlr_output_cursor *wlr_output_cursor_create(struct wlr_output *output) {
 | 
					struct wlr_output_cursor *wlr_output_cursor_create(struct wlr_output *output) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -649,8 +649,8 @@ void wlr_surface_get_matrix(struct wlr_surface *surface,
 | 
				
			||||||
		float (*matrix)[16],
 | 
							float (*matrix)[16],
 | 
				
			||||||
		const float (*projection)[16],
 | 
							const float (*projection)[16],
 | 
				
			||||||
		const float (*transform)[16]) {
 | 
							const float (*transform)[16]) {
 | 
				
			||||||
	int width = surface->texture->width / surface->current->scale;
 | 
						int width = surface->texture->width;
 | 
				
			||||||
	int height = surface->texture->height / surface->current->scale;
 | 
						int height = surface->texture->height;
 | 
				
			||||||
	float scale[16];
 | 
						float scale[16];
 | 
				
			||||||
	wlr_matrix_identity(matrix);
 | 
						wlr_matrix_identity(matrix);
 | 
				
			||||||
	if (transform) {
 | 
						if (transform) {
 | 
				
			||||||
| 
						 | 
					@ -905,3 +905,27 @@ struct wlr_subsurface *wlr_surface_subsurface_at(struct wlr_surface *surface,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return NULL;
 | 
						return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void wlr_surface_send_enter(struct wlr_surface *surface,
 | 
				
			||||||
 | 
							struct wlr_output *output) {
 | 
				
			||||||
 | 
						struct wl_client *client = wl_resource_get_client(surface->resource);
 | 
				
			||||||
 | 
						struct wl_resource *resource;
 | 
				
			||||||
 | 
						wl_resource_for_each(resource, &output->wl_resources) {
 | 
				
			||||||
 | 
							if (client == wl_resource_get_client(resource)) {
 | 
				
			||||||
 | 
								wl_surface_send_enter(surface->resource, resource);
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void wlr_surface_send_leave(struct wlr_surface *surface,
 | 
				
			||||||
 | 
							struct wlr_output *output) {
 | 
				
			||||||
 | 
						struct wl_client *client = wl_resource_get_client(surface->resource);
 | 
				
			||||||
 | 
						struct wl_resource *resource;
 | 
				
			||||||
 | 
						wl_resource_for_each(resource, &output->wl_resources) {
 | 
				
			||||||
 | 
							if (client == wl_resource_get_client(resource)) {
 | 
				
			||||||
 | 
								wl_surface_send_leave(surface->resource, resource);
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue