Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add org.freedesktop.portal.RemoteDesktop support #263

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

andreafeletto
Copy link

@andreafeletto andreafeletto commented Mar 9, 2023

Implements #2

ToDo:

  • devices selection
  • pointer support
    • relative motion
    • absolute motion
    • buttons
    • scroll
  • keyboard support
  • touch support

@David96
Copy link
Contributor

David96 commented Mar 12, 2023

Thanks a lot for implementing this! I just added button events: https://github.com/David96/xdg-desktop-portal-wlr/tree/remotedesktop
Feel free to use however you want, I basically just copied your code, so I don't care about authorship or anything here.

@andreafeletto
Copy link
Author

Thanks a lot for implementing this! I just added button events: https://github.com/David96/xdg-desktop-portal-wlr/tree/remotedesktop Feel free to use however you want, I basically just copied your code, so I don't care about authorship or anything here.

Thanks. Give me another 4/5 days and I'll get back to this.

@DefaultUser
Copy link

DefaultUser commented Oct 21, 2023

I've successfully tested pointer movement and buttons with kdeconnect (23.04) and wayfire (on Raspberry Pi OS v5). Scrolling does seem to have some code already, but it wasn't working here. I could see dbus messages in dbus-monitor, but no scrolling happened.

I started working on keyboard support, but I'm not sure if my approach is suitable as I have no experience with xkbcommon, evdev or wayland. You can find my implementation in DefaultUser@b092b2a

(Edit: fixed the link to the commit)

@DefaultUser
Copy link

I've fixed the scrolling issues I mentioned in my previous comment. This also fixed some smaller issues I was experiencing (see commit message for details).
I am not sure if my approach is the best, but KDEConnect's remote input feature now works fine with wayfire.
The fix is here: DefaultUser@b2cacc9

@PedroHLC
Copy link

PedroHLC commented Nov 5, 2023

but KDEConnect's remote input feature now works fine with wayfire.

Worked fine with my sway too (sway master/020a572, wlroots master/26eac25, portal-wlr remotedesktop/b2cacc9 but rebased over master/84a9cf4). Tested mouse movement, mouse buttons, scrolling, dragging (cursed over WAN latency), and keyboard (on multiple apps).

@tralph3
Copy link

tralph3 commented Apr 23, 2024

I have been using @DefaultUser's fork for the past few weeks and works almost perfectly. Mouse input is perfect, but there's some keyboard functions that are wonky. The X key seems to send a Mute volume command instead of the actual letter.

It is nearly there tho. I don't expect there to be much more work required.

@DefaultUser
Copy link

@tralph3 : I assume that you're using Wayfire. Wayfire uses the underlying keycodes instead of the key symbols for binds and ignores the keymap this. I think that is was planned to add an option to change this in Wayfire, but I don't know if it is already implemented.
I have to admit that my branch only covers exactly what I need from it (ASCII input), but it offers a starting point for someone with more time to fix this.
I currently use a build where I simply remap the buttons in the keymap that have binds in Wayfire's default config and add some special cases for them in code. This is quite an ugly workaround.
The proper way to handle this is by adding more keymap definitions and switching between them dynamically. That way, non-ASCII characters could be handled.

@tralph3
Copy link

tralph3 commented Apr 24, 2024

I use Hyprland, actually.

@leon-erd
Copy link

leon-erd commented May 29, 2024

I have also been using this a bit now on Hyprland and its amazing to be able to use the pointer and type something!!
Things that map the wrong way for me:
z -> increase volume
y -> decrease volume
x -> toggle mute
j -> print
capital latters are mapped as lower case letters
special symbols do not work (some math symbols, currencies, degree symbol, shapes, ...)

@Enovale
Copy link

Enovale commented Jun 5, 2024

I just took a crack at implementing a more "proper" solution using libxkbcommon and had some success, all the basic keys are working as expected, though symbols are still not working. This is my first time coding in C so I would definitely want it to be checked over by someone before going forward but to get the ball rolling even more, here's what I have:

Enovale/xdg-desktop-portal-wlr@11817f9

EDIT: Capital letters aren't working currently either.

@leon-erd
Copy link

leon-erd commented Jun 5, 2024

