Skip to content

Commit 2fb0036

Browse files
deveeehiker
authored andcommitted
Make changing to fullscreen on linux safer.
Now we are waiting until window state is already changed to fullscreen. We are getting real window size at the end of creating window function and previously it was sometimes reporting size of the window in windowed mode, which could causing issues in gui. Previously this was workarounded by forcing minimal window size to be at least in screen resolution, but window managers don't like to have non-resizeable fullscreen windows. Now this workaround is not needed anymore.
1 parent 87d0680 commit 2fb0036

File tree

1 file changed

+41
-13
lines changed

1 file changed

+41
-13
lines changed

lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -917,25 +917,12 @@ bool CIrrDeviceLinux::createWindow()
917917
XFlush(display);
918918
#endif
919919

920-
// Workaround for Gnome which sometimes creates window smaller than display
921-
XSizeHints *hints = XAllocSizeHints();
922-
hints->flags=PMinSize;
923-
hints->min_width=Width;
924-
hints->min_height=Height;
925-
XSetWMNormalHints(display, window, hints);
926-
XFree(hints);
927-
928920
// Set the fullscreen mode via the window manager. This allows alt-tabing, volume hot keys & others.
929921
// Get the needed atom from there freedesktop names
930922
Atom WMStateAtom = XInternAtom(display, "_NET_WM_STATE", true);
931923
Atom WMFullscreenAtom = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", true);
932-
// Set the fullscreen property
933-
XChangeProperty(display, window, WMStateAtom, XA_ATOM, 32, PropModeReplace,
934-
reinterpret_cast<unsigned char*>(&WMFullscreenAtom), 1);
935924

936-
// Notify the root window
937925
XEvent xev = {0}; // The event should be filled with zeros before setting its attributes
938-
939926
xev.type = ClientMessage;
940927
xev.xclient.window = window;
941928
xev.xclient.message_type = WMStateAtom;
@@ -946,6 +933,47 @@ bool CIrrDeviceLinux::createWindow()
946933
SubstructureRedirectMask | SubstructureNotifyMask, &xev);
947934

948935
XFlush(display);
936+
937+
// Wait until window state is already changed to fullscreen
938+
bool fullscreen = false;
939+
for (int i = 0; i < 500; i++)
940+
{
941+
Atom type;
942+
int format;
943+
unsigned long numItems, bytesAfter;
944+
unsigned char* data = NULL;
945+
946+
int s = XGetWindowProperty(display, window, WMStateAtom,
947+
0l, 1024, False, XA_ATOM, &type,
948+
&format, &numItems, &bytesAfter,
949+
&data);
950+
951+
if (s == Success)
952+
{
953+
Atom* atoms = (Atom*)data;
954+
955+
for (unsigned int i = 0; i < numItems; ++i)
956+
{
957+
if (atoms[i] == WMFullscreenAtom)
958+
{
959+
fullscreen = true;
960+
break;
961+
}
962+
}
963+
}
964+
965+
XFree(data);
966+
967+
if (fullscreen == true)
968+
break;
969+
970+
usleep(1000);
971+
}
972+
973+
if (!fullscreen)
974+
{
975+
os::Printer::log("Warning! Got timeout while checking fullscreen sate", ELL_WARNING);
976+
}
949977
}
950978
else
951979
{

0 commit comments

Comments
 (0)