Fix KDE/GNOME windowed/fullscreen switching

core4
nimetu 3 years ago
parent a04956989a
commit 853e19cd64

@ -641,6 +641,9 @@ void CDriverGL::setWindowIcon(const std::vector<NLMISC::CBitmap> &bitmaps)
} }
// -------------------------------------------------- // --------------------------------------------------
static Bool WaitForNotify( Display *dpy, XEvent *event, XPointer arg ) {
return (event->type == MapNotify) && (event->xmap.window == reinterpret_cast<Window>(arg));
}
bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool resizeable) bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool resizeable)
{ {
H_AUTO_OGL(CDriverGL_setDisplay) H_AUTO_OGL(CDriverGL_setDisplay)
@ -1146,14 +1149,17 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re
} }
glXMakeCurrent (_dpy, _win, _ctx); glXMakeCurrent (_dpy, _win, _ctx);
// XMapRaised (_dpy, _win);
// XMapWindow(_dpy, _win);
_EventEmitter.init (_dpy, _win, this); _EventEmitter.init (_dpy, _win, this);
// XEvent event; // KDE/GNOME has issues selecting correct fullscreen monitor if window is not visible before setMode()
// XIfEvent(dpy, &event, WaitForNotify, (char *)this); if (!mode.Windowed)
{
XMapRaised(_dpy, _win);
XEvent event;
nlctassert(sizeof(XPointer) >= sizeof(_win));
XPeekIfEvent(_dpy, &event, WaitForNotify, reinterpret_cast<XPointer>(_win));
}
#endif // NL_OS_UNIX #endif // NL_OS_UNIX
@ -2805,8 +2811,18 @@ void CDriverGL::showWindow(bool show)
#elif defined (NL_OS_UNIX) #elif defined (NL_OS_UNIX)
if (show) if (show)
{
// if window is mapped, then MapNotify event will not trigger and XPeekIfEvent deadlocks
XWindowAttributes attr;
XGetWindowAttributes(_dpy, _win, &attr);
if (attr.map_state == IsUnmapped)
{ {
XMapRaised(_dpy, _win); XMapRaised(_dpy, _win);
// sync to MapNotify event or setWindowSize() in GNOME might resize window to wrong size
XEvent event;
nlctassert(sizeof(XPointer) >= sizeof(_win));
XPeekIfEvent(_dpy, &event, WaitForNotify, reinterpret_cast<XPointer>(_win));
}
// fix window position if windows manager want to impose them // fix window position if windows manager want to impose them
setWindowPos(_WindowX, _WindowY); setWindowPos(_WindowX, _WindowY);

Loading…
Cancel
Save