[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master a42df6542a: Fix toggling `x-gtk-use-native-input'.
From: |
Po Lu |
Subject: |
master a42df6542a: Fix toggling `x-gtk-use-native-input'. |
Date: |
Fri, 4 Feb 2022 00:14:05 -0500 (EST) |
branch: master
commit a42df6542ac8b66d7a05c2746b2045d1e7df252b
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Fix toggling `x-gtk-use-native-input'.
* lisp/term/x-win.el (x-internal-focus-input-context):
(x-gtk-use-native-input-watcher): Update for changes to
`x-internal-focus-input-context'.
* src/xfns.c (Fx_internal_focus_input_context): New parameter
`focus'.
---
lisp/term/x-win.el | 5 ++---
src/xfns.c | 20 +++++++++++++++-----
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/lisp/term/x-win.el b/lisp/term/x-win.el
index 80a7d81d08..298c23566e 100644
--- a/lisp/term/x-win.el
+++ b/lisp/term/x-win.el
@@ -1563,16 +1563,15 @@ EVENT is a preedit-text event."
(defvaralias 'x-gtk-use-system-tooltips 'use-system-tooltips)
-(declare-function x-internal-focus-input-context (frame) "xfns.c")
+(declare-function x-internal-focus-input-context (focus frame) "xfns.c")
(defun x-gtk-use-native-input-watcher (_symbol newval &rest _ignored)
"Variable watcher for `x-gtk-use-native-input'.
If NEWVAL is non-nil and the selected frame is displayed through X,
focus the GTK input context."
(when (and (featurep 'gtk)
- newval
(eq (framep (selected-frame)) 'x))
- (x-internal-focus-input-context (selected-frame))))
+ (x-internal-focus-input-context newval (selected-frame))))
(add-variable-watcher 'x-gtk-use-native-input
#'x-gtk-use-native-input-watcher)
diff --git a/src/xfns.c b/src/xfns.c
index deaf4204a9..4b10f5035a 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -8567,18 +8567,28 @@ DEFUN ("x-gtk-debug", Fx_gtk_debug, Sx_gtk_debug, 1, 1,
0,
#endif /* USE_GTK */
DEFUN ("x-internal-focus-input-context", Fx_internal_focus_input_context,
- Sx_internal_focus_input_context, 1, 1, 0,
+ Sx_internal_focus_input_context, 2, 2, 0,
doc: /* Focus and set the client window of FRAME's GTK input context.
+If FOCUS is nil, focus out and remove the client window instead.
This should be called from a variable watcher for `x-gtk-use-native-input'.
*/)
- (Lisp_Object frame)
+ (Lisp_Object focus, Lisp_Object frame)
{
#ifdef USE_GTK
struct frame *f = decode_window_system_frame (frame);
GtkWidget *widget = FRAME_GTK_OUTER_WIDGET (f);
- gtk_im_context_focus_in (FRAME_X_OUTPUT (f)->im_context);
- gtk_im_context_set_client_window (FRAME_X_OUTPUT (f)->im_context,
- gtk_widget_get_window (widget));
+ if (!NILP (focus))
+ {
+ gtk_im_context_focus_in (FRAME_X_OUTPUT (f)->im_context);
+ gtk_im_context_set_client_window (FRAME_X_OUTPUT (f)->im_context,
+ gtk_widget_get_window (widget));
+ }
+ else
+ {
+ gtk_im_context_focus_out (FRAME_X_OUTPUT (f)->im_context);
+ gtk_im_context_set_client_window (FRAME_X_OUTPUT (f)->im_context,
+ NULL);
+ }
#endif
return Qnil;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master a42df6542a: Fix toggling `x-gtk-use-native-input'.,
Po Lu <=