aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-06 14:49:33 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-07 11:07:29 +1000
commit1059e173f4c0139e909c7d8b5d450f30c0adad0e (patch)
treef14474b2d5118151129593443e5f8f785c3f6ab0 /sway/desktop
parentMerge pull request #2778 from emersion/swaybar-seat-pointer (diff)
downloadsway-1059e173f4c0139e909c7d8b5d450f30c0adad0e.tar.gz
sway-1059e173f4c0139e909c7d8b5d450f30c0adad0e.tar.zst
sway-1059e173f4c0139e909c7d8b5d450f30c0adad0e.zip
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')
-rw-r--r--sway/desktop/xdg_shell.c17
-rw-r--r--sway/desktop/xdg_shell_v6.c17
2 files changed, 34 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 @@
20 20
21static const struct sway_view_child_impl popup_impl; 21static const struct sway_view_child_impl popup_impl;
22 22
23static void popup_get_root_coords(struct sway_view_child *child,
24 int *root_sx, int *root_sy) {
25 struct sway_xdg_popup *popup = (struct sway_xdg_popup *)child;
26 struct wlr_xdg_surface *surface = popup->wlr_xdg_surface;
27 *root_sx = -surface->geometry.x;
28 *root_sy = -surface->geometry.y;
29 while (surface && surface->role == WLR_XDG_SURFACE_ROLE_POPUP) {
30 *root_sx += surface->popup->geometry.x;
31 *root_sy += surface->popup->geometry.y;
32 surface = wlr_xdg_surface_from_wlr_surface(surface->popup->parent);
33 }
34}
35
23static void popup_destroy(struct sway_view_child *child) { 36static void popup_destroy(struct sway_view_child *child) {
24 if (!sway_assert(child->impl == &popup_impl, 37 if (!sway_assert(child->impl == &popup_impl,
25 "Expected an xdg_shell popup")) { 38 "Expected an xdg_shell popup")) {
@@ -32,6 +45,7 @@ static void popup_destroy(struct sway_view_child *child) {
32} 45}
33 46
34static const struct sway_view_child_impl popup_impl = { 47static const struct sway_view_child_impl popup_impl = {
48 .get_root_coords = popup_get_root_coords,
35 .destroy = popup_destroy, 49 .destroy = popup_destroy,
36}; 50};
37 51
@@ -85,6 +99,9 @@ static struct sway_xdg_popup *popup_create(
85 wl_signal_add(&xdg_surface->events.destroy, &popup->destroy); 99 wl_signal_add(&xdg_surface->events.destroy, &popup->destroy);
86 popup->destroy.notify = popup_handle_destroy; 100 popup->destroy.notify = popup_handle_destroy;
87 101
102 wl_signal_add(&xdg_surface->events.map, &popup->child.surface_map);
103 wl_signal_add(&xdg_surface->events.unmap, &popup->child.surface_unmap);
104
88 popup_unconstrain(popup); 105 popup_unconstrain(popup);
89 106
90 return popup; 107 return popup;
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c
index a7838c0f..765a80b1 100644
--- a/sway/desktop/xdg_shell_v6.c
+++ b/sway/desktop/xdg_shell_v6.c
@@ -19,6 +19,19 @@
19 19
20static const struct sway_view_child_impl popup_impl; 20static const struct sway_view_child_impl popup_impl;
21 21
22static void popup_get_root_coords(struct sway_view_child *child,
23 int *root_sx, int *root_sy) {
24 struct sway_xdg_popup_v6 *popup = (struct sway_xdg_popup_v6 *)child;
25 struct wlr_xdg_surface_v6 *surface = popup->wlr_xdg_surface_v6;
26 *root_sx = -surface->geometry.x;
27 *root_sy = -surface->geometry.y;
28 while (surface && surface->role == WLR_XDG_SURFACE_V6_ROLE_POPUP) {
29 *root_sx += surface->popup->geometry.x;
30 *root_sy += surface->popup->geometry.y;
31 surface = surface->popup->parent;
32 }
33}
34
22static void popup_destroy(struct sway_view_child *child) { 35static void popup_destroy(struct sway_view_child *child) {
23 if (!sway_assert(child->impl == &popup_impl, 36 if (!sway_assert(child->impl == &popup_impl,
24 "Expected an xdg_shell_v6 popup")) { 37 "Expected an xdg_shell_v6 popup")) {
@@ -31,6 +44,7 @@ static void popup_destroy(struct sway_view_child *child) {
31} 44}
32 45
33static const struct sway_view_child_impl popup_impl = { 46static const struct sway_view_child_impl popup_impl = {
47 .get_root_coords = popup_get_root_coords,
34 .destroy = popup_destroy, 48 .destroy = popup_destroy,
35}; 49};
36 50
@@ -84,6 +98,9 @@ static struct sway_xdg_popup_v6 *popup_create(
84 wl_signal_add(&xdg_surface->events.destroy, &popup->destroy); 98 wl_signal_add(&xdg_surface->events.destroy, &popup->destroy);
85 popup->destroy.notify = popup_handle_destroy; 99 popup->destroy.notify = popup_handle_destroy;
86 100
101 wl_signal_add(&xdg_surface->events.map, &popup->child.surface_map);
102 wl_signal_add(&xdg_surface->events.unmap, &popup->child.surface_unmap);
103
87 popup_unconstrain(popup); 104 popup_unconstrain(popup);
88 105
89 return popup; 106 return popup;