I am writing a GTK4 application using Python which simulates user input on Wayland. On X11, this could be done using a number of ways like using pyautogui or uinput, however, on Wayland, the only workaround to make this possible without using sudo I can find is to use the Remote Desktop portal and simulate the input in a Xdp.Session, which has the benefit of needing explicit permission by the user as well.
The problem I am facing is that the calls to pointer_button() do not simulate a mouse click. There is not any output in the terminal, either.
The other methods, like pointer_motion(), pointer_position() to move the mouse and keyboard_key() to simulate keyboard key presses are working perfectly fine.
I have added “–device=all” to the Flatpak manifest. This problem does not occur when the same program is run in KDE.
Earlier I was passing 2 and Xdp.ButtonState.PRESSED, as 2 is the button number for right click in xinput. Now I am passing Gdk.KEY_Pointer_Button2 and Xdp.ButtonState.PRESSED, but the same issue is happening.
The logs are:
Jun 10 13:45:25 debian gnome-shell[2560]: INPUT: Creating new virtual input device of type 0 (0x5647ee44a1e0)
Jun 10 13:45:26 debian gnome-shell[2560]: Unknown/invalid virtual device button 0xfeea pressed
Jun 10 13:45:26 debian gnome-shell[2560]: Unknown/invalid virtual device button 0xfeea pressed
Jun 10 13:45:27 debian gnome-shell[2560]: Unknown/invalid virtual device button 0xfeea pressed
Jun 10 13:45:27 debian gnome-shell[2560]: Unknown/invalid virtual device button 0xfeea pressed
Jun 10 13:45:28 debian gnome-shell[2560]: Unknown/invalid virtual device button 0xfeea pressed
Jun 10 13:45:28 debian gnome-shell[2560]: Unknown/invalid virtual device button 0xfeea pressedGdk.KEY_Pointer_Button2, Xdp.ButtonState.PRESSED
Jun 10 13:45:29 debian gnome-shell[2560]: Unknown/invalid virtual device button 0xfeea pressed
But it seems you are passing GDK codes. Change to use e.g. BTN_LEFT from linux/input-event-codes.h. If you’re not using C/C++, then either copy the values of the ones you care about, or see if there are dependencies you can use that packages these constants in some language specific way.