-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Implement window transparency to mouse events (#1236) #1568
Conversation
This adds the GLFW_MOUSE_PASSTHRU window hint and attribute for controlling whether mouse input passes through the window to whatever window is behind it. Closes #1568.
The client clip region was left in place when mouse passthrough was disabled, leading to missing mouse input if the window grew beyond it. Related to #1568.
Returning HTTRANSPARENT from WM_NCHITTEST does cause the window to be transparent for some hit-testing APIs but does not make it pass mouse input through to whatever window is below it. For that to work on modern Windows, the window needs to be both layered and extended-window-style-transparent. Related to #1568.
Platform code may not modify shared state. Related to #1568.
Thank you for this PR! My proposed changes are now in the
Yup, looks good! I modified the logic for the internal flag a little, to keep modifications of shared state inside shared code.
The X11 path looks good and worked fine on X11 on both Linux and Cygwin. It needed a pre-fix because GLFW now loads all of Xlib dynamically, and there was an issue with not removing the custom input shape, but that was all. I had to replace the Win32 implementation, though. While the
It seems to work perfectly in Weston. I've tried opaque windows and the gears example, setting it at creation or after. The macOS path also just worked. |
I tested the |
Thank you for looking into my PR.
Please do whatever you think is necessary 👍
Google search sends mixed signals. Maybe it should be |
That form of the name is typically only available if the development package is installed and may point to a library with a different ABI. |
The client clip region was left in place when mouse passthrough was disabled, leading to missing mouse input if the window grew beyond it. Related to #1568.
Returning HTTRANSPARENT from WM_NCHITTEST does cause the window to be transparent for some hit-testing APIs but does not make it pass mouse input through to whatever window is below it. For that to work on modern Windows, the window needs to be both layered and extended-window-style-transparent. Additional logic changes to ensure mouse input passthrough, framebuffer transparency and window opacity are mindful of one another when modifying WS_EX_LAYERED. Related to #1568.
Platform code may not modify shared state. Related to #1568.
Thanks @rokups and @elmindreda for looking into this!
One thought was coming to mind but then I realized it wouldn't meaningfully affect our use case. For the sake of completeneness I'm writing it down: I haven't performed the tests yet, but I wonder if this might be altering performances of the swap/composition in any way. I guess we could do a quick test of running unthrottled with both settings and see if it makes any diffferences (worth testing with both variations of As Dear ImGui multi-viewports only temporarily enable this flags during dragging of a window the difference would likely not matter. |
Results: Well, it turns out that just copying |
Thank you for looking into it and posting the results! |
This is an implementation for window transparency for mouse events requested in #1236. There are some things to discuss before merging.
GLFW_MOUSE_PASSTHRU
define andmousePassthru
variable. I used terminology suggested in #1236. Naming is hard so if anyone has a better idea - speak up. Maybe we shuld doPASSTHRU
->PASSTHROUGH
at least.Is
GLFW_MOUSE_PASSTHRU
defined in appropriate place and is it's value proper?I tried to add documentation comments but i did so without fully understanding what i am doing. In case anything is missing/incorrect please let me know.
libXext.so.6
- hope that ".6" is pretty much same across all distributions. I may be wrong.CYGWIN - untested. Only reason why it would break is
libXext-6.so
being named something else i think.Not sure if i got all
_glfw.x11.xshape
right.Wayland while i think is implemented correctly - does not work. I tested with gears example, setting
glfwWindowHint(GLFW_MOUSE_PASSTHRU, GLFW_TRUE);
before window creation. It may be that kwin compositor does not have required bits for this to work. If anyone runs Gnome wayland - i would greatly appreciate if you could test this PR. Otherwise i may get around to setting up a VM for a test, but i would love to avoid it if possible.X11/Windows/MacOS - everything works as expected.