aboutsummaryrefslogtreecommitdiff
path: root/rootston/xwayland.c
diff options
context:
space:
mode:
Diffstat (limited to 'rootston/xwayland.c')
-rw-r--r--rootston/xwayland.c107
1 files changed, 83 insertions, 24 deletions
diff --git a/rootston/xwayland.c b/rootston/xwayland.c
index dfa602b1..5f677116 100644
--- a/rootston/xwayland.c
+++ b/rootston/xwayland.c
@@ -11,8 +11,7 @@
static void activate(struct roots_view *view, bool active) {
assert(view->type == ROOTS_XWAYLAND_VIEW);
- struct wlr_xwayland *xwayland = view->desktop->xwayland;
- wlr_xwayland_surface_activate(xwayland, view->xwayland_surface, active);
+ wlr_xwayland_surface_activate(view->xwayland_surface, active);
}
static void move(struct roots_view *view, double x, double y) {
@@ -20,8 +19,8 @@ static void move(struct roots_view *view, double x, double y) {
struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface;
view->x = x;
view->y = y;
- wlr_xwayland_surface_configure(view->desktop->xwayland, xwayland_surface,
- x, y, xwayland_surface->width, xwayland_surface->height);
+ wlr_xwayland_surface_configure(xwayland_surface, x, y,
+ xwayland_surface->width, xwayland_surface->height);
}
static void apply_size_constraints(
@@ -52,13 +51,12 @@ static void resize(struct roots_view *view, uint32_t width, uint32_t height) {
assert(view->type == ROOTS_XWAYLAND_VIEW);
struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface;
- uint32_t contrained_width, contrained_height;
- apply_size_constraints(xwayland_surface, width, height, &contrained_width,
- &contrained_height);
+ uint32_t constrained_width, constrained_height;
+ apply_size_constraints(xwayland_surface, width, height, &constrained_width,
+ &constrained_height);
- wlr_xwayland_surface_configure(view->desktop->xwayland, xwayland_surface,
- xwayland_surface->x, xwayland_surface->y, contrained_width,
- contrained_height);
+ wlr_xwayland_surface_configure(xwayland_surface, xwayland_surface->x,
+ xwayland_surface->y, constrained_width, constrained_height);
}
static void move_resize(struct roots_view *view, double x, double y,
@@ -66,30 +64,46 @@ static void move_resize(struct roots_view *view, double x, double y,
assert(view->type == ROOTS_XWAYLAND_VIEW);
struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface;
- uint32_t contrained_width, contrained_height;
- apply_size_constraints(xwayland_surface, width, height, &contrained_width,
- &contrained_height);
+ bool update_x = x != view->x;
+ bool update_y = y != view->y;
- x = x + width - contrained_width;
- y = y + height - contrained_height;
+ uint32_t constrained_width, constrained_height;
+ apply_size_constraints(xwayland_surface, width, height, &constrained_width,
+ &constrained_height);
- view->x = x;
- view->y = y;
+ if (update_x) {
+ x = x + width - constrained_width;
+ }
+ if (update_y) {
+ y = y + height - constrained_height;
+ }
- wlr_xwayland_surface_configure(view->desktop->xwayland, xwayland_surface,
- x, y, contrained_width, contrained_height);
+ view->pending_move_resize.update_x = update_x;
+ view->pending_move_resize.update_y = update_y;
+ view->pending_move_resize.x = x;
+ view->pending_move_resize.y = y;
+ view->pending_move_resize.width = constrained_width;
+ view->pending_move_resize.height = constrained_height;
+
+ wlr_xwayland_surface_configure(xwayland_surface, x, y, constrained_width,
+ constrained_height);
}
static void close(struct roots_view *view) {
assert(view->type == ROOTS_XWAYLAND_VIEW);
- wlr_xwayland_surface_close(view->desktop->xwayland, view->xwayland_surface);
+ wlr_xwayland_surface_close(view->xwayland_surface);
}
static void maximize(struct roots_view *view, bool maximized) {
assert(view->type == ROOTS_XWAYLAND_VIEW);
- wlr_xwayland_surface_set_maximized(view->desktop->xwayland,
- view->xwayland_surface, maximized);
+ wlr_xwayland_surface_set_maximized(view->xwayland_surface, maximized);
+}
+
+static void set_fullscreen(struct roots_view *view, bool fullscreen) {
+ assert(view->type == ROOTS_XWAYLAND_VIEW);
+
+ wlr_xwayland_surface_set_fullscreen(view->xwayland_surface, fullscreen);
}
static void handle_destroy(struct wl_listener *listener, void *data) {
@@ -121,8 +135,8 @@ static void handle_request_configure(struct wl_listener *listener, void *data) {
roots_surface->view->x = (double)event->x;
roots_surface->view->y = (double)event->y;
- wlr_xwayland_surface_configure(roots_surface->view->desktop->xwayland,
- xwayland_surface, event->x, event->y, event->width, event->height);
+ wlr_xwayland_surface_configure(xwayland_surface, event->x, event->y,
+ event->width, event->height);
}
static struct roots_seat *guess_seat_for_view(struct roots_view *view) {
@@ -175,6 +189,37 @@ static void handle_request_maximize(struct wl_listener *listener, void *data) {
view_maximize(view, maximized);
}
+static void handle_request_fullscreen(struct wl_listener *listener,
+ void *data) {
+ struct roots_xwayland_surface *roots_surface =
+ wl_container_of(listener, roots_surface, request_fullscreen);
+ struct roots_view *view = roots_surface->view;
+ struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface;
+
+ view_set_fullscreen(view, xwayland_surface->fullscreen, NULL);
+}
+
+static void handle_surface_commit(struct wl_listener *listener, void *data) {
+ struct roots_xwayland_surface *roots_surface =
+ wl_container_of(listener, roots_surface, surface_commit);
+ struct roots_view *view = roots_surface->view;
+ struct wlr_surface *wlr_surface = view->wlr_surface;
+
+ int width = wlr_surface->current->width;
+ int height = wlr_surface->current->height;
+
+ if (view->pending_move_resize.update_x) {
+ view->x = view->pending_move_resize.x +
+ view->pending_move_resize.width - width;
+ view->pending_move_resize.update_x = false;
+ }
+ if (view->pending_move_resize.update_y) {
+ view->y = view->pending_move_resize.y +
+ view->pending_move_resize.height - height;
+ view->pending_move_resize.update_y = false;
+ }
+}
+
static void handle_map_notify(struct wl_listener *listener, void *data) {
struct roots_xwayland_surface *roots_surface =
wl_container_of(listener, roots_surface, map_notify);
@@ -186,6 +231,10 @@ static void handle_map_notify(struct wl_listener *listener, void *data) {
view->x = (double)xsurface->x;
view->y = (double)xsurface->y;
+ roots_surface->surface_commit.notify = handle_surface_commit;
+ wl_signal_add(&xsurface->surface->events.commit,
+ &roots_surface->surface_commit);
+
wl_list_insert(&desktop->views, &view->link);
}
@@ -194,6 +243,8 @@ static void handle_unmap_notify(struct wl_listener *listener, void *data) {
wl_container_of(listener, roots_surface, unmap_notify);
roots_surface->view->wlr_surface = NULL;
+ wl_list_remove(&roots_surface->surface_commit.link);
+
wl_list_remove(&roots_surface->view->link);
}
@@ -228,6 +279,13 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
roots_surface->request_maximize.notify = handle_request_maximize;
wl_signal_add(&surface->events.request_maximize,
&roots_surface->request_maximize);
+ roots_surface->request_fullscreen.notify = handle_request_fullscreen;
+ wl_signal_add(&surface->events.request_fullscreen,
+ &roots_surface->request_fullscreen);
+
+ roots_surface->surface_commit.notify = handle_surface_commit;
+ wl_signal_add(&surface->surface->events.commit,
+ &roots_surface->surface_commit);
struct roots_view *view = calloc(1, sizeof(struct roots_view));
if (view == NULL) {
@@ -245,6 +303,7 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
view->move = move;
view->move_resize = move_resize;
view->maximize = maximize;
+ view->set_fullscreen = set_fullscreen;
view->close = close;
roots_surface->view = view;
view_init(view, desktop);