godot icon indicating copy to clipboard operation
godot copied to clipboard

Redirect mouse events to the window under cursor, simplify popup menu input processing.

Open bruvzg opened this issue 1 year ago • 18 comments

  • Redirect all mouse events to the window under the cursor.
  • Simplify PopupMenu input handling.

Fixes https://github.com/godotengine/godot/issues/88324 Fixes https://github.com/godotengine/godot/issues/70361 Fixes https://github.com/godotengine/godot/issues/77246 Fixes https://github.com/godotengine/godot/issues/66273 Fixes https://github.com/godotengine/godot/issues/73926

Supersede https://github.com/godotengine/godot/pull/85583 Supersede https://github.com/godotengine/godot/pull/88366 Supersede https://github.com/godotengine/godot/pull/88342

bruvzg avatar Feb 16 '24 07:02 bruvzg

Seems to be working on macOS (and sidecar on iOS), Windows, X11/GNOME, and in a single-window mode. Confined/Captured mode seems to work fine. As well as on Android and iOS (with touch screen instead of mouse).

bruvzg avatar Feb 16 '24 09:02 bruvzg

Actually, there is an extra case that probably require additional handling, and I have not accounted for: WINDOW_FLAG_MOUSE_PASSTHROUGH (not sure if it's used for anything in editor, but should pass event to the underlying window if set).

bruvzg avatar Feb 16 '24 22:02 bruvzg

Actually, there is an extra case that probably require additional handling, and I have not accounted for: WINDOW_FLAG_MOUSE_PASSTHROUGH

Added extra check for X11, should be already handled on other platforms.

bruvzg avatar Feb 17 '24 16:02 bruvzg

Seems to work fine for me on KDE Wayland.

akien-mga avatar Feb 17 '24 18:02 akien-mga

@Sauermann Are you using Windows 10 or 11? I'm not able to reproduce #88324 on Windows 10, but I can confirm the PR fixes #73926 and #70361 for me.

KoBeWi avatar Feb 18 '24 12:02 KoBeWi

@KoBeWi Please note, that I have tested this on Linux.

Sauermann avatar Feb 18 '24 12:02 Sauermann

Ah ok, I misunderstood your comment.

KoBeWi avatar Feb 18 '24 12:02 KoBeWi

@Sauermann Are you using Windows 10 or 11? I'm not able to reproduce #88324 on Windows 10, but I can confirm the PR fixes #73926 and #70361 for me.

I was able to reproduce #88324 on windows 11 and this PR has solved the issue for me.

DanielSnd avatar Feb 18 '24 16:02 DanielSnd

Did some testing on Linux, I think I mostly have the same results as @Sauermann. I wrote them in each relevant issue to keep things a bit clearer about what is reproducible in master and whether this PR improves it.

I confirm this PR fixes #88324 and #66273.

For me #70361 is only reproducible in single-window mode, and this PR doesn't fix it on Linux. Does it fix it on Windows for single-window mode? If not, we might want to keep the issue open for single-window mode, or open a new one.

Likewise for #77246, it seems specific to single-window mode on Linux, and this PR doesn't fix it.

akien-mga avatar Feb 19 '24 10:02 akien-mga

https://github.com/godotengine/godot/issues/70361 and https://github.com/godotengine/godot/issues/77246 are reproducible (and fixed) in multi window mode on Windows, not reproducible on macOS, and I have not tested single-window mode.

bruvzg avatar Feb 19 '24 10:02 bruvzg

I can also confirm that the Popup behaviour is much better with this PR. Although it still does not feel perfect yet, e.g. when moving the mouse a lot, the highlighting may not be visible. Still an improvement.

What I'm wondering here: When I debugged this issue on Windows, I saw weird or even wrong behaviour what _get_focused_window_or_popup returned, thats why my PR fixed the issue by not calling it (https://github.com/godotengine/godot/pull/85583). Windows did already send the event with the correct window id (hwnd), why do we need to 'calculate' a receiving window and use it instead?

Maran23 avatar Feb 19 '24 11:02 Maran23

Don't miss @Sauermann's comment:

Currently (https://github.com/godotengine/godot/commit/8f0c20ee8d5564d4a8131deb4d5341b60edbcff8) it is possible to drag and drop from a secondary window to the root window. With this PR, this functionality is no longer possible. This can be verified in the editor by making the FileSystem dock floating and trying to drag and drop the icon.svg into the respective slot in the Inspector of a Sprite2D node.

That's a regerssion.

Inve1951 avatar Feb 19 '24 13:02 Inve1951

This does not actually fixes https://github.com/godotengine/godot/issues/88324 but it helps working around it.

The root cause of the issue is still there, but this reduces the chances to trigger the bug. See https://github.com/godotengine/godot/issues/88324#issuecomment-1952399913

EmrysMyrddin avatar Feb 19 '24 13:02 EmrysMyrddin

On Windows 10.0.22621. I can confirm that this PR fixes #70361, #77246, #73926, and #66273 in multiwindow mode. #73926 and #66273 are only reproducible on multiwindow mode, so these can be closed. #70361 and #77246 are present on single window mode still. I believe this is related to #84466 and Viewport's mouse focus, and can be fixed separately.

This breaks drag and drop between multiple windows for me as well.

The root cause of the issue is still there, but this reduces the chances to trigger the bug. See https://github.com/godotengine/godot/issues/88324#issuecomment-1952399913

I cannot reproduce #88324, but I believe that is a separate timing issue, since this PR changes popups to need mouse up.

kitbdev avatar Feb 20 '24 01:02 kitbdev

I Just have some concerns related to the changes in the popup menu class. Your changes to the display server is a replacement for this pull request https://github.com/godotengine/godot/pull/86952 which have caused a lot of issues to the popup menu recently, so we can just revert it and we merge your pull request without the changes to the popup menu files to redirect all mouse events to the window under the cursor, which was the correct fix to the first issue instead of the other hack to enable a missing feature. I also have made the popup menu updates the selection when the mouse is pressed, to make it work fine with touch input if we enable emulate mouse from touch in project settings. here's the changes in my pull request https://github.com/godotengine/godot/pull/87462 with the old behavior and the only missing fix is to redirect the mouse release event to the popup menu window under the cursor when it opens to allow opening the popup and triggering an action in a single mouse click for non-embedded subwindows. Thank you.

WhalesState avatar Feb 20 '24 05:02 WhalesState

I think it will be easier to backup your popup menu changes and you submit them later on another pull request after merging my pull request to avoid rebasing and conflict. Since most of the popup menu issues have been fixed after reverting and more issues was fixed in my pull request.

WhalesState avatar Feb 21 '24 13:02 WhalesState

This still breaks multi-window drag and drop.

Fixes:

  • https://github.com/godotengine/godot/issues/73926
  • https://github.com/godotengine/godot/issues/66273

Only fixes in multiple window mode:

  • https://github.com/godotengine/godot/issues/70361
  • https://github.com/godotengine/godot/issues/77246

#88324 is already fixed. Since the rebase, no longer simplifies PopupMenu input handling.

kitbdev avatar May 13 '24 17:05 kitbdev

Needs a rebase since https://github.com/godotengine/godot/pull/67531 got merged.

Anutrix avatar Sep 24 '24 09:09 Anutrix