Avoid window size to be larger than available space.
When window size is equal to screen resolution and user selected windowed mode, we can assume that he wants maximized window.
This commit is contained in:
parent
9c3998be0e
commit
38a4e06a6c
@ -993,8 +993,6 @@ bool CIrrDeviceLinux::createWindow()
|
||||
XSetWMProtocols(display, window, &wmDelete, 1);
|
||||
|
||||
if (CreationParams.Fullscreen)
|
||||
{
|
||||
if (netWM)
|
||||
{
|
||||
// Some window managers don't respect values from XCreateWindow and
|
||||
// place window in random position. This may cause that fullscreen
|
||||
@ -1005,11 +1003,28 @@ bool CIrrDeviceLinux::createWindow()
|
||||
XRaiseWindow(display, window);
|
||||
XFlush(display);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Set the fullscreen mode via the window manager. This allows alt-tabing, volume hot keys & others.
|
||||
// Get the needed atom from there freedesktop names
|
||||
unsigned int display_width = XDisplayWidth(display, screennr);
|
||||
unsigned int display_height = XDisplayHeight(display, screennr);
|
||||
|
||||
bool has_display_size = (Width == display_width && Height == display_height);
|
||||
|
||||
if (netWM && (CreationParams.Fullscreen || has_display_size))
|
||||
{
|
||||
Atom WMStateAtom = XInternAtom(display, "_NET_WM_STATE", true);
|
||||
Atom WMFullscreenAtom = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", true);
|
||||
Atom WMStateAtom1 = None;
|
||||
Atom WMStateAtom2 = None;
|
||||
|
||||
if (CreationParams.Fullscreen)
|
||||
{
|
||||
WMStateAtom1 = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
WMStateAtom1 = XInternAtom(display, "_NET_WM_STATE_MAXIMIZED_HORZ", true);
|
||||
WMStateAtom2 = XInternAtom(display, "_NET_WM_STATE_MAXIMIZED_VERT", true);
|
||||
}
|
||||
|
||||
XEvent xev = {0}; // The event should be filled with zeros before setting its attributes
|
||||
xev.type = ClientMessage;
|
||||
@ -1017,14 +1032,16 @@ bool CIrrDeviceLinux::createWindow()
|
||||
xev.xclient.message_type = WMStateAtom;
|
||||
xev.xclient.format = 32;
|
||||
xev.xclient.data.l[0] = 1;
|
||||
xev.xclient.data.l[1] = WMFullscreenAtom;
|
||||
xev.xclient.data.l[1] = WMStateAtom1;
|
||||
xev.xclient.data.l[2] = WMStateAtom2;
|
||||
|
||||
XSendEvent(display, RootWindow(display, visual->screen), false,
|
||||
SubstructureRedirectMask | SubstructureNotifyMask, &xev);
|
||||
|
||||
XFlush(display);
|
||||
|
||||
// Wait until window state is already changed to fullscreen
|
||||
bool fullscreen = false;
|
||||
// Wait until window state is already changed
|
||||
bool changed = false;
|
||||
for (int i = 0; i < 500; i++)
|
||||
{
|
||||
Atom type;
|
||||
@ -1041,9 +1058,9 @@ bool CIrrDeviceLinux::createWindow()
|
||||
{
|
||||
for (unsigned int i = 0; i < numItems; ++i)
|
||||
{
|
||||
if (atoms[i] == WMFullscreenAtom)
|
||||
if (atoms[i] == WMStateAtom1)
|
||||
{
|
||||
fullscreen = true;
|
||||
changed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1051,18 +1068,19 @@ bool CIrrDeviceLinux::createWindow()
|
||||
XFree(atoms);
|
||||
}
|
||||
|
||||
if (fullscreen == true)
|
||||
if (changed == true)
|
||||
break;
|
||||
|
||||
usleep(1000);
|
||||
}
|
||||
|
||||
if (!fullscreen)
|
||||
if (!changed)
|
||||
{
|
||||
os::Printer::log("Warning! Got timeout while checking fullscreen sate", ELL_WARNING);
|
||||
os::Printer::log("Warning! Got timeout when changing window state", ELL_WARNING);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (!netWM && CreationParams.Fullscreen)
|
||||
{
|
||||
XSetInputFocus(display, window, RevertToParent, CurrentTime);
|
||||
int grabKb = XGrabKeyboard(display, window, True, GrabModeAsync,
|
||||
@ -1074,7 +1092,6 @@ bool CIrrDeviceLinux::createWindow()
|
||||
XWarpPointer(display, None, window, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// attach external window
|
||||
|
Loading…
Reference in New Issue
Block a user