summaryrefslogtreecommitdiff
path: root/sway/desktop/xdg_shell.c
diff options
context:
space:
mode:
authorRyan Dwyer <[email protected]>2018-10-06 14:49:33 +1000
committerRyan Dwyer <[email protected]>2018-10-07 11:07:29 +1000
commit1059e173f4c0139e909c7d8b5d450f30c0adad0e (patch)
treef14474b2d5118151129593443e5f8f785c3f6ab0 /sway/desktop/xdg_shell.c
parent8393266eb5ab046d591595593d8966fa3c791bd5 (diff)
Only damage popups when popups have damage
The previous behaviour was to damage the entire view, which would recurse into each popup. This patch makes it damage only the popup's surface, and respect the surface damage given by the client. This adds listeners to the popup's map and unmap events rather than doing the damage in the create and destroy functions. To get the popup's position relative to the view, a new child_impl function get_root_coords has been introduced, which traverses up the parents.
Diffstat (limited to 'sway/desktop/xdg_shell.c')
-rw-r--r--sway/desktop/xdg_shell.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c
index a8b527a7..9036448b 100644
--- a/sway/desktop/xdg_shell.c
+++ b/sway/desktop/xdg_shell.c
@@ -20,6 +20,19 @@
static const struct sway_view_child_impl popup_impl;
+static void popup_get_root_coords(struct sway_view_child *child,
+ int *root_sx, int *root_sy) {
+ struct sway_xdg_popup *popup = (struct sway_xdg_popup *)child;
+ struct wlr_xdg_surface *surface = popup->wlr_xdg_surface;
+ *root_sx = -surface->geometry.x;
+ *root_sy = -surface->geometry.y;
+ while (surface && surface->role == WLR_XDG_SURFACE_ROLE_POPUP) {
+ *root_sx += surface->popup->geometry.x;
+ *root_sy += surface->popup->geometry.y;
+ surface = wlr_xdg_surface_from_wlr_surface(surface->popup->parent);
+ }
+}
+
static void popup_destroy(struct sway_view_child *child) {
if (!sway_assert(child->impl == &popup_impl,
"Expected an xdg_shell popup")) {
@@ -32,6 +45,7 @@ static void popup_destroy(struct sway_view_child *child) {
}
static const struct sway_view_child_impl popup_impl = {
+ .get_root_coords = popup_get_root_coords,
.destroy = popup_destroy,
};
@@ -85,6 +99,9 @@ static struct sway_xdg_popup *popup_create(
wl_signal_add(&xdg_surface->events.destroy, &popup->destroy);
popup->destroy.notify = popup_handle_destroy;
+ wl_signal_add(&xdg_surface->events.map, &popup->child.surface_map);
+ wl_signal_add(&xdg_surface->events.unmap, &popup->child.surface_unmap);
+
popup_unconstrain(popup);
return popup;