-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Add mouse event pass-through support for window. #39944
Conversation
If there's a sample project available, I can have a test for this on Linux :) |
Test project (white polygon should be solid, rest of the window click-through): Transo4.zip |
Testing on Gentoo with KDE Plasma X11, opening the project as-is doesn't seem to be working. Click events don't pass through the window. I might need to check again with the 3.2 branch so I can use the per-pixel alpha to see it clearly EDIT: Tried it with the 3.2.3 branch from your repository too, same result EDIT 2: xeyes does work, and it uses the same SHAPE extension too |
Nevermind, fixed it @bruvzg, you accidentally checked if the extension was not enabled 😂 |
I had @Ashesh3 test it on Windows and it didn't seem to work. I was looking through the MSDN Win32 docs about HTTRANSPARENT and this might be the reason why:
I didn't see any docs about whether the thread mentioned is the process thread, but I can have another look |
@bruvzg More documentation diving and I see two possible methods:
I could try to implement the second one, since it doesn't force a fully transparent region |
I have tested it on Window 10 too, and it doesn't work.
Posting just hit test message doesn't work either, maybe forwarding all mouse events and activation messages do (with coordinate conversion, since mouse use client coodrs). Probably this will end up to be extremely complicated and bug prone. For now, I have changed it to |
Yeah I ended up on the same conclusion as well, considering WS_EX_LAYERED worked the same way :) |
@Technohacker This is now updated if you want to test again on Windows (there's also a |
Terribly sorry for the delay, had other projects to deal with 😅 Linux X11 KDE Plasma: Working perfectly :) |
The feature is one I'm looking forward to, so I thought I'd go ahead and test it on windows. This is my first time compiling godot, so apologies in advance if I did anything incorrectly, but it does work on windows with the given test project. |
CC @pouleyKetchoupp to review X11 changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
The X11 code looks fine (apart from the little detail I've pointed out).
I've tested on Ubuntu 20.04:
Gnome - works only with borderless windows.
Plasma - works as intended.
Is the issue with Gnome a deal breaker? I'm not sure what real life use cases are for this feature. If needed, I can help investigate.
dccbf66
to
59d806b
Compare
doc/classes/DisplayServer.xml
Outdated
<description> | ||
Sets a polygonal region of the window which accepts mouse events. Mouse events outside the region will be passed through. | ||
Passing an empty array will disable passthrough support (all mouse events will be intercepted by the window, which is the default behavior). | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line == paragraph in the XML.
doc/classes/DisplayServer.xml
Outdated
# Reset region to default. | ||
DisplayServer.window_set_mouse_passthrough([]) | ||
[/codeblock] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow. If it's mostly used for widgets, I guess it's not a big deal for now if it doesn't play well with window decorations in some cases. |
59d806b
to
6a14c72
Compare
Thanks! |
Adds
DisplayServer.window_set_mouse_passthrough
function to set polygonal region of the window which accepts mouse events, mouse events outside the region will be passed through to the window behind it.Region can be drawn using Path2D (or similar) node and set by calling:
The same changes for 3.2 are available in click-through-3 branch.
Fixes #39914