[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#9977: [PATCH] Fix focus handling when using emacsclient --parent-id
From: |
David Benjamin |
Subject: |
bug#9977: [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@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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bug#9977: [PATCH] Fix focus handling when using emacsclient --parent-id,
David Benjamin <=