Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempted fix for both drag and doubleclick #1704

Merged
merged 5 commits into from
Aug 8, 2022

Conversation

leaanthony
Copy link
Member

@leaanthony leaanthony commented Aug 6, 2022

Fixes #1703

Working on:

  • MacOS
  • Windows
  • Linux

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Aug 6, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: ec81d4d
Status:⚡️  Build in progress...

View logs

@stffabi
Copy link
Collaborator

stffabi commented Aug 6, 2022

I've just tested MacOS and Windows.

MacOS: Everything works fine, dragging works and double click events on a data-wails-drag also works as expected.
Windows: Dragging works as expected without any delay, but double click events on a data-wails-drag don't get triggered anymore.

@leaanthony
Copy link
Member Author

Ah thanks for trying 🙏 I wonder why webview 2 would be so different around this? I'll test Linux tonight and think about a windows fix.

@stffabi
Copy link
Collaborator

stffabi commented Aug 6, 2022

I suspect it's because of the Win32 ReleaseCapture call in startDrag.

@leaanthony
Copy link
Member Author

Can confirm it is the drag that is preventing the double click events from propagating.

@leaanthony
Copy link
Member Author

I've just pushed a shameful hack that does appear to fix it, though I suspect it wont work on all machines in all scenarios 😱

@ghostiam
Copy link

ghostiam commented Aug 6, 2022

@leaanthony I checked on Windows, there is the same problem as it was on MacOS. Without this hack (but with doubleclick not working), there is no delay when moving the window.

@leaanthony
Copy link
Member Author

Without rewriting the whole of the move window code (and I did try tonight) I'm not sure what we can do right now

@ghostiam
Copy link

ghostiam commented Aug 6, 2022

On Windows, with the hack I sometimes can't right click to open the inspector and check which events are running. This highlights the elements, as if I'm double-clicking, but I'm only pressing the right mouse button.

2022-08-06.20.27.03.mov

@ghostiam
Copy link

ghostiam commented Aug 6, 2022

I don't think it's worth using move window anywhere. In practice, this is rarely used. Perhaps it should be documented that there is such a behavior as not passing events to child elements.

UPD:
I did a move to the whole application to show the bug with a delay, but in practice it would be enough just a titlebar, for which you can move the window.

@ghostiam
Copy link

ghostiam commented Aug 6, 2022

On Windows, with the hack I sometimes can't right click to open the inspector and check which events are running. This highlights the elements, as if I'm double-clicking, but I'm only pressing the right mouse button.

2022-08-06.20.27.03.mov

I found the reason for the quick closing of the context menu. When pressing with two fingers on the touchpad, the events of pressing and releasing occur very quickly, if I make a click, then enough time elapses that this bug does not exist.

UPD
I just noticed that without a hack, the context menu does not open at all when touching the touchpad.

@leaanthony
Copy link
Member Author

Thanks for your testing. I think we'll just change how windows implements drag. Hacks are too flaky 😁

@leaanthony
Copy link
Member Author

I've tried all different approaches: JS only solution that only sends a drag message if the button is down AND you're moving, and also a Go-side solution that basically does the same. It appears the same issue occurs: There's no way to detect the mouse button up event and therefore reset the drag flag. This leads to some odd behaviour where sometimes it drags, sometimes it's delayed, sometimes it works just fine. If webview2 forwarded mouse events to the host then we'd be ok but it doesn't. I've posted a couple of messages to the WebView2 feedback around this so lets see what comes back.

@leaanthony
Copy link
Member Author

leaanthony commented Aug 6, 2022

Just pushed a potential fix. Seems to work well for Windows. Not tried the others but it shouldn't affect anything.

@leaanthony
Copy link
Member Author

@ghostiam how does this work for you?

@ghostiam
Copy link

ghostiam commented Aug 8, 2022

@leaanthony checked, events on windows work, dragging of windows works too.
Everything works on MacOS too.

@stffabi
Copy link
Collaborator

stffabi commented Aug 8, 2022

I can also confirm that it works as expected on MacOS and Windows within our application. Thanks @leaanthony for looking into this 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[v2] delay when dragging a window with data-wails-drag attribute
3 participants