Fixed: #941 Dead keys are not working on Linux
This commit is contained in:
parent
efc6cbef2e
commit
7cbae09b75
2 changed files with 30 additions and 13 deletions
|
@ -1127,7 +1127,7 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nldebug("3D: XCreateWindow() OK");
|
nldebug("3D: XCreateWindow() OK");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -382,13 +382,17 @@ void CUnixEventEmitter::processMessage (XEvent &event, CEventServer &server)
|
||||||
}
|
}
|
||||||
Case(KeyPress)
|
Case(KeyPress)
|
||||||
{
|
{
|
||||||
|
// save keycode because XFilterEvent could set it to 0
|
||||||
uint keyCode = event.xkey.keycode;
|
uint keyCode = event.xkey.keycode;
|
||||||
KeySym k = XKeycodeToKeysym(_dpy, keyCode, 0);
|
KeySym k;
|
||||||
char Text[256];
|
static char Text[256];
|
||||||
int c = 0;
|
int c = 0;
|
||||||
|
|
||||||
// if key event is filtered, we must NOT use XLookupString
|
// check if event is filtered
|
||||||
if (!XFilterEvent(&event, _win))
|
bool filtered = XFilterEvent(&event, _win);
|
||||||
|
|
||||||
|
// if key event is filtered, we shouldn't use XLookupString to retrieve KeySym
|
||||||
|
if (!filtered)
|
||||||
{
|
{
|
||||||
Status status = XLookupNone;
|
Status status = XLookupNone;
|
||||||
|
|
||||||
|
@ -400,24 +404,37 @@ void CUnixEventEmitter::processMessage (XEvent &event, CEventServer &server)
|
||||||
if (status == XLookupNone)
|
if (status == XLookupNone)
|
||||||
c = XLookupString(&event.xkey, Text, sizeof(Text), &k, NULL);
|
c = XLookupString(&event.xkey, Text, sizeof(Text), &k, NULL);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
k = XKeycodeToKeysym(_dpy, keyCode, 0);
|
||||||
|
}
|
||||||
|
|
||||||
TKey key = getKeyFromKeySym(k);
|
// send CEventKeyDown event only if keyCode is defined
|
||||||
if(key == KeyNOKEY)
|
if (keyCode)
|
||||||
key = getKeyFromKeycode(keyCode);
|
{
|
||||||
|
TKey key = getKeyFromKeySym(k);
|
||||||
|
if(key == KeyNOKEY)
|
||||||
|
key = getKeyFromKeycode(keyCode);
|
||||||
|
|
||||||
server.postEvent (new CEventKeyDown (key, getKeyButton(event.xbutton.state), _PreviousKey != key, this));
|
server.postEvent (new CEventKeyDown (key, getKeyButton(event.xbutton.state), _PreviousKey != key, this));
|
||||||
_PreviousKey = key;
|
_PreviousKey = key;
|
||||||
|
|
||||||
// don't send a control character when deleting
|
// don't send a control character when deleting
|
||||||
if (key == KeyDELETE)
|
if (key == KeyDELETE)
|
||||||
c = 0;
|
c = 0;
|
||||||
|
}
|
||||||
|
|
||||||
Text[c] = '\0';
|
Text[c] = '\0';
|
||||||
if(c>0)
|
if(c>0)
|
||||||
{
|
{
|
||||||
|
#ifdef X_HAVE_UTF8_STRING
|
||||||
ucstring ucstr;
|
ucstring ucstr;
|
||||||
ucstr.fromUtf8(Text);
|
ucstr.fromUtf8(Text);
|
||||||
server.postEvent (new CEventChar (ucstr[0], noKeyButton, this));
|
server.postEvent (new CEventChar (ucstr[0], noKeyButton, this));
|
||||||
|
#else
|
||||||
|
for (int i = 0; i < c; i++)
|
||||||
|
server.postEvent (new CEventChar ((ucchar)(unsigned char)Text[i], noKeyButton, this));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue