emacs-diffs
[Top][All Lists]
Advanced

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

master fd2252294b: Fix frame focus handling with native input


From: Po Lu
Subject: master fd2252294b: Fix frame focus handling with native input
Date: Wed, 16 Feb 2022 02:41:38 -0500 (EST)

branch: master
commit fd2252294b679b1e50ed1aedf4c1a076fbae60e3
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Fix frame focus handling with native input
    
    * lisp/term/x-win.el (x-gtk-use-native-input-watcher): Stop
    passing frame parameter  to `x-internal-focus-input-context'.
    * src/xfns.c (Fx_internal_focus_input_context): Focus all focus
    frames from all displays.
---
 lisp/term/x-win.el |  6 +++---
 src/xfns.c         | 43 ++++++++++++++++++++++++++++---------------
 2 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/lisp/term/x-win.el b/lisp/term/x-win.el
index 298c23566e..9ae238661e 100644
--- a/lisp/term/x-win.el
+++ b/lisp/term/x-win.el
@@ -1567,11 +1567,11 @@ EVENT is a preedit-text event."
 
 (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."
+If NEWVAL is non-nil, focus the GTK input context of focused
+frames on all displays."
   (when (and (featurep 'gtk)
              (eq (framep (selected-frame)) 'x))
-    (x-internal-focus-input-context newval (selected-frame))))
+    (x-internal-focus-input-context newval)))
 
 (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 f00b738908..0a8d18d918 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -8772,28 +8772,41 @@ 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, 2, 2, 0,
-       doc: /* Focus and set the client window of FRAME's GTK input context.
+       Sx_internal_focus_input_context, 1, 1, 0,
+       doc: /* Focus and set the client window of all focused frames' 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 focus, Lisp_Object frame)
+  (Lisp_Object focus)
 {
 #ifdef USE_GTK
-  struct frame *f = decode_window_system_frame (frame);
-  GtkWidget *widget = FRAME_GTK_OUTER_WIDGET (f);
+  struct x_display_info *dpyinfo;
+  struct frame *f;
+  GtkWidget *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
+  block_input ();
+  for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next)
     {
-      gtk_im_context_focus_out (FRAME_X_OUTPUT (f)->im_context);
-      gtk_im_context_set_client_window (FRAME_X_OUTPUT (f)->im_context,
-                                       NULL);
+      f = dpyinfo->x_focus_frame;
+
+      if (f)
+       {
+         widget = FRAME_GTK_OUTER_WIDGET (f);
+
+         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);
+           }
+       }
     }
+  unblock_input ();
 #endif
 
   return Qnil;



reply via email to

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