mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-19 21:56:13 +00:00
Fixed: #1057 X11 Key auto repeat
This commit is contained in:
parent
d4ff95bf3a
commit
cfb5f27650
1 changed files with 35 additions and 5 deletions
|
@ -393,6 +393,24 @@ TKey getKeyFromKeySym (KeySym keysym)
|
||||||
return KeyNOKEY;
|
return KeyNOKEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if the next pressed key is the same
|
||||||
|
static bool keyRepeat(Display *display, XEvent *event)
|
||||||
|
{
|
||||||
|
XEvent peekevent;
|
||||||
|
|
||||||
|
if (XPending(display))
|
||||||
|
{
|
||||||
|
XPeekEvent(display, &peekevent);
|
||||||
|
|
||||||
|
if ((peekevent.type == KeyPress) &&
|
||||||
|
(peekevent.xkey.keycode == event->xkey.keycode) &&
|
||||||
|
((peekevent.xkey.time-event->xkey.time) < 2))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server)
|
bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server)
|
||||||
{
|
{
|
||||||
if (!server)
|
if (!server)
|
||||||
|
@ -541,21 +559,33 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server)
|
||||||
}
|
}
|
||||||
case KeyRelease:
|
case KeyRelease:
|
||||||
{
|
{
|
||||||
TKey key = getKeyFromKeySym(XKeycodeToKeysym(_dpy, event.xkey.keycode, 0));
|
if (!keyRepeat(_dpy, &event))
|
||||||
|
{
|
||||||
|
KeySym k;
|
||||||
|
// only need to get correct KeySym
|
||||||
|
int c = XLookupString(&event.xkey, NULL, 0, &k, NULL);
|
||||||
|
|
||||||
|
TKey key = getKeyFromKeySym(k);
|
||||||
if(key == KeyNOKEY)
|
if(key == KeyNOKEY)
|
||||||
key = getKeyFromKeycode(event.xkey.keycode);
|
key = getKeyFromKeycode(event.xkey.keycode);
|
||||||
|
|
||||||
server->postEvent (new CEventKeyUp (key, getKeyButton(event.xbutton.state), this));
|
server->postEvent (new CEventKeyUp (key, getKeyButton(event.xbutton.state), this));
|
||||||
_PreviousKey = KeyNOKEY;
|
_PreviousKey = KeyNOKEY;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FocusIn:
|
case FocusIn:
|
||||||
|
// keyboard focus
|
||||||
if (_ic) XSetICFocus(_ic);
|
if (_ic) XSetICFocus(_ic);
|
||||||
break;
|
break;
|
||||||
case FocusOut:
|
case FocusOut:
|
||||||
|
// keyboard focus
|
||||||
if (_ic) XUnsetICFocus(_ic);
|
if (_ic) XUnsetICFocus(_ic);
|
||||||
break;
|
break;
|
||||||
|
case KeymapNotify:
|
||||||
|
break;
|
||||||
case MappingNotify:
|
case MappingNotify:
|
||||||
|
// update keymap
|
||||||
XRefreshKeyboardMapping((XMappingEvent *)&event);
|
XRefreshKeyboardMapping((XMappingEvent *)&event);
|
||||||
break;
|
break;
|
||||||
case DestroyNotify:
|
case DestroyNotify:
|
||||||
|
|
Loading…
Reference in a new issue