emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/pgtk 9704e23 081/100: Enable GtkIMContext by default


From: Yuuki Harano
Subject: feature/pgtk 9704e23 081/100: Enable GtkIMContext by default
Date: Tue, 24 Nov 2020 08:02:42 -0500 (EST)

branch: feature/pgtk
commit 9704e23f4c2cd56bc8091e2024c7b972a3254bb7
Author: Yuuki Harano <masm+github@masm11.me>
Commit: Jeff Walsh <jeff.walsh@drtusers-MacBook-Pro.local>

    Enable GtkIMContext by default
    
    * lisp/term/pgtk-win.el: Call pgtk-use-im-context after init.
    
    * src/pgtkim.c (pgtk_im_use_context): New function.
    (pgtk_im_init): Call pgtk_im_use_context.
    (Fpgtk_use_im_context): Call pgtk_im_use_context.
    (syms_of_pgtkim): New variable Vpgtk_use_im_context_on_new_connection.
---
 lisp/term/pgtk-win.el |  8 ++++++++
 src/pgtkim.c          | 54 ++++++++++++++++++++++++++++++++-------------------
 2 files changed, 42 insertions(+), 20 deletions(-)

diff --git a/lisp/term/pgtk-win.el b/lisp/term/pgtk-win.el
index 4598ba0..a41d3a3 100644
--- a/lisp/term/pgtk-win.el
+++ b/lisp/term/pgtk-win.el
@@ -398,6 +398,14 @@ See the documentation of 
`create-fontset-from-fontset-spec' for the format.")
     (overlay-put ov 'before-string ovstr)
     (setq pgtk-preedit-overlay ov)))
 
+
+(add-hook 'after-init-hook
+          (function
+           (lambda ()
+             (when (eq window-system 'pgtk)
+               (pgtk-use-im-context pgtk-use-im-context-on-new-connection)))))
+
+
 (provide 'pgtk-win)
 (provide 'term/pgtk-win)
 
diff --git a/src/pgtkim.c b/src/pgtkim.c
index 15088bc..0ec931c 100644
--- a/src/pgtkim.c
+++ b/src/pgtkim.c
@@ -210,27 +210,10 @@ pgtk_im_filter_keypress (struct frame *f, GdkEventKey * 
ev)
   return false;
 }
 
-void
-pgtk_im_init (struct pgtk_display_info *dpyinfo)
-{
-  dpyinfo->im.context = NULL;
-}
-
-void
-pgtk_im_finish (struct pgtk_display_info *dpyinfo)
-{
-  if (dpyinfo->im.context != NULL)
-    g_object_unref (dpyinfo->im.context);
-  dpyinfo->im.context = NULL;
-}
-
-DEFUN ("pgtk-use-im-context", Fpgtk_use_im_context, Spgtk_use_im_context, 1, 
2, 0,
-       doc: /* Set whether use Gtk's im context. */)
-  (Lisp_Object use_p, Lisp_Object terminal)
+static void
+pgtk_im_use_context (struct pgtk_display_info *dpyinfo, bool use_p)
 {
-  struct pgtk_display_info *dpyinfo = check_pgtk_display_info (terminal);
-
-  if (NILP (use_p))
+  if (!use_p)
     {
       if (dpyinfo->im.context != NULL)
        {
@@ -269,6 +252,31 @@ DEFUN ("pgtk-use-im-context", Fpgtk_use_im_context, 
Spgtk_use_im_context, 1, 2,
            pgtk_im_focus_in (dpyinfo->im.focused_frame);
        }
     }
+}
+
+void
+pgtk_im_init (struct pgtk_display_info *dpyinfo)
+{
+  dpyinfo->im.context = NULL;
+
+  pgtk_im_use_context (dpyinfo, !NILP 
(Vpgtk_use_im_context_on_new_connection));
+}
+
+void
+pgtk_im_finish (struct pgtk_display_info *dpyinfo)
+{
+  if (dpyinfo->im.context != NULL)
+    g_object_unref (dpyinfo->im.context);
+  dpyinfo->im.context = NULL;
+}
+
+DEFUN ("pgtk-use-im-context", Fpgtk_use_im_context, Spgtk_use_im_context, 1, 
2, 0,
+       doc: /* Set whether to use GtkIMContext. */)
+  (Lisp_Object use_p, Lisp_Object terminal)
+{
+  struct pgtk_display_info *dpyinfo = check_pgtk_display_info (terminal);
+
+  pgtk_im_use_context (dpyinfo, !NILP (use_p));
 
   return Qnil;
 }
@@ -282,4 +290,10 @@ syms_of_pgtkim (void)
   DEFSYM (Qul, "ul");
   DEFSYM (Qfg, "fg");
   DEFSYM (Qbg, "bg");
+
+  DEFVAR_LISP ("pgtk-use-im-context-on-new-connection", 
Vpgtk_use_im_context_on_new_connection,
+              doc: /* Whether to use GtkIMContext on a new connection.
+If you want to change it after connection, use the `pgtk-use-im-context'
+function.  */ );
+  Vpgtk_use_im_context_on_new_connection = Qt;
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]