2003-12-03 Padraig O'Briain <padraig.obriain@sun.com>
- * atk-bridge.c: (atk_bridge_init): Create accessible application
+ *registryd/deviceeventcontroller.c: Add an idle handler which polls
+ the keyboard on a timeout intil the key state goes from pressed to
+ released. Fixes bug #111429.
+
+2003-12-03 Padraig O'Briain <padraig.obriain@sun.com>
+
+ * atk-bridge/bridge.c: (atk_bridge_init): Create accessible application
root object so that it is present when a context menu in an
out-of-process applet is popped up.
(spi_atk_bridge_do_registration): Create acceessible application root
#include "../libspi/spi-private.h"
#include "deviceeventcontroller.h"
+#define CHECK_RELEASE_DELAY 20
+#define BIT(c, x) (c[x/8]&(1<<(x%8)))
+static guint check_release_handler = 0;
+static Accessibility_DeviceEvent pressed_event;
+static SpiDEController *saved_controller;
+static void wait_for_release_event (GdkEvent *event, SpiDEController *controller);
+
/* Our parent Gtk object type */
#define PARENT_TYPE BONOBO_TYPE_OBJECT
if (is_consumed)
XAllowEvents (spi_get_display (), AsyncKeyboard, CurrentTime);
else
- XAllowEvents (spi_get_display (), ReplayKeyboard, CurrentTime);
+ {
+ wait_for_release_event (event, controller);
+ XAllowEvents (spi_get_display (), ReplayKeyboard, CurrentTime);
+ }
}
return GDK_FILTER_CONTINUE;
return retval;
}
+static gboolean
+is_key_released (KeyCode code)
+{
+ char keys[32];
+ int down;
+ int i;
+
+ XQueryKeymap (spi_get_display (), keys);
+ down = BIT (keys, code);
+ return (down == 0);
+}
+
+static gboolean
+check_release (gpointer data)
+{
+ gboolean released;
+ Accessibility_DeviceEvent *event = (Accessibility_DeviceEvent *)data;
+ KeyCode code = event->hw_code;
+ CORBA_Environment ev;
+
+ released = is_key_released (code);
+
+ if (released)
+ {
+ check_release_handler = 0;
+ event->type = Accessibility_KEY_RELEASED_EVENT;
+ ev._major = CORBA_NO_EXCEPTION;
+ spi_controller_notify_keylisteners (saved_controller, event, CORBA_TRUE, &ev);
+ }
+ return (released == 0);
+}
+
+static void wait_for_release_event (GdkEvent *event,
+ SpiDEController *controller)
+{
+ pressed_event = spi_keystroke_from_x_key_event ((XKeyEvent *) event);
+ saved_controller = controller;
+ check_release_handler = g_timeout_add (CHECK_RELEASE_DELAY, check_release, &pressed_event);
+}
+
BONOBO_TYPE_FUNC_FULL (SpiDEController,
Accessibility_DeviceEventController,
PARENT_TYPE,