aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar absrd <fk@bsrd.io>2019-01-29 20:52:59 +0100
committerLibravatar emersion <contact@emersion.fr>2019-01-30 19:53:59 +0100
commitee4b8a39385203a560818f99b380565d16bc7665 (patch)
treed2dad79e472eaa5314f4de46a72abf467d37e628
parentImplement pointer-constraints-unstable-v1 (diff)
downloadsway-ee4b8a39385203a560818f99b380565d16bc7665.tar.gz
sway-ee4b8a39385203a560818f99b380565d16bc7665.tar.zst
sway-ee4b8a39385203a560818f99b380565d16bc7665.zip
Add relative pointer
-rw-r--r--include/sway/server.h3
-rw-r--r--sway/input/cursor.c14
-rw-r--r--sway/server.c4
3 files changed, 21 insertions, 0 deletions
diff --git a/include/sway/server.h b/include/sway/server.h
index fa2c6557..5eef7c1a 100644
--- a/include/sway/server.h
+++ b/include/sway/server.h
@@ -9,6 +9,7 @@
9#include <wlr/types/wlr_data_device.h> 9#include <wlr/types/wlr_data_device.h>
10#include <wlr/types/wlr_layer_shell_v1.h> 10#include <wlr/types/wlr_layer_shell_v1.h>
11#include <wlr/types/wlr_presentation_time.h> 11#include <wlr/types/wlr_presentation_time.h>
12#include <wlr/types/wlr_relative_pointer_v1.h>
12#include <wlr/types/wlr_server_decoration.h> 13#include <wlr/types/wlr_server_decoration.h>
13#include <wlr/types/wlr_xdg_shell_v6.h> 14#include <wlr/types/wlr_xdg_shell_v6.h>
14#include <wlr/types/wlr_xdg_shell.h> 15#include <wlr/types/wlr_xdg_shell.h>
@@ -51,6 +52,8 @@ struct sway_server {
51 struct wl_listener xwayland_ready; 52 struct wl_listener xwayland_ready;
52#endif 53#endif
53 54
55 struct wlr_relative_pointer_manager_v1 *relative_pointer_manager;
56
54 struct wlr_server_decoration_manager *server_decoration_manager; 57 struct wlr_server_decoration_manager *server_decoration_manager;
55 struct wl_listener server_decoration; 58 struct wl_listener server_decoration;
56 struct wl_list decorations; // sway_server_decoration::link 59 struct wl_list decorations; // sway_server_decoration::link
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index c87efc2b..78e2f695 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -403,6 +403,14 @@ static void handle_cursor_motion(struct wl_listener *listener, void *data) {
403 double dx = event->delta_x; 403 double dx = event->delta_x;
404 double dy = event->delta_y; 404 double dy = event->delta_y;
405 405
406 double dx_unaccel = event->unaccel_dx;
407 double dy_unaccel = event->unaccel_dy;
408
409 wlr_relative_pointer_manager_v1_send_relative_motion(
410 server.relative_pointer_manager,
411 cursor->seat->wlr_seat, event->time_msec, dx, dy,
412 dx_unaccel, dy_unaccel);
413
406 struct wlr_surface *surface = NULL; 414 struct wlr_surface *surface = NULL;
407 double sx, sy; 415 double sx, sy;
408 struct sway_node *node = node_at_coords(cursor->seat, 416 struct sway_node *node = node_at_coords(cursor->seat,
@@ -438,6 +446,12 @@ static void cursor_motion_absolute(struct sway_cursor *cursor,
438 wlr_cursor_absolute_to_layout_coords(cursor->cursor, dev, 446 wlr_cursor_absolute_to_layout_coords(cursor->cursor, dev,
439 x, y, &lx, &ly); 447 x, y, &lx, &ly);
440 448
449 double dx = lx - cursor->cursor->x;
450 double dy = ly - cursor->cursor->y;
451 wlr_relative_pointer_manager_v1_send_relative_motion(
452 server.relative_pointer_manager,
453 cursor->seat->wlr_seat, (uint64_t)time_msec * 1000, dx, dy, dx, dy);
454
441 struct wlr_surface *surface = NULL; 455 struct wlr_surface *surface = NULL;
442 double sx, sy; 456 double sx, sy;
443 struct sway_node *node = node_at_coords(cursor->seat, 457 struct sway_node *node = node_at_coords(cursor->seat,
diff --git a/sway/server.c b/sway/server.c
index 82262585..712d8022 100644
--- a/sway/server.c
+++ b/sway/server.c
@@ -15,6 +15,7 @@
15#include <wlr/types/wlr_gtk_primary_selection.h> 15#include <wlr/types/wlr_gtk_primary_selection.h>
16#include <wlr/types/wlr_idle.h> 16#include <wlr/types/wlr_idle.h>
17#include <wlr/types/wlr_layer_shell_v1.h> 17#include <wlr/types/wlr_layer_shell_v1.h>
18#include <wlr/types/wlr_relative_pointer_v1.h>
18#include <wlr/types/wlr_pointer_constraints_v1.h> 19#include <wlr/types/wlr_pointer_constraints_v1.h>
19#include <wlr/types/wlr_screencopy_v1.h> 20#include <wlr/types/wlr_screencopy_v1.h>
20#include <wlr/types/wlr_server_decoration.h> 21#include <wlr/types/wlr_server_decoration.h>
@@ -106,6 +107,9 @@ bool server_init(struct sway_server *server) {
106 server->xdg_decoration.notify = handle_xdg_decoration; 107 server->xdg_decoration.notify = handle_xdg_decoration;
107 wl_list_init(&server->xdg_decorations); 108 wl_list_init(&server->xdg_decorations);
108 109
110 server->relative_pointer_manager =
111 wlr_relative_pointer_manager_v1_create(server->wl_display);
112
109 server->pointer_constraints = 113 server->pointer_constraints =
110 wlr_pointer_constraints_v1_create(server->wl_display); 114 wlr_pointer_constraints_v1_create(server->wl_display);
111 server->pointer_constraint.notify = handle_pointer_constraint; 115 server->pointer_constraint.notify = handle_pointer_constraint;