Trust WM_TAKE_FOCUS but handle exceptions

This commit is contained in:
Bastien Dejean 2015-11-07 10:49:33 +01:00
parent 09b6d1bbe5
commit 36f740f98b
3 changed files with 11 additions and 3 deletions

3
tree.c
View file

@ -422,8 +422,9 @@ client_t *make_client(xcb_window_t win, unsigned int border_width)
c->locked = c->sticky = c->urgent = c->private = c->icccm_focus = false;
xcb_icccm_get_wm_protocols_reply_t protocols;
if (xcb_icccm_get_wm_protocols_reply(dpy, xcb_icccm_get_wm_protocols(dpy, win, ewmh->WM_PROTOCOLS), &protocols, NULL) == 1) {
if (has_proto(WM_TAKE_FOCUS, &protocols))
if (has_proto(WM_TAKE_FOCUS, &protocols)) {
c->icccm_focus = true;
}
xcb_icccm_get_wm_protocols_reply_wipe(&protocols);
}
c->num_states = 0;

View file

@ -840,9 +840,11 @@ void set_input_focus(node_t *n)
if (n == NULL) {
clear_input_focus();
} else {
if (n->client->icccm_focus)
if (n->client->icccm_focus && strstr(ICCCM_FOCUS_EXCEPTIONS, n->client->class_name) == NULL) {
send_client_message(n->client->window, ewmh->WM_PROTOCOLS, WM_TAKE_FOCUS);
xcb_set_input_focus(dpy, XCB_INPUT_FOCUS_POINTER_ROOT, n->client->window, XCB_CURRENT_TIME);
} else {
xcb_set_input_focus(dpy, XCB_INPUT_FOCUS_POINTER_ROOT, n->client->window, XCB_CURRENT_TIME);
}
}
}

View file

@ -25,6 +25,11 @@
#ifndef BSPWM_WINDOW_H
#define BSPWM_WINDOW_H
/* A comma separated list of class names of programs that include the WM_FOCUS
* atom in their WM_PROTOCOLS property but don't handle the corresponding
* client message */
#define ICCCM_FOCUS_EXCEPTIONS "Skype"
#include <stdarg.h>
#include <xcb/xcb.h>
#include <xcb/xcb_event.h>