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 | |
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
-rw-r--r-- | include/sway/tree/view.h | 11 | ||||
-rw-r--r-- | sway/desktop/xdg_shell_v6.c | 72 | ||||
-rw-r--r-- | sway/tree/view.c | 2 |
3 files changed, 85 insertions, 0 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index f8e41652..2eca7a3e 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h | |||
@@ -60,6 +60,7 @@ struct sway_xdg_shell_v6_view { | |||
60 | struct wl_listener request_move; | 60 | struct wl_listener request_move; |
61 | struct wl_listener request_resize; | 61 | struct wl_listener request_resize; |
62 | struct wl_listener request_maximize; | 62 | struct wl_listener request_maximize; |
63 | struct wl_listener new_popup; | ||
63 | struct wl_listener map; | 64 | struct wl_listener map; |
64 | struct wl_listener unmap; | 65 | struct wl_listener unmap; |
65 | struct wl_listener destroy; | 66 | struct wl_listener destroy; |
@@ -122,6 +123,16 @@ struct sway_view_child { | |||
122 | struct wl_listener view_unmap; | 123 | struct wl_listener view_unmap; |
123 | }; | 124 | }; |
124 | 125 | ||
126 | struct sway_xdg_popup_v6 { | ||
127 | struct sway_view_child child; | ||
128 | |||
129 | struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6; | ||
130 | |||
131 | struct wl_listener new_popup; | ||
132 | struct wl_listener unmap; | ||
133 | struct wl_listener destroy; | ||
134 | }; | ||
135 | |||
125 | const char *view_get_title(struct sway_view *view); | 136 | const char *view_get_title(struct sway_view *view); |
126 | 137 | ||
127 | const char *view_get_app_id(struct sway_view *view); | 138 | const char *view_get_app_id(struct sway_view *view); |
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 | ||
diff --git a/sway/tree/view.c b/sway/tree/view.c index 85fd3093..293edc95 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -176,6 +176,8 @@ void view_unmap(struct sway_view *view) { | |||
176 | 176 | ||
177 | struct sway_container *parent = container_destroy(view->swayc); | 177 | struct sway_container *parent = container_destroy(view->swayc); |
178 | 178 | ||
179 | wl_list_remove(&view->surface_new_subsurface.link); | ||
180 | |||
179 | view->swayc = NULL; | 181 | view->swayc = NULL; |
180 | view->surface = NULL; | 182 | view->surface = NULL; |
181 | 183 | ||