From 1515c56caef9ee670d9ddb6dd748f2ce9d5523f0 Mon Sep 17 00:00:00 2001 From: emersion Date: Mon, 11 Mar 2019 11:21:18 +0100 Subject: [PATCH] output: remove lx, ly Fixes https://github.com/swaywm/wlroots/issues/1610 --- include/wlr/types/wlr_output.h | 4 ---- rootston/output.c | 28 +++++++++++++++++++++------- rootston/xdg_shell.c | 13 ++++++------- rootston/xdg_shell_v6.c | 13 ++++++------- types/wlr_output.c | 18 +----------------- types/wlr_output_layout.c | 4 ---- types/wlr_output_management_v1.c | 2 -- 7 files changed, 34 insertions(+), 48 deletions(-) diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index 84791b2d..8590b8ad 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -111,9 +111,6 @@ struct wlr_output { struct wlr_output_cursor *hardware_cursor; int software_cursor_locks; // number of locks forcing software cursors - // the output position in layout space reported to clients - int32_t lx, ly; - struct wl_listener display_destroy; void *data; @@ -173,7 +170,6 @@ bool wlr_output_set_custom_mode(struct wlr_output *output, int32_t width, int32_t height, int32_t refresh); void wlr_output_set_transform(struct wlr_output *output, enum wl_output_transform transform); -void wlr_output_set_position(struct wlr_output *output, int32_t lx, int32_t ly); void wlr_output_set_scale(struct wlr_output *output, float scale); void wlr_output_set_subpixel(struct wlr_output *output, enum wl_output_subpixel subpixel); void wlr_output_destroy(struct wlr_output *output); diff --git a/rootston/output.c b/rootston/output.c index 54d27d0d..92a969f7 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -122,12 +122,15 @@ void output_surface_for_each_surface(struct roots_output *output, void output_view_for_each_surface(struct roots_output *output, struct roots_view *view, roots_surface_iterator_func_t iterator, void *user_data) { + struct wlr_box *output_box = + wlr_output_layout_get_box(output->desktop->layout, output->wlr_output); + struct surface_iterator_data data = { .user_iterator = iterator, .user_data = user_data, .output = output, - .ox = view->box.x - output->wlr_output->lx, - .oy = view->box.y - output->wlr_output->ly, + .ox = view->box.x - output_box->x, + .oy = view->box.y - output_box->y, .width = view->box.width, .height = view->box.height, .rotation = view->rotation, @@ -140,11 +143,14 @@ void output_view_for_each_surface(struct roots_output *output, void output_xwayland_children_for_each_surface( struct roots_output *output, struct wlr_xwayland_surface *surface, roots_surface_iterator_func_t iterator, void *user_data) { + struct wlr_box *output_box = + wlr_output_layout_get_box(output->desktop->layout, output->wlr_output); + struct wlr_xwayland_surface *child; wl_list_for_each(child, &surface->children, parent_link) { if (child->mapped) { - double ox = child->x - output->wlr_output->lx; - double oy = child->y - output->wlr_output->ly; + double ox = child->x - output_box->x; + double oy = child->y - output_box->y; output_surface_for_each_surface(output, child->surface, ox, oy, iterator, user_data); } @@ -187,6 +193,9 @@ void output_layer_for_each_surface(struct roots_output *output, void output_drag_icons_for_each_surface(struct roots_output *output, struct roots_input *input, roots_surface_iterator_func_t iterator, void *user_data) { + struct wlr_box *output_box = + wlr_output_layout_get_box(output->desktop->layout, output->wlr_output); + struct roots_seat *seat; wl_list_for_each(seat, &input->seats, link) { struct roots_drag_icon *drag_icon = seat->drag_icon; @@ -194,8 +203,8 @@ void output_drag_icons_for_each_surface(struct roots_output *output, continue; } - double ox = drag_icon->x - output->wlr_output->lx; - double oy = drag_icon->y - output->wlr_output->ly; + double ox = drag_icon->x - output_box->x; + double oy = drag_icon->y - output_box->y; output_surface_for_each_surface(output, drag_icon->wlr_drag_icon->surface, ox, oy, iterator, user_data); } @@ -430,7 +439,12 @@ static void update_output_manager_config(struct roots_desktop *desktop) { struct roots_output *output; wl_list_for_each(output, &desktop->outputs, link) { - wlr_output_configuration_head_v1_create(config, output->wlr_output); + struct wlr_output_configuration_head_v1 *config_head = + wlr_output_configuration_head_v1_create(config, output->wlr_output); + struct wlr_box *output_box = wlr_output_layout_get_box( + output->desktop->layout, output->wlr_output); + config_head->state.x = output_box->x; + config_head->state.y = output_box->y; } wlr_output_manager_v1_set_configuration(desktop->output_manager_v1, config); diff --git a/rootston/xdg_shell.c b/rootston/xdg_shell.c index de9830e6..60222750 100644 --- a/rootston/xdg_shell.c +++ b/rootston/xdg_shell.c @@ -87,21 +87,20 @@ static void popup_unconstrain(struct roots_xdg_popup *popup) { struct wlr_output *output = wlr_output_layout_output_at(layout, dest_x, dest_y); - if (output == NULL) { return; } - int width = 0, height = 0; - wlr_output_effective_resolution(output, &width, &height); + struct wlr_box *output_box = + wlr_output_layout_get_box(view->desktop->layout, output); // the output box expressed in the coordinate system of the toplevel parent // of the popup struct wlr_box output_toplevel_sx_box = { - .x = output->lx - view->box.x, - .y = output->ly - view->box.y, - .width = width, - .height = height + .x = output_box->x - view->box.x, + .y = output_box->y - view->box.y, + .width = output_box->width, + .height = output_box->height, }; wlr_xdg_popup_unconstrain_from_box( diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c index cb2a9eab..b80ea38d 100644 --- a/rootston/xdg_shell_v6.c +++ b/rootston/xdg_shell_v6.c @@ -87,21 +87,20 @@ static void popup_unconstrain(struct roots_xdg_popup_v6 *popup) { struct wlr_output *output = wlr_output_layout_output_at(layout, dest_x, dest_y); - if (output == NULL) { return; } - int width = 0, height = 0; - wlr_output_effective_resolution(output, &width, &height); + struct wlr_box *output_box = + wlr_output_layout_get_box(view->desktop->layout, output); // the output box expressed in the coordinate system of the toplevel parent // of the popup struct wlr_box output_toplevel_sx_box = { - .x = output->lx - view->box.x, - .y = output->ly - view->box.y, - .width = width, - .height = height + .x = output_box->x - view->box.x, + .y = output_box->y - view->box.y, + .width = output_box->width, + .height = output_box->height, }; wlr_xdg_popup_v6_unconstrain_from_box(popup->wlr_popup, &output_toplevel_sx_box); diff --git a/types/wlr_output.c b/types/wlr_output.c index a8c86771..0c7003a7 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -23,7 +23,7 @@ static void output_send_to_resource(struct wl_resource *resource) { struct wlr_output *output = wlr_output_from_resource(resource); const uint32_t version = wl_resource_get_version(resource); if (version >= WL_OUTPUT_GEOMETRY_SINCE_VERSION) { - wl_output_send_geometry(resource, output->lx, output->ly, + wl_output_send_geometry(resource, 0, 0, output->phys_width, output->phys_height, output->subpixel, output->make, output->model, output->transform); } @@ -223,22 +223,6 @@ void wlr_output_set_transform(struct wlr_output *output, wlr_signal_emit_safe(&output->events.transform, output); } -void wlr_output_set_position(struct wlr_output *output, int32_t lx, - int32_t ly) { - if (lx == output->lx && ly == output->ly) { - return; - } - - output->lx = lx; - output->ly = ly; - - // TODO: only send geometry and done - struct wl_resource *resource; - wl_resource_for_each(resource, &output->resources) { - output_send_to_resource(resource); - } -} - void wlr_output_set_scale(struct wlr_output *output, float scale) { if (output->scale == scale) { return; diff --git a/types/wlr_output_layout.c b/types/wlr_output_layout.c index c0f7134e..d602e55c 100644 --- a/types/wlr_output_layout.c +++ b/types/wlr_output_layout.c @@ -127,10 +127,6 @@ static void output_layout_reconfigure(struct wlr_output_layout *layout) { max_x += box->width; } - wl_list_for_each(l_output, &layout->outputs, link) { - wlr_output_set_position(l_output->output, l_output->x, l_output->y); - } - wlr_signal_emit_safe(&layout->events.change, layout); } diff --git a/types/wlr_output_management_v1.c b/types/wlr_output_management_v1.c index 9c78a7f2..6f968a63 100644 --- a/types/wlr_output_management_v1.c +++ b/types/wlr_output_management_v1.c @@ -122,8 +122,6 @@ struct wlr_output_configuration_head_v1 * config_head->state.custom_mode.width = output->width; config_head->state.custom_mode.height = output->height; config_head->state.custom_mode.refresh = output->refresh; - config_head->state.x = output->lx; - config_head->state.y = output->ly; config_head->state.transform = output->transform; config_head->state.scale = output->scale; return config_head;