From c9116fd7bea5b4332f2e9dc02e2960c5c9bb9285 Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 21 Nov 2010 22:25:41 +0100 Subject: [PATCH] Changed: Listen for more X messages --- .../3d/driver/opengl/driver_opengl_window.cpp | 2 + .../3d/driver/opengl/unix_event_emitter.cpp | 43 ++++++++++++++++--- .../src/3d/driver/opengl/unix_event_emitter.h | 5 ++- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp index b363dec83..2dcf45075 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -1588,6 +1588,8 @@ bool CDriverGL::destroyWindow() #elif defined (NL_OS_UNIX) + _EventEmitter.closeIM(); + if (_DestroyWindow) { if (_ctx) diff --git a/code/nel/src/3d/driver/opengl/unix_event_emitter.cpp b/code/nel/src/3d/driver/opengl/unix_event_emitter.cpp index 343e6e247..8e61f88c0 100644 --- a/code/nel/src/3d/driver/opengl/unix_event_emitter.cpp +++ b/code/nel/src/3d/driver/opengl/unix_event_emitter.cpp @@ -45,8 +45,7 @@ CUnixEventEmitter::CUnixEventEmitter ():_dpy(NULL), _win(0), _emulateRawMode(fal CUnixEventEmitter::~CUnixEventEmitter() { - if (_ic) XDestroyIC(_ic); - if (_im) XCloseIM(_im); + closeIM(); } void CUnixEventEmitter::init(Display *dpy, Window win, NL3D::IDriver *driver) @@ -55,7 +54,7 @@ void CUnixEventEmitter::init(Display *dpy, Window win, NL3D::IDriver *driver) _win = win; _driver = driver; - XSelectInput (_dpy, _win, KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask|StructureNotifyMask|ExposureMask|EnterWindowMask|LeaveWindowMask); + XSelectInput (_dpy, _win, KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask|StructureNotifyMask|ExposureMask|EnterWindowMask|LeaveWindowMask|FocusChangeMask) // define Atoms used by clipboard XA_CLIPBOARD = XInternAtom(dpy, "CLIPBOARD", False); @@ -71,7 +70,7 @@ void CUnixEventEmitter::init(Display *dpy, Window win, NL3D::IDriver *driver) TODO: implements all useful events processing ButtonMotionMask|Button1MotionMask|Button2MotionMask| Button3MotionMask|Button4MotionMask|Button5MotionMask|KeymapStateMask| - SubstructureNotifyMask|VisibilityChangeMask|FocusChangeMask|PropertyChangeMask| + SubstructureNotifyMask|VisibilityChangeMask|PropertyChangeMask| ColormapChangeMask|OwnerGrabButtonMask */ @@ -80,7 +79,14 @@ void CUnixEventEmitter::init(Display *dpy, Window win, NL3D::IDriver *driver) void CUnixEventEmitter::createIM() { +#ifdef X_HAVE_UTF8_STRING + + XModifierKeymap *g_mod_map = XGetModifierMapping(_dpy); + + char *modifiers = XSetLocaleModifiers(getenv("XMODIFIERS")); + _im = XOpenIM(_dpy, NULL, NULL, NULL); + if (_im) { _ic = XCreateIC(_im, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, _win, XNFocusWindow, _win, NULL); @@ -96,8 +102,27 @@ void CUnixEventEmitter::createIM() { nlwarning("XCreateIC failed"); } + +#endif } +void CUnixEventEmitter::closeIM() +{ +#ifdef X_HAVE_UTF8_STRING + if (_ic) + { + XDestroyIC(_ic); + _ic = 0; + } + + if (_im) + { + XCloseIM(_im); + _im = 0; + } +#endif +} + void CUnixEventEmitter::submitEvents(CEventServer & server, bool allWindows) { while (XPending(_dpy)) @@ -761,13 +786,19 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) } case FocusIn: // keyboard focus -// server->postEvent (new CEventSetFocus (true, this)); +#ifdef X_HAVE_UTF8_STRING if (_ic) XSetICFocus(_ic); +#endif + server->postEvent (new CEventSetFocus (true, this)); + // server->postEvent(new CEventActivate(true, this)); break; case FocusOut: // keyboard focus -// server->postEvent (new CEventSetFocus (false, this)); +#ifdef X_HAVE_UTF8_STRING if (_ic) XUnsetICFocus(_ic); +#endif + server->postEvent (new CEventSetFocus (false, this)); + // server->postEvent(new CEventActivate(false, this)); break; case KeymapNotify: break; diff --git a/code/nel/src/3d/driver/opengl/unix_event_emitter.h b/code/nel/src/3d/driver/opengl/unix_event_emitter.h index 1ca017cf0..f7ebf2c19 100644 --- a/code/nel/src/3d/driver/opengl/unix_event_emitter.h +++ b/code/nel/src/3d/driver/opengl/unix_event_emitter.h @@ -76,6 +76,9 @@ public: */ virtual bool pasteTextFromClipboard(ucstring &text); + void createIM(); + void closeIM(); + private: // Private internal server message @@ -98,8 +101,6 @@ private: CEventServer *_Server; }; - void createIM(); - Display* _dpy; Window _win; std::map _PressedKeys;