From 6a472bd6dafc85e2ae5e841c94fd78066023c2d6 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Thu, 16 Jul 2020 23:24:48 +0200 Subject: [PATCH] GLFW: X11: Fix disabling of GLFW_MOUSE_PASSTHROUGH From upstream: https://github.com/glfw/glfw/commit/e81d38125660b94bb48a362a58f162c38a230d37. --- glfw/x11_platform.h | 4 ++++ glfw/x11_window.c | 26 ++++++++++++-------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/glfw/x11_platform.h b/glfw/x11_platform.h index 94ab2a835..ac24a624b 100644 --- a/glfw/x11_platform.h +++ b/glfw/x11_platform.h @@ -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; diff --git a/glfw/x11_window.c b/glfw/x11_window.c index 44626f306..3413ca151 100644 --- a/glfw/x11_window.c +++ b/glfw/x11_window.c @@ -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; }