[uim-commit] r3098 - trunk/gtk

ekato at freedesktop.org ekato at freedesktop.org
Mon Feb 6 15:08:09 PST 2006


Author: ekato
Date: 2006-02-06 15:07:59 -0800 (Mon, 06 Feb 2006)
New Revision: 3098

Modified:
   trunk/gtk/gtk-im-uim.c
Log:
* gtk/gtk-im-uim.c (IMUIMContext) : Add comment about event_rec.
(event_key_equal) : New.
(init_event_key_rec) : New.
(store_event_key) : New.
(im_uim_filter_keypress) : Use event_key_equal instead of just
  comparing the time as a paranoia check.
(im_uim_init) : Initialize event_rec totally.
(handle_key_on_toplevel) : Store all event attributes.


Modified: trunk/gtk/gtk-im-uim.c
===================================================================
--- trunk/gtk/gtk-im-uim.c	2006-02-05 15:44:29 UTC (rev 3097)
+++ trunk/gtk/gtk-im-uim.c	2006-02-06 23:07:59 UTC (rev 3098)
@@ -64,9 +64,6 @@
 #define IM_UIM_USE_SNOOPER	0
 #define IM_UIM_USE_TOPLEVEL	1
 
-/* still need investigating... */
-#define IM_UIM_USE_TOPLEVEL_EVENT_HACK	1
-
 /* exported symbols */
 GtkIMContext *im_module_create(const gchar *context_id);
 void im_module_list(const GtkIMContextInfo ***contexts, int *n_contexts);
@@ -102,10 +99,15 @@
 
 #if IM_UIM_USE_TOPLEVEL
   GtkWidget *widget;
-#if IM_UIM_USE_TOPLEVEL_EVENT_HACK
+  /*
+   * event_rec is used to check the incoming event is already handled
+   * in our toplevel handler.  Since some widget (e.g. OOo2.0's vcl
+   * plugin) already connects key press/release event handlers to the
+   * topleve window, our toplevel handler is not called in the first
+   * place.
+   */ 
   GdkEventKey event_rec;
 #endif
-#endif
 
   struct _IMUIMContext *prev, *next;
 } IMUIMContext;
@@ -497,8 +499,46 @@
   return GDK_FILTER_CONTINUE;
 }
 
+#if IM_UIM_USE_TOPLEVEL
+static inline gboolean
+event_key_equal(GdkEventKey *event1, GdkEventKey *event2)
+{
+  return (event1->type == event2->type &&
+	  event1->window == event2->window &&
+	  event1->send_event == event2->send_event &&
+	  event1->time == event2->time &&
+	  event1->state == event2->state &&
+	  event1->keyval == event2->keyval &&
+	  event1->length == event2->length &&
+	  event1->string == event2->string &&
+	  event1->hardware_keycode == event2->hardware_keycode &&
+	  event1->group == event2->group);
+}
 
+static void
+init_event_key_rec(GdkEventKey *event)
+{
+  event->type = -1;
+  event->window = NULL;
+  event->send_event = 0;
+  event->time = 0;
+  event->state = 0;
+  event->keyval = 0;
+  event->length = 0;
+  event->string = NULL;
+  event->hardware_keycode = 0;
+  event->group = 0;
+}
 
+static inline void
+store_event_key(GdkEventKey *dest, GdkEventKey *source)
+{
+  memcpy(dest, source, sizeof(GdkEventKey));
+}
+#endif
+
+
+
 /* callback functions for libuim */
 
 static void
@@ -936,13 +976,9 @@
 #if IM_UIM_USE_SNOOPER
   if (!snooper_installed) {
 #elif IM_UIM_USE_TOPLEVEL
-#if IM_UIM_USE_TOPLEVEL_EVENT_HACK
   if (!cur_toplevel || (cur_toplevel && grab_widget) ||
-		  key->time != uic->event_rec.time) {
+		  !event_key_equal(&uic->event_rec, key)) {
 #else
-  if (!cur_toplevel || (cur_toplevel && grab_widget)) {
-#endif
-#else
   if (TRUE) {
 #endif
     int rv, kv, mod;
@@ -1121,10 +1157,8 @@
   uic->win = NULL;
 #if IM_UIM_USE_TOPLEVEL
   uic->widget = NULL;
-#if IM_UIM_USE_TOPLEVEL_EVENT_HACK
-  uic->event_rec.time = 0;
+  init_event_key_rec(&uic->event_rec);
 #endif
-#endif
   uic->caret_state_indicator = NULL;
   uic->pseg = NULL;
   uic->nr_psegs = 0;
@@ -1308,9 +1342,7 @@
   if (focused_context == uic) {
     int rv, kv, mod;
 
-#if IM_UIM_USE_TOPLEVEL_EVENT_HACK
-    uic->event_rec.time = event->time;
-#endif
+    store_event_key(&uic->event_rec, event);
     im_uim_convert_keyevent(event, &kv, &mod);
 
     if (event->type == GDK_KEY_RELEASE)



More information about the uim-commit mailing list