diff options
-rw-r--r-- | include/sway/tree/view.h | 2 | ||||
-rw-r--r-- | sway/desktop/xdg_shell.c | 92 | ||||
-rw-r--r-- | sway/tree/container.c | 2 |
3 files changed, 40 insertions, 56 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 9e34b0d1..5f8d2f58 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h | |||
@@ -108,7 +108,7 @@ struct sway_view { | |||
108 | list_t *executed_criteria; // struct criteria * | 108 | list_t *executed_criteria; // struct criteria * |
109 | 109 | ||
110 | union { | 110 | union { |
111 | struct wlr_xdg_surface *wlr_xdg_surface; | 111 | struct wlr_xdg_toplevel *wlr_xdg_toplevel; |
112 | #if HAVE_XWAYLAND | 112 | #if HAVE_XWAYLAND |
113 | struct wlr_xwayland_surface *wlr_xwayland_surface; | 113 | struct wlr_xwayland_surface *wlr_xwayland_surface; |
114 | #endif | 114 | #endif |
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 585e5ee8..fe6e0fae 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c | |||
@@ -119,7 +119,7 @@ static struct sway_xdg_shell_view *xdg_shell_view_from_view( | |||
119 | static void get_constraints(struct sway_view *view, double *min_width, | 119 | static void get_constraints(struct sway_view *view, double *min_width, |
120 | double *max_width, double *min_height, double *max_height) { | 120 | double *max_width, double *min_height, double *max_height) { |
121 | struct wlr_xdg_toplevel_state *state = | 121 | struct wlr_xdg_toplevel_state *state = |
122 | &view->wlr_xdg_surface->toplevel->current; | 122 | &view->wlr_xdg_toplevel->current; |
123 | *min_width = state->min_width > 0 ? state->min_width : DBL_MIN; | 123 | *min_width = state->min_width > 0 ? state->min_width : DBL_MIN; |
124 | *max_width = state->max_width > 0 ? state->max_width : DBL_MAX; | 124 | *max_width = state->max_width > 0 ? state->max_width : DBL_MAX; |
125 | *min_height = state->min_height > 0 ? state->min_height : DBL_MIN; | 125 | *min_height = state->min_height > 0 ? state->min_height : DBL_MIN; |
@@ -133,9 +133,9 @@ static const char *get_string_prop(struct sway_view *view, | |||
133 | } | 133 | } |
134 | switch (prop) { | 134 | switch (prop) { |
135 | case VIEW_PROP_TITLE: | 135 | case VIEW_PROP_TITLE: |
136 | return view->wlr_xdg_surface->toplevel->title; | 136 | return view->wlr_xdg_toplevel->title; |
137 | case VIEW_PROP_APP_ID: | 137 | case VIEW_PROP_APP_ID: |
138 | return view->wlr_xdg_surface->toplevel->app_id; | 138 | return view->wlr_xdg_toplevel->app_id; |
139 | default: | 139 | default: |
140 | return NULL; | 140 | return NULL; |
141 | } | 141 | } |
@@ -148,7 +148,7 @@ static uint32_t configure(struct sway_view *view, double lx, double ly, | |||
148 | if (xdg_shell_view == NULL) { | 148 | if (xdg_shell_view == NULL) { |
149 | return 0; | 149 | return 0; |
150 | } | 150 | } |
151 | return wlr_xdg_toplevel_set_size(view->wlr_xdg_surface->toplevel, | 151 | return wlr_xdg_toplevel_set_size(view->wlr_xdg_toplevel, |
152 | width, height); | 152 | width, height); |
153 | } | 153 | } |
154 | 154 | ||
@@ -156,43 +156,37 @@ static void set_activated(struct sway_view *view, bool activated) { | |||
156 | if (xdg_shell_view_from_view(view) == NULL) { | 156 | if (xdg_shell_view_from_view(view) == NULL) { |
157 | return; | 157 | return; |
158 | } | 158 | } |
159 | struct wlr_xdg_surface *surface = view->wlr_xdg_surface; | 159 | wlr_xdg_toplevel_set_activated(view->wlr_xdg_toplevel, activated); |
160 | if (surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) { | ||
161 | wlr_xdg_toplevel_set_activated(surface->toplevel, activated); | ||
162 | } | ||
163 | } | 160 | } |
164 | 161 | ||
165 | static void set_tiled(struct sway_view *view, bool tiled) { | 162 | static void set_tiled(struct sway_view *view, bool tiled) { |
166 | if (xdg_shell_view_from_view(view) == NULL) { | 163 | if (xdg_shell_view_from_view(view) == NULL) { |
167 | return; | 164 | return; |
168 | } | 165 | } |
169 | struct wlr_xdg_surface *surface = view->wlr_xdg_surface; | ||
170 | enum wlr_edges edges = WLR_EDGE_NONE; | 166 | enum wlr_edges edges = WLR_EDGE_NONE; |
171 | if (tiled) { | 167 | if (tiled) { |
172 | edges = WLR_EDGE_LEFT | WLR_EDGE_RIGHT | WLR_EDGE_TOP | | 168 | edges = WLR_EDGE_LEFT | WLR_EDGE_RIGHT | WLR_EDGE_TOP | |
173 | WLR_EDGE_BOTTOM; | 169 | WLR_EDGE_BOTTOM; |
174 | } | 170 | } |
175 | wlr_xdg_toplevel_set_tiled(surface->toplevel, edges); | 171 | wlr_xdg_toplevel_set_tiled(view->wlr_xdg_toplevel, edges); |
176 | } | 172 | } |
177 | 173 | ||
178 | static void set_fullscreen(struct sway_view *view, bool fullscreen) { | 174 | static void set_fullscreen(struct sway_view *view, bool fullscreen) { |
179 | if (xdg_shell_view_from_view(view) == NULL) { | 175 | if (xdg_shell_view_from_view(view) == NULL) { |
180 | return; | 176 | return; |
181 | } | 177 | } |
182 | struct wlr_xdg_surface *surface = view->wlr_xdg_surface; | 178 | wlr_xdg_toplevel_set_fullscreen(view->wlr_xdg_toplevel, fullscreen); |
183 | wlr_xdg_toplevel_set_fullscreen(surface->toplevel, fullscreen); | ||
184 | } | 179 | } |
185 | 180 | ||
186 | static void set_resizing(struct sway_view *view, bool resizing) { | 181 | static void set_resizing(struct sway_view *view, bool resizing) { |
187 | if (xdg_shell_view_from_view(view) == NULL) { | 182 | if (xdg_shell_view_from_view(view) == NULL) { |
188 | return; | 183 | return; |
189 | } | 184 | } |
190 | struct wlr_xdg_surface *surface = view->wlr_xdg_surface; | 185 | wlr_xdg_toplevel_set_resizing(view->wlr_xdg_toplevel, resizing); |
191 | wlr_xdg_toplevel_set_resizing(surface->toplevel, resizing); | ||
192 | } | 186 | } |
193 | 187 | ||
194 | static bool wants_floating(struct sway_view *view) { | 188 | static bool wants_floating(struct sway_view *view) { |
195 | struct wlr_xdg_toplevel *toplevel = view->wlr_xdg_surface->toplevel; | 189 | struct wlr_xdg_toplevel *toplevel = view->wlr_xdg_toplevel; |
196 | struct wlr_xdg_toplevel_state *state = &toplevel->current; | 190 | struct wlr_xdg_toplevel_state *state = &toplevel->current; |
197 | return (state->min_width != 0 && state->min_height != 0 | 191 | return (state->min_width != 0 && state->min_height != 0 |
198 | && (state->min_width == state->max_width | 192 | && (state->min_width == state->max_width |
@@ -205,7 +199,7 @@ static void for_each_surface(struct sway_view *view, | |||
205 | if (xdg_shell_view_from_view(view) == NULL) { | 199 | if (xdg_shell_view_from_view(view) == NULL) { |
206 | return; | 200 | return; |
207 | } | 201 | } |
208 | wlr_xdg_surface_for_each_surface(view->wlr_xdg_surface, iterator, | 202 | wlr_xdg_surface_for_each_surface(view->wlr_xdg_toplevel->base, iterator, |
209 | user_data); | 203 | user_data); |
210 | } | 204 | } |
211 | 205 | ||
@@ -214,8 +208,8 @@ static void for_each_popup_surface(struct sway_view *view, | |||
214 | if (xdg_shell_view_from_view(view) == NULL) { | 208 | if (xdg_shell_view_from_view(view) == NULL) { |
215 | return; | 209 | return; |
216 | } | 210 | } |
217 | wlr_xdg_surface_for_each_popup_surface(view->wlr_xdg_surface, iterator, | 211 | wlr_xdg_surface_for_each_popup_surface(view->wlr_xdg_toplevel->base, |
218 | user_data); | 212 | iterator, user_data); |
219 | } | 213 | } |
220 | 214 | ||
221 | static bool is_transient_for(struct sway_view *child, | 215 | static bool is_transient_for(struct sway_view *child, |
@@ -223,9 +217,9 @@ static bool is_transient_for(struct sway_view *child, | |||
223 | if (xdg_shell_view_from_view(child) == NULL) { | 217 | if (xdg_shell_view_from_view(child) == NULL) { |
224 | return false; | 218 | return false; |
225 | } | 219 | } |
226 | struct wlr_xdg_toplevel *toplevel = child->wlr_xdg_surface->toplevel; | 220 | struct wlr_xdg_toplevel *toplevel = child->wlr_xdg_toplevel; |
227 | while (toplevel) { | 221 | while (toplevel) { |
228 | if (toplevel->parent == ancestor->wlr_xdg_surface->toplevel) { | 222 | if (toplevel->parent == ancestor->wlr_xdg_toplevel) { |
229 | return true; | 223 | return true; |
230 | } | 224 | } |
231 | toplevel = toplevel->parent; | 225 | toplevel = toplevel->parent; |
@@ -237,16 +231,12 @@ static void _close(struct sway_view *view) { | |||
237 | if (xdg_shell_view_from_view(view) == NULL) { | 231 | if (xdg_shell_view_from_view(view) == NULL) { |
238 | return; | 232 | return; |
239 | } | 233 | } |
240 | struct wlr_xdg_surface *surface = view->wlr_xdg_surface; | 234 | wlr_xdg_toplevel_send_close(view->wlr_xdg_toplevel); |
241 | if (surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL | ||
242 | && surface->toplevel) { | ||
243 | wlr_xdg_toplevel_send_close(surface->toplevel); | ||
244 | } | ||
245 | } | 235 | } |
246 | 236 | ||
247 | static void close_popups(struct sway_view *view) { | 237 | static void close_popups(struct sway_view *view) { |
248 | struct wlr_xdg_popup *popup, *tmp; | 238 | struct wlr_xdg_popup *popup, *tmp; |
249 | wl_list_for_each_safe(popup, tmp, &view->wlr_xdg_surface->popups, link) { | 239 | wl_list_for_each_safe(popup, tmp, &view->wlr_xdg_toplevel->base->popups, link) { |
250 | wlr_xdg_popup_destroy(popup); | 240 | wlr_xdg_popup_destroy(popup); |
251 | } | 241 | } |
252 | } | 242 | } |
@@ -281,7 +271,7 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
281 | struct sway_xdg_shell_view *xdg_shell_view = | 271 | struct sway_xdg_shell_view *xdg_shell_view = |
282 | wl_container_of(listener, xdg_shell_view, commit); | 272 | wl_container_of(listener, xdg_shell_view, commit); |
283 | struct sway_view *view = &xdg_shell_view->view; | 273 | struct sway_view *view = &xdg_shell_view->view; |
284 | struct wlr_xdg_surface *xdg_surface = view->wlr_xdg_surface; | 274 | struct wlr_xdg_surface *xdg_surface = view->wlr_xdg_toplevel->base; |
285 | 275 | ||
286 | struct wlr_box new_geo; | 276 | struct wlr_box new_geo; |
287 | wlr_xdg_surface_get_geometry(xdg_surface, &new_geo); | 277 | wlr_xdg_surface_get_geometry(xdg_surface, &new_geo); |
@@ -338,21 +328,15 @@ static void handle_new_popup(struct wl_listener *listener, void *data) { | |||
338 | static void handle_request_fullscreen(struct wl_listener *listener, void *data) { | 328 | static void handle_request_fullscreen(struct wl_listener *listener, void *data) { |
339 | struct sway_xdg_shell_view *xdg_shell_view = | 329 | struct sway_xdg_shell_view *xdg_shell_view = |
340 | wl_container_of(listener, xdg_shell_view, request_fullscreen); | 330 | wl_container_of(listener, xdg_shell_view, request_fullscreen); |
341 | struct wlr_xdg_surface *xdg_surface = | 331 | struct wlr_xdg_toplevel *toplevel = xdg_shell_view->view.wlr_xdg_toplevel; |
342 | xdg_shell_view->view.wlr_xdg_surface; | ||
343 | struct sway_view *view = &xdg_shell_view->view; | 332 | struct sway_view *view = &xdg_shell_view->view; |
344 | 333 | ||
345 | if (!sway_assert(xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL, | 334 | if (!toplevel->base->mapped) { |
346 | "xdg_shell requested fullscreen of surface with role %i", | ||
347 | xdg_surface->role)) { | ||
348 | return; | ||
349 | } | ||
350 | if (!xdg_surface->mapped) { | ||
351 | return; | 335 | return; |
352 | } | 336 | } |
353 | 337 | ||
354 | struct sway_container *container = view->container; | 338 | struct sway_container *container = view->container; |
355 | struct wlr_xdg_toplevel_requested *req = &xdg_surface->toplevel->requested; | 339 | struct wlr_xdg_toplevel_requested *req = &toplevel->requested; |
356 | if (req->fullscreen && req->fullscreen_output && req->fullscreen_output->data) { | 340 | if (req->fullscreen && req->fullscreen_output && req->fullscreen_output->data) { |
357 | struct sway_output *output = req->fullscreen_output->data; | 341 | struct sway_output *output = req->fullscreen_output->data; |
358 | struct sway_workspace *ws = output_get_active_workspace(output); | 342 | struct sway_workspace *ws = output_get_active_workspace(output); |
@@ -424,13 +408,13 @@ static void handle_map(struct wl_listener *listener, void *data) { | |||
424 | struct sway_xdg_shell_view *xdg_shell_view = | 408 | struct sway_xdg_shell_view *xdg_shell_view = |
425 | wl_container_of(listener, xdg_shell_view, map); | 409 | wl_container_of(listener, xdg_shell_view, map); |
426 | struct sway_view *view = &xdg_shell_view->view; | 410 | struct sway_view *view = &xdg_shell_view->view; |
427 | struct wlr_xdg_surface *xdg_surface = view->wlr_xdg_surface; | 411 | struct wlr_xdg_toplevel *toplevel = view->wlr_xdg_toplevel; |
428 | 412 | ||
429 | view->natural_width = view->wlr_xdg_surface->current.geometry.width; | 413 | view->natural_width = toplevel->base->current.geometry.width; |
430 | view->natural_height = view->wlr_xdg_surface->current.geometry.height; | 414 | view->natural_height = toplevel->base->current.geometry.height; |
431 | if (!view->natural_width && !view->natural_height) { | 415 | if (!view->natural_width && !view->natural_height) { |
432 | view->natural_width = view->wlr_xdg_surface->surface->current.width; | 416 | view->natural_width = toplevel->base->surface->current.width; |
433 | view->natural_height = view->wlr_xdg_surface->surface->current.height; | 417 | view->natural_height = toplevel->base->surface->current.height; |
434 | } | 418 | } |
435 | 419 | ||
436 | bool csd = false; | 420 | bool csd = false; |
@@ -441,44 +425,44 @@ static void handle_map(struct wl_listener *listener, void *data) { | |||
441 | csd = mode == WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE; | 425 | csd = mode == WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE; |
442 | } else { | 426 | } else { |
443 | struct sway_server_decoration *deco = | 427 | struct sway_server_decoration *deco = |
444 | decoration_from_surface(xdg_surface->surface); | 428 | decoration_from_surface(toplevel->base->surface); |
445 | csd = !deco || deco->wlr_server_decoration->mode == | 429 | csd = !deco || deco->wlr_server_decoration->mode == |
446 | WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT; | 430 | WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT; |
447 | } | 431 | } |
448 | 432 | ||
449 | view_map(view, view->wlr_xdg_surface->surface, | 433 | view_map(view, toplevel->base->surface, |
450 | xdg_surface->toplevel->requested.fullscreen, | 434 | toplevel->requested.fullscreen, |
451 | xdg_surface->toplevel->requested.fullscreen_output, | 435 | toplevel->requested.fullscreen_output, |
452 | csd); | 436 | csd); |
453 | 437 | ||
454 | transaction_commit_dirty(); | 438 | transaction_commit_dirty(); |
455 | 439 | ||
456 | xdg_shell_view->commit.notify = handle_commit; | 440 | xdg_shell_view->commit.notify = handle_commit; |
457 | wl_signal_add(&xdg_surface->surface->events.commit, | 441 | wl_signal_add(&toplevel->base->surface->events.commit, |
458 | &xdg_shell_view->commit); | 442 | &xdg_shell_view->commit); |
459 | 443 | ||
460 | xdg_shell_view->new_popup.notify = handle_new_popup; | 444 | xdg_shell_view->new_popup.notify = handle_new_popup; |
461 | wl_signal_add(&xdg_surface->events.new_popup, | 445 | wl_signal_add(&toplevel->base->events.new_popup, |
462 | &xdg_shell_view->new_popup); | 446 | &xdg_shell_view->new_popup); |
463 | 447 | ||
464 | xdg_shell_view->request_fullscreen.notify = handle_request_fullscreen; | 448 | xdg_shell_view->request_fullscreen.notify = handle_request_fullscreen; |
465 | wl_signal_add(&xdg_surface->toplevel->events.request_fullscreen, | 449 | wl_signal_add(&toplevel->events.request_fullscreen, |
466 | &xdg_shell_view->request_fullscreen); | 450 | &xdg_shell_view->request_fullscreen); |
467 | 451 | ||
468 | xdg_shell_view->request_move.notify = handle_request_move; | 452 | xdg_shell_view->request_move.notify = handle_request_move; |
469 | wl_signal_add(&xdg_surface->toplevel->events.request_move, | 453 | wl_signal_add(&toplevel->events.request_move, |
470 | &xdg_shell_view->request_move); | 454 | &xdg_shell_view->request_move); |
471 | 455 | ||
472 | xdg_shell_view->request_resize.notify = handle_request_resize; | 456 | xdg_shell_view->request_resize.notify = handle_request_resize; |
473 | wl_signal_add(&xdg_surface->toplevel->events.request_resize, | 457 | wl_signal_add(&toplevel->events.request_resize, |
474 | &xdg_shell_view->request_resize); | 458 | &xdg_shell_view->request_resize); |
475 | 459 | ||
476 | xdg_shell_view->set_title.notify = handle_set_title; | 460 | xdg_shell_view->set_title.notify = handle_set_title; |
477 | wl_signal_add(&xdg_surface->toplevel->events.set_title, | 461 | wl_signal_add(&toplevel->events.set_title, |
478 | &xdg_shell_view->set_title); | 462 | &xdg_shell_view->set_title); |
479 | 463 | ||
480 | xdg_shell_view->set_app_id.notify = handle_set_app_id; | 464 | xdg_shell_view->set_app_id.notify = handle_set_app_id; |
481 | wl_signal_add(&xdg_surface->toplevel->events.set_app_id, | 465 | wl_signal_add(&toplevel->events.set_app_id, |
482 | &xdg_shell_view->set_app_id); | 466 | &xdg_shell_view->set_app_id); |
483 | } | 467 | } |
484 | 468 | ||
@@ -492,7 +476,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) { | |||
492 | wl_list_remove(&xdg_shell_view->destroy.link); | 476 | wl_list_remove(&xdg_shell_view->destroy.link); |
493 | wl_list_remove(&xdg_shell_view->map.link); | 477 | wl_list_remove(&xdg_shell_view->map.link); |
494 | wl_list_remove(&xdg_shell_view->unmap.link); | 478 | wl_list_remove(&xdg_shell_view->unmap.link); |
495 | view->wlr_xdg_surface = NULL; | 479 | view->wlr_xdg_toplevel = NULL; |
496 | if (view->xdg_decoration) { | 480 | if (view->xdg_decoration) { |
497 | view->xdg_decoration->view = NULL; | 481 | view->xdg_decoration->view = NULL; |
498 | } | 482 | } |
@@ -523,7 +507,7 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) { | |||
523 | } | 507 | } |
524 | 508 | ||
525 | view_init(&xdg_shell_view->view, SWAY_VIEW_XDG_SHELL, &view_impl); | 509 | view_init(&xdg_shell_view->view, SWAY_VIEW_XDG_SHELL, &view_impl); |
526 | xdg_shell_view->view.wlr_xdg_surface = xdg_surface; | 510 | xdg_shell_view->view.wlr_xdg_toplevel = xdg_surface->toplevel; |
527 | 511 | ||
528 | xdg_shell_view->map.notify = handle_map; | 512 | xdg_shell_view->map.notify = handle_map; |
529 | wl_signal_add(&xdg_surface->events.map, &xdg_shell_view->map); | 513 | wl_signal_add(&xdg_surface->events.map, &xdg_shell_view->map); |
diff --git a/sway/tree/container.c b/sway/tree/container.c index bcac36b1..527759ba 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -194,7 +194,7 @@ static struct sway_container *surface_at_view(struct sway_container *con, double | |||
194 | #endif | 194 | #endif |
195 | case SWAY_VIEW_XDG_SHELL: | 195 | case SWAY_VIEW_XDG_SHELL: |
196 | _surface = wlr_xdg_surface_surface_at( | 196 | _surface = wlr_xdg_surface_surface_at( |
197 | view->wlr_xdg_surface, | 197 | view->wlr_xdg_toplevel->base, |
198 | view_sx, view_sy, &_sx, &_sy); | 198 | view_sx, view_sy, &_sx, &_sy); |
199 | break; | 199 | break; |
200 | } | 200 | } |