React to xdg shell resize requests

This commit is contained in:
emersion 2017-09-30 10:39:06 +02:00
parent 0c48ef5ad8
commit 97679b8e12
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
5 changed files with 39 additions and 4 deletions

View file

@ -14,6 +14,11 @@ static void get_input_bounds(struct roots_view *view, struct wlr_box *box) {
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6;
memcpy(box, surf->geometry, sizeof(struct wlr_box));
// TODO: real input bounds
box->x -= 10;
box->y -= 10;
box->width += 20;
box->height += 20;
}
static void activate(struct roots_view *view, bool active) {
@ -37,6 +42,19 @@ static void handle_request_move(struct wl_listener *listener, void *data) {
view_begin_move(input, event->cursor, view);
}
static void handle_request_resize(struct wl_listener *listener, void *data) {
struct roots_xdg_surface_v6 *roots_xdg_surface =
wl_container_of(listener, roots_xdg_surface, request_resize);
struct roots_view *view = roots_xdg_surface->view;
struct roots_input *input = view->desktop->server->input;
struct wlr_xdg_toplevel_v6_resize_event *e = data;
const struct roots_input_event *event = get_input_event(input, e->serial);
if (!event || input->mode != ROOTS_CURSOR_PASSTHROUGH) {
return;
}
view_begin_resize(input, event->cursor, view);
}
static void handle_destroy(struct wl_listener *listener, void *data) {
struct roots_xdg_surface_v6 *roots_xdg_surface =
wl_container_of(listener, roots_xdg_surface, destroy);
@ -71,6 +89,9 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
roots_surface->request_move.notify = handle_request_move;
wl_signal_add(&surface->events.request_move, &roots_surface->request_move);
wl_list_init(&roots_surface->request_resize.link);
roots_surface->request_resize.notify = handle_request_resize;
wl_signal_add(&surface->events.request_resize,
&roots_surface->request_resize);
wl_list_init(&roots_surface->request_show_window_menu.link);
struct roots_view *view = calloc(1, sizeof(struct roots_view));