summaryrefslogtreecommitdiff
path: root/sway/desktop/xwayland.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/desktop/xwayland.c')
-rw-r--r--sway/desktop/xwayland.c76
1 files changed, 51 insertions, 25 deletions
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 6447b711..a1837420 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -11,6 +11,7 @@
#include "sway/input/seat.h"
#include "sway/output.h"
#include "sway/server.h"
+#include "sway/tree/arrange.h"
#include "sway/tree/container.h"
#include "sway/tree/layout.h"
#include "sway/tree/view.h"
@@ -167,19 +168,18 @@ static uint32_t get_int_prop(struct sway_view *view, enum sway_view_prop prop) {
}
}
-static void configure(struct sway_view *view, double lx, double ly, int width,
+static uint32_t configure(struct sway_view *view, double lx, double ly, int width,
int height) {
struct sway_xwayland_view *xwayland_view = xwayland_view_from_view(view);
if (xwayland_view == NULL) {
- return;
+ return 0;
}
struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
- xwayland_view->pending_lx = lx;
- xwayland_view->pending_ly = ly;
- xwayland_view->pending_width = width;
- xwayland_view->pending_height = height;
wlr_xwayland_surface_configure(xsurface, lx, ly, width, height);
+
+ // xwayland doesn't give us a serial for the configure
+ return 0;
}
static void set_activated(struct sway_view *view, bool activated) {
@@ -218,19 +218,11 @@ static void _close(struct sway_view *view) {
wlr_xwayland_surface_close(view->wlr_xwayland_surface);
}
-static void destroy(struct sway_view *view) {
+static void _free(struct sway_view *view) {
struct sway_xwayland_view *xwayland_view = xwayland_view_from_view(view);
if (xwayland_view == NULL) {
return;
}
- wl_list_remove(&xwayland_view->destroy.link);
- wl_list_remove(&xwayland_view->request_configure.link);
- wl_list_remove(&xwayland_view->request_fullscreen.link);
- wl_list_remove(&xwayland_view->set_title.link);
- wl_list_remove(&xwayland_view->set_class.link);
- wl_list_remove(&xwayland_view->set_window_type.link);
- wl_list_remove(&xwayland_view->map.link);
- wl_list_remove(&xwayland_view->unmap.link);
free(xwayland_view);
}
@@ -242,7 +234,7 @@ static const struct sway_view_impl view_impl = {
.set_fullscreen = set_fullscreen,
.wants_floating = wants_floating,
.close = _close,
- .destroy = destroy,
+ .free = _free,
};
static void handle_commit(struct wl_listener *listener, void *data) {
@@ -250,22 +242,35 @@ static void handle_commit(struct wl_listener *listener, void *data) {
wl_container_of(listener, xwayland_view, commit);
struct sway_view *view = &xwayland_view->view;
struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
- if (view->swayc && container_is_floating(view->swayc)) {
- view_update_size(view, xsurface->width, xsurface->height);
- } else {
- view_update_size(view, xwayland_view->pending_width,
- xwayland_view->pending_height);
+
+ // Don't allow xwayland views to do resize or reposition themselves if
+ // they're involved in a transaction. Once the transaction has finished
+ // they'll apply the next time a commit happens.
+ if (view->swayc && view->swayc->instructions->length) {
+ if (view->swayc && container_is_floating(view->swayc)) {
+ view_update_size(view, xsurface->width, xsurface->height);
+ } else {
+ view_update_size(view, view->swayc->width, view->swayc->height);
+ }
+ view_update_position(view, view->x, view->y);
}
- view_update_position(view,
- xwayland_view->pending_lx, xwayland_view->pending_ly);
view_damage_from(view);
}
static void handle_unmap(struct wl_listener *listener, void *data) {
struct sway_xwayland_view *xwayland_view =
wl_container_of(listener, xwayland_view, unmap);
+ struct sway_view *view = &xwayland_view->view;
+
+ if (!sway_assert(view->surface, "Cannot unmap unmapped view")) {
+ return;
+ }
+
+ struct sway_container *parent = view_unmap(view);
+ arrange_and_commit(parent);
+
wl_list_remove(&xwayland_view->commit.link);
- view_unmap(&xwayland_view->view);
+ view->surface = NULL;
}
static void handle_map(struct wl_listener *listener, void *data) {
@@ -289,11 +294,30 @@ static void handle_map(struct wl_listener *listener, void *data) {
if (xsurface->fullscreen) {
view_set_fullscreen(view, true);
}
+ arrange_and_commit(view->swayc->parent);
}
static void handle_destroy(struct wl_listener *listener, void *data) {
struct sway_xwayland_view *xwayland_view =
wl_container_of(listener, xwayland_view, destroy);
+ struct sway_view *view = &xwayland_view->view;
+
+ if (view->surface) {
+ struct sway_container *parent = view_unmap(view);
+ arrange_and_commit(parent);
+
+ wl_list_remove(&xwayland_view->commit.link);
+ view->surface = NULL;
+ }
+
+ wl_list_remove(&xwayland_view->destroy.link);
+ wl_list_remove(&xwayland_view->request_configure.link);
+ wl_list_remove(&xwayland_view->request_fullscreen.link);
+ wl_list_remove(&xwayland_view->set_title.link);
+ wl_list_remove(&xwayland_view->set_class.link);
+ wl_list_remove(&xwayland_view->set_window_type.link);
+ wl_list_remove(&xwayland_view->map.link);
+ wl_list_remove(&xwayland_view->unmap.link);
view_destroy(&xwayland_view->view);
}
@@ -309,7 +333,8 @@ static void handle_request_configure(struct wl_listener *listener, void *data) {
return;
}
// TODO: Let floating views do whatever
- configure(view, view->swayc->x, view->swayc->y, view->width, view->height);
+ configure(view, view->swayc->current.view_x, view->swayc->current.view_y,
+ view->swayc->current.view_width, view->swayc->current.view_height);
}
static void handle_request_fullscreen(struct wl_listener *listener, void *data) {
@@ -321,6 +346,7 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data)
return;
}
view_set_fullscreen(view, xsurface->fullscreen);
+ arrange_and_commit(view->swayc);
}
static void handle_set_title(struct wl_listener *listener, void *data) {