42
42
#include "machine.h"
44
44
#include "uiarch.h"
47
void kbd_arch_init(void)
51
signed long kbd_arch_keyname_to_keynum(char *keyname)
55
sym = XStringToKeysym(keyname);
60
return (signed long)sym;
63
const char *kbd_arch_keynum_to_keyname(signed long keynum)
65
return XKeysymToString((KeySym)keynum);
68
/* ------------------------------------------------------------------ */
70
/* Meta status (used to filter out keypresses when meta is pressed). */
71
static int meta_count = 0;
72
static int control_count, shift_count;
74
void x11kbd_press(signed long key)
77
log_debug("KeyPress `%s'.", XKeysymToString(key));
97
#ifdef MODE_SWITCH_AS_META
104
if ((meta_count != 0) &&
105
ui_dispatch_hotkeys(key))
117
keyboard_key_pressed(key);
120
void x11kbd_release(signed long key)
123
log_debug("KeyRelease `%s'.", XKeysymToString(key));
135
if (control_count > 0)
144
#ifdef MODE_SWITCH_AS_META
157
if (IsModifierKey(key)) {
158
/* FIXME: This is a dirty kludge. X11 can sometimes give the
159
KeyPress event with the shifted KeySym, and the KeyRelease one
160
with the same KeySym unshifted, so we loose control of what
161
has been pressed and what has been released (all KeySyms are
162
handled independently here). For example, if the user does
163
<Press Shift> <Press 1> <Release Shift> <Release 1>, we get
164
<KeyPress Shift>, <KeyPress !>, <KeyRelease Shift>,
165
<KeyRelease 1>. To avoid disasters, we reset all the keyboard
166
when a modifier has been released, but this heavily simplifies
167
the behavior of multiple keys. Does anybody know a way to
168
avoid this X11 oddity? */
169
/*virtual_shift_down = 0;*/
170
keyboard_key_clear();
171
/* TODO: do we have to cleanup joypads here too? */
177
keyboard_key_released(key);
180
void x11kbd_enter_leave(void)
182
keyboard_key_clear();
187
void x11kbd_focus_change(void)
189
keyboard_key_clear();
190
meta_count = control_count = shift_count = 0;
47
194
void kbd_event_handler(Widget w, XtPointer client_data, XEvent *report,