Use Wayland protocol to warp pointer (PR #25721)

49 views
Skip to first unread message

VZ

unread,
Aug 22, 2025, 2:04:09 PMAug 22
to wx-...@googlegroups.com, Subscribed

See #23778.

This has been only tested with Jay Wayland compositor as it's the only one I could find that implements this protocol already. Unfortunately this doesn't work quite right there:

  1. The position of the cursor seems to be off by the decorations size.
  2. When the mouse moves after warp, it jumps back to the old position.

I could work around (1) but (2) makes this rather unusable, so I hope that it's a bug in Jay (at least in the scenario in which I'm using it, as a nested compositor), and I wonder if (1) couldn't be a bug too, so it would be great if somebody could please test this with a more common compositor supporting this protocol.


You can view, comment on, or merge this pull request online at:

  https://github.com/wxWidgets/wxWidgets/pull/25721

Commit Summary

  • 655f902 Test WarpPointer() in the drawing sample
  • 147458e Use wp_pointer_warp_v1 if available in wxWindow::WarpPointer()

File Changes

(15 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25721@github.com>

VZ

unread,
Aug 22, 2025, 3:23:28 PMAug 22
to wx-...@googlegroups.com, Push

@vadz pushed 5 commits.

  • ceace94 Fix compilation with old Wayland client protocol headers
  • e23a779 Don't crash on startup when using X11 and not Wayland
  • 9ba03ae Exclude headers generated by wayland-scanner from code checks
  • b9641f3 Add a separate file for wayland-scanner-generated C code
  • 09f27c1 Don't create Wayland seat objects unnecessarily


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25721/before/147458e0eda99b21dc1ba353e188c4478af4febf/after/09f27c1e0db1ebb402efe14f181e802937eeebbe@github.com>

VZ

unread,
Aug 22, 2025, 3:28:09 PMAug 22
to wx-...@googlegroups.com, Push

@vadz pushed 3 commits.

  • c375a91 Exclude headers generated by wayland-scanner from code checks
  • 3baa162 Add a separate file for wayland-scanner-generated C code
  • 20b0522 Don't create Wayland seat objects unnecessarily


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25721/before/09f27c1e0db1ebb402efe14f181e802937eeebbe/after/20b0522e5de0fdde76402263e5de6d1b61f00326@github.com>

VZ

unread,
Aug 22, 2025, 5:16:17 PMAug 22
to wx-...@googlegroups.com, Push

@vadz pushed 1 commit.

  • 63707e2 Also exclude wayland-scanner-generated sources from space checks


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25721/before/20b0522e5de0fdde76402263e5de6d1b61f00326/after/63707e27679d8da70ba865da2c4561905daa4904@github.com>

mahkoh

unread,
Aug 22, 2025, 11:32:07 PMAug 22
to wx-...@googlegroups.com, Subscribed
mahkoh left a comment (wxWidgets/wxWidgets#25721)

When the mouse moves after warp, it jumps back to the old position.

at least in the scenario in which I'm using it, as a nested compositor

The X11 backend that you are using here is essentially unmaintained. In this particular case, the issue is that it receives absolute cursor positioning events from the X server. You can warp the cursor, but the next time you move the mouse it the position will be overwritten by the position the X server sends us. I don't think that is necessarily a bug, if you used another absolute positioning input method, such as a touch screen or a tablet, you would see the same behavior and it would not be surprising.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25721/c3216199518@github.com>

mahkoh

unread,
Aug 22, 2025, 11:43:27 PMAug 22
to wx-...@googlegroups.com, Subscribed

@mahkoh commented on this pull request.


In include/wx/gtk/private/wayland.h:

> @@ -18,7 +18,13 @@
 // GTK version to compile the code using it.
 #if defined(GDK_WINDOWING_WAYLAND) && GTK_CHECK_VERSION(3,20,0)
     #ifdef wxHAVE_WAYLAND_CLIENT
-        #define wxHAVE_WAYLAND_PROTOCOLS
+        #include <wayland-client-protocol.h>
+
+        // Old headers don't define this flag used in
+        // pointer-warp-v1-client-protocol.h, so we can't compile it with them.
+        #ifdef WL_MARSHAL_FLAG_DESTROY
+            #define wxHAVE_WAYLAND_PROTOCOLS

You should generate these files at compile time with the wayland-scanner version installed on the system. This will ensure that the generated code is in sync with the installed libwayland.

What you should do is check the required protocol xml files into the wxwidgets repository.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25721/review/3146814443@github.com>

mahkoh

unread,
Aug 22, 2025, 11:51:54 PMAug 22
to wx-...@googlegroups.com, Subscribed
mahkoh left a comment (wxWidgets/wxWidgets#25721)

The position of the cursor seems to be off by the decorations size.

I have not looked at the code but I think what is happening here is that the gtk coordinates that you are working with are not surface-local coordinates but rather xdg_surface geometry coordinates or something similar.

Since the protocol requires surface-local coordinates, you have to find a way to transform your coordinates into surface-local coordinates, or you can't use the protocol.

It could be a bug in the compositor but when I tested the code with SDL and blender it worked fine.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25721/c3216213265@github.com>

mahkoh

unread,
Aug 23, 2025, 12:09:42 AMAug 23
to wx-...@googlegroups.com, Subscribed
mahkoh left a comment (wxWidgets/wxWidgets#25721)

You can verify this by e.g. creating an example program that warps the cursor to 100x100 and then look at the WAYLAND_DEBUG output.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25721/c3216223009@github.com>

VZ

unread,
Aug 23, 2025, 9:38:14 AMAug 23
to wx-...@googlegroups.com, Subscribed

@vadz commented on this pull request.


In include/wx/gtk/private/wayland.h:

> @@ -18,7 +18,13 @@
 // GTK version to compile the code using it.
 #if defined(GDK_WINDOWING_WAYLAND) && GTK_CHECK_VERSION(3,20,0)
     #ifdef wxHAVE_WAYLAND_CLIENT
-        #define wxHAVE_WAYLAND_PROTOCOLS
+        #include <wayland-client-protocol.h>
+
+        // Old headers don't define this flag used in
+        // pointer-warp-v1-client-protocol.h, so we can't compile it with them.
+        #ifdef WL_MARSHAL_FLAG_DESTROY
+            #define wxHAVE_WAYLAND_PROTOCOLS

Sorry, I know we're supposed to do this, but I really don't want to even think about adding support for running wayland-scanner to bakefile-generated makefiles. At least for now, we'll live with these files in the repository.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25721/review/3148143000@github.com>

VZ

unread,
Aug 23, 2025, 9:44:41 AMAug 23
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25721)

Thanks for looking at this!

Are you able to test this with some other compositor with support for this protocol?

Since the protocol requires surface-local coordinates, you have to find a way to transform your coordinates into surface-local coordinates, or you can't use the protocol.

Is the difference between these coordinates just the decorations size or is there something more to it? I don't see anything coordinates-related in xdg_surface...

You can verify this by e.g. creating an example program that warps the cursor to 100x100 and then look at the WAYLAND_DEBUG output.

Well, this is what the modified sample does, but I'm not sure what am I supposed to conclude from this.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25721/c3217001177@github.com>

mahkoh

unread,
Aug 23, 2025, 9:56:37 AMAug 23
to wx-...@googlegroups.com, Subscribed
mahkoh left a comment (wxWidgets/wxWidgets#25721)

You can move the cursor over the point that you think is the 100x100 point and the events will tell you the surface-local coordinates.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25721/c3217010670@github.com>

VZ

unread,
Aug 28, 2025, 8:04:56 PM (10 days ago) Aug 28
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25721)

You can move the cursor over the point that you think is the 100x100 point and the events will tell you the surface-local coordinates.

If you mean the coordinates from pointer_handle_motion (part of pointer listener), then I get back exactly the coordinates I pass to it, but I'm not sure if they are "surface local".

In the meanwhile, I've also tested with mutter by running it in another VT as I still have no idea how to run it as nested compositor (again). In my uninformed opinion it looks like its implementation of the protocol is totally broken, see my comment there.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25721/c3235300427@github.com>

VZ

unread,
Aug 28, 2025, 8:24:15 PM (10 days ago) Aug 28
to wx-...@googlegroups.com, Push

@vadz pushed 1 commit.

  • e8e1433 Account for the window origin when warping pointer using Wayland


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25721/before/63707e27679d8da70ba865da2c4561905daa4904/after/e8e1433d1fdec26a5bd35ac4ca7d339ca0e57755@github.com>

VZ

unread,
Aug 28, 2025, 8:24:59 PM (10 days ago) Aug 28
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25721)

I've fixed the offset with Jay by using gdk_window_get_origin(), see e8e1433 (Account for the window origin when warping pointer using Wayland, 2025-08-29).

I'd still be very grateful if somebody could please test this with KDE, I'd rather avoid having to install (or build?) it here myself just for this...


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25721/c3235332324@github.com>

VZ

unread,
Aug 31, 2025, 6:00:22 PM (7 days ago) Aug 31
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25721)

I'm probably going to merge this, even if it's not very useful for now (but if my mutter MR gets merged it will at least work in GNOME when a mouse button is pressed, which is better than never working), if there are no other comments.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25721/c3240441578@github.com>

VZ

unread,
Sep 6, 2025, 2:43:35 PM (2 days ago) Sep 6
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25721)

