RamonUnch / AltSnap

Maintained continuation of Stefan Sundin's AltDrag
GNU General Public License v3.0
2.16k stars 72 forks source link

Alt Button gets Stuck Using Sunshine/Moonlight #380

Open jet082 opened 1 year ago

jet082 commented 1 year ago

This bug has also been reported here - https://github.com/LizardByte/Sunshine/issues/791.

With Nvidia ending Geforce streaming, we are having to rely on community produced alternatives, the largest of which is Sunshine. The advantage of Sunshine is that it works on just about any hardware and does not require a nvidia card.

It works extremely well, but has a consistent problem with altsnap. Namely, when pressing the alt button to move a window, it does not release it when you life your finger off the alt button. In fact, it seems to exist in a somewhat middle state. Pressing tab does not alt tab and, in fact, pressing alt+tab will alt-tab as expected. However, it will not release the window from your mouse and it will continue to drag it around the screen. Moreover, any clicks you send will be sent to that window, even if you've alt-tabbed it into the background.

The fix, currently, is to go into another RDP program, press the alt key, and then re-enter moonlight.

I do not know if there is anything that can be done on the alt-snap side of things, but this is a killer for me.

RamonUnch commented 1 year ago

Of course there is the quick solution to blacklist the window so that altsnap will not interact, but you will no longer be able to use AltSnap on this window.

Better would be to find a fix. I will have to investigate this.

Could you test to see if a hot-click gives the same problem? Also could you test with the latest beta of AltSnap:

hooks1.59test23_x64.zip

You will need to exit AltSnap, and overwrite both AltSnap.exe and hooks.dll I do not expect any difference with the beta build.

RamonUnch commented 1 year ago

Also try this build that will release Alt after some delay if the Alt key is not repeating. (I do not have Sunshine/Moonlight nor the Hardware to run it).

In theory it should fix it, but I suspect there are also problems with the mouse by itself.

hooks1.59test24_x64.zip

RamonUnch commented 1 year ago

Another question, does Pressing ESC release Alt? In theory if AltSnap is locked in a movement, pressing ESC will end the movement and reset the key state.

RamonUnch commented 1 year ago

@jet082 Any news on this issue? have you tested any of the builds I gave you?

jet082 commented 1 year ago

@jet082 Any news on this issue? have you tested any of the builds I gave you?

Okay @RamonUnch I got to testing it and can report the following:

The escape key does in fact release it. However, this is an issue since some remote methods of access (my iPad for example) do not have an escape key.

As for the second build with the release after a few seconds - it does work! However, it obviously does not fix the issue since waiting a few seconds after a dragging action isn't really usable.

RamonUnch commented 1 year ago

As for the second build with the release after a few seconds - it does work! However, it obviously does not fix the issue since waiting a few seconds after a dragging action isn't really usable.

I think I can reduce the delay a lot, plus I am sure I can be smarter.

Does it happen that Alt gets stuck without it being a Alt+Click? In this case I could release the Alt at the end of an Alt+Click. (with an option)

jet082 commented 1 year ago

I'm not sure I know exactly what you mean. I have never had alt get stuck outside of an alt-snap usage. It does not get stuck on alt+tab, etc.

RamonUnch commented 1 year ago

AltSnap1.59test25_x64.zip

This one has smaller delays. Alt will auto-release as soon as it should receive the auto-repeated key. Yo know that the keyboard re-sends the keydown event when you hold it down, so we can know that Alt is no longer down by checking if Alt still auto-repeats.

By default it means something aroud 500ms/300ms depending on how long you hold Alt. If you want more reactivity you will need to reduce the keyboard repeat delay and increase the keyboard repeat rate.

RamonUnch commented 1 year ago

Of course this is a temporary hack that will be available as an advanced option only. The best would be to fix Sunshine.

jet082 commented 1 year ago

How do I enable this? I was able to test it finally and it seems to have reverted the prior fix, but by the way you've worded this it sounds like it is now an advanced option?

jet082 commented 1 year ago

Unfortunately, the old version is also now having the same issue. I'm not sure why, but it no longer seems to work after the latest nvidia driver update (which also killed Gamestream permanently - requiring Sunshine).

Here's one potential solution - could you make it so that suspend/resume alt-snap also releases the hook on the window? Currently, if I suspend alt-snap and then resume it, it immediately resumes dragging the same window it was dragging before.

For Sunshine users, it would be possible to move something, then hit a hotkey to toggle suspend alt-snap to release the hold, then hit the hotkey again to resume alt-snap. If I could add that to my workflow, it would be a little annoying, but it would work.

RamonUnch commented 1 year ago

I did not merge this patch into the main branch because I had not enough information.

When you release the click, the movement should end, regardless of the Alt state, so from what you describe sunshine also blocks the mouse up event, which makes the problem even more insane.

The issue is that AltSnap cannot physically be informed when a key or a mouse button is released, if it was only the keyboard, then auto-releasing the key after a delay would kinda solve the issue, but for the mouse we are out of luck, because even if I were able to guess if the button is up in 100ms or so (which I can't for mouse button), this would be a far too long delay for the mouse.

RamonUnch commented 1 year ago

For Sunshine users, it would be possible to move something, then hit a hotkey to toggle suspend alt-snap to release the hold, then hit the hotkey again to resume alt-snap. If I could add that to my workflow, it would be a little annoying, but it would work.

A toggle AltState key would be interesting concept indeed. Might also help some people with an unusual setup, Keep in mind that you can always press ESC and the movement will end.

jet082 commented 1 year ago

This is true. However, not all keyboards have escape keys. For remote access software on phones or (in my case) iPad keyboards, escape is not always an option.

Perhaps we could simplify this by being able to configure the Escape key to something else, including a combination (alt+Q or something)?

RamonUnch commented 1 year ago

Could you make it so that suspend/resume alt-snap also releases the hook on the window?

I will do that.

RamonUnch commented 1 year ago

This is true. However, not all keyboards have escape keys. For remote access software on phones or (in my case) iPad keyboards, escape is not always an option.

So it should be both a configurable key and a configurable shortcut, I guess.

RamonUnch commented 1 year ago

AltSnap_1.59p1_x64.zip

This build is the same as the release build except that it ends any movement when suspending AltSnap.

jet082 commented 1 year ago

Okay that version fixes the issue with suspending altsnap and makes it usable in Sunshine. Obviously the toggle alt key option would be better, but I'm considering this particular problem closed for now. I'll make a new issue for that.

Thank you!

RamonUnch commented 1 year ago

I prefer to keep it opened because for now it is only a workaround. The other issue is about a new feature that would go beyond the scope of simply helping with Sunshine/Moonlight.