mirror of
https://github.com/glfw/glfw.git
synced 2025-10-03 13:20:58 +00:00
Merge 566d18c59e
into 7f4e947447
This commit is contained in:
commit
043b006faf
@ -334,6 +334,16 @@ static Atom getSupportedAtom(Atom* supportedAtoms,
|
||||
return None;
|
||||
}
|
||||
|
||||
// X error handler and state variable needed to catch BadWindow in detectEWMH
|
||||
//
|
||||
static Bool handlerRan;
|
||||
static int setFlagOnXError(Display* display, XErrorEvent* err)
|
||||
{
|
||||
handlerRan = True;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Check whether the running window manager is EWMH-compliant
|
||||
//
|
||||
static void detectEWMH(void)
|
||||
@ -359,14 +369,27 @@ static void detectEWMH(void)
|
||||
return;
|
||||
}
|
||||
|
||||
// Since we don't trust that the window ID is valid, we set an error handler
|
||||
// In order to ensure the handler runs immediately, also make XLib
|
||||
// synchronous for the duration
|
||||
handlerRan = False;
|
||||
int (*oldHandler)(Display*, XErrorEvent*) = XSetErrorHandler(setFlagOnXError);
|
||||
XSynchronize(_glfw.x11.display, True);
|
||||
|
||||
// It should be the ID of a child window (of the root)
|
||||
// Then we look for the same property on the child window
|
||||
if (_glfwGetWindowProperty(*windowFromRoot,
|
||||
unsigned long windowCount = _glfwGetWindowProperty(*windowFromRoot,
|
||||
supportingWmCheck,
|
||||
XA_WINDOW,
|
||||
(unsigned char**) &windowFromChild) != 1)
|
||||
(unsigned char**) &windowFromChild);
|
||||
|
||||
XSetErrorHandler(oldHandler);
|
||||
XSynchronize(_glfw.x11.display, False);
|
||||
|
||||
if (windowCount != 1 || handlerRan)
|
||||
{
|
||||
XFree(windowFromRoot);
|
||||
if (!handlerRan)
|
||||
XFree(windowFromChild);
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user