aboutsummaryrefslogtreecommitdiff
path: root/rootston/xdg_shell_v6.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-09-23 18:18:19 -0400
committerDrew DeVault <sir@cmpwn.com>2017-09-23 18:18:19 -0400
commit0ca7932c3f23dddd7e8375a89e727223d665c8d5 (patch)
treefbe23d68b68c668baa50e5e70a22713f6c8d5dc1 /rootston/xdg_shell_v6.c
parent96b401c05d03f801c303ebe591bb6e208281d0ac (diff)
Implement xdg surface request_move
Diffstat (limited to 'rootston/xdg_shell_v6.c')
-rw-r--r--rootston/xdg_shell_v6.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c
index 0c32bd97..4a809930 100644
--- a/rootston/xdg_shell_v6.c
+++ b/rootston/xdg_shell_v6.c
@@ -8,6 +8,7 @@
#include <wlr/util/log.h>
#include "rootston/desktop.h"
#include "rootston/server.h"
+#include "rootston/input.h"
static void get_input_bounds(struct roots_view *view, struct wlr_box *box) {
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
@@ -23,6 +24,32 @@ static void activate(struct roots_view *view, bool active) {
}
}
+static void handle_request_move(struct wl_listener *listener, void *data) {
+ struct roots_xdg_surface_v6 *roots_xdg_surface =
+ wl_container_of(listener, roots_xdg_surface, request_move);
+ struct roots_view *view = roots_xdg_surface->view;
+ struct roots_input *input = view->desktop->server->input;
+ struct wlr_xdg_toplevel_v6_move_event *e = data;
+
+ // TODO: Some of this might want to live in cursor.c I guess
+ struct roots_input_event *event = NULL;
+ size_t len = sizeof(input->input_events) / sizeof(*input->input_events);
+ for (size_t i = 0; i < len; ++i) {
+ if (input->input_events[i].cursor
+ && input->input_events[i].serial == e->serial) {
+ event = &input->input_events[i];
+ break;
+ }
+ }
+ if (!event || input->mode != ROOTS_CURSOR_PASSTHROUGH) {
+ return;
+ }
+ input->mode = ROOTS_CURSOR_MOVE;
+ input->offs_x = input->cursor->x - view->x;
+ input->offs_y = input->cursor->y - view->y;
+ wlr_seat_pointer_clear_focus(input->wl_seat);
+}
+
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);
@@ -54,6 +81,8 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
wl_list_init(&roots_surface->ping_timeout.link);
wl_list_init(&roots_surface->request_minimize.link);
wl_list_init(&roots_surface->request_move.link);
+ 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);
wl_list_init(&roots_surface->request_show_window_menu.link);
@@ -65,6 +94,7 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
view->wlr_surface = surface->surface;
view->get_input_bounds = get_input_bounds;
view->activate = activate;
+ view->desktop = desktop;
roots_surface->view = view;
wl_list_insert(&desktop->views, &view->link);
}