aboutsummaryrefslogtreecommitdiff
path: root/rootston
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2019-01-04 13:42:53 +0100
committerGitHub <noreply@github.com>2019-01-04 13:42:53 +0100
commit610f5bfc7712657fafea507f3d830cd6d60dc836 (patch)
tree8be316c900366e386349b28d5943105deee88a71 /rootston
parentbcf48931db14f24fcd35a6999969864ca2539d32 (diff)
parent78caed0c99f64e6192778ea90371848323f72379 (diff)
Merge pull request #1432 from ForTheReallys/relative-pointers
Relative pointers
Diffstat (limited to 'rootston')
-rw-r--r--rootston/cursor.c36
-rw-r--r--rootston/desktop.c2
2 files changed, 38 insertions, 0 deletions
diff --git a/rootston/cursor.c b/rootston/cursor.c
index b9ded30e..1fdf1dbb 100644
--- a/rootston/cursor.c
+++ b/rootston/cursor.c
@@ -305,11 +305,41 @@ static void roots_cursor_press_button(struct roots_cursor *cursor,
}
}
+static void notify_relative_motion(struct roots_seat *seat, uint64_t time_msec,
+ double dx, double dy, double dx_unaccel, double dy_unaccel) {
+ struct wlr_relative_pointer_manager_v1 *relative_pointer_manager =
+ seat->input->server->desktop->relative_pointer_manager;
+
+ struct wlr_seat_client *client = seat->seat->pointer_state.focused_client;
+ if (client == NULL) {
+ return;
+ }
+
+ struct wlr_relative_pointer_v1 *pointer;
+ wl_list_for_each(pointer, &relative_pointer_manager->relative_pointers, link) {
+ struct wlr_seat_client *relative_pointer_client =
+ wlr_seat_client_from_pointer_resource(pointer->pointer);
+
+ if (seat->seat == pointer->seat &&
+ client == relative_pointer_client) {
+ wlr_relative_pointer_v1_send_relative_motion(pointer,
+ time_msec, dx, dy, dx_unaccel, dy_unaccel);
+ }
+
+ }
+}
+
void roots_cursor_handle_motion(struct roots_cursor *cursor,
struct wlr_event_pointer_motion *event) {
double dx = event->delta_x;
double dy = event->delta_y;
+ double unaccel_dx = event->unaccel_dx;
+ double unaccel_dy = event->unaccel_dy;
+
+ notify_relative_motion(cursor->seat,
+ (uint64_t)event->time_msec * 1000, dx, dy, unaccel_dx, unaccel_dy);
+
if (cursor->active_constraint) {
struct roots_view *view = cursor->pointer_view->view;
assert(view);
@@ -349,6 +379,12 @@ void roots_cursor_handle_motion_absolute(struct roots_cursor *cursor,
wlr_cursor_absolute_to_layout_coords(cursor->cursor, event->device, event->x,
event->y, &lx, &ly);
+ double dx = lx - cursor->cursor->x;
+ double dy = ly - cursor->cursor->y;
+
+ notify_relative_motion(cursor->seat,
+ (uint64_t)event->time_msec * 1000, dx, dy, dx, dy);
+
if (cursor->pointer_view) {
struct roots_view *view = cursor->pointer_view->view;
diff --git a/rootston/desktop.c b/rootston/desktop.c
index 48e2635c..77a52571 100644
--- a/rootston/desktop.c
+++ b/rootston/desktop.c
@@ -1081,6 +1081,8 @@ struct roots_desktop *desktop_create(struct roots_server *server,
wlr_presentation_create(server->wl_display, server->backend);
desktop->foreign_toplevel_manager_v1 =
wlr_foreign_toplevel_manager_v1_create(server->wl_display);
+ desktop->relative_pointer_manager =
+ wlr_relative_pointer_manager_v1_create(server->wl_display);
return desktop;
}