Commit bca1bb22 authored by nadro's avatar nadro

Added support for fullscreen window manager on linux. Patch provided by Deve.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4918 dfc29bdd-3216-0410-991c-e03cc46cb475
parent d8676389
-------------------------- --------------------------
Changes in 1.9 (not yet released) Changes in 1.9 (not yet released)
- Added support for fullscreen window manager on linux. Patch provided by Deve.
- Fixed several selection, highlighting and clipping bugs in CGUITreeview (thx @ AReichl for the patch + test) - Fixed several selection, highlighting and clipping bugs in CGUITreeview (thx @ AReichl for the patch + test)
- Removed DllMain from the static windows build (thx @ AReichl for reporting) - Removed DllMain from the static windows build (thx @ AReichl for reporting)
- Fixed maximize/minimize under Linux by supporting NETWM hints. Patch provided by hendu. - Fixed maximize/minimize under Linux by supporting NETWM hints. Patch provided by hendu.
......
...@@ -685,9 +685,20 @@ bool CIrrDeviceLinux::createWindow() ...@@ -685,9 +685,20 @@ bool CIrrDeviceLinux::createWindow()
y = CreationParams.WindowPosition.Y; y = CreationParams.WindowPosition.Y;
} }
// create new Window Atom *list = 0;
// Remove window manager decoration in fullscreen Atom type = 0;
WndAttributes.override_redirect = CreationParams.Fullscreen; int form = 0;
unsigned long remain = 0, len = 0;
Atom WMCheck = XInternAtom(XDisplay, "_NET_SUPPORTING_WM_CHECK", false);
Status s = XGetWindowProperty(XDisplay, DefaultRootWindow(XDisplay), WMCheck, 0L, 1L, False, XA_WINDOW,
&type, &form, &len, &remain, (unsigned char **)&list);
bool netWM = (s == Success) && len;
// create new Window
// Remove window manager decoration in fullscreen
WndAttributes.override_redirect = !netWM && CreationParams.Fullscreen;
XWindow = XCreateWindow(XDisplay, XWindow = XCreateWindow(XDisplay,
RootWindow(XDisplay, VisualInfo->screen), RootWindow(XDisplay, VisualInfo->screen),
x, y, Width, Height, 0, VisualInfo->depth, x, y, Width, Height, 0, VisualInfo->depth,
...@@ -702,14 +713,45 @@ bool CIrrDeviceLinux::createWindow() ...@@ -702,14 +713,45 @@ bool CIrrDeviceLinux::createWindow()
XSetWMProtocols(XDisplay, XWindow, &wmDelete, 1); XSetWMProtocols(XDisplay, XWindow, &wmDelete, 1);
if (CreationParams.Fullscreen) if (CreationParams.Fullscreen)
{ {
XSetInputFocus(XDisplay, XWindow, RevertToParent, CurrentTime); if (netWM)
int grabKb = XGrabKeyboard(XDisplay, XWindow, True, GrabModeAsync, {
GrabModeAsync, CurrentTime); // Workaround for Gnome which sometimes creates window smaller than display
IrrPrintXGrabError(grabKb, "XGrabKeyboard"); XSizeHints *hints = XAllocSizeHints();
int grabPointer = XGrabPointer(XDisplay, XWindow, True, ButtonPressMask, hints->flags=PMinSize;
GrabModeAsync, GrabModeAsync, XWindow, None, CurrentTime); hints->min_width=Width;
IrrPrintXGrabError(grabPointer, "XGrabPointer"); hints->min_height=Height;
XWarpPointer(XDisplay, None, XWindow, 0, 0, 0, 0, 0, 0); XSetWMNormalHints(XDisplay, XWindow, hints);
XFree(hints);
// Set the fullscreen mode via the window manager. This allows alt-tabing, volume hot keys & others.
// Get the needed atom from there freedesktop names
Atom WMStateAtom = XInternAtom(XDisplay, "_NET_WM_STATE", true);
Atom WMFullscreenAtom = XInternAtom(XDisplay, "_NET_WM_STATE_FULLSCREEN", true);
// Set the fullscreen property
XChangeProperty(XDisplay, XWindow, WMStateAtom, XA_ATOM, 32, PropModeReplace, reinterpret_cast<unsigned char *>(& WMFullscreenAtom), 1);
// Notify the root window
XEvent xev = {0}; // The event should be filled with zeros before setting its attributes
xev.type = ClientMessage;
xev.xclient.window = XWindow;
xev.xclient.message_type = WMStateAtom;
xev.xclient.format = 32;
xev.xclient.data.l[0] = 1;
xev.xclient.data.l[1] = WMFullscreenAtom;
XSendEvent(XDisplay, DefaultRootWindow(XDisplay), false, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
}
else
{
XSetInputFocus(XDisplay, XWindow, RevertToParent, CurrentTime);
int grabKb = XGrabKeyboard(XDisplay, XWindow, True, GrabModeAsync,
GrabModeAsync, CurrentTime);
IrrPrintXGrabError(grabKb, "XGrabKeyboard");
int grabPointer = XGrabPointer(XDisplay, XWindow, True, ButtonPressMask,
GrabModeAsync, GrabModeAsync, XWindow, None, CurrentTime);
IrrPrintXGrabError(grabPointer, "XGrabPointer");
XWarpPointer(XDisplay, None, XWindow, 0, 0, 0, 0, 0, 0);
}
} }
} }
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment