aboutsummaryrefslogtreecommitdiff
path: root/rootston/xwayland.c
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2017-11-03 14:49:15 +0100
committeremersion <contact@emersion.fr>2017-11-03 14:49:15 +0100
commitcf713edc1052943ceaf33fd3b41242b5775fd924 (patch)
treec20f7b856e8bb08b40b41bbab3afe6b9a0ff41f2 /rootston/xwayland.c
parentec11a95d0c945d138cede66b7c6e53e343c82f8f (diff)
Fix moving views when resizing below min size
Diffstat (limited to 'rootston/xwayland.c')
-rw-r--r--rootston/xwayland.c50
1 files changed, 41 insertions, 9 deletions
diff --git a/rootston/xwayland.c b/rootston/xwayland.c
index 2d7fe946..e3fc1c84 100644
--- a/rootston/xwayland.c
+++ b/rootston/xwayland.c
@@ -15,38 +15,69 @@ static void activate(struct roots_view *view, bool active) {
wlr_xwayland_surface_activate(xwayland, view->xwayland_surface, active);
}
-static void resize(struct roots_view *view, uint32_t width, uint32_t height) {
+static void move(struct roots_view *view, double x, double y) {
assert(view->type == ROOTS_XWAYLAND_VIEW);
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);
+}
+
+static void apply_size_constraints(
+ struct wlr_xwayland_surface *xwayland_surface, uint32_t width,
+ uint32_t height, uint32_t *dest_width, uint32_t *dest_height) {
+ *dest_width = width;
+ *dest_height = height;
struct wlr_xwayland_surface_size_hints *size_hints =
xwayland_surface->size_hints;
if (size_hints != NULL) {
if (width < (uint32_t)size_hints->min_width) {
- width = size_hints->min_width;
+ *dest_width = size_hints->min_width;
} else if (size_hints->max_width > 0 &&
width > (uint32_t)size_hints->max_width) {
- width = size_hints->max_width;
+ *dest_width = size_hints->max_width;
}
if (height < (uint32_t)size_hints->min_height) {
- height = size_hints->min_height;
+ *dest_height = size_hints->min_height;
} else if (size_hints->max_height > 0 &&
height > (uint32_t)size_hints->max_height) {
- height = size_hints->max_height;
+ *dest_height = size_hints->max_height;
}
}
+}
+
+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);
wlr_xwayland_surface_configure(view->desktop->xwayland, xwayland_surface,
- xwayland_surface->x, xwayland_surface->y, width, height);
+ xwayland_surface->x, xwayland_surface->y, contrained_width,
+ contrained_height);
}
-static void set_position(struct roots_view *view, double x, double y) {
+static void move_resize(struct roots_view *view, double x, double y,
+ 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);
+
+ x = x + width - contrained_width;
+ y = y + height - contrained_height;
+
view->x = x;
view->y = y;
+
wlr_xwayland_surface_configure(view->desktop->xwayland, xwayland_surface,
- x, y, xwayland_surface->width, xwayland_surface->height);
+ x, y, contrained_width, contrained_height);
}
static void close(struct roots_view *view) {
@@ -204,7 +235,8 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
view->desktop = desktop;
view->activate = activate;
view->resize = resize;
- view->set_position = set_position;
+ view->move = move;
+ view->move_resize = move_resize;
view->close = close;
roots_surface->view = view;
wlr_list_add(desktop->views, view);