obs-vkcapture icon indicating copy to clipboard operation
obs-vkcapture copied to clipboard

Wayland missing cursor

Open Tesla-Tank opened this issue 1 year ago • 6 comments

I'm using Nobara37 and don't have the option to enable cursor capture on wayland. Any suggestions? Thank you.

Tesla-Tank avatar Mar 12 '23 05:03 Tesla-Tank

It requires this protocol https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/124 and there is only one implementation currently - patch for sway.

Unless you are capturing native wayland games, you can run OBS under xwayland obs -platform xcb to get cursor capture.

nowrep avatar Mar 12 '23 06:03 nowrep

Running obs with xwayland and gamecapture doesn't show anything. I tried using it on AoE and vkcube, nothing is showing up. Any suggestions?

Tesla-Tank avatar Mar 13 '23 01:03 Tesla-Tank

@nowrep am I wrong in thinking that since we're injecting a dll in to the client app, we should be able to ignore compositor support and just straight wire the cursor to OBS?

Or is this more of a "I don't want the extra work" sort of issue?

It would be nice if there was some way to capture games cursors, without opening OBS in X mode, I want to keep using wlrobs, as pipewire always prompts for capture device (at-least it did this last time I tried).

Also why does this plugin need a special wayland protocol when cursor works fine in wlrobs and pipewire capture?

YellowOnion avatar Sep 12 '23 00:09 YellowOnion

@nowrep am I wrong in thinking that since we're injecting a dll in to the client app, we should be able to ignore compositor support and just straight wire the cursor to OBS?

In theory yes, in practice it's way more complicated. It's pretty simple to get mouse events (I even have a branch with this https://github.com/nowrep/obs-vkcapture/commit/5cd5a4442b5cecc24c10330ba3102558fb3bfebd) but that's where the simple part ends.

It also needs to get the cursor image data, and it's not possible with the proxy approach above. This needs to either hook libwayland (at runtime, not with LD_PRELOAD because Vulkan layer is loaded late) or use private structs from libwayland (this is already used with xlib but there it's not much of an issue since xlib is not in active development anymore).

And even if we get there, it's not a win yet. Wayland cursors are not special, it's just another wl_surface which means it may be shm buffer or it could also be dma-buf. Not every dma-buf can be cpu mapped (and on nvidia, NO dma-buf can be cpu mapped), so this also adds lot of code.

So it definitely is possible and I think this issue should be re-opened. If this approach is implemented, it would also solve the cursor alignment inside game window.

Also why does this plugin need a special wayland protocol when cursor works fine in wlrobs and pipewire capture?

It uses "software" cursor, eg. it asks the compositor to draw the cursor into the captured buffer.

nowrep avatar Sep 12 '23 06:09 nowrep

There's also another issue with the cursor image: new protocol https://wayland.app/protocols/cursor-shape-v1

So ideally we would get the cursor image from compositor and read the cursor coordinates inside captured window from the process itself (which is what the wip branch already does).

nowrep avatar Sep 13 '23 10:09 nowrep

With this approach, I think there's also the issue of getting the correct cursor image at any given time - when hovering over text inputs, for instance, the cursor should be text. Cursor shape changes work correctly when playing x11 games, of course.

Unless get_pointer() would already let that happen?

fililip avatar Aug 01 '24 01:08 fililip