diff options
author | Tony Crisci <tony@dubstepdish.com> | 2017-11-05 08:09:45 -0500 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2017-11-05 08:09:45 -0500 |
commit | b74c4cf974933f2e1dedf8f872bd43b5b25277a4 (patch) | |
tree | 79b300e5d1d268004cdf2272e6b2f6987b990232 /rootston/xwayland.c | |
parent | 704f0f158a669689b78311cde35a736057f983b4 (diff) | |
parent | 74a45ee776ec05b5dbe7bae5be456ba08a850d7b (diff) |
Merge branch 'master' into feature/multiseat
Diffstat (limited to 'rootston/xwayland.c')
-rw-r--r-- | rootston/xwayland.c | 50 |
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); |