From 59787a3fd3ac616cdf7eb1e886a7d8fa71d1dd39 Mon Sep 17 00:00:00 2001 From: ross Date: Thu, 20 Sep 2007 08:45:38 +0000 Subject: [PATCH] 2007-09-20 Ross Burton * src/matchbox-keyboard.h: * src/matchbox-keyboard-remote.c: Change mb_kbd_remote_process_xevents to return MBKeyboardRemoteOperation instead of performing the operation. Also Declare mb_kbd_ui_limit_orientation. * src/matchbox-keyboard-ui.c: Action the operation reutrned returned by process_xevents, and if we receive a Hide command wait for 100ms before hiding the keyboard, so that if we immediately receive a Show the keyboard doesn't flicker. Based on a patch by Daniel Willmann . git-svn-id: https://svn.o-hand.com/repos/matchbox/trunk/matchbox-keyboard@1687 b067294f-1dea-0310-9683-c47a78595994 --- ChangeLog | 16 ++++++++++++++ src/matchbox-keyboard-remote.c | 9 ++++---- src/matchbox-keyboard-ui.c | 39 +++++++++++++++++++++++++++++++--- src/matchbox-keyboard.h | 14 +++++++++++- 4 files changed, 70 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index ce895b3..37415d4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2007-09-20 Ross Burton + + * src/matchbox-keyboard.h: + * src/matchbox-keyboard-remote.c: + Change mb_kbd_remote_process_xevents to return + MBKeyboardRemoteOperation instead of performing the operation. + Also Declare mb_kbd_ui_limit_orientation. + + * src/matchbox-keyboard-ui.c: + Action the operation reutrned returned by process_xevents, and if + we receive a Hide command wait for 100ms before hiding the + keyboard, so that if we immediately receive a Show the keyboard + doesn't flicker. + + Based on a patch by Daniel Willmann . + 2007-09-17 Matthew Allum * src/matchbox-keyboard-key.c: diff --git a/src/matchbox-keyboard-remote.c b/src/matchbox-keyboard-remote.c index afc27cb..62a3267 100644 --- a/src/matchbox-keyboard-remote.c +++ b/src/matchbox-keyboard-remote.c @@ -28,7 +28,7 @@ mb_kbd_remote_init (MBKeyboardUI *ui) "_MB_IM_INVOKER_COMMAND", False); } -void +MBKeyboardRemoteOperation mb_kbd_remote_process_xevents (MBKeyboardUI *ui, XEvent *xevent) { DBG("got a message\n"); @@ -39,12 +39,13 @@ mb_kbd_remote_process_xevents (MBKeyboardUI *ui, XEvent *xevent) DBG("is a Client Message\n"); if (xevent->xclient.message_type == Atom_MB_IM_INVOKER_COMMAND) { - DBG("got a message of type _MB_IM_INVOKER_COMMAND, val %i\n", + DBG("got a message of type _MB_IM_INVOKER_COMMAND, val %lu\n", xevent->xclient.data.l[0]); if (xevent->xclient.data.l[0] == 1) - mb_kbd_ui_show (ui); + return MBKeyboardRemoteShow; else - mb_kbd_ui_hide (ui); + return MBKeyboardRemoteHide; } } + return MBKeyboardRemoteNone; } diff --git a/src/matchbox-keyboard-ui.c b/src/matchbox-keyboard-ui.c index 0ff1eae..1f974bf 100644 --- a/src/matchbox-keyboard-ui.c +++ b/src/matchbox-keyboard-ui.c @@ -1096,6 +1096,8 @@ mb_kbd_ui_event_loop(MBKeyboardUI *ui) /* Key repeat - values for standard xorg install ( xset q) */ int repeat_delay = 100 * 10000; int repeat_rate = 30 * 1000; + int hide_delay = 100 * 1000; + int to_hide = 0; int press_x = 0, press_y = 0; @@ -1182,11 +1184,42 @@ mb_kbd_ui_event_loop(MBKeyboardUI *ui) mb_kbd_xembed_process_xevents (ui, &xev); if (ui->is_daemon) - mb_kbd_remote_process_xevents (ui, &xev); - - } + { + switch (mb_kbd_remote_process_xevents (ui, &xev)) + { + case MBKeyboardRemoteHide: + if (to_hide == 1) { + mb_kbd_ui_hide(ui); + } + tvt.tv_usec = hide_delay; + to_hide = 1; + break; + case MBKeyboardRemoteShow: + mb_kbd_ui_show(ui); + tvt.tv_usec = repeat_delay; + to_hide = 0; + break; + case MBKeyboardRemoteNone: + if (to_hide == 1) { + mb_kbd_ui_hide(ui); + tvt.tv_usec = repeat_delay; + to_hide = 0; + } + break; + } + } + } else { + /* Hide timed out */ + if (to_hide) + { + DBG("Hide timed out, calling mb_kbd_ui_hide"); + mb_kbd_ui_hide(ui); + tvt.tv_usec = repeat_delay; + to_hide = 0; + } + /* Keyrepeat */ if (mb_kbd_get_held_key(ui->kbd) != NULL) { diff --git a/src/matchbox-keyboard.h b/src/matchbox-keyboard.h index 4f33cda..74059b1 100644 --- a/src/matchbox-keyboard.h +++ b/src/matchbox-keyboard.h @@ -144,6 +144,14 @@ typedef enum } MBKeyboardDisplayOrientation; +typedef enum +{ + MBKeyboardRemoteShow, + MBKeyboardRemoteHide, + MBKeyboardRemoteNone, +} +MBKeyboardRemoteOperation; + struct MBKeyboard { MBKeyboardUI *ui; @@ -179,6 +187,10 @@ struct MBKeyboardUIBackend int mb_kbd_ui_init(MBKeyboard *kbd); +void +mb_kbd_ui_limit_orientation (MBKeyboardUI *ui, + MBKeyboardDisplayOrientation orientation); + int mb_kbd_ui_realize(MBKeyboardUI *ui); @@ -285,7 +297,7 @@ mb_kbd_xembed_process_xevents (MBKeyboardUI *ui, XEvent *xevent); void mb_kbd_remote_init (MBKeyboardUI *ui); -void +MBKeyboardRemoteOperation mb_kbd_remote_process_xevents (MBKeyboardUI *ui, XEvent *xevent); /**** Keyboard ****/