Commit 03b15054 authored by hybrid's avatar hybrid

Added NETWM support for maximize/minimize under Linux. Fixed aliasing in X11 text conversion.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4885 dfc29bdd-3216-0410-991c-e03cc46cb475
parent b5ade26c
...@@ -64,6 +64,9 @@ namespace ...@@ -64,6 +64,9 @@ namespace
Atom X_ATOM_TARGETS; Atom X_ATOM_TARGETS;
Atom X_ATOM_UTF8_STRING; Atom X_ATOM_UTF8_STRING;
Atom X_ATOM_TEXT; Atom X_ATOM_TEXT;
Atom X_ATOM_NETWM_MAXIMIZE_VERT;
Atom X_ATOM_NETWM_MAXIMIZE_HORZ;
Atom X_ATOM_NETWM_STATE;
}; };
namespace irr namespace irr
...@@ -77,6 +80,7 @@ CIrrDeviceLinux::CIrrDeviceLinux(const SIrrlichtCreationParameters& param) ...@@ -77,6 +80,7 @@ CIrrDeviceLinux::CIrrDeviceLinux(const SIrrlichtCreationParameters& param)
#ifdef _IRR_COMPILE_WITH_X11_ #ifdef _IRR_COMPILE_WITH_X11_
XDisplay(0), VisualInfo(0), Screennr(0), XWindow(0), StdHints(0), SoftwareImage(0), XDisplay(0), VisualInfo(0), Screennr(0), XWindow(0), StdHints(0), SoftwareImage(0),
XInputMethod(0), XInputContext(0), XInputMethod(0), XInputContext(0),
HasNetWM(false),
#ifdef _IRR_COMPILE_WITH_OPENGL_ #ifdef _IRR_COMPILE_WITH_OPENGL_
GlxWin(0), GlxWin(0),
Context(0), Context(0),
...@@ -814,6 +818,11 @@ bool CIrrDeviceLinux::createWindow() ...@@ -814,6 +818,11 @@ bool CIrrDeviceLinux::createWindow()
initXAtoms(); initXAtoms();
// check netwm support
Atom WMCheck = XInternAtom(XDisplay, "_NET_SUPPORTING_WM_CHECK", true);
if (WMCheck != None)
HasNetWM = true;
#endif // #ifdef _IRR_COMPILE_WITH_X11_ #endif // #ifdef _IRR_COMPILE_WITH_X11_
return true; return true;
} }
...@@ -1220,9 +1229,13 @@ bool CIrrDeviceLinux::run() ...@@ -1220,9 +1229,13 @@ bool CIrrDeviceLinux::run()
} }
else // Old version without InputContext. Does not support i18n, but good to have as fallback. else // Old version without InputContext. Does not support i18n, but good to have as fallback.
{ {
char buf[8]={0}; union
XLookupString(&event.xkey, buf, sizeof(buf), &mp.X11Key, NULL); {
irrevent.KeyInput.Char = ((wchar_t*)(buf))[0]; char buf[8];
wchar_t wbuf[2];
} tmp = {0};
XLookupString(&event.xkey, tmp.buf, sizeof(tmp.buf), &mp.X11Key, NULL);
irrevent.KeyInput.Char = tmp.wbuf[0];
} }
irrevent.EventType = irr::EET_KEY_INPUT_EVENT; irrevent.EventType = irr::EET_KEY_INPUT_EVENT;
...@@ -1589,6 +1602,23 @@ void CIrrDeviceLinux::minimizeWindow() ...@@ -1589,6 +1602,23 @@ void CIrrDeviceLinux::minimizeWindow()
void CIrrDeviceLinux::maximizeWindow() void CIrrDeviceLinux::maximizeWindow()
{ {
#ifdef _IRR_COMPILE_WITH_X11_ #ifdef _IRR_COMPILE_WITH_X11_
// Maximize is not implemented in bare X, it's a WM construct.
if (HasNetWM)
{
XEvent ev = {0};
ev.type = ClientMessage;
ev.xclient.window = XWindow;
ev.xclient.message_type = X_ATOM_NETWM_STATE;
ev.xclient.format = 32;
ev.xclient.data.l[0] = 1; // _NET_WM_STATE_ADD
ev.xclient.data.l[1] = X_ATOM_NETWM_MAXIMIZE_VERT;
ev.xclient.data.l[2] = X_ATOM_NETWM_MAXIMIZE_HORZ;
XSendEvent(XDisplay, DefaultRootWindow(XDisplay), false,
SubstructureNotifyMask|SubstructureRedirectMask, &ev);
}
XMapWindow(XDisplay, XWindow); XMapWindow(XDisplay, XWindow);
#endif #endif
} }
...@@ -1598,6 +1628,23 @@ void CIrrDeviceLinux::maximizeWindow() ...@@ -1598,6 +1628,23 @@ void CIrrDeviceLinux::maximizeWindow()
void CIrrDeviceLinux::restoreWindow() void CIrrDeviceLinux::restoreWindow()
{ {
#ifdef _IRR_COMPILE_WITH_X11_ #ifdef _IRR_COMPILE_WITH_X11_
// Maximize is not implemented in bare X, it's a WM construct.
if (HasNetWM)
{
XEvent ev = {0};
ev.type = ClientMessage;
ev.xclient.window = XWindow;
ev.xclient.message_type = X_ATOM_NETWM_STATE;
ev.xclient.format = 32;
ev.xclient.data.l[0] = 0; // _NET_WM_STATE_REMOVE
ev.xclient.data.l[1] = X_ATOM_NETWM_MAXIMIZE_VERT;
ev.xclient.data.l[2] = X_ATOM_NETWM_MAXIMIZE_HORZ;
XSendEvent(XDisplay, DefaultRootWindow(XDisplay), false,
SubstructureNotifyMask|SubstructureRedirectMask, &ev);
}
XMapWindow(XDisplay, XWindow); XMapWindow(XDisplay, XWindow);
#endif #endif
} }
...@@ -2143,6 +2190,9 @@ void CIrrDeviceLinux::initXAtoms() ...@@ -2143,6 +2190,9 @@ void CIrrDeviceLinux::initXAtoms()
X_ATOM_TARGETS = XInternAtom(XDisplay, "TARGETS", False); X_ATOM_TARGETS = XInternAtom(XDisplay, "TARGETS", False);
X_ATOM_UTF8_STRING = XInternAtom (XDisplay, "UTF8_STRING", False); X_ATOM_UTF8_STRING = XInternAtom (XDisplay, "UTF8_STRING", False);
X_ATOM_TEXT = XInternAtom (XDisplay, "TEXT", False); X_ATOM_TEXT = XInternAtom (XDisplay, "TEXT", False);
X_ATOM_NETWM_MAXIMIZE_VERT = XInternAtom(XDisplay, "_NET_WM_STATE_MAXIMIZED_VERT", true);
X_ATOM_NETWM_MAXIMIZE_HORZ = XInternAtom(XDisplay, "_NET_WM_STATE_MAXIMIZED_HORZ", true);
X_ATOM_NETWM_STATE = XInternAtom(XDisplay, "_NET_WM_STATE", true);
#endif #endif
} }
......
...@@ -402,6 +402,7 @@ namespace irr ...@@ -402,6 +402,7 @@ namespace irr
XImage* SoftwareImage; XImage* SoftwareImage;
XIM XInputMethod; XIM XInputMethod;
XIC XInputContext; XIC XInputContext;
bool HasNetWM;
mutable core::stringc Clipboard; mutable core::stringc Clipboard;
#ifdef _IRR_LINUX_X11_VIDMODE_ #ifdef _IRR_LINUX_X11_VIDMODE_
XF86VidModeModeInfo OldVideoMode; XF86VidModeModeInfo OldVideoMode;
......
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