mirror of
https://github.com/labwc/labwc.git
synced 2026-02-24 01:40:15 -05:00
layer: on popup destory, return focus
...to whoever had it before the popop Co-authored-by: @tokyo4j
This commit is contained in:
parent
180293e0bb
commit
a277c35c3d
2 changed files with 18 additions and 5 deletions
|
|
@ -31,6 +31,7 @@ struct lab_layer_popup {
|
||||||
struct wlr_scene_tree *scene_tree;
|
struct wlr_scene_tree *scene_tree;
|
||||||
struct server *server;
|
struct server *server;
|
||||||
struct lab_layer_surface *lab_layer_surface;
|
struct lab_layer_surface *lab_layer_surface;
|
||||||
|
bool parent_was_focused;
|
||||||
|
|
||||||
/* To simplify moving popup nodes from the bottom to the top layer */
|
/* To simplify moving popup nodes from the bottom to the top layer */
|
||||||
struct wlr_box output_toplevel_sx_box;
|
struct wlr_box output_toplevel_sx_box;
|
||||||
|
|
|
||||||
22
src/layers.c
22
src/layers.c
|
|
@ -448,7 +448,13 @@ handle_popup_destroy(struct wl_listener *listener, void *data)
|
||||||
wl_list_remove(&popup->commit.link);
|
wl_list_remove(&popup->commit.link);
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor_update_focus(popup->server);
|
/* Give focus back to whoever had it before the popup */
|
||||||
|
if (popup->parent_was_focused && popup->wlr_popup->parent) {
|
||||||
|
struct seat *seat = &popup->server->seat;
|
||||||
|
seat_force_focus_surface(seat, popup->wlr_popup->parent);
|
||||||
|
} else {
|
||||||
|
desktop_focus_topmost_view(popup->server);
|
||||||
|
}
|
||||||
|
|
||||||
free(popup);
|
free(popup);
|
||||||
}
|
}
|
||||||
|
|
@ -512,12 +518,18 @@ handle_popup_commit(struct wl_listener *listener, void *data)
|
||||||
wl_list_remove(&popup->commit.link);
|
wl_list_remove(&popup->commit.link);
|
||||||
popup->commit.notify = NULL;
|
popup->commit.notify = NULL;
|
||||||
|
|
||||||
if (!seat->server->session_lock_manager->locked
|
/* Force focus when popup was triggered by IPC */
|
||||||
&& popup->wlr_popup->seat) {
|
struct server *server = popup->server;
|
||||||
|
struct seat *seat = &server->seat;
|
||||||
|
bool locked = server->session_lock_manager->locked;
|
||||||
|
if (seat->seat->keyboard_state.focused_surface
|
||||||
|
== popup->wlr_popup->parent) {
|
||||||
|
popup->parent_was_focused = true;
|
||||||
|
}
|
||||||
|
if (!locked && popup->wlr_popup->seat) {
|
||||||
struct wlr_layer_surface_v1 *layer_surface =
|
struct wlr_layer_surface_v1 *layer_surface =
|
||||||
popup->lab_layer_surface->layer_surface;
|
popup->lab_layer_surface->layer_surface;
|
||||||
seat_force_focus_surface(&popup->server->seat,
|
seat_force_focus_surface(seat, layer_surface->surface);
|
||||||
layer_surface->surface);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue