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

Ignoring mouse events / transparent for inputs / disable hit testing #1236

Closed
ocornut opened this issue Mar 20, 2018 · 3 comments
Closed

Ignoring mouse events / transparent for inputs / disable hit testing #1236

ocornut opened this issue Mar 20, 2018 · 3 comments
Assignees
Labels
enhancement Feature suggestions and PRs macOS Wayland Windows Win32 specific (not Cygwin or WSL) X11
Projects
Milestone

Comments

@ocornut
Copy link
Contributor

ocornut commented Mar 20, 2018

Hello,

Using a long subject line because I don't know what is the most appropriate cross-platform terminology and people might search for this under different names

This is feature request for a window hint, let's tentatively call it GLFW_MOUSE_PASSTHRU (exact naming to be determined). I am using it as part of the same work I mentioned in #1166 (GIF at the end of this post).

(Note, this is unrelated to transparency from a visual point of view, already discussed many times here: https://github.com/glfw/glfw/issues?utf8=%E2%9C%93&q=transparent)


Windows
The WndProc handler would do:

if (msg == WM_NCHITTEST)
    return HTTRANSPARENT;

Mac
I think we can use the 'ignoresMouseEvents' property of 'NSWindow' (untested)
https://developer.apple.com/documentation/appkit/nswindow/1419354-ignoresmouseevents?language=objc

A Boolean value that indicates whether the window is transparent to mouse events.

Wayland
Possibly 'wl_surface::set_input_region' (untested)
https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_surface

Input events happening outside of this region will try the next surface in the server surface stack. The compositor ignores the parts of the input region that fall outside of the surface. [...] The initial value for an input region is infinite. That means the whole surface will accept input. Setting the pending input region has copy semantics, and the wl_region object can be destroyed immediately. A NULL wl_region causes the input region to be set to infinite.

X11
I'm not sure how X11 works. For reference, Qt uses xcb_xfixes_create_region()+xcb_xfixes_set_window_shape_region_checked:
https://git.merproject.org/mer-core/qtbase/blob/master/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp#L1151


Context (gif): I am dragging a glfw window (that is right under my mouse cursor) and need to detect the window under so I can drop into them. Similarly to #1166 I can provide a rough (but usable) approximation on client-side by using the desktop size/position of all my windows, but of course this would bypass the window manager and ignore the proper z-order of windows (including windows from foreign application).

EDIT To clarify, at the moment I am testing this by using win32-specific code and installing a WndProc hook.

viewport_20180318


The naming and my use case are a little tricky because I toggle this feature on an existing GLFW window, and right now I still receive the currently captured mouse position for that window, which is ideal and desirable in my use case, and I think more flexible. This is why I didn't suggest a name like GLFW_IGNORE_MOUSE_INPUTS, because both CursorPosCallback and glfwGetCursorPos() still work fine.

Thanks for your consideration,
Omar

@RosculescuCiprian
Copy link

Hello,
Is there any word on this? I think the idea is great and would love to see it in GLFW.

@slauko
Copy link

slauko commented May 14, 2020

would like to see something in that way too, having the issue that i need to create an overlay above some other application window on linux but still want to click stuff behind the overlay

@elmindreda elmindreda added this to Urgent in Queue Jul 2, 2020
@elmindreda elmindreda added this to the 3.4 milestone Jul 2, 2020
@elmindreda elmindreda linked a pull request Jul 3, 2020 that will close this issue
@elmindreda elmindreda moved this from Urgent to Now in Queue Jul 9, 2020
@elmindreda
Copy link
Member

This feature has been added as GLFW_MOUSE_PASSTHROUGH with #1568 by @rokups and will be included in 3.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature suggestions and PRs macOS Wayland Windows Win32 specific (not Cygwin or WSL) X11
Projects
Development

Successfully merging a pull request may close this issue.

4 participants