diff options
author | BrassyPanache <brassy.panache@gmail.com> | 2020-08-26 17:33:40 +1000 |
---|---|---|
committer | Tudor Brindus <me@tbrindus.ca> | 2020-09-04 17:00:22 -0400 |
commit | 7ca9ef12f8b6a00b8020a500433fabc6b645d85c (patch) | |
tree | ecadf4df32b463ba0f99063d8b1b9db2d524c2f3 | |
parent | swaynag: adds option to separately specify the text color for buttons (diff) | |
download | sway-7ca9ef12f8b6a00b8020a500433fabc6b645d85c.tar.gz sway-7ca9ef12f8b6a00b8020a500433fabc6b645d85c.tar.zst sway-7ca9ef12f8b6a00b8020a500433fabc6b645d85c.zip |
Re-focus on parent surface if it is available
My primary issue was IntelliJ IDEA's code suggestion pop-up not returning focus
to the active editing window.
I have spent some time looking at the changes of @Xyene (#5398) and
@RyanDwyer (#2103). I think my proposed change maintains the status
quo for the most part whilst fixing my focus issue.
I have verified that @Xyene's fix for IntelliJ sub-menus still works.
I have done basic testing which consists of:
- Chrome
- IntelliJ IDEA 2020.2.1
- VSCode
- Alacritty
It seems to hold up. I at least didn't see any obvious errors.
Relates to #3007
-rw-r--r-- | sway/desktop/xwayland.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index db21dc78..89b1a481 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c | |||
@@ -92,20 +92,15 @@ static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) { | |||
92 | wl_list_remove(&surface->commit.link); | 92 | wl_list_remove(&surface->commit.link); |
93 | 93 | ||
94 | struct sway_seat *seat = input_manager_current_seat(); | 94 | struct sway_seat *seat = input_manager_current_seat(); |
95 | if (seat->wlr_seat->keyboard_state.focused_surface == | 95 | if (seat->wlr_seat->keyboard_state.focused_surface == xsurface->surface) { |
96 | xsurface->surface) { | 96 | // This simply returns focus to the parent surface if there's one available. |
97 | 97 | // This seems to handle JetBrains issues. | |
98 | // Try to find another unmanaged surface from the same process to pass | 98 | if (xsurface->parent && |
99 | // focus to. This is necessary because some applications (e.g. Jetbrains | 99 | wlr_surface_is_xwayland_surface(xsurface->parent->surface)) { |
100 | // IDEs) represent their multi-level menus as unmanaged surfaces, and | 100 | struct wlr_xwayland_surface *next_surface = |
101 | // when closing a submenu, the main menu should get input focus. | 101 | wlr_xwayland_surface_from_wlr_surface(xsurface->parent->surface); |
102 | struct sway_xwayland_unmanaged *current; | 102 | if (wlr_xwayland_or_surface_wants_focus(next_surface)) { |
103 | wl_list_for_each(current, &root->xwayland_unmanaged, link) { | 103 | seat_set_focus_surface(seat, xsurface->parent->surface, false); |
104 | struct wlr_xwayland_surface *prev_xsurface = | ||
105 | current->wlr_xwayland_surface; | ||
106 | if (prev_xsurface->pid == xsurface->pid && | ||
107 | wlr_xwayland_or_surface_wants_focus(prev_xsurface)) { | ||
108 | seat_set_focus_surface(seat, prev_xsurface->surface, false); | ||
109 | return; | 104 | return; |
110 | } | 105 | } |
111 | } | 106 | } |