Add relative pointer
This commit is contained in:
parent
cedde21c96
commit
ee4b8a3938
|
@ -9,6 +9,7 @@
|
||||||
#include <wlr/types/wlr_data_device.h>
|
#include <wlr/types/wlr_data_device.h>
|
||||||
#include <wlr/types/wlr_layer_shell_v1.h>
|
#include <wlr/types/wlr_layer_shell_v1.h>
|
||||||
#include <wlr/types/wlr_presentation_time.h>
|
#include <wlr/types/wlr_presentation_time.h>
|
||||||
|
#include <wlr/types/wlr_relative_pointer_v1.h>
|
||||||
#include <wlr/types/wlr_server_decoration.h>
|
#include <wlr/types/wlr_server_decoration.h>
|
||||||
#include <wlr/types/wlr_xdg_shell_v6.h>
|
#include <wlr/types/wlr_xdg_shell_v6.h>
|
||||||
#include <wlr/types/wlr_xdg_shell.h>
|
#include <wlr/types/wlr_xdg_shell.h>
|
||||||
|
@ -51,6 +52,8 @@ struct sway_server {
|
||||||
struct wl_listener xwayland_ready;
|
struct wl_listener xwayland_ready;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct wlr_relative_pointer_manager_v1 *relative_pointer_manager;
|
||||||
|
|
||||||
struct wlr_server_decoration_manager *server_decoration_manager;
|
struct wlr_server_decoration_manager *server_decoration_manager;
|
||||||
struct wl_listener server_decoration;
|
struct wl_listener server_decoration;
|
||||||
struct wl_list decorations; // sway_server_decoration::link
|
struct wl_list decorations; // sway_server_decoration::link
|
||||||
|
|
|
@ -403,6 +403,14 @@ static void handle_cursor_motion(struct wl_listener *listener, void *data) {
|
||||||
double dx = event->delta_x;
|
double dx = event->delta_x;
|
||||||
double dy = event->delta_y;
|
double dy = event->delta_y;
|
||||||
|
|
||||||
|
double dx_unaccel = event->unaccel_dx;
|
||||||
|
double dy_unaccel = event->unaccel_dy;
|
||||||
|
|
||||||
|
wlr_relative_pointer_manager_v1_send_relative_motion(
|
||||||
|
server.relative_pointer_manager,
|
||||||
|
cursor->seat->wlr_seat, event->time_msec, dx, dy,
|
||||||
|
dx_unaccel, dy_unaccel);
|
||||||
|
|
||||||
struct wlr_surface *surface = NULL;
|
struct wlr_surface *surface = NULL;
|
||||||
double sx, sy;
|
double sx, sy;
|
||||||
struct sway_node *node = node_at_coords(cursor->seat,
|
struct sway_node *node = node_at_coords(cursor->seat,
|
||||||
|
@ -438,6 +446,12 @@ static void cursor_motion_absolute(struct sway_cursor *cursor,
|
||||||
wlr_cursor_absolute_to_layout_coords(cursor->cursor, dev,
|
wlr_cursor_absolute_to_layout_coords(cursor->cursor, dev,
|
||||||
x, y, &lx, &ly);
|
x, y, &lx, &ly);
|
||||||
|
|
||||||
|
double dx = lx - cursor->cursor->x;
|
||||||
|
double dy = ly - cursor->cursor->y;
|
||||||
|
wlr_relative_pointer_manager_v1_send_relative_motion(
|
||||||
|
server.relative_pointer_manager,
|
||||||
|
cursor->seat->wlr_seat, (uint64_t)time_msec * 1000, dx, dy, dx, dy);
|
||||||
|
|
||||||
struct wlr_surface *surface = NULL;
|
struct wlr_surface *surface = NULL;
|
||||||
double sx, sy;
|
double sx, sy;
|
||||||
struct sway_node *node = node_at_coords(cursor->seat,
|
struct sway_node *node = node_at_coords(cursor->seat,
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <wlr/types/wlr_gtk_primary_selection.h>
|
#include <wlr/types/wlr_gtk_primary_selection.h>
|
||||||
#include <wlr/types/wlr_idle.h>
|
#include <wlr/types/wlr_idle.h>
|
||||||
#include <wlr/types/wlr_layer_shell_v1.h>
|
#include <wlr/types/wlr_layer_shell_v1.h>
|
||||||
|
#include <wlr/types/wlr_relative_pointer_v1.h>
|
||||||
#include <wlr/types/wlr_pointer_constraints_v1.h>
|
#include <wlr/types/wlr_pointer_constraints_v1.h>
|
||||||
#include <wlr/types/wlr_screencopy_v1.h>
|
#include <wlr/types/wlr_screencopy_v1.h>
|
||||||
#include <wlr/types/wlr_server_decoration.h>
|
#include <wlr/types/wlr_server_decoration.h>
|
||||||
|
@ -106,6 +107,9 @@ bool server_init(struct sway_server *server) {
|
||||||
server->xdg_decoration.notify = handle_xdg_decoration;
|
server->xdg_decoration.notify = handle_xdg_decoration;
|
||||||
wl_list_init(&server->xdg_decorations);
|
wl_list_init(&server->xdg_decorations);
|
||||||
|
|
||||||
|
server->relative_pointer_manager =
|
||||||
|
wlr_relative_pointer_manager_v1_create(server->wl_display);
|
||||||
|
|
||||||
server->pointer_constraints =
|
server->pointer_constraints =
|
||||||
wlr_pointer_constraints_v1_create(server->wl_display);
|
wlr_pointer_constraints_v1_create(server->wl_display);
|
||||||
server->pointer_constraint.notify = handle_pointer_constraint;
|
server->pointer_constraint.notify = handle_pointer_constraint;
|
||||||
|
|
Loading…
Reference in a new issue