RamonUnch / AltSnap

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

Cursor can't left-click until a right-click is issued #545

Open sysfsss opened 4 months ago

sysfsss commented 4 months ago

Just use the program for a while, resize some windows (I resized 'MSYS2' - my terminal), use Windows a bit, and eventually, the left mouse button won't do anything on any windows, won't drag on the desktop, nothing. Only by right-clicking anywhere 1-2 times will the cursor start responding again (easily noted by the context menu opening).

Tested on a full, multi-month install of Windows 10, and a bare install of Windows 11, and going back to a bare install of Windows 10.

I used to use this program in tandem with "MaxTo", a program that allows you to create virtual window layouts on your screen (love it) and I thought it was the problem, but on this latest bare install of Windows 10, I never installed it - yet, the behavior still rears its head.

If you need a list of programs I had open at the time:

No other windows open.

In my system tray:

My action center is set to Alarms only, I have task view, search, weather turned off.

I run at 3840x2160, 100% scaling (nothing blown up in size)

RamonUnch commented 4 months ago

This is a problem sometime, The issue is that if a program is a bit long to respond (for example a laggy window) then the mouse up input will be blocked and the mouse button state can become inconsistent.

The problem is that the key and mouse events have to be treated instantly, which mean that if by luck there is a lag and you press/release a button for this lag then you can get in a state where you will have to click with the left and right button to reset the consistency.

I do not know if I am clear but the thing is that I do not know how to completely solve the randomly locked button problem. I already use a separated thread to move the window itself, but there are still things I must do synchronously which can take some time and then it is possible to get in this bad state.

For me it happens from time to time, especially when I move laggy windows. Maybe One a day. How often do you have the problem?

sysfsss commented 4 months ago

I follow you.

I've got it happening multiple times a day during consistent use - maybe 5, 6 times.

RE: a slow window, I think Signal Messenger may be the likely culprit as at has lagged in front of me in the past. Same for Ableton, it can lag a bit when processing many tracks at once or working with a slow plugin.

I do want to note that this is new behavior. This wasn't happening last year, far as I can remember. Not sure if there were any complaints of this in 2023, but this has gotten pretty frustrating to the point I wanted to cut and issue - I'm at least glad I'm not alone :)

I will try a couple of the 2023 releases for a bit and report results. Trying the December release now.

RamonUnch commented 4 months ago

If you can spot which version created the problem then it would be great, It means the problem can be mitigated at least partially.

RamonUnch commented 4 months ago

maybe it is related to restoring a window, since 1.62 I had to make the restoration of windows synchronous because or the invisible borders. https://github.com/RamonUnch/AltSnap/pull/472 If you had pre-1.62 then 1.62 could be the culprit. but it maybe something else again.

sysfsss commented 4 months ago

Just happened. I had just switched when I posted last. So about 6 hours for it to occur. It was right after I'd clicked between Discord and Signal Messenger. So that's 1.62.

I'm rolling further back to 1.61.

sysfsss commented 4 months ago

So far so good on 1.61.

maybe it is related to restoring a window, since 1.62 I had to make the restoration of windows synchronous because or the invisible borders. #472 If you had pre-1.62 then 1.62 could be the culprit. but it maybe something else again.

so maybe this?

RamonUnch commented 4 months ago

here is a build were I just reverted the above commit. Of course the other minor invisible border bug is back but I will make a thread to fix it later, if this build works for you.

AltSnap1.64_test8_x64.zip

sysfsss commented 3 months ago

Sorry to report that on 1.61, i had JUST opened Ableton, clicked 'no' on a "recover your project that got lost last time" popup thing, then the cursor was trapped again where i couldn't click. i clicked everywhere. right click got it going. Surprised it took that long to happen. i'll see if ableton is the culprit while i try that build out, too, i'll try to open and close it more.

Trying 1.64.

sysfsss commented 3 months ago

OH! Okay, this happened immediately with that new exe + dll. what happened is that the cursor started goofing up IN ableton (Ableton Live 12 Suite) and i couldn't click anything else, not even the systray or the bottom right sliver that shows the desktop. This time, WITHOUT right-clicking, i just clicked inside the beatgrid in ableton and it worked. no right click necessary.

so this seems to be isolated to ableton. ostensibly. i'm going to monitor it later when ableton is closed and see how long i can make it. if it happens again, my only other thought is an invisible window captured focus. makes no sense though because it's Escalated and nothing is locking the screen like a UAC prompt or anything (i have UAC off and defender is now removed, sooooo idk)

anyway. still using the test files and will let you know what else i find.

sysfsss commented 3 months ago

was playing around in ableton. clicked foobar2000. Alt (winkey actually, this may be important) clicked to drag it onto the screen (it was half off screen due to changing res from 4k to 2k earlier) and the cursor locked again and i had to right click something.

i'm about to chalk this up to ableton. unfortunately, i don't use ableton 11 anymore so i can't test that

sysfsss commented 3 months ago

Still happening, even without Ableton running. Happened when I moved and resized an MSYS2 window this time. i dunno what the pattern is. maybe it's Signal. i'll uninstall that and see. This is so weird

sysfsss commented 3 months ago

Okay, I've narrowed it down more. There is no specific program that is contributing to the behavior.

