From c7c301c17ff1e16ab8f08266c3acb4c230169d1d Mon Sep 17 00:00:00 2001 From: Rouven Czerwinski Date: Sat, 13 Oct 2018 21:01:02 +0200 Subject: [PATCH] view: move arrange_workspace into view_map For mouse_warping cursor to correctly work on newly spawned containers, the workspace needs to be arranged before the cursor is warped. The shell functions each implement their own fullscreen and arrange checks, move them into the view_map function and pass their states via boolean arguments. Fixes #2819 --- include/sway/tree/view.h | 3 ++- sway/desktop/xdg_shell.c | 20 ++++++-------------- sway/desktop/xdg_shell_v6.c | 20 ++++---------------- sway/desktop/xwayland.c | 12 +----------- sway/tree/view.c | 26 +++++++++++++++++++++----- 5 files changed, 34 insertions(+), 47 deletions(-) diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 870ef2e0ed..dc1f0b023b 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -329,7 +329,8 @@ void view_destroy(struct sway_view *view); void view_begin_destroy(struct sway_view *view); -void view_map(struct sway_view *view, struct wlr_surface *wlr_surface); +void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, + bool fullscreen, bool decoration); void view_unmap(struct sway_view *view); diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 465822046a..1ed45a6b7a 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -406,27 +406,19 @@ static void handle_map(struct wl_listener *listener, void *data) { view->natural_height = view->wlr_xdg_surface->surface->current.height; } - view_map(view, view->wlr_xdg_surface->surface); + bool csd = false; if (!view->xdg_decoration) { struct sway_server_decoration *deco = - decoration_from_surface(xdg_surface->surface); - bool csd = !deco || deco->wlr_server_decoration->mode == + decoration_from_surface(xdg_surface->surface); + csd = !deco || deco->wlr_server_decoration->mode == WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT; - view_update_csd_from_client(view, csd); - } - if (xdg_surface->toplevel->client_pending.fullscreen) { - container_set_fullscreen(view->container, true); - arrange_workspace(view->container->workspace); - } else { - if (view->container->parent) { - arrange_container(view->container->parent); - } else if (view->container->workspace) { - arrange_workspace(view->container->workspace); - } } + view_map(view, view->wlr_xdg_surface->surface, + xdg_surface->toplevel->client_pending.fullscreen, csd); + transaction_commit_dirty(); xdg_shell_view->commit.notify = handle_commit; diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index 165cc7eb22..78e5dceb84 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c @@ -402,25 +402,13 @@ static void handle_map(struct wl_listener *listener, void *data) { 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); - struct sway_server_decoration *deco = - decoration_from_surface(xdg_surface->surface); + decoration_from_surface(xdg_surface->surface); bool csd = !deco || deco->wlr_server_decoration->mode == - WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT; - view_update_csd_from_client(view, csd); + WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT; + + view_map(view, view->wlr_xdg_surface_v6->surface, xdg_surface->toplevel->client_pending.fullscreen, csd); - if (xdg_surface->toplevel->client_pending.fullscreen) { - container_set_fullscreen(view->container, true); - arrange_workspace(view->container->workspace); - } else { - if (view->container->parent) { - arrange_container(view->container->parent); - } else if (view->container->workspace) { - arrange_workspace(view->container->workspace); - } - } transaction_commit_dirty(); xdg_shell_v6_view->commit.notify = handle_commit; diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index ebf2131e82..066556b8fc 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -405,18 +405,8 @@ static void handle_map(struct wl_listener *listener, void *data) { xwayland_view->commit.notify = handle_commit; // Put it back into the tree - view_map(view, xsurface->surface); + view_map(view, xsurface->surface, xsurface->fullscreen, false); - if (xsurface->fullscreen) { - container_set_fullscreen(view->container, true); - arrange_workspace(view->container->workspace); - } else { - if (view->container->parent) { - arrange_container(view->container->parent); - } else if (view->container->workspace) { - arrange_workspace(view->container->workspace); - } - } transaction_commit_dirty(); } diff --git a/sway/tree/view.c b/sway/tree/view.c index e613ac0b00..bdd5f8302c 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -535,7 +535,8 @@ static bool should_focus(struct sway_view *view) { return len == 0; } -void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { +void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, + bool fullscreen, bool decoration) { if (!sway_assert(view->surface == NULL, "cannot map mapped view")) { return; } @@ -586,13 +587,28 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { } } - if (should_focus(view)) { - input_manager_set_focus(input_manager, &view->container->node); - } - view_update_title(view, false); container_update_representation(view->container); view_execute_criteria(view); + + if (decoration) { + view_update_csd_from_client(view, decoration); + } + + if (fullscreen) { + container_set_fullscreen(view->container, true); + arrange_workspace(view->container->workspace); + } else { + if (view->container->parent) { + arrange_container(view->container->parent); + } else if (view->container->workspace) { + arrange_workspace(view->container->workspace); + } + } + + if (should_focus(view)) { + input_manager_set_focus(input_manager, &view->container->node); + } } void view_unmap(struct sway_view *view) {