djpohly / dwl

dwm for Wayland - ARCHIVE: development has moved to Codeberg
https://codeberg.org/dwl/dwl
Other
1.94k stars 283 forks source link

Enable wlroots relative pointer and pointer constraint #473

Closed mpolitzer closed 1 year ago

mpolitzer commented 1 year ago

I had issues running a first person shooter game[1] on dwl. The mouse was "stuck" pointing down at the ground regardless of what type of motion I did making the game unplayable. After running the game successfully on sway I enabled the relative pointer extension on dwl as a test and got it to work.

I added the patch[2] below in case anyone else is interested in this.

best, Marcelo

[1] "7 days to die" via "Steam" [2]

diff --git a/dwl.c b/dwl.c
index 4ff5c37..3e553d1 100644
--- a/dwl.c
+++ b/dwl.c
@@ -50,6 +50,7 @@
 #include <wlr/types/wlr_xdg_decoration_v1.h>
 #include <wlr/types/wlr_xdg_output_v1.h>
 #include <wlr/types/wlr_xdg_shell.h>
+#include <wlr/types/wlr_relative_pointer_v1.h>
 #include <wlr/util/log.h>
 #include <xkbcommon/xkbcommon.h>
 #ifdef XWAYLAND
@@ -348,6 +349,7 @@ static struct wlr_input_inhibit_manager *input_inhibit_mgr;
 static struct wlr_layer_shell_v1 *layer_shell;
 static struct wlr_output_manager_v1 *output_mgr;
 static struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard_mgr;
+struct wlr_relative_pointer_manager_v1 *relative_pointer_mgr;

 static struct wlr_cursor *cursor;
 static struct wlr_xcursor_manager *cursor_mgr;
@@ -1713,6 +1715,12 @@ motionrelative(struct wl_listener *listener, void *data)
     * special configuration applied for the specific input device which
     * generated the event. You can pass NULL for the device if you want to move
     * the cursor around without any input. */
+   wlr_relative_pointer_manager_v1_send_relative_motion
+       (relative_pointer_mgr
+       ,seat
+       ,(uint64_t)event->time_msec * 1000
+       ,event->delta_x, event->delta_y
+       ,event->unaccel_dx, event->unaccel_dy);
    wlr_cursor_move(cursor, &event->pointer->base, event->delta_x, event->delta_y);
    motionnotify(event->time_msec);
 }
@@ -2184,6 +2192,7 @@ setup(void)
    wlr_viewporter_create(dpy);
    wlr_single_pixel_buffer_manager_v1_create(dpy);
    wlr_subcompositor_create(dpy);
+   relative_pointer_mgr = wlr_relative_pointer_manager_v1_create(dpy);

    /* Initializes the interface used to implement urgency hints */
    activation = wlr_xdg_activation_v1_create(dpy);
mpolitzer commented 1 year ago

Could somebody help with implementing the wlr_pointer_constraint_v1?

pm4rcin commented 1 year ago

Duplicate #317. Check that discussion. As for patches both are on wiki.

mpolitzer commented 1 year ago

I missed that. Thanks.