void ProcessEvents() { IntPtr display = API.DefaultDisplay; using (new XLock(display)) { Functions.XQueryKeymap(display, keys); for (int keycode = 8; keycode < 256; keycode++) { bool pressed = (keys[keycode >> 3] >> (keycode & 0x07) & 0x01) != 0; Key key; for (int mod = 0; mod < KeysymsPerKeycode; mod++) { IntPtr keysym = Functions.XKeycodeToKeysym(display, (byte)keycode, mod); if (keysym != IntPtr.Zero && keymap.TryGetValue((XKey)keysym, out key)) { if (pressed) { state.EnableBit((int)key); } else { state.DisableBit((int)key); } break; } } } } }