2 * Copyright (c) 2009, Wei Mingzhi <whistler@openoffice.org>.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, see <http://www.gnu.org/licenses>.
23 #include <X11/Xutil.h>
24 #include <X11/keysym.h>
25 #include <X11/XKBlib.h>
27 #include "../frontend/main.h"
28 #include "../frontend/plugin_lib.h"
30 static Atom wmprotocols, wmdelwindow;
31 static int initialized;
35 static void InitKeyboard(void) {
36 Display *disp = (Display *)gpuDisp;
38 wmprotocols = XInternAtom(disp, "WM_PROTOCOLS", 0);
39 wmdelwindow = XInternAtom(disp, "WM_DELETE_WINDOW", 0);
40 XkbSetDetectableAutoRepeat(disp, 1, NULL);
44 static void DestroyKeyboard(void) {
45 Display *disp = (Display *)gpuDisp;
47 XkbSetDetectableAutoRepeat(disp, 0, NULL);
49 #include "maemo_common.h"
51 int maemo_x11_update_keys() {
54 XClientMessageEvent *xce;
56 Display *disp = (Display *)gpuDisp;
66 while (XPending(disp)>0) {
67 XNextEvent(disp, &evt);
71 key_press_event(evt.xkey.keycode, evt.type==KeyPress ? 1 : (evt.type==KeyRelease ? 2 : 0) );
75 xce = (XClientMessageEvent *)&evt;
76 if (xce->message_type == wmprotocols && (Atom)xce->data.l[0] == wmdelwindow)