mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-01-02 11:08:24 -05:00
Fix moving views when resizing below min size
This commit is contained in:
parent
ec11a95d0c
commit
cf713edc10
6 changed files with 159 additions and 66 deletions
|
|
@ -15,32 +15,7 @@ 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) {
|
||||
assert(view->type == ROOTS_XWAYLAND_VIEW);
|
||||
struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface;
|
||||
|
||||
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;
|
||||
} else if (size_hints->max_width > 0 &&
|
||||
width > (uint32_t)size_hints->max_width) {
|
||||
width = size_hints->max_width;
|
||||
}
|
||||
if (height < (uint32_t)size_hints->min_height) {
|
||||
height = size_hints->min_height;
|
||||
} else if (size_hints->max_height > 0 &&
|
||||
height > (uint32_t)size_hints->max_height) {
|
||||
height = size_hints->max_height;
|
||||
}
|
||||
}
|
||||
|
||||
wlr_xwayland_surface_configure(view->desktop->xwayland, xwayland_surface,
|
||||
xwayland_surface->x, xwayland_surface->y, width, height);
|
||||
}
|
||||
|
||||
static void set_position(struct roots_view *view, double x, double y) {
|
||||
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;
|
||||
|
|
@ -49,6 +24,62 @@ static void set_position(struct roots_view *view, double x, double y) {
|
|||
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) {
|
||||
*dest_width = size_hints->min_width;
|
||||
} else if (size_hints->max_width > 0 &&
|
||||
width > (uint32_t)size_hints->max_width) {
|
||||
*dest_width = size_hints->max_width;
|
||||
}
|
||||
if (height < (uint32_t)size_hints->min_height) {
|
||||
*dest_height = size_hints->min_height;
|
||||
} else if (size_hints->max_height > 0 &&
|
||||
height > (uint32_t)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, contrained_width,
|
||||
contrained_height);
|
||||
}
|
||||
|
||||
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, contrained_width, contrained_height);
|
||||
}
|
||||
|
||||
static void close(struct roots_view *view) {
|
||||
assert(view->type == ROOTS_XWAYLAND_VIEW);
|
||||
wlr_xwayland_surface_close(view->desktop->xwayland, view->xwayland_surface);
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue