diff --git a/include/layers.h b/include/layers.h index 7b6270ed..827c2ada 100644 --- a/include/layers.h +++ b/include/layers.h @@ -32,6 +32,7 @@ struct lab_layer_popup { struct wl_listener commit; struct wl_listener destroy; struct wl_listener new_popup; + struct wl_listener reposition; }; void layers_init(struct server *server); diff --git a/src/layers.c b/src/layers.c index 4a853fe3..df556761 100644 --- a/src/layers.c +++ b/src/layers.c @@ -356,6 +356,7 @@ popup_handle_destroy(struct wl_listener *listener, void *data) wl_container_of(listener, popup, destroy); wl_list_remove(&popup->destroy.link); wl_list_remove(&popup->new_popup.link); + wl_list_remove(&popup->reposition.link); /* Usually already removed unless there was no commit at all */ if (popup->commit.notify) { @@ -381,6 +382,15 @@ popup_handle_commit(struct wl_listener *listener, void *data) } } +static void +popup_handle_reposition(struct wl_listener *listener, void *data) +{ + struct lab_layer_popup *popup = + wl_container_of(listener, popup, reposition); + wlr_xdg_popup_unconstrain_from_box(popup->wlr_popup, + &popup->output_toplevel_sx_box); +} + static void popup_handle_new_popup(struct wl_listener *listener, void *data); static struct lab_layer_popup * @@ -410,6 +420,9 @@ create_popup(struct wlr_xdg_popup *wlr_popup, struct wlr_scene_tree *parent) popup->commit.notify = popup_handle_commit; wl_signal_add(&wlr_popup->base->surface->events.commit, &popup->commit); + popup->reposition.notify = popup_handle_reposition; + wl_signal_add(&wlr_popup->events.reposition, &popup->reposition); + return popup; } diff --git a/src/xdg-popup.c b/src/xdg-popup.c index 0d1ed909..d6bc99f0 100644 --- a/src/xdg-popup.c +++ b/src/xdg-popup.c @@ -19,6 +19,7 @@ struct xdg_popup { struct wl_listener commit; struct wl_listener destroy; struct wl_listener new_popup; + struct wl_listener reposition; }; static void @@ -47,6 +48,7 @@ handle_xdg_popup_destroy(struct wl_listener *listener, void *data) struct xdg_popup *popup = wl_container_of(listener, popup, destroy); wl_list_remove(&popup->destroy.link); wl_list_remove(&popup->new_popup.link); + wl_list_remove(&popup->reposition.link); /* Usually already removed unless there was no commit at all */ if (popup->commit.notify) { @@ -69,6 +71,13 @@ handle_xdg_popup_commit(struct wl_listener *listener, void *data) } } +static void +handle_xdg_popup_reposition(struct wl_listener *listener, void *data) +{ + struct xdg_popup *popup = wl_container_of(listener, popup, reposition); + popup_unconstrain(popup); +} + static void popup_handle_new_xdg_popup(struct wl_listener *listener, void *data) { @@ -100,6 +109,9 @@ xdg_popup_create(struct view *view, struct wlr_xdg_popup *wlr_popup) popup->commit.notify = handle_xdg_popup_commit; wl_signal_add(&wlr_popup->base->surface->events.commit, &popup->commit); + popup->reposition.notify = handle_xdg_popup_reposition; + wl_signal_add(&wlr_popup->events.reposition, &popup->reposition); + /* * We must add xdg popups to the scene graph so they get rendered. The * wlroots scene graph provides a helper for this, but to use it we must diff --git a/src/xdg.c b/src/xdg.c index 2b8bf96e..86ee06c3 100644 --- a/src/xdg.c +++ b/src/xdg.c @@ -14,7 +14,7 @@ #include "window-rules.h" #include "workspaces.h" -#define LAB_XDG_SHELL_VERSION (2) +#define LAB_XDG_SHELL_VERSION (3) #define CONFIGURE_TIMEOUT_MS 100 static struct xdg_toplevel_view *