GNU bug report logs - #9977
[PATCH] Fix focus handling when using emacsclient --parent-id

Previous Next

Package: emacs;

Reported by: David Benjamin <davidben <at> MIT.EDU>

Date: Sun, 6 Nov 2011 22:16:01 UTC

Severity: normal

Tags: patch

Done: Chong Yidong <cyd <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 9977 in the body.
You can then email your comments to 9977 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#9977; Package emacs. (Sun, 06 Nov 2011 22:16:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to David Benjamin <davidben <at> MIT.EDU>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 06 Nov 2011 22:16:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: David Benjamin <davidben <at> MIT.EDU>
To: bug-gnu-emacs <at> gnu.org
Cc: David Benjamin <davidben <at> mit.edu>
Subject: [PATCH] Fix focus handling when using emacsclient --parent-id
Date: Sun,  6 Nov 2011 16:50:11 -0500
Using emacsclient --parent-id causes emacs to call XSetInputFocus which
interferes with XEmbed (normally the embedder forwards key events). On
my system, it also interferes with compiz.

* xterm.h: Add x_embed_request_focus.

* xterm.c (x_embed_request_focus): New function to request focus
via XEmbed.

* xfns.c (Fx_focus_frame): If the frame is embedded, request focus
via XEmbed instead of using XSetInputFocus and _NET_ACTIVE_WINDOW.
---

This is a fairly small change I think, but it is also more than 15 lines, so if
you need a copyright form, send one my way.

 src/ChangeLog |   10 ++++++++++
 src/xfns.c    |   13 ++++++++++---
 src/xterm.c   |   13 +++++++++++++
 src/xterm.h   |    1 +
 4 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 8f56286..ec14669 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,13 @@
+2011-11-06  David Benjamin  <davidben <at> mit.edu>
+
+	* xterm.h: Add x_embed_request_focus.
+
+	* xterm.c (x_embed_request_focus): New function to request focus
+	via XEmbed.
+
+	* xfns.c (Fx_focus_frame): If the frame is embedded, request focus
+	via XEmbed instead of using XSetInputFocus and _NET_ACTIVE_WINDOW.
+
 2011-11-06  Chong Yidong  <cyd <at> gnu.org>
 
 	* window.c (Fwindow_live_p, Fwindow_frame, Fframe_root_window)
diff --git a/src/xfns.c b/src/xfns.c
index 49c4c77..200ba49 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -3519,9 +3519,16 @@ FRAME nil means use the selected frame.  */)
 
   BLOCK_INPUT;
   x_catch_errors (dpy);
-  XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-		  RevertToParent, CurrentTime);
-  x_ewmh_activate_frame (f);
+  if (FRAME_X_EMBEDDED_P (f))
+    {
+      x_embed_request_focus (f);
+    }
+  else
+    {
+      XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
+		      RevertToParent, CurrentTime);
+      x_ewmh_activate_frame (f);
+    }
   x_uncatch_errors ();
   UNBLOCK_INPUT;
 
diff --git a/src/xterm.c b/src/xterm.c
index fb77faa..cf2c6ca 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -8978,6 +8978,19 @@ x_lower_frame (struct frame *f)
     }
 }
 
+/* Request focus with XEmbed */
+
+void
+x_embed_request_focus (FRAME_PTR f)
+{
+  /* See XEmbed Protocol Specification at
+     http://freedesktop.org/wiki/Specifications/xembed-spec  */
+
+  if (f->async_visible)
+    xembed_send_message (f, CurrentTime,
+			 XEMBED_REQUEST_FOCUS, 0, 0, 0);
+}
+
 /* Activate frame with Extended Window Manager Hints */
 
 void
diff --git a/src/xterm.h b/src/xterm.h
index e10a6bc..50ed5e1 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -964,6 +964,7 @@ extern void x_clear_errors (Display *);
 extern void x_set_window_size (struct frame *, int, int, int);
 extern void x_set_mouse_position (struct frame *, int, int);
 extern void x_set_mouse_pixel_position (struct frame *, int, int);
+extern void x_embed_request_focus (struct frame *);
 extern void x_ewmh_activate_frame (struct frame *);
 extern void x_make_frame_visible (struct frame *);
 extern void x_make_frame_invisible (struct frame *);
-- 
1.7.8.rc0.36.g1d443





Reply sent to Chong Yidong <cyd <at> gnu.org>:
You have taken responsibility. (Sat, 07 Jan 2012 07:04:02 GMT) Full text and rfc822 format available.

Notification sent to David Benjamin <davidben <at> MIT.EDU>:
bug acknowledged by developer. (Sat, 07 Jan 2012 07:04:02 GMT) Full text and rfc822 format available.

Message #10 received at 9977-done <at> debbugs.gnu.org (full text, mbox):

From: Chong Yidong <cyd <at> gnu.org>
To: David Benjamin <davidben <at> MIT.EDU>
Cc: 9977-done <at> debbugs.gnu.org
Subject: Re: [PATCH] Fix focus handling when using emacsclient --parent-id
Date: Sat, 07 Jan 2012 15:03:02 +0800
> Using emacsclient --parent-id causes emacs to call XSetInputFocus
> which interferes with XEmbed (normally the embedder forwards key
> events). On my system, it also interferes with compiz.

Thanks, looks good.  I've committed it to trunk.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 04 Feb 2012 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 105 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.