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

Open
ocornut opened this Issue Mar 20, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment