[uim-commit] r3147 - in trunk: doc scm uim

yamaken at freedesktop.org yamaken at freedesktop.org
Tue Feb 28 16:23:59 PST 2006


Author: yamaken
Date: 2006-02-28 16:23:56 -0800 (Tue, 28 Feb 2006)
New Revision: 3147

Modified:
   trunk/doc/COMPATIBILITY
   trunk/scm/im-switcher.scm
   trunk/uim/libtool-version.mk
   trunk/uim/uim-func.c
   trunk/uim/uim-internal.h
   trunk/uim/uim.c
   trunk/uim/uim.h
Log:
* This commit add new optional uim API callback functions. Bridge
  developers, please support them.

* uim/uim.h
  - (uim_set_im_switch_request_cb): New function decl
* uim/uim-internal.h
  - (struct uim_context_): Add member 'switch_app_global_im_cb' and
    'switch_system_global_im_cb'
* uim/uim-func.c
  - (switch_app_global_im, switch_system_global_im): New static function
  - (uim_init_im_subrs): Add initialization for
    im-switch-app-global-im and im-switch-system-global-im
* uim/uim.c
  - (uim_create_context): Add initialization for the new members
  - (uim_set_im_switch_request_cb): New function
* uim/libtool-version.mk
  - (libuim_version): Increment to 2:0:1
* scm/im-switcher.scm
  - (imsw-propagation): New variable
  - (imsw-actions): Support the callbacks
* doc/COMPATIBILITY
  - Add new section "Context-originated IM switching of other contexts"


Modified: trunk/doc/COMPATIBILITY
===================================================================
--- trunk/doc/COMPATIBILITY	2006-02-28 18:44:21 UTC (rev 3146)
+++ trunk/doc/COMPATIBILITY	2006-03-01 00:23:56 UTC (rev 3147)
@@ -57,6 +57,24 @@
 
 The changes are described below in most recently updated order.
 ------------------------------------------------------------------------------
+Summary: Context-originated IM switching of other contexts
+Affects: Bridge developers
+Updates: C API
+Version: 1.1.0
+Revision: ac3147
+Date: 2006-02-24
+Modifier: YamaKen
+Related: action-based IM switcher
+URL:
+Changes:
+  (new) uim_set_im_switch_request_cb()
+  (new) im-switch-app-global-im
+  (new) im-switch-system-global-im
+Description:
+  These APIs are used for IM switching of specific set of contexts other than
+  currently focused context. It ordinarily issued in response to
+  action_imsw_*, and can be used for switching by keystroke.
+------------------------------------------------------------------------------
 Summary: Obsolete prop_label handlings
 Affects: Helper program developers, Bridge developers
 Updates: Helper protocol, Scheme API

Modified: trunk/scm/im-switcher.scm
===================================================================
--- trunk/scm/im-switcher.scm	2006-02-28 18:44:21 UTC (rev 3146)
+++ trunk/scm/im-switcher.scm	2006-03-01 00:23:56 UTC (rev 3147)
@@ -39,6 +39,11 @@
 (require "i18n.scm")
 (require "load-action.scm")
 
+;; FIXME: make customizable
+(define imsw-propagation 'focused-context)
+;;(define imsw-propagation 'app-global)
+;;(define imsw-propagation 'system-global)
+
 (define imsw-indication-id-alist
   '())
 
@@ -85,20 +90,28 @@
 				      idname))
 
 			       (lambda (ctx) ;; action handler
-				 (uim-switch-im (context-id ctx) idname)
-				 ;; FIXME: Switch IM of all contexts to the
-				 ;; idname. It should be performed by each
-				 ;; bridges via new callback, since some IM
-				 ;; environments do not have the concept 'all
-				 ;; context' (i.e. single-context system).
-				 ;;
-				 ;; FIXME: im-change-whole-desktop should not
-				 ;; be called directly.
-				 ;; 'im-switch-system-global-im' is
-				 ;; appropriate?
-				 ;;
-				 ;; (im-change-whole-desktop idname)
-				 ))
+				 (let ((cid (context-id ctx)))
+				   (uim-switch-im cid idname)
+				   (case imsw-propagation
+				     ((focused-context)
+				      #t)
+
+				     ((app-global)
+				      ;; Performed by each bridges via the
+				      ;; callback, since the concept
+				      ;; "application global" is differently
+				      ;; mapped to a set of input context for
+				      ;; each IM environment. (i.e. an
+				      ;; application may not have dedicated
+				      ;; process)
+				      (im-switch-app-global-im cid idname))
+
+				     ((system-global)
+				      ;; Performed by each bridges via the
+				      ;; callback, since some IM environments
+				      ;; do not have the concept "all context"
+				      ;; (i.e. single-context system).
+				      (im-switch-system-global-im cid idname))))))
 	      act-name))
 	  im-list))))
 

Modified: trunk/uim/libtool-version.mk
===================================================================
--- trunk/uim/libtool-version.mk	2006-02-28 18:44:21 UTC (rev 3146)
+++ trunk/uim/libtool-version.mk	2006-03-01 00:23:56 UTC (rev 3147)
@@ -1,5 +1,5 @@
 # The versions consists of CURRENT:REVISION:AGE to indicate ABI information.
 # See "Versioning" section of info of libtool for each meaning.
 
-libuim_version = 1:1:1
+libuim_version = 2:0:1
 libuim_custom_version = 2:0:0

