aboutsummaryrefslogtreecommitdiff
path: root/sway/desktop/layer_shell.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/desktop/layer_shell.c')
-rw-r--r--sway/desktop/layer_shell.c45
1 files changed, 23 insertions, 22 deletions
diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c
index 8c6cedfe..979c4449 100644
--- a/sway/desktop/layer_shell.c
+++ b/sway/desktop/layer_shell.c
@@ -542,6 +542,26 @@ static void popup_damage(struct sway_layer_popup *layer_popup, bool whole) {
output_damage_surface(output, ox, oy, surface, whole);
}
+static void popup_unconstrain(struct sway_layer_popup *popup) {
+ struct sway_layer_surface *layer = popup_get_layer(popup);
+ struct wlr_xdg_popup *wlr_popup = popup->wlr_popup;
+
+ struct wlr_output *wlr_output = layer->layer_surface->output;
+ sway_assert(wlr_output, "wlr_layer_surface_v1 has null output");
+ struct sway_output *output = wlr_output->data;
+
+ // the output box expressed in the coordinate system of the toplevel parent
+ // of the popup
+ struct wlr_box output_toplevel_sx_box = {
+ .x = -layer->geo.x,
+ .y = -layer->geo.y,
+ .width = output->width,
+ .height = output->height,
+ };
+
+ wlr_xdg_popup_unconstrain_from_box(wlr_popup, &output_toplevel_sx_box);
+}
+
static void popup_handle_map(struct wl_listener *listener, void *data) {
struct sway_layer_popup *popup = wl_container_of(listener, popup, map);
struct sway_layer_surface *layer = popup_get_layer(popup);
@@ -558,6 +578,9 @@ static void popup_handle_unmap(struct wl_listener *listener, void *data) {
static void popup_handle_commit(struct wl_listener *listener, void *data) {
struct sway_layer_popup *popup = wl_container_of(listener, popup, commit);
+ if (popup->wlr_popup->base->initial_commit) {
+ popup_unconstrain(popup);
+ }
popup_damage(popup, false);
}
@@ -572,26 +595,6 @@ static void popup_handle_destroy(struct wl_listener *listener, void *data) {
free(popup);
}
-static void popup_unconstrain(struct sway_layer_popup *popup) {
- struct sway_layer_surface *layer = popup_get_layer(popup);
- struct wlr_xdg_popup *wlr_popup = popup->wlr_popup;
-
- struct wlr_output *wlr_output = layer->layer_surface->output;
- sway_assert(wlr_output, "wlr_layer_surface_v1 has null output");
- struct sway_output *output = wlr_output->data;
-
- // the output box expressed in the coordinate system of the toplevel parent
- // of the popup
- struct wlr_box output_toplevel_sx_box = {
- .x = -layer->geo.x,
- .y = -layer->geo.y,
- .width = output->width,
- .height = output->height,
- };
-
- wlr_xdg_popup_unconstrain_from_box(wlr_popup, &output_toplevel_sx_box);
-}
-
static void popup_handle_new_popup(struct wl_listener *listener, void *data);
static struct sway_layer_popup *create_popup(struct wlr_xdg_popup *wlr_popup,
@@ -617,8 +620,6 @@ static struct sway_layer_popup *create_popup(struct wlr_xdg_popup *wlr_popup,
popup->new_popup.notify = popup_handle_new_popup;
wl_signal_add(&wlr_popup->base->events.new_popup, &popup->new_popup);
- popup_unconstrain(popup);
-
return popup;
}