From 1f2e399ade77070a2d0b82856ad9a3eef96b8676 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 24 May 2018 22:30:44 +1000 Subject: Implement floating --- sway/desktop/xwayland.c | 97 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 77 insertions(+), 20 deletions(-) (limited to 'sway/desktop/xwayland.c') diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 6a99a66a..56cac1bd 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -152,7 +152,9 @@ static uint32_t get_int_prop(struct sway_view *view, enum sway_view_prop prop) { } } -static void configure(struct sway_view *view, double ox, double oy, int width, +// The x and y arguments are output-local for tiled views, and layout +// coordinates for floating views. +static void configure(struct sway_view *view, double x, double y, int width, int height) { struct sway_xwayland_view *xwayland_view = xwayland_view_from_view(view); if (xwayland_view == NULL) { @@ -160,25 +162,33 @@ static void configure(struct sway_view *view, double ox, double oy, int width, } struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; - struct sway_container *output = container_parent(view->swayc, C_OUTPUT); - if (!sway_assert(output, "view must be within tree to set position")) { - return; - } - struct sway_container *root = container_parent(output, C_ROOT); - if (!sway_assert(root, "output must be within tree to set position")) { - return; - } - struct wlr_output_layout *layout = root->sway_root->output_layout; - struct wlr_output_layout_output *loutput = - wlr_output_layout_get(layout, output->sway_output->wlr_output); - if (!sway_assert(loutput, "output must be within layout to set position")) { - return; + double lx, ly; + if (view->swayc->is_floating) { + lx = x; + ly = y; + } else { + struct sway_container *output = container_parent(view->swayc, C_OUTPUT); + if (!sway_assert(output, "view must be within tree to set position")) { + return; + } + struct sway_container *root = container_parent(output, C_ROOT); + if (!sway_assert(root, "output must be within tree to set position")) { + return; + } + struct wlr_output_layout *layout = root->sway_root->output_layout; + struct wlr_output_layout_output *loutput = + wlr_output_layout_get(layout, output->sway_output->wlr_output); + if (!sway_assert(loutput, + "output must be within layout to set position")) { + return; + } + lx = x + loutput->x; + ly = y + loutput->y; } xwayland_view->pending_width = width; xwayland_view->pending_height = height; - wlr_xwayland_surface_configure(xsurface, ox + loutput->x, oy + loutput->y, - width, height); + wlr_xwayland_surface_configure(xsurface, lx, ly, width, height); } static void set_activated(struct sway_view *view, bool activated) { @@ -189,6 +199,14 @@ static void set_activated(struct sway_view *view, bool activated) { wlr_xwayland_surface_activate(surface, activated); } +static void set_maximized(struct sway_view *view, bool maximized) { + if (xwayland_view_from_view(view) == NULL) { + return; + } + struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface; + wlr_xwayland_surface_set_maximized(surface, maximized); +} + static void set_fullscreen(struct sway_view *view, bool fullscreen) { if (xwayland_view_from_view(view) == NULL) { return; @@ -197,6 +215,35 @@ static void set_fullscreen(struct sway_view *view, bool fullscreen) { wlr_xwayland_surface_set_fullscreen(surface, fullscreen); } +static bool wants_floating(struct sway_view *view) { + // TODO: + // We want to return true if the window type contains any of these: + // NET_WM_WINDOW_TYPE_DIALOG + // NET_WM_WINDOW_TYPE_UTILITY + // NET_WM_WINDOW_TYPE_TOOLBAR + // NET_WM_WINDOW_TYPE_SPLASH + // + // We also want to return true if the NET_WM_STATE is MODAL. + // wlroots doesn't appear to provide all this information at the moment. + struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; + uint32_t *atom = xsurface->window_type; + for (size_t i = 0; i < xsurface->window_type_len; ++i) { + wlr_log(L_DEBUG, "xwayland window type %i", *atom); + // TODO: Come up with a better way of doing this + switch (*atom) { + case 36: // NET_WM_WINDOW_TYPE_UTILITY + case 44: // NET_WM_WINDOW_TYPE_SPLASH + case 276: // ? PGP passphrase dialog + case 337: // ? Firefox open file dialog + case 338: // ? Firefox open file dialog + return true; + } + ++atom; + } + + return false; +} + static void _close(struct sway_view *view) { if (xwayland_view_from_view(view) == NULL) { return; @@ -225,7 +272,9 @@ static const struct sway_view_impl view_impl = { .get_int_prop = get_int_prop, .configure = configure, .set_activated = set_activated, + .set_maximized = set_maximized, .set_fullscreen = set_fullscreen, + .wants_floating = wants_floating, .close = _close, .destroy = destroy, }; @@ -234,10 +283,18 @@ static void handle_commit(struct wl_listener *listener, void *data) { struct sway_xwayland_view *xwayland_view = wl_container_of(listener, xwayland_view, commit); struct sway_view *view = &xwayland_view->view; - // NOTE: We intentionally discard the view's desired width here - // TODO: Let floating views do whatever - view_update_size(view, xwayland_view->pending_width, - xwayland_view->pending_height); + struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; + if (!view->natural_width && !view->natural_height) { + view->natural_width = xsurface->width; + view->natural_height = xsurface->height; + } + if (view->swayc && view->swayc->is_floating) { + view_update_size(view, xsurface->width, xsurface->height); + view_update_position(view, xsurface->x, xsurface->y); + } else { + view_update_size(view, xwayland_view->pending_width, + xwayland_view->pending_height); + } view_damage_from(view); } -- cgit v1.2.3 From aaba7642b3e4e9a63aea49412b10221f399b17af Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Fri, 25 May 2018 09:26:23 +1000 Subject: Replace is_floating boolean with function --- include/sway/tree/container.h | 12 ++++++++---- sway/commands/floating.c | 2 +- sway/commands/layout.c | 10 +++------- sway/commands/sticky.c | 2 +- sway/criteria.c | 4 ++-- sway/desktop/output.c | 2 +- sway/desktop/xdg_shell.c | 2 +- sway/desktop/xdg_shell_v6.c | 2 +- sway/desktop/xwayland.c | 4 ++-- sway/tree/container.c | 24 ++++++++++++++++-------- sway/tree/layout.c | 4 ++-- sway/tree/view.c | 12 ++++++------ 12 files changed, 44 insertions(+), 36 deletions(-) (limited to 'sway/desktop/xwayland.c') diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index 906088f0..71935697 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -76,8 +76,6 @@ struct sway_container { enum sway_container_layout layout; enum sway_container_layout prev_layout; - // Saves us from searching the list of children/floating in the parent - bool is_floating; bool is_sticky; // For C_ROOT, this has no meaning @@ -243,8 +241,14 @@ void container_set_floating(struct sway_container *container, bool enable); void container_set_geometry_from_view(struct sway_container *container); /** - * Determine if the given container is itself floating or has a floating - * ancestor. + * Determine if the given container is itself floating. + * This will return false for any descendants of a floating container. + */ +bool container_is_floating(struct sway_container *container); + +/** + * Determine if the given container is itself floating or is a child of a + * floating container. */ bool container_self_or_parent_floating(struct sway_container *container); diff --git a/sway/commands/floating.c b/sway/commands/floating.c index 38a4e1da..46b761da 100644 --- a/sway/commands/floating.c +++ b/sway/commands/floating.c @@ -28,7 +28,7 @@ struct cmd_results *cmd_floating(int argc, char **argv) { } else if (strcasecmp(argv[0], "disable") == 0) { wants_floating = false; } else if (strcasecmp(argv[0], "toggle") == 0) { - wants_floating = !container->is_floating; + wants_floating = !container_is_floating(container); } else { return cmd_results_new(CMD_FAILURE, "floating", "Expected 'floating '"); diff --git a/sway/commands/layout.c b/sway/commands/layout.c index 6b44b001..a009e38f 100644 --- a/sway/commands/layout.c +++ b/sway/commands/layout.c @@ -12,19 +12,15 @@ struct cmd_results *cmd_layout(int argc, char **argv) { } struct sway_container *parent = config->handler_context.current_container; - // TODO: floating - /* - if (parent->is_floating) { - return cmd_results_new(CMD_FAILURE, "layout", "Unable to change layout of floating windows"); + if (container_is_floating(parent)) { + return cmd_results_new(CMD_FAILURE, "layout", + "Unable to change layout of floating windows"); } - */ while (parent->type == C_VIEW) { parent = parent->parent; } - // TODO: stacks and tabs - if (strcasecmp(argv[0], "default") == 0) { parent->layout = parent->prev_layout; if (parent->layout == L_NONE) { diff --git a/sway/commands/sticky.c b/sway/commands/sticky.c index 4bb4bd39..732ccb98 100644 --- a/sway/commands/sticky.c +++ b/sway/commands/sticky.c @@ -17,7 +17,7 @@ struct cmd_results *cmd_sticky(int argc, char **argv) { } struct sway_container *container = config->handler_context.current_container; - if (!container->is_floating) { + if (!container_is_floating(container)) { return cmd_results_new(CMD_FAILURE, "sticky", "Can't set sticky on a tiled container"); } diff --git a/sway/criteria.c b/sway/criteria.c index e97b12f8..a263485a 100644 --- a/sway/criteria.c +++ b/sway/criteria.c @@ -121,13 +121,13 @@ static bool criteria_matches_view(struct criteria *criteria, } if (criteria->floating) { - if (!view->swayc->is_floating) { + if (!container_is_floating(view->swayc)) { return false; } } if (criteria->tiling) { - if (view->swayc->is_floating) { + if (container_is_floating(view->swayc)) { return false; } } diff --git a/sway/desktop/output.c b/sway/desktop/output.c index e91be4d4..4e5d106f 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -1147,7 +1147,7 @@ void output_damage_whole_container(struct sway_output *output, .width = con->width, .height = con->height, }; - if (con->is_floating) { + if (container_is_floating(con)) { box.x -= output->wlr_output->lx; box.y -= output->wlr_output->ly; } diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index e1a73b20..ebb12211 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -185,7 +185,7 @@ static void handle_commit(struct wl_listener *listener, void *data) { view->natural_width = geometry->width; view->natural_height = geometry->height; } - if (view->swayc && view->swayc->is_floating) { + if (view->swayc && container_is_floating(view->swayc)) { view_update_size(view, geometry->width, geometry->height); } else { view_update_size(view, xdg_shell_view->pending_width, diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index 47e4162a..f3df2fe8 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c @@ -184,7 +184,7 @@ static void handle_commit(struct wl_listener *listener, void *data) { view->natural_width = geometry->width; view->natural_height = geometry->height; } - if (view->swayc && view->swayc->is_floating) { + if (view->swayc && container_is_floating(view->swayc)) { view_update_size(view, geometry->width, geometry->height); } else { view_update_size(view, xdg_shell_v6_view->pending_width, diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 56cac1bd..1373d968 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -163,7 +163,7 @@ static void configure(struct sway_view *view, double x, double y, int width, struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; double lx, ly; - if (view->swayc->is_floating) { + if (container_is_floating(view->swayc)) { lx = x; ly = y; } else { @@ -288,7 +288,7 @@ static void handle_commit(struct wl_listener *listener, void *data) { view->natural_width = xsurface->width; view->natural_height = xsurface->height; } - if (view->swayc && view->swayc->is_floating) { + if (view->swayc && container_is_floating(view->swayc)) { view_update_size(view, xsurface->width, xsurface->height); view_update_position(view, xsurface->x, xsurface->y); } else { diff --git a/sway/tree/container.c b/sway/tree/container.c index 17d29d92..c16f1748 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -924,7 +924,7 @@ static void configure_floating_view(struct sway_view *view) { } void container_set_floating(struct sway_container *container, bool enable) { - if (container->is_floating == enable) { + if (container_is_floating(container) == enable) { return; } @@ -935,7 +935,6 @@ void container_set_floating(struct sway_container *container, bool enable) { if (enable) { container_remove_child(container); container_add_child(workspace->sway_workspace->floating, container); - container->is_floating = true; if (container->type == C_VIEW) { configure_floating_view(container->sway_view); } @@ -950,7 +949,6 @@ void container_set_floating(struct sway_container *container, bool enable) { if (container->type == C_VIEW) { view_set_maximized(container->sway_view, true); } - container->is_floating = false; container->is_sticky = false; container_reap_empty_recursive(workspace->sway_workspace->floating); } @@ -962,7 +960,8 @@ void container_set_geometry_from_view(struct sway_container *container) { if (!sway_assert(container->type == C_VIEW, "Expected a view")) { return; } - if (!sway_assert(container->is_floating, "Expected a floating view")) { + if (!sway_assert(container_is_floating(container), + "Expected a floating view")) { return; } struct sway_view *view = container->sway_view; @@ -977,9 +976,18 @@ void container_set_geometry_from_view(struct sway_container *container) { } bool container_self_or_parent_floating(struct sway_container *container) { - while (container->parent->type != C_WORKSPACE - && container->parent->parent->type != C_WORKSPACE) { - container = container->parent; + struct sway_container *workspace = container_parent(container, C_WORKSPACE); + if (!workspace) { + return false; + } + return container_has_anscestor(container, + workspace->sway_workspace->floating); +} + +bool container_is_floating(struct sway_container *container) { + struct sway_container *workspace = container_parent(container, C_WORKSPACE); + if (!workspace) { + return false; } - return container->is_floating; + return container->parent == workspace->sway_workspace->floating; } diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 59ad0b53..28775253 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c @@ -154,7 +154,7 @@ void container_move_to(struct sway_container *container, || container_has_ancestor(container, destination)) { return; } - if (container->is_floating) { + if (container_is_floating(container)) { // TODO return; } @@ -718,7 +718,7 @@ struct sway_container *container_get_in_direction( enum movement_direction dir) { struct sway_container *parent = container->parent; - if (container->is_floating) { + if (container_is_floating(container)) { return NULL; } diff --git a/sway/tree/view.c b/sway/tree/view.c index 651a2be6..8548d9b8 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -458,7 +458,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { } // If we're about to launch the view into the floating container, then // launch it as a tiled view in the root of the workspace instead. - if (focus->is_floating) { + if (container_is_floating(focus)) { focus = focus->parent->parent; } free(criterias); @@ -531,7 +531,7 @@ void view_unmap(struct sway_view *view) { } void view_update_position(struct sway_view *view, double lx, double ly) { - if (!view->swayc->is_floating) { + if (!container_is_floating(view->swayc)) { return; } container_damage_whole(view->swayc); @@ -548,7 +548,7 @@ void view_update_size(struct sway_view *view, int width, int height) { container_damage_whole(view->swayc); view->width = width; view->height = height; - if (view->swayc->is_floating) { + if (container_is_floating(view->swayc)) { container_set_geometry_from_view(view->swayc); } container_damage_whole(view->swayc); @@ -904,15 +904,15 @@ bool view_is_visible(struct sway_view *view) { container_parent(view->swayc, C_WORKSPACE); // Determine if view is nested inside a floating container which is sticky. // A simple floating view will have this ancestry: - // C_VIEW (is_floating=true) -> floating -> workspace + // C_VIEW -> floating -> workspace // A more complex ancestry could be: - // C_VIEW -> C_CONTAINER (tabbed and is_floating) -> floating -> workspace + // C_VIEW -> C_CONTAINER (tabbed) -> floating -> workspace struct sway_container *floater = view->swayc; while (floater->parent->type != C_WORKSPACE && floater->parent->parent->type != C_WORKSPACE) { floater = floater->parent; } - bool is_sticky = floater->is_floating && floater->is_sticky; + bool is_sticky = container_is_floating(floater) && floater->is_sticky; // Check view isn't in a tabbed or stacked container on an inactive tab struct sway_seat *seat = input_manager_current_seat(input_manager); struct sway_container *container = view->swayc; -- cgit v1.2.3 From 02de2a6f65c189bf563cca5b4d3fbc11826ea7f7 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 26 May 2018 09:22:10 +1000 Subject: Rename set_maximized functions to set_tiled --- include/sway/tree/view.h | 4 ++-- sway/desktop/xdg_shell.c | 6 +++--- sway/desktop/xdg_shell_v6.c | 6 +++--- sway/desktop/xwayland.c | 6 +++--- sway/tree/container.c | 2 +- sway/tree/view.c | 8 ++++---- 6 files changed, 16 insertions(+), 16 deletions(-) (limited to 'sway/desktop/xwayland.c') diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 6990e5b6..7a94b2c2 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -32,7 +32,7 @@ struct sway_view_impl { void (*configure)(struct sway_view *view, double ox, double oy, int width, int height); void (*set_activated)(struct sway_view *view, bool activated); - void (*set_maximized)(struct sway_view *view, bool maximized); + void (*set_tiled)(struct sway_view *view, bool tiled); void (*set_fullscreen)(struct sway_view *view, bool fullscreen); bool (*wants_floating)(struct sway_view *view); void (*for_each_surface)(struct sway_view *view, @@ -220,7 +220,7 @@ void view_autoconfigure(struct sway_view *view); void view_set_activated(struct sway_view *view, bool activated); -void view_set_maximized(struct sway_view *view, bool maximized); +void view_set_tiled(struct sway_view *view, bool tiled); void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen); diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index ebb12211..73d9477f 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -111,12 +111,12 @@ static void set_activated(struct sway_view *view, bool activated) { } } -static void set_maximized(struct sway_view *view, bool maximized) { +static void set_tiled(struct sway_view *view, bool tiled) { if (xdg_shell_view_from_view(view) == NULL) { return; } struct wlr_xdg_surface *surface = view->wlr_xdg_surface; - wlr_xdg_toplevel_set_maximized(surface, maximized); + wlr_xdg_toplevel_set_maximized(surface, tiled); } static void set_fullscreen(struct sway_view *view, bool fullscreen) { @@ -168,7 +168,7 @@ static const struct sway_view_impl view_impl = { .get_string_prop = get_string_prop, .configure = configure, .set_activated = set_activated, - .set_maximized = set_maximized, + .set_tiled = set_tiled, .set_fullscreen = set_fullscreen, .wants_floating = wants_floating, .for_each_surface = for_each_surface, diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index f3df2fe8..6c98744c 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c @@ -110,12 +110,12 @@ static void set_activated(struct sway_view *view, bool activated) { } } -static void set_maximized(struct sway_view *view, bool maximized) { +static void set_tiled(struct sway_view *view, bool tiled) { if (xdg_shell_v6_view_from_view(view) == NULL) { return; } struct wlr_xdg_surface_v6 *surface = view->wlr_xdg_surface_v6; - wlr_xdg_toplevel_v6_set_maximized(surface, maximized); + wlr_xdg_toplevel_v6_set_maximized(surface, tiled); } static void set_fullscreen(struct sway_view *view, bool fullscreen) { @@ -167,7 +167,7 @@ static const struct sway_view_impl view_impl = { .get_string_prop = get_string_prop, .configure = configure, .set_activated = set_activated, - .set_maximized = set_maximized, + .set_tiled = set_tiled, .set_fullscreen = set_fullscreen, .wants_floating = wants_floating, .for_each_surface = for_each_surface, diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 1373d968..783868bc 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -199,12 +199,12 @@ static void set_activated(struct sway_view *view, bool activated) { wlr_xwayland_surface_activate(surface, activated); } -static void set_maximized(struct sway_view *view, bool maximized) { +static void set_tiled(struct sway_view *view, bool tiled) { if (xwayland_view_from_view(view) == NULL) { return; } struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface; - wlr_xwayland_surface_set_maximized(surface, maximized); + wlr_xwayland_surface_set_maximized(surface, tiled); } static void set_fullscreen(struct sway_view *view, bool fullscreen) { @@ -272,7 +272,7 @@ static const struct sway_view_impl view_impl = { .get_int_prop = get_int_prop, .configure = configure, .set_activated = set_activated, - .set_maximized = set_maximized, + .set_tiled = set_tiled, .set_fullscreen = set_fullscreen, .wants_floating = wants_floating, .close = _close, diff --git a/sway/tree/container.c b/sway/tree/container.c index 532722e8..12f74e37 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -921,7 +921,7 @@ void container_set_floating(struct sway_container *container, bool enable) { container->width = container->parent->width; container->height = container->parent->height; if (container->type == C_VIEW) { - view_set_maximized(container->sway_view, true); + view_set_tiled(container->sway_view, true); } container->is_sticky = false; container_reap_empty_recursive(workspace->sway_workspace->floating); diff --git a/sway/tree/view.c b/sway/tree/view.c index 65961dd9..3de9879e 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -139,7 +139,7 @@ static void view_autoconfigure_floating(struct sway_view *view) { int ly = output->y + (ws->height - height) / 2; view->border_left = view->border_right = view->border_bottom = true; - view_set_maximized(view, false); + view_set_tiled(view, false); view_configure(view, lx, ly, width, height); } @@ -257,9 +257,9 @@ void view_set_activated(struct sway_view *view, bool activated) { } } -void view_set_maximized(struct sway_view *view, bool maximized) { - if (view->impl->set_maximized) { - view->impl->set_maximized(view, maximized); +void view_set_tiled(struct sway_view *view, bool tiled) { + if (view->impl->set_tiled) { + view->impl->set_tiled(view, tiled); } } -- cgit v1.2.3 From e4e912ea91a5a36d9f17c1730ffbf29707984399 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 26 May 2018 16:26:10 +1000 Subject: Store swayc coordinates as layout-local --- include/sway/tree/container.h | 3 +- include/sway/tree/view.h | 4 +-- sway/desktop/output.c | 83 +++++++++++++------------------------------ sway/desktop/xdg_shell.c | 4 +-- sway/desktop/xdg_shell_v6.c | 4 +-- sway/desktop/xwayland.c | 28 +-------------- sway/input/cursor.c | 14 ++++---- sway/tree/arrange.c | 4 +-- sway/tree/container.c | 42 +++++++++++----------- sway/tree/view.c | 15 ++++---- 10 files changed, 71 insertions(+), 130 deletions(-) (limited to 'sway/desktop/xwayland.c') diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index e4f74b08..4b686040 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -79,8 +79,7 @@ struct sway_container { bool is_sticky; // For C_ROOT, this has no meaning - // For C_OUTPUT, this is the output position in layout coordinates - // For other types, this is the position in output-local coordinates + // For other types, this is the position in layout coordinates // Includes borders double x, y; double width, height; diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 7a94b2c2..65a23902 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -29,7 +29,7 @@ struct sway_view_impl { const char *(*get_string_prop)(struct sway_view *view, enum sway_view_prop prop); uint32_t (*get_int_prop)(struct sway_view *view, enum sway_view_prop prop); - void (*configure)(struct sway_view *view, double ox, double oy, int width, + void (*configure)(struct sway_view *view, double lx, double ly, int width, int height); void (*set_activated)(struct sway_view *view, bool activated); void (*set_tiled)(struct sway_view *view, bool tiled); @@ -48,7 +48,7 @@ struct sway_view { struct sway_container *swayc; // NULL for unmapped views struct wlr_surface *surface; // NULL for unmapped views - // Geometry of the view itself (excludes borders) + // Geometry of the view itself (excludes borders) in layout coordinates double x, y; int width, height; diff --git a/sway/desktop/output.c b/sway/desktop/output.c index fb80fd87..8600d049 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -65,6 +65,13 @@ struct root_geometry { float rotation; }; +struct render_data { + struct root_geometry root_geo; + struct sway_output *output; + pixman_region32_t *damage; + float alpha; +}; + static bool get_surface_box(struct root_geometry *geo, struct sway_output *output, struct wlr_surface *surface, int sx, int sy, struct wlr_box *surface_box) { @@ -116,8 +123,9 @@ static void surface_for_each_surface(struct wlr_surface *surface, static void output_view_for_each_surface(struct sway_view *view, struct root_geometry *geo, wlr_surface_iterator_func_t iterator, void *user_data) { - geo->x = view->x; - geo->y = view->y; + struct render_data *data = user_data; + geo->x = view->x - data->output->wlr_output->lx; + geo->y = view->y - data->output->wlr_output->ly; geo->width = view->surface->current->width; geo->height = view->surface->current->height; geo->rotation = 0; // TODO @@ -160,13 +168,6 @@ static void scale_box(struct wlr_box *box, float scale) { box->height *= scale; } -struct render_data { - struct root_geometry root_geo; - struct sway_output *output; - pixman_region32_t *damage; - float alpha; -}; - static void scissor_output(struct wlr_output *wlr_output, pixman_box32_t *rect) { struct wlr_renderer *renderer = wlr_backend_get_renderer(wlr_output->backend); @@ -275,7 +276,10 @@ static void render_rect(struct wlr_output *wlr_output, struct wlr_renderer *renderer = wlr_backend_get_renderer(wlr_output->backend); - struct wlr_box box = *_box; + struct wlr_box box; + memcpy(&box, _box, sizeof(struct wlr_box)); + box.x -= wlr_output->lx * wlr_output->scale; + box.y -= wlr_output->ly * wlr_output->scale; pixman_region32_t damage; pixman_region32_init(&damage); @@ -450,8 +454,10 @@ static void render_titlebar(struct sway_output *output, wlr_texture_get_size(marks_texture, &texture_box.width, &texture_box.height); texture_box.x = - (x + width - TITLEBAR_H_PADDING) * output_scale - texture_box.width; - texture_box.y = (y + TITLEBAR_V_PADDING) * output_scale; + (x - output->wlr_output->lx + width - TITLEBAR_H_PADDING) + * output_scale - texture_box.width; + texture_box.y = (y - output->wlr_output->ly + TITLEBAR_V_PADDING) + * output_scale; float matrix[9]; wlr_matrix_project_box(matrix, &texture_box, @@ -472,8 +478,10 @@ static void render_titlebar(struct sway_output *output, struct wlr_box texture_box; wlr_texture_get_size(title_texture, &texture_box.width, &texture_box.height); - texture_box.x = (x + TITLEBAR_H_PADDING) * output_scale; - texture_box.y = (y + TITLEBAR_V_PADDING) * output_scale; + texture_box.x = (x - output->wlr_output->lx + TITLEBAR_H_PADDING) + * output_scale; + texture_box.y = (y - output->wlr_output->ly + TITLEBAR_V_PADDING) + * output_scale; float matrix[9]; wlr_matrix_project_box(matrix, &texture_box, @@ -771,28 +779,8 @@ static bool floater_intersects_output(struct sway_container *floater, output->sway_output->wlr_output, &box); } -static void container_translate(struct sway_container *con, int x, int y) { - con->x += x; - con->y += y; - if (con->type == C_VIEW) { - con->sway_view->x += x; - con->sway_view->y += y; - } else { - for (int i = 0; i < con->children->length; ++i) { - struct sway_container *child = con->children->items[i]; - container_translate(child, x, y); - } - } -} - static void render_floating_container(struct sway_output *soutput, pixman_region32_t *damage, struct sway_container *con) { - // We need to translate the floating container's coordinates from layout - // coordinates into output-local coordinates. This needs to happen for all - // children of the floating container too. - struct sway_container *output = container_parent(con, C_OUTPUT); - container_translate(con, -output->x, -output->y); - if (con->type == C_VIEW) { struct sway_view *view = con->sway_view; struct sway_seat *seat = input_manager_current_seat(input_manager); @@ -821,8 +809,6 @@ static void render_floating_container(struct sway_output *soutput, } else { render_container(soutput, damage, con, false); } - // Undo the translation - container_translate(con, output->x, output->y); } static void render_floating(struct sway_output *soutput, @@ -1123,15 +1109,7 @@ static void output_damage_view(struct sway_output *output, void output_damage_from_view(struct sway_output *output, struct sway_view *view) { - if (container_self_or_parent_floating(view->swayc)) { - view->x -= output->swayc->x; - view->y -= output->swayc->y; - output_damage_view(output, view, false); - view->x += output->swayc->x; - view->y += output->swayc->y; - } else { - output_damage_view(output, view, false); - } + output_damage_view(output, view, false); } static void output_damage_whole_container_iterator(struct sway_container *con, @@ -1148,24 +1126,13 @@ static void output_damage_whole_container_iterator(struct sway_container *con, void output_damage_whole_container(struct sway_output *output, struct sway_container *con) { struct wlr_box box = { - .x = con->x, - .y = con->y, + .x = con->x - output->wlr_output->lx, + .y = con->y - output->wlr_output->ly, .width = con->width, .height = con->height, }; - if (container_is_floating(con)) { - box.x -= output->wlr_output->lx; - box.y -= output->wlr_output->ly; - } scale_box(&box, output->wlr_output->scale); wlr_output_damage_add_box(output->damage, &box); - - if (con->type == C_VIEW) { - output_damage_whole_container_iterator(con, output); - } else { - container_descendants(con, C_VIEW, - output_damage_whole_container_iterator, output); - } } static void damage_handle_destroy(struct wl_listener *listener, void *data) { diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 73d9477f..412488b3 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -87,7 +87,7 @@ static const char *get_string_prop(struct sway_view *view, enum sway_view_prop p } } -static void configure(struct sway_view *view, double ox, double oy, int width, +static void configure(struct sway_view *view, double lx, double ly, int width, int height) { struct sway_xdg_shell_view *xdg_shell_view = xdg_shell_view_from_view(view); @@ -98,7 +98,7 @@ static void configure(struct sway_view *view, double ox, double oy, int width, xdg_shell_view->pending_width = width; xdg_shell_view->pending_height = height; wlr_xdg_toplevel_set_size(view->wlr_xdg_surface, width, height); - view_update_position(view, ox, oy); + view_update_position(view, lx, ly); } static void set_activated(struct sway_view *view, bool activated) { diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index 6c98744c..b3653913 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c @@ -86,7 +86,7 @@ static const char *get_string_prop(struct sway_view *view, enum sway_view_prop p } } -static void configure(struct sway_view *view, double ox, double oy, int width, +static void configure(struct sway_view *view, double lx, double ly, int width, int height) { struct sway_xdg_shell_v6_view *xdg_shell_v6_view = xdg_shell_v6_view_from_view(view); @@ -97,7 +97,7 @@ static void configure(struct sway_view *view, double ox, double oy, int width, xdg_shell_v6_view->pending_width = width; xdg_shell_v6_view->pending_height = height; wlr_xdg_toplevel_v6_set_size(view->wlr_xdg_surface_v6, width, height); - view_update_position(view, ox, oy); + view_update_position(view, lx, ly); } static void set_activated(struct sway_view *view, bool activated) { diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 783868bc..fc488162 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -152,9 +152,7 @@ static uint32_t get_int_prop(struct sway_view *view, enum sway_view_prop prop) { } } -// The x and y arguments are output-local for tiled views, and layout -// coordinates for floating views. -static void configure(struct sway_view *view, double x, double y, int width, +static void configure(struct sway_view *view, double lx, double ly, int width, int height) { struct sway_xwayland_view *xwayland_view = xwayland_view_from_view(view); if (xwayland_view == NULL) { @@ -162,30 +160,6 @@ static void configure(struct sway_view *view, double x, double y, int width, } struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; - double lx, ly; - if (container_is_floating(view->swayc)) { - lx = x; - ly = y; - } else { - struct sway_container *output = container_parent(view->swayc, C_OUTPUT); - if (!sway_assert(output, "view must be within tree to set position")) { - return; - } - struct sway_container *root = container_parent(output, C_ROOT); - if (!sway_assert(root, "output must be within tree to set position")) { - return; - } - struct wlr_output_layout *layout = root->sway_root->output_layout; - struct wlr_output_layout_output *loutput = - wlr_output_layout_get(layout, output->sway_output->wlr_output); - if (!sway_assert(loutput, - "output must be within layout to set position")) { - return; - } - lx = x + loutput->x; - ly = y + loutput->y; - } - xwayland_view->pending_width = width; xwayland_view->pending_height = height; wlr_xwayland_surface_configure(xsurface, lx, ly, width, height); diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 96bf574c..16e5427b 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -46,7 +46,7 @@ static struct wlr_surface *layer_surface_at(struct sway_output *output, * location, it is stored in **surface (it may not be a view). */ static struct sway_container *container_at_coords( - struct sway_seat *seat, double x, double y, + struct sway_seat *seat, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy) { // check for unmanaged views first struct wl_list *unmanaged = &root_container.sway_root->xwayland_unmanaged; @@ -55,8 +55,8 @@ static struct sway_container *container_at_coords( struct wlr_xwayland_surface *xsurface = unmanaged_surface->wlr_xwayland_surface; - double _sx = x - unmanaged_surface->lx; - double _sy = y - unmanaged_surface->ly; + double _sx = lx - unmanaged_surface->lx; + double _sy = ly - unmanaged_surface->ly; if (wlr_surface_point_accepts_input(xsurface->surface, _sx, _sy)) { *surface = xsurface->surface; *sx = _sx; @@ -69,12 +69,12 @@ static struct sway_container *container_at_coords( struct wlr_output_layout *output_layout = root_container.sway_root->output_layout; struct wlr_output *wlr_output = wlr_output_layout_output_at( - output_layout, x, y); + output_layout, lx, ly); if (wlr_output == NULL) { return NULL; } struct sway_output *output = wlr_output->data; - double ox = x, oy = y; + double ox = lx, oy = ly; wlr_output_layout_output_coords(output_layout, wlr_output, &ox, &oy); // find the focused workspace on the output for this seat @@ -108,10 +108,10 @@ static struct sway_container *container_at_coords( } struct sway_container *c; - if ((c = floating_container_at(x, y, surface, sx, sy))) { + if ((c = floating_container_at(lx, ly, surface, sx, sy))) { return c; } - if ((c = container_at(ws, ox, oy, surface, sx, sy))) { + if ((c = container_at(ws, lx, ly, surface, sx, sy))) { return c; } diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c index da4f7889..721b557e 100644 --- a/sway/tree/arrange.c +++ b/sway/tree/arrange.c @@ -73,8 +73,8 @@ void arrange_workspace(struct sway_container *workspace) { area->width, area->height, area->x, area->y); workspace->width = area->width; workspace->height = area->height; - workspace->x = area->x; - workspace->y = area->y; + workspace->x = output->x + area->x; + workspace->y = output->y + area->y; wlr_log(L_DEBUG, "Arranging workspace '%s' at %f, %f", workspace->name, workspace->x, workspace->y); arrange_children_of(workspace); diff --git a/sway/tree/container.c b/sway/tree/container.c index 12f74e37..7928ffc3 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -467,14 +467,14 @@ struct sway_container *container_parent(struct sway_container *container, } static struct sway_container *container_at_view(struct sway_container *swayc, - double ox, double oy, + double lx, double ly, struct wlr_surface **surface, double *sx, double *sy) { if (!sway_assert(swayc->type == C_VIEW, "Expected a view")) { return NULL; } struct sway_view *sview = swayc->sway_view; - double view_sx = ox - sview->x; - double view_sy = oy - sview->y; + double view_sx = lx - sview->x; + double view_sy = ly - sview->y; double _sx, _sy; struct wlr_surface *_surface = NULL; @@ -516,18 +516,18 @@ static struct sway_container *container_at_view(struct sway_container *swayc, * container_at for a container with layout L_TABBED. */ static struct sway_container *container_at_tabbed(struct sway_container *parent, - double ox, double oy, + double lx, double ly, struct wlr_surface **surface, double *sx, double *sy) { - if (oy < parent->y || oy > parent->y + parent->height) { + if (ly < parent->y || ly > parent->y + parent->height) { return NULL; } struct sway_seat *seat = input_manager_current_seat(input_manager); // Tab titles int title_height = container_titlebar_height(); - if (oy < parent->y + title_height) { + if (ly < parent->y + title_height) { int tab_width = parent->width / parent->children->length; - int child_index = (ox - parent->x) / tab_width; + int child_index = (lx - parent->x) / tab_width; if (child_index >= parent->children->length) { child_index = parent->children->length - 1; } @@ -538,23 +538,23 @@ static struct sway_container *container_at_tabbed(struct sway_container *parent, // Surfaces struct sway_container *current = seat_get_active_child(seat, parent); - return container_at(current, ox, oy, surface, sx, sy); + return container_at(current, lx, ly, surface, sx, sy); } /** * container_at for a container with layout L_STACKED. */ static struct sway_container *container_at_stacked( - struct sway_container *parent, double ox, double oy, + struct sway_container *parent, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy) { - if (oy < parent->y || oy > parent->y + parent->height) { + if (ly < parent->y || ly > parent->y + parent->height) { return NULL; } struct sway_seat *seat = input_manager_current_seat(input_manager); // Title bars int title_height = container_titlebar_height(); - int child_index = (oy - parent->y) / title_height; + int child_index = (ly - parent->y) / title_height; if (child_index < parent->children->length) { struct sway_container *child = parent->children->items[child_index]; return seat_get_focus_inactive(seat, child); @@ -563,14 +563,14 @@ static struct sway_container *container_at_stacked( // Surfaces struct sway_container *current = seat_get_active_child(seat, parent); - return container_at(current, ox, oy, surface, sx, sy); + return container_at(current, lx, ly, surface, sx, sy); } /** * container_at for a container with layout L_HORIZ or L_VERT. */ static struct sway_container *container_at_linear(struct sway_container *parent, - double ox, double oy, + double lx, double ly, struct wlr_surface **surface, double *sx, double *sy) { for (int i = 0; i < parent->children->length; ++i) { struct sway_container *child = parent->children->items[i]; @@ -580,22 +580,22 @@ static struct sway_container *container_at_linear(struct sway_container *parent, .width = child->width, .height = child->height, }; - if (wlr_box_contains_point(&box, ox, oy)) { - return container_at(child, ox, oy, surface, sx, sy); + if (wlr_box_contains_point(&box, lx, ly)) { + return container_at(child, lx, ly, surface, sx, sy); } } return NULL; } struct sway_container *container_at(struct sway_container *parent, - double ox, double oy, + double lx, double ly, struct wlr_surface **surface, double *sx, double *sy) { if (!sway_assert(parent->type >= C_WORKSPACE, "Expected workspace or deeper")) { return NULL; } if (parent->type == C_VIEW) { - return container_at_view(parent, ox, oy, surface, sx, sy); + return container_at_view(parent, lx, ly, surface, sx, sy); } if (!parent->children->length) { return NULL; @@ -604,11 +604,11 @@ struct sway_container *container_at(struct sway_container *parent, switch (parent->layout) { case L_HORIZ: case L_VERT: - return container_at_linear(parent, ox, oy, surface, sx, sy); + return container_at_linear(parent, lx, ly, surface, sx, sy); case L_TABBED: - return container_at_tabbed(parent, ox, oy, surface, sx, sy); + return container_at_tabbed(parent, lx, ly, surface, sx, sy); case L_STACKED: - return container_at_stacked(parent, ox, oy, surface, sx, sy); + return container_at_stacked(parent, lx, ly, surface, sx, sy); case L_FLOATING: sway_assert(false, "Didn't expect to see floating here"); return NULL; @@ -837,7 +837,7 @@ static size_t get_tree_representation(struct sway_container *parent, char *buffe lenient_strcat(buffer, "S["); break; case L_FLOATING: - strcpy(buffer, "F["); + lenient_strcat(buffer, "F["); break; case L_NONE: lenient_strcat(buffer, "D["); diff --git a/sway/tree/view.c b/sway/tree/view.c index 3de9879e..065d00db 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -119,10 +119,10 @@ const char *view_get_shell(struct sway_view *view) { return "unknown"; } -void view_configure(struct sway_view *view, double ox, double oy, int width, +void view_configure(struct sway_view *view, double lx, double ly, int width, int height) { if (view->impl->configure) { - view->impl->configure(view, ox, oy, width, height); + view->impl->configure(view, lx, ly, width, height); } } @@ -134,9 +134,8 @@ static void view_autoconfigure_floating(struct sway_view *view) { view->natural_width > max_width ? max_width : view->natural_width; int height = view->natural_height > max_height ? max_height : view->natural_height; - struct sway_container *output = ws->parent; - int lx = output->x + (ws->width - width) / 2; - int ly = output->y + (ws->height - height) / 2; + int lx = ws->x + (ws->width - width) / 2; + int ly = ws->y + (ws->height - height) / 2; view->border_left = view->border_right = view->border_bottom = true; view_set_tiled(view, false); @@ -152,8 +151,7 @@ void view_autoconfigure(struct sway_view *view) { struct sway_container *output = container_parent(view->swayc, C_OUTPUT); if (view->is_fullscreen) { - view_configure(view, 0, 0, output->width, output->height); - view->x = view->y = 0; + view_configure(view, output->x, output->y, output->width, output->height); return; } @@ -560,6 +558,9 @@ void view_unmap(struct sway_view *view) { } void view_update_position(struct sway_view *view, double lx, double ly) { + if (view->x == lx && view->y == ly) { + return; + } if (!container_is_floating(view->swayc)) { return; } -- cgit v1.2.3 From 5b1601c2e32b43cbb253fcd396ab9096f51b7e6c Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 26 May 2018 21:33:18 +1000 Subject: Don't let xwayland views set position unless unmanaged --- include/sway/tree/view.h | 1 + sway/desktop/xwayland.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'sway/desktop/xwayland.c') diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 65a23902..5c2f759c 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -137,6 +137,7 @@ struct sway_xwayland_view { struct wl_listener unmap; struct wl_listener destroy; + int pending_lx, pending_ly; int pending_width, pending_height; }; diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index fc488162..f3264ddc 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -160,6 +160,8 @@ static void configure(struct sway_view *view, double lx, double ly, int width, } struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; + xwayland_view->pending_lx = lx; + xwayland_view->pending_ly = ly; xwayland_view->pending_width = width; xwayland_view->pending_height = height; wlr_xwayland_surface_configure(xsurface, lx, ly, width, height); @@ -264,7 +266,8 @@ static void handle_commit(struct wl_listener *listener, void *data) { } if (view->swayc && container_is_floating(view->swayc)) { view_update_size(view, xsurface->width, xsurface->height); - view_update_position(view, xsurface->x, xsurface->y); + view_update_position(view, + xwayland_view->pending_lx, xwayland_view->pending_ly); } else { view_update_size(view, xwayland_view->pending_width, xwayland_view->pending_height); -- cgit v1.2.3 From becceafa7f12f1a1668daca0b27c4102282d9076 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 26 May 2018 23:45:27 +1000 Subject: Remove unfinished wants_floating implementation for xwayland --- sway/desktop/xwayland.c | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'sway/desktop/xwayland.c') diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index f3264ddc..7dc860aa 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -201,22 +201,6 @@ static bool wants_floating(struct sway_view *view) { // // We also want to return true if the NET_WM_STATE is MODAL. // wlroots doesn't appear to provide all this information at the moment. - struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; - uint32_t *atom = xsurface->window_type; - for (size_t i = 0; i < xsurface->window_type_len; ++i) { - wlr_log(L_DEBUG, "xwayland window type %i", *atom); - // TODO: Come up with a better way of doing this - switch (*atom) { - case 36: // NET_WM_WINDOW_TYPE_UTILITY - case 44: // NET_WM_WINDOW_TYPE_SPLASH - case 276: // ? PGP passphrase dialog - case 337: // ? Firefox open file dialog - case 338: // ? Firefox open file dialog - return true; - } - ++atom; - } - return false; } -- cgit v1.2.3 From 97672295ed50d1d6272876c4a3b6b5607cab05c6 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sun, 27 May 2018 23:43:05 +1000 Subject: Don't unmaximize floating views --- include/sway/tree/view.h | 3 --- sway/desktop/xdg_shell.c | 9 --------- sway/desktop/xdg_shell_v6.c | 9 --------- sway/desktop/xwayland.c | 9 --------- sway/tree/container.c | 3 --- sway/tree/view.c | 7 ------- 6 files changed, 40 deletions(-) (limited to 'sway/desktop/xwayland.c') diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 5c2f759c..7362df5c 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -32,7 +32,6 @@ struct sway_view_impl { void (*configure)(struct sway_view *view, double lx, double ly, int width, int height); void (*set_activated)(struct sway_view *view, bool activated); - void (*set_tiled)(struct sway_view *view, bool tiled); void (*set_fullscreen)(struct sway_view *view, bool fullscreen); bool (*wants_floating)(struct sway_view *view); void (*for_each_surface)(struct sway_view *view, @@ -221,8 +220,6 @@ void view_autoconfigure(struct sway_view *view); void view_set_activated(struct sway_view *view, bool activated); -void view_set_tiled(struct sway_view *view, bool tiled); - void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen); void view_set_fullscreen(struct sway_view *view, bool fullscreen); diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 30990f67..7a39a84c 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -111,14 +111,6 @@ static void set_activated(struct sway_view *view, bool activated) { } } -static void set_tiled(struct sway_view *view, bool tiled) { - if (xdg_shell_view_from_view(view) == NULL) { - return; - } - struct wlr_xdg_surface *surface = view->wlr_xdg_surface; - wlr_xdg_toplevel_set_maximized(surface, tiled); -} - static void set_fullscreen(struct sway_view *view, bool fullscreen) { if (xdg_shell_view_from_view(view) == NULL) { return; @@ -170,7 +162,6 @@ static const struct sway_view_impl view_impl = { .get_string_prop = get_string_prop, .configure = configure, .set_activated = set_activated, - .set_tiled = set_tiled, .set_fullscreen = set_fullscreen, .wants_floating = wants_floating, .for_each_surface = for_each_surface, diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index 7cba6e49..b1b8091b 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c @@ -110,14 +110,6 @@ static void set_activated(struct sway_view *view, bool activated) { } } -static void set_tiled(struct sway_view *view, bool tiled) { - if (xdg_shell_v6_view_from_view(view) == NULL) { - return; - } - struct wlr_xdg_surface_v6 *surface = view->wlr_xdg_surface_v6; - wlr_xdg_toplevel_v6_set_maximized(surface, tiled); -} - static void set_fullscreen(struct sway_view *view, bool fullscreen) { if (xdg_shell_v6_view_from_view(view) == NULL) { return; @@ -169,7 +161,6 @@ static const struct sway_view_impl view_impl = { .get_string_prop = get_string_prop, .configure = configure, .set_activated = set_activated, - .set_tiled = set_tiled, .set_fullscreen = set_fullscreen, .wants_floating = wants_floating, .for_each_surface = for_each_surface, diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 7dc860aa..d0fbcaeb 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -175,14 +175,6 @@ static void set_activated(struct sway_view *view, bool activated) { wlr_xwayland_surface_activate(surface, activated); } -static void set_tiled(struct sway_view *view, bool tiled) { - if (xwayland_view_from_view(view) == NULL) { - return; - } - struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface; - wlr_xwayland_surface_set_maximized(surface, tiled); -} - static void set_fullscreen(struct sway_view *view, bool fullscreen) { if (xwayland_view_from_view(view) == NULL) { return; @@ -232,7 +224,6 @@ static const struct sway_view_impl view_impl = { .get_int_prop = get_int_prop, .configure = configure, .set_activated = set_activated, - .set_tiled = set_tiled, .set_fullscreen = set_fullscreen, .wants_floating = wants_floating, .close = _close, diff --git a/sway/tree/container.c b/sway/tree/container.c index 4e041508..9e70da09 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -920,9 +920,6 @@ void container_set_floating(struct sway_container *container, bool enable) { container_add_child(workspace, container); container->width = container->parent->width; container->height = container->parent->height; - if (container->type == C_VIEW) { - view_set_tiled(container->sway_view, true); - } container->is_sticky = false; container_reap_empty_recursive(workspace->sway_workspace->floating); } diff --git a/sway/tree/view.c b/sway/tree/view.c index 30d5c7b4..6e589611 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -138,7 +138,6 @@ static void view_autoconfigure_floating(struct sway_view *view) { int ly = ws->y + (ws->height - height) / 2; view->border_left = view->border_right = view->border_bottom = true; - view_set_tiled(view, false); view_configure(view, lx, ly, width, height); } @@ -255,12 +254,6 @@ void view_set_activated(struct sway_view *view, bool activated) { } } -void view_set_tiled(struct sway_view *view, bool tiled) { - if (view->impl->set_tiled) { - view->impl->set_tiled(view, tiled); - } -} - // Set fullscreen, but without IPC events or arranging windows. void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen) { if (view->is_fullscreen == fullscreen) { -- cgit v1.2.3 From 9119f876552a47716bd317524bf5d786f909e5e5 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Wed, 30 May 2018 10:22:35 +1000 Subject: Fix floating position when view is floated when mapped --- sway/desktop/xdg_shell.c | 22 ++++++++++++---------- sway/desktop/xdg_shell_v6.c | 22 ++++++++++++---------- sway/desktop/xwayland.c | 7 +++---- 3 files changed, 27 insertions(+), 24 deletions(-) (limited to 'sway/desktop/xwayland.c') diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 7a39a84c..32d1e3ca 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -173,17 +173,13 @@ static void handle_commit(struct wl_listener *listener, void *data) { struct sway_xdg_shell_view *xdg_shell_view = wl_container_of(listener, xdg_shell_view, commit); struct sway_view *view = &xdg_shell_view->view; - int width = view->wlr_xdg_surface->geometry.width; - int height = view->wlr_xdg_surface->geometry.height; - if (!width && !height) { - width = view->wlr_xdg_surface->surface->current->width; - height = view->wlr_xdg_surface->surface->current->height; - } - if (!view->natural_width && !view->natural_height) { - view->natural_width = width; - view->natural_height = height; - } if (view->swayc && container_is_floating(view->swayc)) { + int width = view->wlr_xdg_surface->geometry.width; + int height = view->wlr_xdg_surface->geometry.height; + if (!width && !height) { + width = view->wlr_xdg_surface->surface->current->width; + height = view->wlr_xdg_surface->surface->current->height; + } view_update_size(view, width, height); } else { view_update_size(view, xdg_shell_view->pending_width, @@ -216,6 +212,12 @@ static void handle_map(struct wl_listener *listener, void *data) { struct sway_view *view = &xdg_shell_view->view; struct wlr_xdg_surface *xdg_surface = view->wlr_xdg_surface; + view->natural_width = view->wlr_xdg_surface->geometry.width; + view->natural_height = view->wlr_xdg_surface->geometry.height; + if (!view->natural_width && !view->natural_height) { + view->natural_width = view->wlr_xdg_surface->surface->current->width; + view->natural_height = view->wlr_xdg_surface->surface->current->height; + } view_map(view, view->wlr_xdg_surface->surface); xdg_shell_view->commit.notify = handle_commit; diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index b1b8091b..6cb489db 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c @@ -172,17 +172,13 @@ static void handle_commit(struct wl_listener *listener, void *data) { struct sway_xdg_shell_v6_view *xdg_shell_v6_view = wl_container_of(listener, xdg_shell_v6_view, commit); struct sway_view *view = &xdg_shell_v6_view->view; - int width = view->wlr_xdg_surface_v6->geometry.width; - int height = view->wlr_xdg_surface_v6->geometry.height; - if (!width && !height) { - width = view->wlr_xdg_surface_v6->surface->current->width; - height = view->wlr_xdg_surface_v6->surface->current->height; - } - if (!view->natural_width && !view->natural_height) { - view->natural_width = width; - view->natural_height = height; - } if (view->swayc && container_is_floating(view->swayc)) { + int width = view->wlr_xdg_surface_v6->geometry.width; + int height = view->wlr_xdg_surface_v6->geometry.height; + if (!width && !height) { + width = view->wlr_xdg_surface_v6->surface->current->width; + height = view->wlr_xdg_surface_v6->surface->current->height; + } view_update_size(view, width, height); } else { view_update_size(view, xdg_shell_v6_view->pending_width, @@ -215,6 +211,12 @@ static void handle_map(struct wl_listener *listener, void *data) { struct sway_view *view = &xdg_shell_v6_view->view; struct wlr_xdg_surface_v6 *xdg_surface = view->wlr_xdg_surface_v6; + view->natural_width = view->wlr_xdg_surface_v6->geometry.width; + view->natural_height = view->wlr_xdg_surface_v6->geometry.height; + if (!view->natural_width && !view->natural_height) { + view->natural_width = view->wlr_xdg_surface_v6->surface->current->width; + view->natural_height = view->wlr_xdg_surface_v6->surface->current->height; + } view_map(view, view->wlr_xdg_surface_v6->surface); xdg_shell_v6_view->commit.notify = handle_commit; diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index d0fbcaeb..76265ea9 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -235,10 +235,6 @@ static void handle_commit(struct wl_listener *listener, void *data) { wl_container_of(listener, xwayland_view, commit); struct sway_view *view = &xwayland_view->view; struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; - if (!view->natural_width && !view->natural_height) { - view->natural_width = xsurface->width; - view->natural_height = xsurface->height; - } if (view->swayc && container_is_floating(view->swayc)) { view_update_size(view, xsurface->width, xsurface->height); view_update_position(view, @@ -263,6 +259,9 @@ static void handle_map(struct wl_listener *listener, void *data) { struct wlr_xwayland_surface *xsurface = data; struct sway_view *view = &xwayland_view->view; + view->natural_width = xsurface->width; + view->natural_height = xsurface->height; + // Wire up the commit listener here, because xwayland map/unmap can change // the underlying wlr_surface wl_signal_add(&xsurface->surface->events.commit, &xwayland_view->commit); -- cgit v1.2.3 From c9e3a313b440c171ae0bf78eb5b85bf63c3121b9 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 31 May 2018 08:30:07 +1000 Subject: Fix fullscreen position of xwayland views --- sway/desktop/xwayland.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sway/desktop/xwayland.c') diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 76265ea9..75bfb7b2 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -237,12 +237,12 @@ static void handle_commit(struct wl_listener *listener, void *data) { struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; if (view->swayc && container_is_floating(view->swayc)) { view_update_size(view, xsurface->width, xsurface->height); - view_update_position(view, - xwayland_view->pending_lx, xwayland_view->pending_ly); } else { view_update_size(view, xwayland_view->pending_width, xwayland_view->pending_height); } + view_update_position(view, + xwayland_view->pending_lx, xwayland_view->pending_ly); view_damage_from(view); } -- cgit v1.2.3