gnif / LookingGlass

An extremely low latency KVMFR (KVM FrameRelay) implementation for guests with VGA PCI Passthrough.
GNU General Public License v2.0
4.64k stars 257 forks source link

Mouse only capture mode #1088

Closed justryanw closed 12 months ago

justryanw commented 12 months ago

I have 2 monitors in my setup so if I have capture mode disabled and look around in game then my mouse will leave the LG window and go onto the second monitor. This means I need to have capture mode enabled however if i need to tab out or press super to bring up activities on gnome i need to disable capture mode then re enable it when going back in. My idea is to have a mouse only capture mode which behaves exactly as the capture disabled mode but if you click inside the LG window then your mouse becomes captured in the window and wont leave however you can still alt tab or press super to switch to another window / free the mouse, this would make LG behave a lot more like an actual game window. Maybe this could be the default behavior for the capture disabled mode instead of adding a new mode.

gnif commented 12 months ago

If I understand this correctly, you want an auto capture on focus mode? If so, yes, this is something we can look at adding.

justryanw commented 12 months ago

Yeah but only for the mouse, so I click in the LG window and the mouse is captured but i can still use alt-tab (or super) to escape the capture instead of normal capture mode where it alt tabs on the windows side

gnif commented 12 months ago

Unfortunately no, capture must be all or nothing.

justryanw commented 12 months ago

Is it not possible to simply restrict the mouse to not leaving the window like games typically do rather than using the capture mode?

gnif commented 12 months ago

Technically yes, but this is becoming niche to your use case and I do not see it being used by others, which not only adds more code to maintain but also another feature to document.

Give me some time to think on this and I will let you know

justryanw commented 12 months ago

I don't think its niche since any one with multiple monitors will have their mouse leave the LG window when looking around in game which means they will have to constantly enable and disable capture mode. If it captures the mouse and doesn't capture the other system keys it means once you full screen a game in windows then the LG window acts similar to the game itself, so you can alt tab from the game, use print screen for screenshots, etc... It would make the experience a lot more seamless, thanks for considering it

gnif commented 12 months ago

Sorry but it is niche, most of our community run multiple monitors (including myself) and happily toggle capture, this is the first time anyone has asked for such a specific half capture mode in over 5 years.

As I said, I will see what we can do, but no promises.

Edit: Also note that many users use focus follows cursor, this would play havoc for these users (i3/sway, etc), so this would have to be a well documented opt-in feature.

justryanw commented 12 months ago

Alright thank you Can I ask then how do you deal with the mouse leaving the window or are you used to just toggling capture mode every time?

gnif commented 12 months ago

Many of us use the VM for productivity applications and games, and/or games that do not require capture (ie non FPV), this auto mode would be quite a nuisance when the guest VM is used for more then just a particular style of game. So just manual toggling is the way to go :)

justryanw commented 12 months ago

fair enough, I mostly use it for the couple games from my library which don't work on linux so when i have discord or a youtube video on my second monitor it means i have to toggle all the time so for me it would be easier for it to capture the mouse like a native game window with capture of system keys as a separate toggle

gnif commented 12 months ago

Btw, have you tried ./looking-glass-client input:grabKeyboard=no Still no auto capture on focus, but it might suit your requirements.

justryanw commented 12 months ago

Oh yeah that's a bit better, I need to enable capture when tabbing back in but at least i can alt tab without having to disable it, it would mean i would have to re launch the client if i ever wanted to alt tab on the windows side tho but I rarely do that so ill keep that enabled.

gnif commented 12 months ago

there you go, new option there input:captureOnFocus=yes combined with input:grabKeyboard=no should do what you are looking for.

justryanw commented 12 months ago

that was quick haha, any way i can toggle being able to use system keys on windows side with the grabKeyboard=no? I can live with relaunching the window if not

gnif commented 12 months ago

not without more extensive changes which I am not inclined to perform sorry

justryanw commented 12 months ago

no problem I could probably just make a separate shortcut for launching without the keyboard option if i need it, thanks for the auto capture tho ill send some monero