summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOkan Demirmen <okan@cvs.openbsd.org>2013-11-01 14:07:20 +0000
committerOkan Demirmen <okan@cvs.openbsd.org>2013-11-01 14:07:20 +0000
commitbc17b9532d19e55d828fbd168a22043133d68868 (patch)
tree8e6d969d8895682735fb8c8742189c947b39c353
parentaa1540565e912aa8efee015254abb26aef4a3929 (diff)
re-add support for WM_TAKE_FOCUS, and additionally this time only call
XSetInputFocus() for clients that have the InputHint; latter fix discovered by Valery Masiutsin with a PoC patch - solves keyboard input focus loss for java apps.
-rw-r--r--app/cwm/calmwm.h3
-rw-r--r--app/cwm/client.c27
2 files changed, 20 insertions, 10 deletions
diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h
index 226c30744..baefe603b 100644
--- a/app/cwm/calmwm.h
+++ b/app/cwm/calmwm.h
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: calmwm.h,v 1.224 2013/10/25 19:46:16 okan Exp $
+ * $OpenBSD: calmwm.h,v 1.225 2013/11/01 14:07:19 okan Exp $
*/
#ifndef _CALMWM_H_
@@ -165,6 +165,7 @@ struct client_ctx {
#define CLIENT_FREEZE 0x0010
#define CLIENT_GROUP 0x0020
#define CLIENT_UNGROUP 0x0040
+#define CLIENT_INPUT 0x0080
#define CLIENT_HIGHLIGHT (CLIENT_GROUP | CLIENT_UNGROUP)
#define CLIENT_MAXFLAGS (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED)
diff --git a/app/cwm/client.c b/app/cwm/client.c
index b3a64fc4e..cc2ad3e95 100644
--- a/app/cwm/client.c
+++ b/app/cwm/client.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: client.c,v 1.142 2013/10/25 19:46:16 okan Exp $
+ * $OpenBSD: client.c,v 1.143 2013/11/01 14:07:19 okan Exp $
*/
#include <sys/param.h>
@@ -99,17 +99,22 @@ client_init(Window win, struct screen_ctx *sc, int mapped)
cc->geom.h = wattr.height;
cc->colormap = wattr.colormap;
+ if ((wmhints = XGetWMHints(X_Dpy, cc->win)) != NULL) {
+ if (wmhints->flags & InputHint) {
+ if (wmhints->input == 1)
+ cc->flags |= CLIENT_INPUT;
+ }
+ }
if (wattr.map_state != IsViewable) {
client_placecalc(cc);
client_move(cc);
- if ((wmhints = XGetWMHints(X_Dpy, cc->win)) != NULL) {
- if (wmhints->flags & StateHint) {
- cc->state = wmhints->initial_state;
- xu_set_wm_state(cc->win, cc->state);
- }
- XFree(wmhints);
+ if ((wmhints) && (wmhints->flags & StateHint)) {
+ cc->state = wmhints->initial_state;
+ xu_set_wm_state(cc->win, cc->state);
}
}
+ if (wmhints)
+ XFree(wmhints);
client_draw_border(cc);
if (xu_get_wm_state(cc->win, &state) < 0)
@@ -208,8 +213,12 @@ client_setactive(struct client_ctx *cc, int fg)
if (fg) {
XInstallColormap(X_Dpy, cc->colormap);
- XSetInputFocus(X_Dpy, cc->win,
- RevertToPointerRoot, CurrentTime);
+ if (cc->flags & CLIENT_INPUT) {
+ XSetInputFocus(X_Dpy, cc->win,
+ RevertToPointerRoot, CurrentTime);
+ }
+ if (cc->xproto & _WM_TAKE_FOCUS)
+ client_msg(cc, cwmh[WM_TAKE_FOCUS]);
conf_grab_mouse(cc->win);
/*
* If we're in the middle of alt-tabbing, don't change