[openi18n-im:01495] Re: iiimx patch to enable key release event

Federic Zhang <[email protected]> Wed, 27 Jul 2005 17:56:19 +0800
Newsgroups gmane.comp.internationalization.input-methods
Message-ID <[email protected]>
Just update.

Today i commit the patch with the modification to let GTK+ client to
filter key release event to XIM server, see the attached one. It means
the event will be sent to IIIM server without any modification on
im-xim.so module. enjoy it.

-federic

> Hi,
> 
> Attached is the patch to enable key release event in IIIMXCF side,
> please review and give feedback, i will commit if nobody objects. Note
> that i don't change IIIMCF_keyevent_To_XKeyEvent in KeyMap.c because
> only key press event will be sent back from server with
> iml_make_keypress_inst if the key isn't consumed by LE.
> 
> To verify whether release event is sent via iiimx to server or not, the
> client should be able to send both press and release event, for Gtk+
> app, please use the attached gtk patch which forces filter_key_release,
> which is just used for verification, rebuild im-xim.so and copy to
> /usr/lib/gtk-2.0/<version>/immodules.
> 
> -federic
>
iiim-xim-key-release2.diff (text/x-patch, 3.5 KB)
Index: xiiimp.so/iiimp/iiimpIC.c
===================================================================
--- xiiimp.so/iiimp/iiimpIC.c	(revision 2784)
+++ xiiimp.so/iiimp/iiimpIC.c	(working copy)
@@ -247,7 +247,11 @@
 	return False;
     }
 
-    if (KeyRelease == ev->xkey.type) {
+    /*
+     * Comment the codes below - FIXME
+     * Key release event should be forwarded with IMForwardEvent to server
+     */
+    if (0 && KeyRelease == ev->xkey.type) {
 	XIMCallback *cb = &ic->forward_event_callback;
 	if (NULL != cb->callback) {
 	    (*cb->callback)((XIC)ic, cb->client_data, (XPointer)ev);
Index: xiiimp.so/iiimp/KeyMap.c
===================================================================
--- xiiimp.so/iiimp/KeyMap.c	(revision 2784)
+++ xiiimp.so/iiimp/KeyMap.c	(working copy)
@@ -1171,6 +1171,9 @@
     }
 
     pkev->modifier = state;
+    /* Set mask with 0x80000000 to indicate the event is key release event */
+    if (ev->type == KeyRelease)
+       pkev->modifier |= 0x80000000;
 
     len = XLookupString(ev, buf, len - 1, &keysym, NULL);
 
Index: xiiimp.so/ChangeLog
===================================================================
--- xiiimp.so/ChangeLog	(revision 2784)
+++ xiiimp.so/ChangeLog	(working copy)
@@ -1,3 +1,12 @@
+2005-07-27  Federic Zhang <[email protected]>
+
+	Add support for key release event.
+
+	* iiimp/iiimpIC.c (IIIMP_Local_KeyFilter): don't use ic->forward_event_callback
+	  to handle key release event, which should be forwarded with IMForwaredEvent to server.
+	* iiimp/KeyMap.c (XKeyEvent_To_IIIMCF_keyevent): mask pkev->modifier with
+	  0x80000000 for key release event which will be sent to server.
+
 2005-07-21  Makoto Fujiyoshi <[email protected]>
 
 	* iiimp/iiimpIM.c (get_IM_language): fix memory leak.
Index: htt_xbe/lib/IMdkit/r6im/R6IMProtocol.cpp
===================================================================
--- htt_xbe/lib/IMdkit/r6im/R6IMProtocol.cpp	(revision 2784)
+++ htt_xbe/lib/IMdkit/r6im/R6IMProtocol.cpp	(working copy)
@@ -208,8 +208,7 @@
     styles.supported_styles = &my_styles2[0];
   }
 
-  unsigned long filter_events = KeyPressMask;
-  // unsigned long filter_events = KeyPressMask | KeyReleaseMask;
+  unsigned long filter_events = KeyPressMask | KeyReleaseMask;
 
   int n = 0;
   args[n].name = (char*)IMServerName; args[n].value = im_name; n++;
@@ -333,6 +332,13 @@
       else if (!strcmp(icp->name, XNFilterEvents)) {
 	icp->value = new CARD32;
 	ic->get_fwin_select_mask((*(CARD32*)icp->value));
+
+	/* This hack is to let gtk+ based client to filter key release event to
+	 * the XIM server (gnome bugzilla #81759)
+	 */
+	if (!(*(CARD32*)icp->value & KeyReleaseMask))
+	  *(CARD32*)icp->value |= KeyReleaseMask;
+
 	icp->value_length = sizeof(CARD32);
       }
       else if (!strcmp(icp->name, XNPreeditState)) {
Index: htt_xbe/lib/ChangeLog
===================================================================
--- htt_xbe/lib/ChangeLog	(revision 2784)
+++ htt_xbe/lib/ChangeLog	(working copy)
@@ -1,3 +1,13 @@
+2005-07-26  Federic Zhang  <[email protected]>
+
+	Add support for key release event.
+
+	* IMdkit/r6im/R6IMProtocol.cpp
+	  (R6IMProtocol::run): add KeyReleaseMask into IMFilterEventMask.
+	  (GetICValues): when client calls XGetICValues to get the value of XNFilterEvents,
+	  set the KeyReleaseMask for GTK+ based client to filter key release event to server
+	  see (gnome bugzill #81759)
+
 2005-04-21  Jens Petersen  <[email protected]>
 
 	* IMdkit/common/Xfactory.cpp (XFactory::create_fontset): Use