summaryrefslogtreecommitdiff
path: root/src/pgtkim.c
diff options
context:
space:
mode:
authorYuuki Harano <masm+github@masm11.me>2020-08-22 19:17:04 +0900
committerJeff Walsh <jeff.walsh@drtusers-MacBook-Pro.local>2020-11-24 12:24:40 +1100
commit9704e23f4c2cd56bc8091e2024c7b972a3254bb7 (patch)
treed950041d2c5244ba1910b46803fb2cb0e0b89653 /src/pgtkim.c
parent6df8556ab71ef8ae38e52d770d56510da65a614e (diff)
downloademacs-9704e23f4c2cd56bc8091e2024c7b972a3254bb7.tar.gz
emacs-9704e23f4c2cd56bc8091e2024c7b972a3254bb7.tar.bz2
emacs-9704e23f4c2cd56bc8091e2024c7b972a3254bb7.zip
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.
Diffstat (limited to 'src/pgtkim.c')
-rw-r--r--src/pgtkim.c54
1 files changed, 34 insertions, 20 deletions
diff --git a/src/pgtkim.c b/src/pgtkim.c
index 15088bc64d4..0ec931c4b1c 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;
}