unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#9977: [PATCH] Fix focus handling when using emacsclient --parent-id
@ 2011-11-06 21:50 David Benjamin
  2012-01-07  7:03 ` Chong Yidong
  0 siblings, 1 reply; 2+ messages in thread
From: David Benjamin @ 2011-11-06 21:50 UTC (permalink / raw)
  To: 9977; +Cc: David Benjamin

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@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@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






^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#9977: [PATCH] Fix focus handling when using emacsclient --parent-id
  2011-11-06 21:50 bug#9977: [PATCH] Fix focus handling when using emacsclient --parent-id David Benjamin
@ 2012-01-07  7:03 ` Chong Yidong
  0 siblings, 0 replies; 2+ messages in thread
From: Chong Yidong @ 2012-01-07  7:03 UTC (permalink / raw)
  To: David Benjamin; +Cc: 9977-done

> 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.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-01-07  7:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-06 21:50 bug#9977: [PATCH] Fix focus handling when using emacsclient --parent-id David Benjamin
2012-01-07  7:03 ` Chong Yidong

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).