|
|
|
@ -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);
|
|
|
|
|