Modified: trunk/uim/uim-func.c
===================================================================
--- trunk/uim/uim-func.c	2006-02-28 18:44:21 UTC (rev 3146)
+++ trunk/uim/uim-func.c	2006-03-01 00:23:56 UTC (rev 3147)
@@ -714,6 +714,37 @@
   return uim_scm_t();
 }
 
+static uim_lisp
+switch_app_global_im(uim_lisp id_, uim_lisp name_)
+{
+  uim_context uc;
+  int id;
+  const char *name;
+
+  uc = uim_find_context(uim_scm_c_int(id_));
+  name = uim_scm_refer_c_str(name_);
+
+  if (uc->switch_app_global_im_cb)
+    uc->switch_app_global_im_cb(uc->ptr, name);
+
+  return uim_scm_t();
+}
+
+static uim_lisp
+switch_system_global_im(uim_lisp id_, uim_lisp name_)
+{
+  uim_context uc;
+  const char *name;
+
+  uc = uim_find_context(uim_scm_c_int(id_));
+  name = uim_scm_refer_c_str(name_);
+
+  if (uc->switch_system_global_im_cb)
+    uc->switch_system_global_im_cb(uc->ptr, name);
+
+  return uim_scm_t();
+}
+
 void
 uim_init_im_subrs(void)
 {
@@ -749,4 +780,7 @@
   uim_scm_init_subr_3("im-delete-surrounding", im_delete_surrounding);
   /**/
   uim_scm_init_subr_2("uim-switch-im", switch_im); /* FIXME: This function name would not be appropriate. */
+  
+  uim_scm_init_subr_2("im-switch-app-global-im", switch_app_global_im);
+  uim_scm_init_subr_2("im-switch-system-global-im", switch_system_global_im);
 }

Modified: trunk/uim/uim-internal.h
===================================================================
--- trunk/uim/uim-internal.h	2006-02-28 18:44:21 UTC (rev 3146)
+++ trunk/uim/uim-internal.h	2006-03-01 00:23:56 UTC (rev 3147)
@@ -113,6 +113,9 @@
   int (*delete_surrounding_text_cb)(void *ptr, int offset, int len);
   /* configuration changed */
   void (*configuration_changed_cb)(void *ptr);
+  /* switch IM */
+  void (*switch_app_global_im_cb)(void *ptr, const char *name);
+  void (*switch_system_global_im_cb)(void *ptr, const char *name);
   /* preedit segments array */
   struct preedit_segment *psegs;
   int nr_psegs;

Modified: trunk/uim/uim.c
===================================================================
--- trunk/uim/uim.c	2006-02-28 18:44:21 UTC (rev 3146)
+++ trunk/uim/uim.c	2006-03-01 00:23:56 UTC (rev 3147)
@@ -162,6 +162,9 @@
   /**/
   uc->configuration_changed_cb = NULL;
   /**/
+  uc->switch_app_global_im_cb = NULL;
+  uc->switch_system_global_im_cb = NULL;
+  /**/
   uc->nr_candidates = 0;
   uc->candidate_index = 0;
   /**/
@@ -212,6 +215,15 @@
 }
 
 void
+uim_set_im_switch_request_cb(uim_context uc,
+			     void (*sw_app_im_cb)(void *ptr, const char *name),
+			     void (*sw_system_im_cb)(void *ptr, const char *name))
+{
+  uc->switch_app_global_im_cb = sw_app_im_cb;
+  uc->switch_system_global_im_cb = sw_system_im_cb;
+}
+
+void
 uim_switch_im(uim_context uc, const char *engine)
 {
   /* related to the commit log of r1400:

Modified: trunk/uim/uim.h
===================================================================
--- trunk/uim/uim.h	2006-02-28 18:44:21 UTC (rev 3146)
+++ trunk/uim/uim.h	2006-03-01 00:23:56 UTC (rev 3147)
@@ -557,6 +557,37 @@
 uim_set_configuration_changed_cb(uim_context uc,
 				 void (*changed_cb)(void *ptr));
 
+/*
+ * Set callback functions called when IM-switching of specific set of context
+ * is requested.
+ *
+ * When the functions are called back, bridges should re-initialize the
+ * specified input contexts with the IM specified by 2nd argument
+ * 'name'. Since the re-initialization method of specified contexts vary for
+ * each IM environment, it is delegated to bridges via the callback. For
+ * example, ordinary desktop system should send the helper message
+ * im_change_whole_desktop in response to @a sw_system_im_cb. But in embedded
+ * systems such as Qtopia, nothing to do with @a sw_system_im_cb since only
+ * one input context is running on the window system and so system-global.
+ *
+ * @param uc input context
+
+ * @param sw_app_im_cb called when re-initialization of all contexts within
+ *        the application that @a uc belongs to, with specified IM is
+ *        requested. 1st argument "ptr" corresponds to the 1st argument of
+ *        uim_create_context, and 2nd "name" is requested idname of IM. The
+ *        originating context is supposed to already be switched, and must not
+ *        switched by the callback.
+ * @param sw_system_im_cb called when re-initialization of all contexts
+ *        running on the system that @a uc is running on, with specified IM is
+ *        requested. The originating context is supposed to already be
+ *        switched.
+ */
+void
+uim_set_im_switch_request_cb(uim_context uc,
+			     void (*sw_app_im_cb)(void *ptr, const char *name),
+			     void (*sw_system_im_cb)(void *ptr, const char *name));
+
 /* Utility functions */
 int
 uim_ipc_open_command(int old_pid, FILE **read_handler, FILE **write_handler, const char *command);



More information about the uim-commit mailing list