X11: Fix disabling of GLFW_MOUSE_PASSTHROUGH

The client clip region was left in place when mouse passthrough was
disabled, leading to missing mouse input if the window grew beyond it.

Related to #1568.
This commit is contained in:
Camilla Löwy 2020-07-06 23:09:28 +02:00
parent d285a9fdeb
commit e81d381256
3 changed files with 18 additions and 19 deletions

View File

@ -864,6 +864,8 @@ static GLFWbool initExtensions(void)
_glfw_dlsym(_glfw.x11.xshape.handle, "XShapeCombineRegion"); _glfw_dlsym(_glfw.x11.xshape.handle, "XShapeCombineRegion");
_glfw.x11.xshape.QueryVersion = (PFN_XShapeQueryVersion) _glfw.x11.xshape.QueryVersion = (PFN_XShapeQueryVersion)
_glfw_dlsym(_glfw.x11.xshape.handle, "XShapeQueryVersion"); _glfw_dlsym(_glfw.x11.xshape.handle, "XShapeQueryVersion");
_glfw.x11.xshape.ShapeCombineMask = (PFN_XShapeCombineMask)
_glfw_dlsym(_glfw.x11.xshape.handle, "XShapeCombineMask");
if (XShapeQueryExtension(_glfw.x11.display, if (XShapeQueryExtension(_glfw.x11.display,
&_glfw.x11.xshape.errorBase, &_glfw.x11.xshape.errorBase,
@ -1285,8 +1287,6 @@ int _glfwPlatformInit(void)
_glfw_dlsym(_glfw.x11.xlib.handle, "XUndefineCursor"); _glfw_dlsym(_glfw.x11.xlib.handle, "XUndefineCursor");
_glfw.x11.xlib.UngrabPointer = (PFN_XUngrabPointer) _glfw.x11.xlib.UngrabPointer = (PFN_XUngrabPointer)
_glfw_dlsym(_glfw.x11.xlib.handle, "XUngrabPointer"); _glfw_dlsym(_glfw.x11.xlib.handle, "XUngrabPointer");
_glfw.x11.xlib.UnionRectWithRegion = (PFN_XUnionRectWithRegion)
_glfw_dlsym(_glfw.x11.xlib.handle, "XUnionRectWithRegion");
_glfw.x11.xlib.UnmapWindow = (PFN_XUnmapWindow) _glfw.x11.xlib.UnmapWindow = (PFN_XUnmapWindow)
_glfw_dlsym(_glfw.x11.xlib.handle, "XUnmapWindow"); _glfw_dlsym(_glfw.x11.xlib.handle, "XUnmapWindow");
_glfw.x11.xlib.UnsetICFocus = (PFN_XUnsetICFocus) _glfw.x11.xlib.UnsetICFocus = (PFN_XUnsetICFocus)

View File

@ -129,7 +129,6 @@ typedef int (* PFN_XSync)(Display*,Bool);
typedef Bool (* PFN_XTranslateCoordinates)(Display*,Window,Window,int,int,int*,int*,Window*); typedef Bool (* PFN_XTranslateCoordinates)(Display*,Window,Window,int,int,int*,int*,Window*);
typedef int (* PFN_XUndefineCursor)(Display*,Window); typedef int (* PFN_XUndefineCursor)(Display*,Window);
typedef int (* PFN_XUngrabPointer)(Display*,Time); typedef int (* PFN_XUngrabPointer)(Display*,Time);
typedef int (* PFN_XUnionRectWithRegion)(XRectangle*,Region,Region);
typedef int (* PFN_XUnmapWindow)(Display*,Window); typedef int (* PFN_XUnmapWindow)(Display*,Window);
typedef void (* PFN_XUnsetICFocus)(XIC); typedef void (* PFN_XUnsetICFocus)(XIC);
typedef VisualID (* PFN_XVisualIDFromVisual)(Visual*); typedef VisualID (* PFN_XVisualIDFromVisual)(Visual*);
@ -232,7 +231,6 @@ typedef void (* PFN_Xutf8SetWMProperties)(Display*,Window,const char*,const char
#define XTranslateCoordinates _glfw.x11.xlib.TranslateCoordinates #define XTranslateCoordinates _glfw.x11.xlib.TranslateCoordinates
#define XUndefineCursor _glfw.x11.xlib.UndefineCursor #define XUndefineCursor _glfw.x11.xlib.UndefineCursor
#define XUngrabPointer _glfw.x11.xlib.UngrabPointer #define XUngrabPointer _glfw.x11.xlib.UngrabPointer
#define XUnionRectWithRegion _glfw.x11.xlib.UnionRectWithRegion
#define XUnmapWindow _glfw.x11.xlib.UnmapWindow #define XUnmapWindow _glfw.x11.xlib.UnmapWindow
#define XUnsetICFocus _glfw.x11.xlib.UnsetICFocus #define XUnsetICFocus _glfw.x11.xlib.UnsetICFocus
#define XVisualIDFromVisual _glfw.x11.xlib.VisualIDFromVisual #define XVisualIDFromVisual _glfw.x11.xlib.VisualIDFromVisual
@ -340,9 +338,12 @@ typedef XRenderPictFormat* (* PFN_XRenderFindVisualFormat)(Display*,Visual const
typedef Bool (* PFN_XShapeQueryExtension)(Display*,int*,int*); typedef Bool (* PFN_XShapeQueryExtension)(Display*,int*,int*);
typedef Status (* PFN_XShapeQueryVersion)(Display*dpy,int*,int*); typedef Status (* PFN_XShapeQueryVersion)(Display*dpy,int*,int*);
typedef void (* PFN_XShapeCombineRegion)(Display*,Window,int,int,int,Region,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 XShapeQueryExtension _glfw.x11.xshape.QueryExtension
#define XShapeQueryVersion _glfw.x11.xshape.QueryVersion #define XShapeQueryVersion _glfw.x11.xshape.QueryVersion
#define XShapeCombineRegion _glfw.x11.xshape.ShapeCombineRegion #define XShapeCombineRegion _glfw.x11.xshape.ShapeCombineRegion
#define XShapeCombineMask _glfw.x11.xshape.ShapeCombineMask
typedef VkFlags VkXlibSurfaceCreateFlagsKHR; typedef VkFlags VkXlibSurfaceCreateFlagsKHR;
typedef VkFlags VkXcbSurfaceCreateFlagsKHR; typedef VkFlags VkXcbSurfaceCreateFlagsKHR;
@ -596,7 +597,6 @@ typedef struct _GLFWlibraryX11
PFN_XTranslateCoordinates TranslateCoordinates; PFN_XTranslateCoordinates TranslateCoordinates;
PFN_XUndefineCursor UndefineCursor; PFN_XUndefineCursor UndefineCursor;
PFN_XUngrabPointer UngrabPointer; PFN_XUngrabPointer UngrabPointer;
PFN_XUnionRectWithRegion UnionRectWithRegion;
PFN_XUnmapWindow UnmapWindow; PFN_XUnmapWindow UnmapWindow;
PFN_XUnsetICFocus UnsetICFocus; PFN_XUnsetICFocus UnsetICFocus;
PFN_XVisualIDFromVisual VisualIDFromVisual; PFN_XVisualIDFromVisual VisualIDFromVisual;
@ -746,6 +746,7 @@ typedef struct _GLFWlibraryX11
PFN_XShapeQueryExtension QueryExtension; PFN_XShapeQueryExtension QueryExtension;
PFN_XShapeCombineRegion ShapeCombineRegion; PFN_XShapeCombineRegion ShapeCombineRegion;
PFN_XShapeQueryVersion QueryVersion; PFN_XShapeQueryVersion QueryVersion;
PFN_XShapeCombineMask ShapeCombineMask;
} xshape; } xshape;
} _GLFWlibraryX11; } _GLFWlibraryX11;

View File

@ -2710,21 +2710,19 @@ void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enable
if (enabled == window->mousePassthrough) if (enabled == window->mousePassthrough)
return; return;
int width = 0; if (enabled)
int height = 0; {
if (!enabled) Region region = XCreateRegion();
_glfwPlatformGetWindowSize(window, &width, &height); 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; window->mousePassthrough = enabled;
} }