The thing I noticed is that when the cursor locks up (literally nothing but moving the mouse and right click worked), it still allowed me to hold winkey and left-click to move task manager. So, left click is tied up, but alt (or meta) + left click works fine. it's still busted after you drag a window, though. you absolutely have to right-click anywhere, and then you'll regain full control. to be clear, it wasn't just left click stuck - back, forward, left/right scroll, up/down scroll, and middle click were all locked up, too, regardless of what window they were tried on.

tried mashing all of the modifier keys, pressing the ctrl shift winkey + B screen repaint thing, alt tab, winkey tab, nothing but a right click seems to fix it

for kicks, i'm gonna install old skool AltDrag and see if the issue persists there. if it does, it's something about all the group policy and disabling/removing of windows defender that i always do. well that went horribly, fast. i'll keep it installed and avoid using the snapping :P it lags out windows and pins the cursor to them til you hit escape. cray.

RamonUnch commented 3 months ago

could you give me your .ini file, might be interesting.

RamonUnch commented 3 months ago

for kicks, i'm gonna install old skool AltDrag and see if the issue persists there. if it does, it's something about all the group policy and disabling/removing of windows defender that i always do. well that went horribly, fast. i'll keep it installed and avoid using the snapping :P it lags out windows and pins the cursor to them til you hit escape. cray.

Yes AltDrag does everything in the same thread and can lock up quite easily.

Also I was thinking, If you have a high frequency mouse and a high refresh rate monitor then playing with performance parameters could help.

sysfsss commented 3 months ago

AltSnap.ini.zip

I run at 3840x2160 at 144Hz. I run a Logitech MX Master 3 wirelessly over the RF Logitech Unifying Receiver, which should have a USB polling rate of 125Hz.

I'll see if I can wire it without the dongle. If it doesn't work, I have a super basic Dell usb mouse I will switch to.

If it still happens, I will drop the screen down to 60Hz. If it's still busted, I'll drop down to 1080p (the struggle!)

sysfsss commented 3 months ago

Alright, so far so good on a basic Dell mouse with nothing but L/R/middle/scroll. Crazy.

Give me the week to play around. I've had good results on 144 and 60 hz

sysfsss commented 3 months ago

Still happening at 60 and 144Hz with a plain ol' USB mouse. got it to fail today during a move.

maybe i need to use alt instead of meta.

i guess i'd have to format again and let windows keep all its blot in order to see if it stops spazzing out.

RamonUnch commented 3 months ago

i guess i'd have to format again and let windows keep all its blot in order to see if it stops spazzing out.

Maybe you wont need to go there, if older versions of AltSanp didnot pause problems then something can be done in order to improve the situation. At this point however it seems that 1.64 test did not help or did it? Does 1.61 works fine or better?

I am not sure I understand the way the problems occurs. It seems from what you describe that just hovering the cursor over some windows without Alt+Click can cause the lock state?

There are some advanced performances options in the .ini file, you could try to use FullWin=0 to move a hollow rectangle instead of the full window, it might be too dramatic of a difference however to be adopted by you, but if the problem persists even with FullWin=0, it might give me some clues on how to improve AltSnap.

Also you can effectively decrease the effective mouse rate for AltSnap with the options in the [Performance] section of the ini file.

sysfsss commented 3 months ago

1.64 didn't help at all. All that I've tried in here are failing.

I'm not able to determine that actual failure mode because the behavior is so random. Trying to induce it by doing a large amount of minimizing, maximizing, opening, closing, moving, resizing, snap-resizing, etc. doesn't get me any closer to a repeatable method.

With FullWin=0 the issue wes immediately present and reproducible for about 30 seconds after opening, and after that I couldn't reproduce.

I'll relax the timings and see if it makes a difference.

Thanks for persisting with me on this.

sysfsss commented 3 months ago

Okay, this is repeatable now. Here's the best way I can explain it:

1 window, centered, snapped to the top of thee screen. 40% of the screen width, 50% of the screen height. 1 window, snapped to bottom-right corner, sized just enough to where its top-left corner is snapped to the other window and is about 10% of the way up that side

Experiment with the top-left corner of the bottom-right window - resize it, snap resize it, snap it to the bigger window. switch focus to the big window. Then resize the smaller window (it'll do it behind the main window due to lack of focus), Click the small window again, and resize it back to snap to the edge of the big window.

At some point of playing around like this, left click will get hung up.

I can reliably repro while playing with it like this, but I haven't tracked down the specific sequence of events that cause it.

In any case, I'm happy to try anything new you want to throw my way. Let me know if you find anything.

RamonUnch commented 3 months ago

Experiment with the top-left corner of the bottom-right window - resize it, snap resize it, snap it to the bigger window. switch focus to the big window. Then resize the smaller window (it'll do it behind the main window due to lack of focus), Click the small window again, and resize it back to snap to the edge of the big window.

At some point of playing around like this, left click will get hung up.

So it seems to occur when snapping? I will investigate more on this direction when I get time.

sysfsss commented 3 months ago

Well, now that I've caught it twice in a row. Seems to happen on resize snapping.

Also, there is a new behavior I noted. If Chrome is the window that gets locked and I can't click anything else, I can still left-click bookmarks, but it issues a right-click instead of a left-click.

With an Explorer (explorer.exe) window, it sticks and then if I left-click the desktop, it issues a right-click.

In both cases if I right-click anywhere, the behavior stops and I'm back to normal.