Page MenuHome

Win32: ReleaseCapture in CreateWindowExW
AbandonedPublic

Authored by Harley Acheson (harley) on Dec 28 2021, 8:40 PM.

Details

Summary

When creating a new window call ReleaseCapture to immediately start
receiving all mouse input, regardless of the position of the cursor or if
there is a previous capture.


When creating a new window on Windows (only) and doing so with the corner action zones (shift-drag), the new window will usually ignore mouse input at first even though it appears to have focus. Following shows trying to drag the window immediately after creating it:

This is because of a previous mouse capture. But in this case we want to start fresh and take immediate input from the new window, not connect the previous mouse inputs when creating the window with new input. This is done by calling ReleaseCapture during window creation. Start getting new mouse inputs, disregarding what came before.

After this patch is applied:

Diff Detail

Repository
rB Blender

Event Timeline

Harley Acheson (harley) requested review of this revision.Dec 28 2021, 8:40 PM
Harley Acheson (harley) created this revision.
Harley Acheson (harley) edited the summary of this revision. (Show Details)

This seems to work as advertised and seems ok for me during testing here. Is there any risk for pen/tablet input? If so might want to poke someone with that hardware to try out.

This seems to work as advertised and seems ok for me during testing here. Is there any risk for pen/tablet input? If so might want to poke someone with that hardware to try out.

Good question. I’ll add Nicholas to reviewers.

My gut instinct is this shouldn't cause any issues for tablets.

intern/ghost/intern/GHOST_WindowWin32.cpp
169

I don't think this comment quite captures what's happening. Mouse input is never sent to non-captured windows that aren't hovered over. IIUC what this fixes is that a new window can't take focus if another window is currently captured?

@Nicholas Rishel (nicholas_rishel) - My gut instinct is this shouldn't cause any issues for tablets.

No, I can't think of anything either since this is only at new window creation.

I don't think this comment quite captures what's happening

Yikes, yes that comment was total crap! Have changed it. Thanks!

My gut instinct is this shouldn't cause any issues for tablets.

Do you want to test this any further, or can we go with your gut instinct?

tested it on desktop, no issues there, so as far as i'm concerned this can land, just holding off till we hear from you.

This revision is now accepted and ready to land.Jan 12 2022, 1:37 AM

Tested on my system, WinInk was fine; Wintab had an issue when pulling out a new window but then immediately drawing to the first (choppy lines where pressure appeared to be constantly toggling on and off). Issue went away after switching windows back and forth. I don't have a hypothesis for why this might occur.

How would this impact the state tracking with updateMouseCapture and m_hasGrabMouse?

Harley Acheson (harley) planned changes to this revision.Jan 13 2022, 8:52 PM

@Nicholas Rishel (nicholas_rishel) - Wintab had an issue when pulling out a new window but then immediately drawing to the first (choppy lines where pressure appeared to be constantly toggling on and off). Issue went away after switching windows back and forth. I don't have a hypothesis for why this might occur.

That sounds like enough to put the kibosh on this patch as I lack the equipment, knowledge, or interest to track down tablet-related issues. The problem this patch is addressing is so subtle and benign anyway. Thanks a lot for looking at this one; glad you're around these parts.

I'll mark this as "plan changes" for now but will probably just abandon.