Changed: Listen for more X messages
This commit is contained in:
parent
1e352ff35e
commit
c9116fd7be
3 changed files with 42 additions and 8 deletions
|
@ -1588,6 +1588,8 @@ bool CDriverGL::destroyWindow()
|
||||||
|
|
||||||
#elif defined (NL_OS_UNIX)
|
#elif defined (NL_OS_UNIX)
|
||||||
|
|
||||||
|
_EventEmitter.closeIM();
|
||||||
|
|
||||||
if (_DestroyWindow)
|
if (_DestroyWindow)
|
||||||
{
|
{
|
||||||
if (_ctx)
|
if (_ctx)
|
||||||
|
|
|
@ -45,8 +45,7 @@ CUnixEventEmitter::CUnixEventEmitter ():_dpy(NULL), _win(0), _emulateRawMode(fal
|
||||||
|
|
||||||
CUnixEventEmitter::~CUnixEventEmitter()
|
CUnixEventEmitter::~CUnixEventEmitter()
|
||||||
{
|
{
|
||||||
if (_ic) XDestroyIC(_ic);
|
closeIM();
|
||||||
if (_im) XCloseIM(_im);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CUnixEventEmitter::init(Display *dpy, Window win, NL3D::IDriver *driver)
|
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;
|
_win = win;
|
||||||
_driver = driver;
|
_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
|
// define Atoms used by clipboard
|
||||||
XA_CLIPBOARD = XInternAtom(dpy, "CLIPBOARD", False);
|
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
|
TODO: implements all useful events processing
|
||||||
ButtonMotionMask|Button1MotionMask|Button2MotionMask|
|
ButtonMotionMask|Button1MotionMask|Button2MotionMask|
|
||||||
Button3MotionMask|Button4MotionMask|Button5MotionMask|KeymapStateMask|
|
Button3MotionMask|Button4MotionMask|Button5MotionMask|KeymapStateMask|
|
||||||
SubstructureNotifyMask|VisibilityChangeMask|FocusChangeMask|PropertyChangeMask|
|
SubstructureNotifyMask|VisibilityChangeMask|PropertyChangeMask|
|
||||||
ColormapChangeMask|OwnerGrabButtonMask
|
ColormapChangeMask|OwnerGrabButtonMask
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -80,7 +79,14 @@ void CUnixEventEmitter::init(Display *dpy, Window win, NL3D::IDriver *driver)
|
||||||
|
|
||||||
void CUnixEventEmitter::createIM()
|
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);
|
_im = XOpenIM(_dpy, NULL, NULL, NULL);
|
||||||
|
|
||||||
if (_im)
|
if (_im)
|
||||||
{
|
{
|
||||||
_ic = XCreateIC(_im, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, _win, XNFocusWindow, _win, NULL);
|
_ic = XCreateIC(_im, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, _win, XNFocusWindow, _win, NULL);
|
||||||
|
@ -96,6 +102,25 @@ void CUnixEventEmitter::createIM()
|
||||||
{
|
{
|
||||||
nlwarning("XCreateIC failed");
|
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)
|
void CUnixEventEmitter::submitEvents(CEventServer & server, bool allWindows)
|
||||||
|
@ -761,13 +786,19 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server)
|
||||||
}
|
}
|
||||||
case FocusIn:
|
case FocusIn:
|
||||||
// keyboard focus
|
// keyboard focus
|
||||||
// server->postEvent (new CEventSetFocus (true, this));
|
#ifdef X_HAVE_UTF8_STRING
|
||||||
if (_ic) XSetICFocus(_ic);
|
if (_ic) XSetICFocus(_ic);
|
||||||
|
#endif
|
||||||
|
server->postEvent (new CEventSetFocus (true, this));
|
||||||
|
// server->postEvent(new CEventActivate(true, this));
|
||||||
break;
|
break;
|
||||||
case FocusOut:
|
case FocusOut:
|
||||||
// keyboard focus
|
// keyboard focus
|
||||||
// server->postEvent (new CEventSetFocus (false, this));
|
#ifdef X_HAVE_UTF8_STRING
|
||||||
if (_ic) XUnsetICFocus(_ic);
|
if (_ic) XUnsetICFocus(_ic);
|
||||||
|
#endif
|
||||||
|
server->postEvent (new CEventSetFocus (false, this));
|
||||||
|
// server->postEvent(new CEventActivate(false, this));
|
||||||
break;
|
break;
|
||||||
case KeymapNotify:
|
case KeymapNotify:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -76,6 +76,9 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bool pasteTextFromClipboard(ucstring &text);
|
virtual bool pasteTextFromClipboard(ucstring &text);
|
||||||
|
|
||||||
|
void createIM();
|
||||||
|
void closeIM();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Private internal server message
|
// Private internal server message
|
||||||
|
@ -98,8 +101,6 @@ private:
|
||||||
CEventServer *_Server;
|
CEventServer *_Server;
|
||||||
};
|
};
|
||||||
|
|
||||||
void createIM();
|
|
||||||
|
|
||||||
Display* _dpy;
|
Display* _dpy;
|
||||||
Window _win;
|
Window _win;
|
||||||
std::map<TKey, bool> _PressedKeys;
|
std::map<TKey, bool> _PressedKeys;
|
||||||
|
|
Loading…
Reference in a new issue