GLFW: X11: Fix disabling of GLFW_MOUSE_PASSTHROUGH

From upstream: e81d381256.
This commit is contained in:
Luflosi 2020-07-16 23:24:48 +02:00
parent d0c6ce9fd7
commit 6a472bd6da
No known key found for this signature in database
GPG Key ID: 4E41E29EDCC345D0
2 changed files with 16 additions and 14 deletions

4
glfw/x11_platform.h vendored
View File

@ -128,9 +128,12 @@ typedef XRenderPictFormat* (* PFN_XRenderFindVisualFormat)(Display*,Visual const
typedef Bool (* PFN_XShapeQueryExtension)(Display*,int*,int*);
typedef Status (* PFN_XShapeQueryVersion)(Display*dpy,int*,int*);
typedef void (* PFN_XShapeCombineRegion)(Display*,Window,int,int,int,Region,int);
typedef void (* PFN_XShapeCombineMask)(Display*,Window,int,int,int,Pixmap,int);
#define XShapeQueryExtension _glfw.x11.xshape.QueryExtension
#define XShapeQueryVersion _glfw.x11.xshape.QueryVersion
#define XShapeCombineRegion _glfw.x11.xshape.ShapeCombineRegion
#define XShapeCombineMask _glfw.x11.xshape.ShapeCombineMask
typedef VkFlags VkXlibSurfaceCreateFlagsKHR;
typedef VkFlags VkXcbSurfaceCreateFlagsKHR;
@ -394,6 +397,7 @@ typedef struct _GLFWlibraryX11
PFN_XShapeQueryExtension QueryExtension;
PFN_XShapeCombineRegion ShapeCombineRegion;
PFN_XShapeQueryVersion QueryVersion;
PFN_XShapeCombineMask ShapeCombineMask;
} xshape;
EventLoopData eventLoopData;

26
glfw/x11_window.c vendored
View File

@ -2594,21 +2594,19 @@ void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, bool enabled)
if (enabled == window->mousePassthrough)
return;
int width = 0;
int height = 0;
if (!enabled)
_glfwPlatformGetWindowSize(window, &width, &height);
if (enabled)
{
Region region = XCreateRegion();
XShapeCombineRegion(_glfw.x11.display, window->x11.handle,
2/*ShapeInput*/, 0, 0, region, 0/*ShapeSet*/);
XDestroyRegion(region);
}
else
{
XShapeCombineMask(_glfw.x11.display, window->x11.handle,
2/*ShapeInput*/, 0, 0, None, 0/*ShapeSet*/);
}
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;
}