Compare commits

..

No commits in common. 'fix-linux-multi-monitor' and 'main/gingo-test' have entirely different histories.

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

@ -1235,9 +1235,27 @@ void prelogInit()
Driver->setWindowIcon(bitmaps); Driver->setWindowIcon(bitmaps);
#endif #endif
// use position saved in config sint32 posX = 0, posY = 0;
if (ClientCfg.Windowed) if (ClientCfg.Windowed)
Driver->setWindowPos(ClientCfg.PositionX, ClientCfg.PositionY); {
// use position saved in config
posX = ClientCfg.PositionX;
posY = ClientCfg.PositionY;
}
else
{
// position is not saved in config so center the window
UDriver::CMode tmp;
if (Driver->getCurrentScreenMode(tmp))
{
posX = (tmp.Width - Driver->getWindowWidth())/2;
posY = (tmp.Height - Driver->getWindowHeight())/2;
}
}
// Set the window position
Driver->setWindowPos(posX, posY);
// Show the window // Show the window
Driver->showWindow(); Driver->showWindow();

Loading…
Cancel
Save