diff options
author | emersion <contact@emersion.fr> | 2018-04-05 16:48:11 -0400 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2018-04-05 16:48:11 -0400 |
commit | f5e5b1819bf88841f6f42fdfe416fa588abbeeb5 (patch) | |
tree | 6b0c006f0d9d59151abc9b4cb20a806273ec6528 /sway/desktop/xdg_shell_v6.c | |
parent | Accumulate damage from subsurfaces (diff) | |
download | sway-f5e5b1819bf88841f6f42fdfe416fa588abbeeb5.tar.gz sway-f5e5b1819bf88841f6f42fdfe416fa588abbeeb5.tar.zst sway-f5e5b1819bf88841f6f42fdfe416fa588abbeeb5.zip |
Track damage of xdg-shell-v6 popups
Diffstat (limited to 'sway/desktop/xdg_shell_v6.c')
-rw-r--r-- | sway/desktop/xdg_shell_v6.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index 7b9d5fb7..baf07a1e 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c | |||
@@ -11,6 +11,66 @@ | |||
11 | #include "sway/input/input-manager.h" | 11 | #include "sway/input/input-manager.h" |
12 | #include "log.h" | 12 | #include "log.h" |
13 | 13 | ||
14 | static const struct sway_view_child_impl popup_impl; | ||
15 | |||
16 | static void popup_destroy(struct sway_view_child *child) { | ||
17 | if (!sway_assert(child->impl == &popup_impl, | ||
18 | "Expected an xdg_shell_v6 popup")) { | ||
19 | return; | ||
20 | } | ||
21 | struct sway_xdg_popup_v6 *popup = (struct sway_xdg_popup_v6 *)child; | ||
22 | wl_list_remove(&popup->new_popup.link); | ||
23 | wl_list_remove(&popup->unmap.link); | ||
24 | wl_list_remove(&popup->destroy.link); | ||
25 | free(popup); | ||
26 | } | ||
27 | |||
28 | static const struct sway_view_child_impl popup_impl = { | ||
29 | .destroy = popup_destroy, | ||
30 | }; | ||
31 | |||
32 | static struct sway_xdg_popup_v6 *popup_create( | ||
33 | struct wlr_xdg_popup_v6 *wlr_popup, struct sway_view *view); | ||
34 | |||
35 | static void popup_handle_new_popup(struct wl_listener *listener, void *data) { | ||
36 | struct sway_xdg_popup_v6 *popup = | ||
37 | wl_container_of(listener, popup, new_popup); | ||
38 | struct wlr_xdg_popup_v6 *wlr_popup = data; | ||
39 | popup_create(wlr_popup, popup->child.view); | ||
40 | } | ||
41 | |||
42 | static void popup_handle_unmap(struct wl_listener *listener, void *data) { | ||
43 | struct sway_xdg_popup_v6 *popup = wl_container_of(listener, popup, unmap); | ||
44 | view_child_destroy(&popup->child); | ||
45 | } | ||
46 | |||
47 | static void popup_handle_destroy(struct wl_listener *listener, void *data) { | ||
48 | struct sway_xdg_popup_v6 *popup = wl_container_of(listener, popup, destroy); | ||
49 | view_child_destroy(&popup->child); | ||
50 | } | ||
51 | |||
52 | static struct sway_xdg_popup_v6 *popup_create( | ||
53 | struct wlr_xdg_popup_v6 *wlr_popup, struct sway_view *view) { | ||
54 | struct wlr_xdg_surface_v6 *xdg_surface = wlr_popup->base; | ||
55 | |||
56 | struct sway_xdg_popup_v6 *popup = | ||
57 | calloc(1, sizeof(struct sway_xdg_popup_v6)); | ||
58 | if (popup == NULL) { | ||
59 | return NULL; | ||
60 | } | ||
61 | view_child_init(&popup->child, &popup_impl, view, xdg_surface->surface); | ||
62 | |||
63 | wl_signal_add(&xdg_surface->events.new_popup, &popup->new_popup); | ||
64 | popup->new_popup.notify = popup_handle_new_popup; | ||
65 | wl_signal_add(&xdg_surface->events.unmap, &popup->unmap); | ||
66 | popup->unmap.notify = popup_handle_unmap; | ||
67 | wl_signal_add(&xdg_surface->events.destroy, &popup->destroy); | ||
68 | popup->destroy.notify = popup_handle_destroy; | ||
69 | |||
70 | return popup; | ||
71 | } | ||
72 | |||
73 | |||
14 | static struct sway_xdg_shell_v6_view *xdg_shell_v6_view_from_view( | 74 | static struct sway_xdg_shell_v6_view *xdg_shell_v6_view_from_view( |
15 | struct sway_view *view) { | 75 | struct sway_view *view) { |
16 | if (!sway_assert(view->type == SWAY_VIEW_XDG_SHELL_V6, | 76 | if (!sway_assert(view->type == SWAY_VIEW_XDG_SHELL_V6, |
@@ -76,6 +136,7 @@ static void destroy(struct sway_view *view) { | |||
76 | } | 136 | } |
77 | wl_list_remove(&xdg_shell_v6_view->commit.link); | 137 | wl_list_remove(&xdg_shell_v6_view->commit.link); |
78 | wl_list_remove(&xdg_shell_v6_view->destroy.link); | 138 | wl_list_remove(&xdg_shell_v6_view->destroy.link); |
139 | wl_list_remove(&xdg_shell_v6_view->new_popup.link); | ||
79 | wl_list_remove(&xdg_shell_v6_view->map.link); | 140 | wl_list_remove(&xdg_shell_v6_view->map.link); |
80 | wl_list_remove(&xdg_shell_v6_view->unmap.link); | 141 | wl_list_remove(&xdg_shell_v6_view->unmap.link); |
81 | free(xdg_shell_v6_view); | 142 | free(xdg_shell_v6_view); |
@@ -100,6 +161,13 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
100 | view_damage_from(view); | 161 | view_damage_from(view); |
101 | } | 162 | } |
102 | 163 | ||
164 | static void handle_new_popup(struct wl_listener *listener, void *data) { | ||
165 | struct sway_xdg_shell_v6_view *xdg_shell_v6_view = | ||
166 | wl_container_of(listener, xdg_shell_v6_view, new_popup); | ||
167 | struct wlr_xdg_popup_v6 *wlr_popup = data; | ||
168 | popup_create(wlr_popup, &xdg_shell_v6_view->view); | ||
169 | } | ||
170 | |||
103 | static void handle_unmap(struct wl_listener *listener, void *data) { | 171 | static void handle_unmap(struct wl_listener *listener, void *data) { |
104 | struct sway_xdg_shell_v6_view *xdg_shell_v6_view = | 172 | struct sway_xdg_shell_v6_view *xdg_shell_v6_view = |
105 | wl_container_of(listener, xdg_shell_v6_view, unmap); | 173 | wl_container_of(listener, xdg_shell_v6_view, unmap); |
@@ -151,6 +219,10 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { | |||
151 | wl_signal_add(&xdg_surface->surface->events.commit, | 219 | wl_signal_add(&xdg_surface->surface->events.commit, |
152 | &xdg_shell_v6_view->commit); | 220 | &xdg_shell_v6_view->commit); |
153 | 221 | ||
222 | xdg_shell_v6_view->new_popup.notify = handle_new_popup; | ||
223 | wl_signal_add(&xdg_surface->events.new_popup, | ||
224 | &xdg_shell_v6_view->new_popup); | ||
225 | |||
154 | xdg_shell_v6_view->map.notify = handle_map; | 226 | xdg_shell_v6_view->map.notify = handle_map; |
155 | wl_signal_add(&xdg_surface->events.map, &xdg_shell_v6_view->map); | 227 | wl_signal_add(&xdg_surface->events.map, &xdg_shell_v6_view->map); |
156 | 228 | ||