Fixed: #1044 Window content is black after switching windowed <-> fullscreen

This commit is contained in:
kervala 2010-08-22 09:57:33 +02:00
parent eaa26434bc
commit b5f6188757

View file

@ -1442,6 +1442,9 @@ bool CDriverGL::setWindowStyle(EWindowStyle windowStyle)
if (_win == EmptyWindow || !_DestroyWindow) if (_win == EmptyWindow || !_DestroyWindow)
return true; return true;
if (getWindowStyle() == windowStyle)
return true;
#if defined(NL_OS_WINDOWS) #if defined(NL_OS_WINDOWS)
// get current style // get current style
@ -1493,6 +1496,12 @@ bool CDriverGL::setWindowStyle(EWindowStyle windowStyle)
#elif defined(NL_OS_UNIX) #elif defined(NL_OS_UNIX)
XWindowAttributes attr;
XGetWindowAttributes(_dpy, _win, &attr);
// if window is mapped use events else properties
if (attr.map_state != IsUnmapped)
{
// Toggle fullscreen // Toggle fullscreen
XEvent xev; XEvent xev;
xev.xclient.type = ClientMessage; xev.xclient.type = ClientMessage;
@ -1512,6 +1521,24 @@ bool CDriverGL::setWindowStyle(EWindowStyle windowStyle)
nlwarning("3D: Failed to toggle to fullscreen"); nlwarning("3D: Failed to toggle to fullscreen");
return false; return false;
} }
}
else
{
Atom _NET_WM_STATE = XInternAtom(_dpy, "_NET_WM_STATE", False);
if (windowStyle == EWSFullscreen)
{
Atom _NET_WM_STATE_FULLSCREEN = XInternAtom(_dpy, "_NET_WM_STATE_FULLSCREEN", False);
// set state property to fullscreen
XChangeProperty(_dpy, _win, _NET_WM_STATE, XA_ATOM, 32, PropModeReplace, (const unsigned char*)&_NET_WM_STATE_FULLSCREEN, 1);
}
else
{
// delete state property
XDeleteProperty(_dpy, _win, _NET_WM_STATE);
}
}
// show window (hack to avoid black window bug) // show window (hack to avoid black window bug)
if (_WindowVisible) if (_WindowVisible)