My mutter MR did get merged, so merging this too. It's not perfect, but better than nothing.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25721/c3262985908@github.com>

VZ

unread,
Sep 6, 2025, 3:21:32 PM (2 days ago) Sep 6
to wx-...@googlegroups.com, Subscribed

Merged #25721 into master.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25721/issue_event/19546809964@github.com>

VZ

unread,
Sep 7, 2025, 6:10:27 PM (7 hours ago) Sep 7
to wx-...@googlegroups.com, Subscribed

@vadz commented on this pull request.


In include/wx/gtk/private/wayland.h:

> @@ -18,7 +18,13 @@
 // GTK version to compile the code using it.
 #if defined(GDK_WINDOWING_WAYLAND) && GTK_CHECK_VERSION(3,20,0)
     #ifdef wxHAVE_WAYLAND_CLIENT
-        #define wxHAVE_WAYLAND_PROTOCOLS
+        #include <wayland-client-protocol.h>
+
+        // Old headers don't define this flag used in
+        // pointer-warp-v1-client-protocol.h, so we can't compile it with them.
+        #ifdef WL_MARSHAL_FLAG_DESTROY
+            #define wxHAVE_WAYLAND_PROTOCOLS

@mahkoh Just FYI, I think I've finally found a relative painless way to run wayland-scanner during the build without dealing with our build system, see #25769.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25721/review/3194624353@github.com>

Reply all
Reply to author
Forward
0 new messages