aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/xdg_shell.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/desktop/xdg_shell.c')
-rw-r--r--sway/desktop/xdg_shell.c59
1 files changed, 27 insertions, 32 deletions
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c
index 667fb9e5..7c78a897 100644
--- a/sway/desktop/xdg_shell.c
+++ b/sway/desktop/xdg_shell.c
@@ -21,18 +21,15 @@
21 21
22static const struct sway_view_child_impl popup_impl; 22static const struct sway_view_child_impl popup_impl;
23 23
24static void popup_get_root_coords(struct sway_view_child *child, 24static void popup_get_view_coords(struct sway_view_child *child,
25 int *root_sx, int *root_sy) { 25 int *sx, int *sy) {
26 struct sway_xdg_popup *popup = (struct sway_xdg_popup *)child; 26 struct sway_xdg_popup *popup = (struct sway_xdg_popup *)child;
27 struct wlr_xdg_surface *surface = popup->wlr_xdg_surface; 27 struct wlr_xdg_surface *surface = popup->wlr_xdg_surface;
28 28
29 int x_offset = -child->view->geometry.x - surface->geometry.x;
30 int y_offset = -child->view->geometry.y - surface->geometry.y;
31
32 wlr_xdg_popup_get_toplevel_coords(surface->popup, 29 wlr_xdg_popup_get_toplevel_coords(surface->popup,
33 x_offset + surface->popup->geometry.x, 30 surface->popup->geometry.x - surface->geometry.x,
34 y_offset + surface->popup->geometry.y, 31 surface->popup->geometry.y - surface->geometry.y,
35 root_sx, root_sy); 32 sx, sy);
36} 33}
37 34
38static void popup_destroy(struct sway_view_child *child) { 35static void popup_destroy(struct sway_view_child *child) {
@@ -47,7 +44,7 @@ static void popup_destroy(struct sway_view_child *child) {
47} 44}
48 45
49static const struct sway_view_child_impl popup_impl = { 46static const struct sway_view_child_impl popup_impl = {
50 .get_root_coords = popup_get_root_coords, 47 .get_view_coords = popup_get_view_coords,
51 .destroy = popup_destroy, 48 .destroy = popup_destroy,
52}; 49};
53 50
@@ -70,13 +67,13 @@ static void popup_unconstrain(struct sway_xdg_popup *popup) {
70 struct sway_view *view = popup->child.view; 67 struct sway_view *view = popup->child.view;
71 struct wlr_xdg_popup *wlr_popup = popup->wlr_xdg_surface->popup; 68 struct wlr_xdg_popup *wlr_popup = popup->wlr_xdg_surface->popup;
72 69
73 struct sway_output *output = view->container->workspace->output; 70 struct sway_output *output = view->container->pending.workspace->output;
74 71
75 // the output box expressed in the coordinate system of the toplevel parent 72 // the output box expressed in the coordinate system of the toplevel parent
76 // of the popup 73 // of the popup
77 struct wlr_box output_toplevel_sx_box = { 74 struct wlr_box output_toplevel_sx_box = {
78 .x = output->lx - view->container->content_x, 75 .x = output->lx - view->container->pending.content_x,
79 .y = output->ly - view->container->content_y, 76 .y = output->ly - view->container->pending.content_y,
80 .width = output->width, 77 .width = output->width,
81 .height = output->height, 78 .height = output->height,
82 }; 79 };
@@ -293,19 +290,23 @@ static void handle_commit(struct wl_listener *listener, void *data) {
293 new_geo.y != view->geometry.y; 290 new_geo.y != view->geometry.y;
294 291
295 if (new_size) { 292 if (new_size) {
296 // The view has unexpectedly sent a new size 293 // The client changed its surface size in this commit. For floating
294 // containers, we resize the container to match. For tiling containers,
295 // we only recenter the surface.
297 desktop_damage_view(view); 296 desktop_damage_view(view);
298 view_update_size(view, new_geo.width, new_geo.height);
299 memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); 297 memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
298 if (container_is_floating(view->container)) {
299 view_update_size(view);
300 transaction_commit_dirty_client();
301 } else {
302 view_center_surface(view);
303 }
300 desktop_damage_view(view); 304 desktop_damage_view(view);
301 transaction_commit_dirty();
302 } 305 }
303 306
304 if (view->container->node.instruction) { 307 if (view->container->node.instruction) {
305 transaction_notify_view_ready_by_serial(view, 308 transaction_notify_view_ready_by_serial(view,
306 xdg_surface->configure_serial); 309 xdg_surface->configure_serial);
307 } else if (new_size) {
308 transaction_notify_view_ready_immediately(view);
309 } 310 }
310 311
311 view_damage_from(view); 312 view_damage_from(view);
@@ -354,7 +355,8 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data)
354 if (e->fullscreen && e->output && e->output->data) { 355 if (e->fullscreen && e->output && e->output->data) {
355 struct sway_output *output = e->output->data; 356 struct sway_output *output = e->output->data;
356 struct sway_workspace *ws = output_get_active_workspace(output); 357 struct sway_workspace *ws = output_get_active_workspace(output);
357 if (ws && !container_is_scratchpad_hidden(container)) { 358 if (ws && !container_is_scratchpad_hidden(container) &&
359 container->pending.workspace != ws) {
358 if (container_is_floating(container)) { 360 if (container_is_floating(container)) {
359 workspace_add_floating(ws, container); 361 workspace_add_floating(ws, container);
360 } else { 362 } else {
@@ -369,11 +371,6 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data)
369 transaction_commit_dirty(); 371 transaction_commit_dirty();
370} 372}
371 373
372static void handle_request_maximize(struct wl_listener *listener, void *data) {
373 struct wlr_xdg_surface *surface = data;
374 wlr_xdg_surface_schedule_configure(surface);
375}
376
377static void handle_request_move(struct wl_listener *listener, void *data) { 374static void handle_request_move(struct wl_listener *listener, void *data) {
378 struct sway_xdg_shell_view *xdg_shell_view = 375 struct sway_xdg_shell_view *xdg_shell_view =
379 wl_container_of(listener, xdg_shell_view, request_move); 376 wl_container_of(listener, xdg_shell_view, request_move);
@@ -416,7 +413,6 @@ static void handle_unmap(struct wl_listener *listener, void *data) {
416 wl_list_remove(&xdg_shell_view->commit.link); 413 wl_list_remove(&xdg_shell_view->commit.link);
417 wl_list_remove(&xdg_shell_view->new_popup.link); 414 wl_list_remove(&xdg_shell_view->new_popup.link);
418 wl_list_remove(&xdg_shell_view->request_fullscreen.link); 415 wl_list_remove(&xdg_shell_view->request_fullscreen.link);
419 wl_list_remove(&xdg_shell_view->request_maximize.link);
420 wl_list_remove(&xdg_shell_view->request_move.link); 416 wl_list_remove(&xdg_shell_view->request_move.link);
421 wl_list_remove(&xdg_shell_view->request_resize.link); 417 wl_list_remove(&xdg_shell_view->request_resize.link);
422 wl_list_remove(&xdg_shell_view->set_title.link); 418 wl_list_remove(&xdg_shell_view->set_title.link);
@@ -438,17 +434,20 @@ static void handle_map(struct wl_listener *listener, void *data) {
438 434
439 bool csd = false; 435 bool csd = false;
440 436
441 if (!view->xdg_decoration) { 437 if (view->xdg_decoration) {
438 enum wlr_xdg_toplevel_decoration_v1_mode mode =
439 view->xdg_decoration->wlr_xdg_decoration->client_pending_mode;
440 csd = mode == WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE;
441 } else {
442 struct sway_server_decoration *deco = 442 struct sway_server_decoration *deco =
443 decoration_from_surface(xdg_surface->surface); 443 decoration_from_surface(xdg_surface->surface);
444 csd = !deco || deco->wlr_server_decoration->mode == 444 csd = !deco || deco->wlr_server_decoration->mode ==
445 WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT; 445 WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT;
446
447 } 446 }
448 447
449 view_map(view, view->wlr_xdg_surface->surface, 448 view_map(view, view->wlr_xdg_surface->surface,
450 xdg_surface->toplevel->client_pending.fullscreen, 449 xdg_surface->toplevel->requested.fullscreen,
451 xdg_surface->toplevel->client_pending.fullscreen_output, 450 xdg_surface->toplevel->requested.fullscreen_output,
452 csd); 451 csd);
453 452
454 transaction_commit_dirty(); 453 transaction_commit_dirty();
@@ -465,10 +464,6 @@ static void handle_map(struct wl_listener *listener, void *data) {
465 wl_signal_add(&xdg_surface->toplevel->events.request_fullscreen, 464 wl_signal_add(&xdg_surface->toplevel->events.request_fullscreen,
466 &xdg_shell_view->request_fullscreen); 465 &xdg_shell_view->request_fullscreen);
467 466
468 xdg_shell_view->request_maximize.notify = handle_request_maximize;
469 wl_signal_add(&xdg_surface->toplevel->events.request_maximize,
470 &xdg_shell_view->request_maximize);
471
472 xdg_shell_view->request_move.notify = handle_request_move; 467 xdg_shell_view->request_move.notify = handle_request_move;
473 wl_signal_add(&xdg_surface->toplevel->events.request_move, 468 wl_signal_add(&xdg_surface->toplevel->events.request_move,
474 &xdg_shell_view->request_move); 469 &xdg_shell_view->request_move);