aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/xwayland.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/desktop/xwayland.c')
-rw-r--r--sway/desktop/xwayland.c64
1 files changed, 31 insertions, 33 deletions
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index e1a2e463..1af8d248 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -105,14 +105,10 @@ static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) {
105 if (seat->wlr_seat->keyboard_state.focused_surface == xsurface->surface) { 105 if (seat->wlr_seat->keyboard_state.focused_surface == xsurface->surface) {
106 // This simply returns focus to the parent surface if there's one available. 106 // This simply returns focus to the parent surface if there's one available.
107 // This seems to handle JetBrains issues. 107 // This seems to handle JetBrains issues.
108 if (xsurface->parent && xsurface->parent->surface && 108 if (xsurface->parent && xsurface->parent->surface
109 wlr_surface_is_xwayland_surface(xsurface->parent->surface)) { 109 && wlr_xwayland_or_surface_wants_focus(xsurface->parent)) {
110 struct wlr_xwayland_surface *next_surface = 110 seat_set_focus_surface(seat, xsurface->parent->surface, false);
111 wlr_xwayland_surface_from_wlr_surface(xsurface->parent->surface); 111 return;
112 if (wlr_xwayland_or_surface_wants_focus(next_surface)) {
113 seat_set_focus_surface(seat, xsurface->parent->surface, false);
114 return;
115 }
116 } 112 }
117 113
118 // Restore focus 114 // Restore focus
@@ -258,6 +254,7 @@ static void set_activated(struct sway_view *view, bool activated) {
258 } 254 }
259 255
260 wlr_xwayland_surface_activate(surface, activated); 256 wlr_xwayland_surface_activate(surface, activated);
257 wlr_xwayland_surface_restack(surface, NULL, XCB_STACK_MODE_ABOVE);
261} 258}
262 259
263static void set_tiled(struct sway_view *view, bool tiled) { 260static void set_tiled(struct sway_view *view, bool tiled) {
@@ -399,30 +396,31 @@ static void handle_commit(struct wl_listener *listener, void *data) {
399 struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; 396 struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
400 struct wlr_surface_state *state = &xsurface->surface->current; 397 struct wlr_surface_state *state = &xsurface->surface->current;
401 398
399 struct wlr_box new_geo;
400 get_geometry(view, &new_geo);
401 bool new_size = new_geo.width != view->geometry.width ||
402 new_geo.height != view->geometry.height ||
403 new_geo.x != view->geometry.x ||
404 new_geo.y != view->geometry.y;
405
406 if (new_size) {
407 // The client changed its surface size in this commit. For floating
408 // containers, we resize the container to match. For tiling containers,
409 // we only recenter the surface.
410 desktop_damage_view(view);
411 memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
412 if (container_is_floating(view->container)) {
413 view_update_size(view);
414 transaction_commit_dirty_client();
415 } else {
416 view_center_surface(view);
417 }
418 desktop_damage_view(view);
419 }
420
402 if (view->container->node.instruction) { 421 if (view->container->node.instruction) {
403 get_geometry(view, &view->geometry);
404 transaction_notify_view_ready_by_geometry(view, 422 transaction_notify_view_ready_by_geometry(view,
405 xsurface->x, xsurface->y, state->width, state->height); 423 xsurface->x, xsurface->y, state->width, state->height);
406 } else {
407 struct wlr_box new_geo;
408 get_geometry(view, &new_geo);
409
410 if ((new_geo.width != view->geometry.width ||
411 new_geo.height != view->geometry.height ||
412 new_geo.x != view->geometry.x ||
413 new_geo.y != view->geometry.y)) {
414 // The view has unexpectedly sent a new size
415 // eg. The Firefox "Save As" dialog when downloading a file
416 desktop_damage_view(view);
417 view_update_size(view, new_geo.width, new_geo.height);
418 memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
419 desktop_damage_view(view);
420 transaction_commit_dirty();
421 transaction_notify_view_ready_by_geometry(view,
422 xsurface->x, xsurface->y, new_geo.width, new_geo.height);
423 } else {
424 memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
425 }
426 } 424 }
427 425
428 view_damage_from(view); 426 view_damage_from(view);
@@ -527,10 +525,10 @@ static void handle_request_configure(struct wl_listener *listener, void *data) {
527 view->natural_height = ev->height; 525 view->natural_height = ev->height;
528 container_floating_resize_and_center(view->container); 526 container_floating_resize_and_center(view->container);
529 527
530 configure(view, view->container->content_x, 528 configure(view, view->container->pending.content_x,
531 view->container->content_y, 529 view->container->pending.content_y,
532 view->container->content_width, 530 view->container->pending.content_width,
533 view->container->content_height); 531 view->container->pending.content_height);
534 node_set_dirty(&view->container->node); 532 node_set_dirty(&view->container->node);
535 } else { 533 } else {
536 configure(view, view->container->current.content_x, 534 configure(view, view->container->current.content_x,