|
|
|
@ -265,9 +265,10 @@ bool GlWndProc(CDriverGL *driver, XEvent &e)
|
|
|
|
|
|
|
|
|
|
case ConfigureNotify:
|
|
|
|
|
|
|
|
|
|
if (driver->_WndActive)
|
|
|
|
|
if (driver->_CurrentMode.Windowed && driver->_WndActive)
|
|
|
|
|
{
|
|
|
|
|
if (driver->_CurrentMode.Windowed)
|
|
|
|
|
// first time setting decoration sizes
|
|
|
|
|
if ((driver->_DecorationWidth == -1) || (driver->_DecorationWidth == 0))
|
|
|
|
|
{
|
|
|
|
|
Atom type_return = 0;
|
|
|
|
|
int format_return = 0;
|
|
|
|
@ -293,19 +294,12 @@ bool GlWndProc(CDriverGL *driver, XEvent &e)
|
|
|
|
|
// don't allow negative decoration sizes
|
|
|
|
|
if (driver->_DecorationWidth < 0) driver->_DecorationWidth = 0;
|
|
|
|
|
if (driver->_DecorationHeight < 0) driver->_DecorationHeight = 0;
|
|
|
|
|
|
|
|
|
|
driver->_WindowX = e.xconfigure.x - driver->_DecorationWidth;
|
|
|
|
|
driver->_WindowY = e.xconfigure.y - driver->_DecorationHeight;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// fullscreen
|
|
|
|
|
driver->_WindowX = e.xconfigure.x;
|
|
|
|
|
driver->_WindowY = e.xconfigure.y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
driver->_CurrentMode.Width = e.xconfigure.width;
|
|
|
|
|
driver->_CurrentMode.Height = e.xconfigure.height;
|
|
|
|
|
driver->_WindowX = e.xconfigure.x - driver->_DecorationWidth;
|
|
|
|
|
driver->_WindowY = e.xconfigure.y - driver->_DecorationHeight;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
@ -647,11 +641,6 @@ void CDriverGL::setWindowIcon(const std::vector<NLMISC::CBitmap> &bitmaps)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------
|
|
|
|
|
#if defined(NL_OS_UNIX) && !defined(NL_OS_MAC)
|
|
|
|
|
static Bool WaitForNotify( Display *dpy, XEvent *event, XPointer arg ) {
|
|
|
|
|
return (event->type == MapNotify) && (event->xmap.window == reinterpret_cast<Window>(arg));
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool resizeable)
|
|
|
|
|
{
|
|
|
|
|
H_AUTO_OGL(CDriverGL_setDisplay)
|
|
|
|
@ -1156,17 +1145,14 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glXMakeCurrent (_dpy, _win, _ctx);
|
|
|
|
|
// XMapRaised (_dpy, _win);
|
|
|
|
|
|
|
|
|
|
// XMapWindow(_dpy, _win);
|
|
|
|
|
|
|
|
|
|
_EventEmitter.init (_dpy, _win, this);
|
|
|
|
|
|
|
|
|
|
// KDE/GNOME has issues selecting correct fullscreen monitor if window is not visible before setMode()
|
|
|
|
|
if (!mode.Windowed)
|
|
|
|
|
{
|
|
|
|
|
XMapRaised(_dpy, _win);
|
|
|
|
|
XEvent event;
|
|
|
|
|
nlctassert(sizeof(XPointer) >= sizeof(_win));
|
|
|
|
|
XPeekIfEvent(_dpy, &event, WaitForNotify, reinterpret_cast<XPointer>(_win));
|
|
|
|
|
}
|
|
|
|
|
// XEvent event;
|
|
|
|
|
// XIfEvent(dpy, &event, WaitForNotify, (char *)this);
|
|
|
|
|
|
|
|
|
|
#endif // NL_OS_UNIX
|
|
|
|
|
|
|
|
|
@ -2498,19 +2484,13 @@ bool CDriverGL::getCurrentScreenMode(GfxMode &mode)
|
|
|
|
|
Window child;
|
|
|
|
|
|
|
|
|
|
// get window position so we can compare monitors (or mouse position if window not visible yet)
|
|
|
|
|
bool useMouseForPosition = true;
|
|
|
|
|
if (_win != EmptyWindow)
|
|
|
|
|
XWindowAttributes xwa;
|
|
|
|
|
XGetWindowAttributes(_dpy, _win, &xwa);
|
|
|
|
|
if (xwa.map_state != IsUnmapped)
|
|
|
|
|
{
|
|
|
|
|
XWindowAttributes xwa;
|
|
|
|
|
XGetWindowAttributes(_dpy, _win, &xwa);
|
|
|
|
|
if (xwa.map_state != IsUnmapped)
|
|
|
|
|
{
|
|
|
|
|
XTranslateCoordinates(_dpy, _win, xwa.root, xwa.x, xwa.y, &x, &y, &child);
|
|
|
|
|
useMouseForPosition = false;
|
|
|
|
|
}
|
|
|
|
|
XTranslateCoordinates(_dpy, _win, xwa.root, xwa.x, xwa.y, &x, &y, &child);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (useMouseForPosition)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sint rx, ry, wx, wy;
|
|
|
|
|
uint mask;
|
|
|
|
@ -2783,7 +2763,15 @@ void CDriverGL::setWindowPos(sint32 x, sint32 y)
|
|
|
|
|
#elif defined (NL_OS_UNIX)
|
|
|
|
|
|
|
|
|
|
if (_CurrentMode.Windowed)
|
|
|
|
|
{
|
|
|
|
|
// first time requesting decoration sizes
|
|
|
|
|
if (_WindowX && _WindowY && !_DecorationWidth && !_DecorationHeight && _WndActive)
|
|
|
|
|
{
|
|
|
|
|
_DecorationWidth = -1;
|
|
|
|
|
_DecorationHeight = -1;
|
|
|
|
|
}
|
|
|
|
|
XMoveWindow(_dpy, _win, x, y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // NL_OS_WINDOWS
|
|
|
|
|
}
|
|
|
|
@ -2811,17 +2799,7 @@ void CDriverGL::showWindow(bool 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);
|
|
|
|
|
// 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));
|
|
|
|
|
}
|
|
|
|
|
XMapRaised(_dpy, _win);
|
|
|
|
|
|
|
|
|
|
// fix window position if windows manager want to impose them
|
|
|
|
|
setWindowPos(_WindowX, _WindowY);
|
|
|
|
|