Cool that you are trying to work on it :)
Unfortunately I also do not know any C so can't help you with the code (but I guess it will be reviewed anyway before getting merged). But I can test some.
Can confirm that the letters are now mapped correctly (except capital as you pointed out already)
Regarding the other characters some are now not working anymore that were working previously:
+ -> =
_ -> -
!@#$%^&*() -> 1234567890
" -> '
: -> ;
? -> /
~ -> `
| -> \
< -> ,
> -> .
{} -> []
from currencies "€" does work. the others not
the rest remains

@leon-erd
Copy link

leon-erd commented Jun 5, 2024

Also Im getting this warning which is treated as error by default. I had to change the compile options before being able to build.

xdg-desktop-portal-wlr> [31/33] Compiling C object xdg-desktop-portal-wlr.p/src_remotedesktop_remotedesktop.c.o
xdg-desktop-portal-wlr> FAILED: xdg-desktop-portal-wlr.p/src_remotedesktop_remotedesktop.c.o
xdg-desktop-portal-wlr> gcc -Ixdg-desktop-portal-wlr.p -I. -I.. -I../include -Iprotocols -I/nix/store/di7vbvn478r2gx1wlfvxvv0ani8fy4qh-wayland-1.22.0-dev/include -I/nix/store/8jwrkvi3r40a2fh56qk6bippnhzxcv03-systemd-255.6-dev/include -I/nix/store/k986n2g13n6hjlmr913hcv3c44jj29nk-pipewire-1.0.6-dev/include/pipewire-0.3 -I/nix/store/k986n2g13n6hjlmr913hcv3c44jj29nk-pipewire-1.0.6-dev/include/spa-0.2 -I/nix/store/9qisjifkjmb1z14vsd9vdw2r44i3z883-inih-58/include -I/nix/store/wsayddhkdwh7a37d9k9kz02pn0r9d469-mesa-24.0.7-dev/include -I/nix/store/xjvnswjz32dw12ld8nb29lhwp92275aj-libdrm-2.4.120-dev/include -I/nix/store/xjvnswjz32dw12ld8nb29lhwp92275aj-libdrm-2.4.120-dev/include/libdrm -I/nix/store/alcgjc7smx41sh1xn1xi07pqpwv2sdi2-libxkbcommon-1.7.0-dev/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=c11 -Wno-missing-braces -Wno-missing-field-initializers -Wno-unused-parameter -D_POSIX_C_SOURCE=200809L '-DSYSCONFDIR="/nix/store/62fg5fzqvama4c1w2jy6d2ry7dv499as-xdg-desktop-portal-wlr-0.7.1/etc"' -DHAVE_LIBSYSTEMD=1 -D_REENTRANT -MD -MQ xdg-desktop-portal-wlr.p/src_remotedesktop_remotedesktop.c.o -MF xdg-desktop-portal-wlr.p/src_remotedesktop_remotedesktop.c.o.d -o xdg-desktop-portal-wlr.p/src_remotedesktop_remotedesktop.c.o -c ../src/remotedesktop/remotedesktop.c
xdg-desktop-portal-wlr> ../src/remotedesktop/remotedesktop.c: In function 'init_keymap':
xdg-desktop-portal-wlr> ../src/remotedesktop/remotedesktop.c:252:9: error: ignoring return value of 'ftruncate' declared with attribute 'warn_unused_result' [-Werror=unused-result]
xdg-desktop-portal-wlr>   252 |         ftruncate(keymap_fd, keymap_size);
xdg-desktop-portal-wlr>       |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
xdg-desktop-portal-wlr> cc1: all warnings being treated as errors
xdg-desktop-portal-wlr> [32/33] Compiling C object xdg-desktop-portal-wlr.p/src_screencast_pipewire_screencast.c.o
xdg-desktop-portal-wlr> ninja: build stopped: subcommand failed.

@Enovale
Copy link

Enovale commented Jun 5, 2024

It's also worth noting that the portal with my changes segfaults and crashes my compositor whenever I run it with -r or otherwise kill it and re-run it. It works fine when systemd boots it up after a reboot, though. I have no idea what's going on with that

@David96
Copy link
Contributor

David96 commented Oct 18, 2024

I also gave keyboard input a shot by simply copying a lot of code from wayvnc and mostly everything seems to work: https://github.com/David96/xdg-desktop-portal-wlr/commits/remotedesktop
Furthermore I made the Start function actually comply with the protocol by starting a screencast session if one exists and adding the stream to the reply. This makes Zoom screen sharing work again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants