mirror of
https://github.com/glfw/glfw.git
synced 2026-09-21 00:30:57 +00:00
Add support for mouse input transparency
This adds the GLFW_MOUSE_PASSTHROUGH window hint and attribute for controlling whether mouse input passes through the window to whatever window is behind it. Fixes #1236. Closes #1568.
This commit is contained in:
committed by
Camilla Löwy
parent
6c031af245
commit
d285a9fdeb
@@ -2702,6 +2702,32 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
|
||||
XFlush(_glfw.x11.display);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled)
|
||||
{
|
||||
if (!_glfw.x11.xshape.available)
|
||||
return;
|
||||
|
||||
if (enabled == window->mousePassthrough)
|
||||
return;
|
||||
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
if (!enabled)
|
||||
_glfwPlatformGetWindowSize(window, &width, &height);
|
||||
|
||||
XRectangle rect;
|
||||
rect.x = 0;
|
||||
rect.y = 0;
|
||||
rect.width = (unsigned short)width;
|
||||
rect.height = (unsigned short)height;
|
||||
|
||||
Region region = XCreateRegion();
|
||||
XUnionRectWithRegion(&rect, region, region);
|
||||
XShapeCombineRegion(_glfw.x11.display, window->x11.handle, 2/*ShapeInput*/, 0, 0, region, 0/*ShapeSet*/);
|
||||
XDestroyRegion(region);
|
||||
window->mousePassthrough = enabled;
|
||||
}
|
||||
|
||||
float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
|
||||
{
|
||||
float opacity = 1.f;
|
||||
|
||||
Reference in New Issue
Block a user