From 57f596118908bf7e9f8859a03632986adbd1f1b4 Mon Sep 17 00:00:00 2001 From: tiosgz Date: Sun, 8 May 2022 10:02:25 +0000 Subject: [PATCH] (Un)focus logic improvements --- kiwmi/desktop/view.c | 7 +++++++ kiwmi/desktop/xdg_shell.c | 14 +++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/kiwmi/desktop/view.c b/kiwmi/desktop/view.c index 014f8c7..6f4c14f 100644 --- a/kiwmi/desktop/view.c +++ b/kiwmi/desktop/view.c @@ -111,6 +111,13 @@ view_set_hidden(struct kiwmi_view *view, bool hidden) wlr_scene_node_set_enabled(&view->desktop_surface.tree->node, !hidden); wlr_scene_node_set_enabled( &view->desktop_surface.popups_tree->node, !hidden); + + struct kiwmi_server *server = + wl_container_of(view->desktop, server, desktop); + struct kiwmi_seat *seat = server->input.seat; + if (seat->focused_view == view) { + seat->focused_view = NULL; + } } struct kiwmi_view * diff --git a/kiwmi/desktop/xdg_shell.c b/kiwmi/desktop/xdg_shell.c index 9aadedc..38e6f5f 100644 --- a/kiwmi/desktop/xdg_shell.c +++ b/kiwmi/desktop/xdg_shell.c @@ -51,6 +51,11 @@ xdg_surface_unmap_notify(struct wl_listener *listener, void *UNUSED(data)) struct kiwmi_server *server = wl_container_of(view->desktop, server, desktop); cursor_refresh_focus(server->input.cursor, NULL, NULL, NULL); + + struct kiwmi_seat *seat = server->input.seat; + if (seat->focused_view == view) { + seat->focused_view = NULL; + } } wl_signal_emit(&view->events.unmap, view); @@ -81,15 +86,6 @@ xdg_surface_destroy_notify(struct wl_listener *listener, void *UNUSED(data)) wlr_scene_node_destroy(&view->desktop_surface.tree->node); wlr_scene_node_destroy(&view->desktop_surface.popups_tree->node); - struct kiwmi_desktop *desktop = view->desktop; - struct kiwmi_server *server = wl_container_of(desktop, server, desktop); - struct kiwmi_seat *seat = server->input.seat; - - if (seat->focused_view == view) { - seat->focused_view = NULL; - } - cursor_refresh_focus(server->input.cursor, NULL, NULL, NULL); - if (view->decoration) { view->decoration->view = NULL; }