aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2018-03-30 17:43:43 -0400
committerLibravatar emersion <contact@emersion.fr>2018-03-30 17:43:43 -0400
commit139f80b0f03cd772e408604203df81f285ca3f67 (patch)
tree94004c7898769b0d33b0980ce062da0e3564b190 /sway/desktop
parentRemove debug, add explicit TODO (diff)
downloadsway-139f80b0f03cd772e408604203df81f285ca3f67.tar.gz
sway-139f80b0f03cd772e408604203df81f285ca3f67.tar.zst
sway-139f80b0f03cd772e408604203df81f285ca3f67.zip
Handle map/unmap events in xdg-shell-v6
Diffstat (limited to 'sway/desktop')
-rw-r--r--sway/desktop/xdg_shell_v6.c44
-rw-r--r--sway/desktop/xwayland.c2
2 files changed, 34 insertions, 12 deletions
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c
index 68abc120..713437f2 100644
--- a/sway/desktop/xdg_shell_v6.c
+++ b/sway/desktop/xdg_shell_v6.c
@@ -79,6 +79,34 @@ static void handle_commit(struct wl_listener *listener, void *data) {
79 view_damage_from(view); 79 view_damage_from(view);
80} 80}
81 81
82static void handle_unmap(struct wl_listener *listener, void *data) {
83 struct sway_xdg_surface_v6 *sway_surface =
84 wl_container_of(listener, sway_surface, unmap);
85 view_damage_whole(sway_surface->view);
86 container_view_destroy(sway_surface->view->swayc);
87 sway_surface->view->swayc = NULL;
88 sway_surface->view->surface = NULL;
89}
90
91static void handle_map(struct wl_listener *listener, void *data) {
92 struct sway_xdg_surface_v6 *sway_surface =
93 wl_container_of(listener, sway_surface, map);
94 struct sway_view *view = sway_surface->view;
95
96 sway_surface->view->surface = view->wlr_xdg_surface_v6->surface;
97
98 container_view_destroy(view->swayc);
99
100 struct sway_seat *seat = input_manager_current_seat(input_manager);
101 struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container);
102 struct sway_container *cont = container_view_create(focus, view);
103 view->swayc = cont;
104 arrange_windows(cont->parent, -1, -1);
105 sway_input_manager_set_focus(input_manager, cont);
106
107 view_damage_whole(sway_surface->view);
108}
109
82static void handle_destroy(struct wl_listener *listener, void *data) { 110static void handle_destroy(struct wl_listener *listener, void *data) {
83 struct sway_xdg_surface_v6 *sway_xdg_surface = 111 struct sway_xdg_surface_v6 *sway_xdg_surface =
84 wl_container_of(listener, sway_xdg_surface, destroy); 112 wl_container_of(listener, sway_xdg_surface, destroy);
@@ -122,7 +150,6 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
122 sway_view->iface.close = close; 150 sway_view->iface.close = close;
123 sway_view->wlr_xdg_surface_v6 = xdg_surface; 151 sway_view->wlr_xdg_surface_v6 = xdg_surface;
124 sway_view->sway_xdg_surface_v6 = sway_surface; 152 sway_view->sway_xdg_surface_v6 = sway_surface;
125 sway_view->surface = xdg_surface->surface;
126 sway_surface->view = sway_view; 153 sway_surface->view = sway_view;
127 154
128 // TODO: 155 // TODO:
@@ -133,15 +160,12 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
133 sway_surface->commit.notify = handle_commit; 160 sway_surface->commit.notify = handle_commit;
134 wl_signal_add(&xdg_surface->surface->events.commit, &sway_surface->commit); 161 wl_signal_add(&xdg_surface->surface->events.commit, &sway_surface->commit);
135 162
136 sway_surface->destroy.notify = handle_destroy; 163 sway_surface->map.notify = handle_map;
137 wl_signal_add(&xdg_surface->events.destroy, &sway_surface->destroy); 164 wl_signal_add(&xdg_surface->events.map, &sway_surface->map);
138
139 struct sway_seat *seat = input_manager_current_seat(input_manager);
140 struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container);
141 struct sway_container *cont = container_view_create(focus, sway_view);
142 sway_view->swayc = cont;
143 165
144 arrange_windows(cont->parent, -1, -1); 166 sway_surface->unmap.notify = handle_unmap;
167 wl_signal_add(&xdg_surface->events.unmap, &sway_surface->unmap);
145 168
146 sway_input_manager_set_focus(input_manager, cont); 169 sway_surface->destroy.notify = handle_destroy;
170 wl_signal_add(&xdg_surface->events.destroy, &sway_surface->destroy);
147} 171}
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 79c675a0..01c993b3 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -127,7 +127,6 @@ static void handle_unmap(struct wl_listener *listener, void *data) {
127} 127}
128 128
129static void handle_map(struct wl_listener *listener, void *data) { 129static void handle_map(struct wl_listener *listener, void *data) {
130 // TODO put the view back into the tree
131 struct sway_xwayland_surface *sway_surface = 130 struct sway_xwayland_surface *sway_surface =
132 wl_container_of(listener, sway_surface, map); 131 wl_container_of(listener, sway_surface, map);
133 struct wlr_xwayland_surface *xsurface = data; 132 struct wlr_xwayland_surface *xsurface = data;
@@ -193,7 +192,6 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
193 sway_view->iface.close = close_view; 192 sway_view->iface.close = close_view;
194 sway_view->wlr_xwayland_surface = xsurface; 193 sway_view->wlr_xwayland_surface = xsurface;
195 sway_view->sway_xwayland_surface = sway_surface; 194 sway_view->sway_xwayland_surface = sway_surface;
196 sway_view->surface = xsurface->surface;
197 sway_surface->view = sway_view; 195 sway_surface->view = sway_view;
198 196
199 wl_list_init(&sway_view->unmanaged_view_link); 197 wl_list_init(&sway_view->unmanaged_view_link);