Fixes #454.
{
focus_monitor(m);
+ if (focus_follows_pointer) {
+ listen_enter_notify(d->root, false);
+ }
+
show_desktop(d);
if (m->desk != d) {
hide_desktop(m->desk);
}
+ if (focus_follows_pointer) {
+ listen_enter_notify(d->root, true);
+ }
+
m->desk = d;
ewmh_update_current_desktop();
c->floating_rectangle.height = height;
xcb_rectangle_t r = c->floating_rectangle;
+ if (focus_follows_pointer) {
+ listen_enter_notify(loc.desktop->root, false);
+ }
+
window_move_resize(e->window, r.x, r.y, r.width, r.height);
+ if (focus_follows_pointer) {
+ listen_enter_notify(loc.desktop->root, true);
+ }
+
put_status(SBSC_MASK_NODE_GEOMETRY, "node_geometry 0x%08X 0x%08X 0x%08X %ux%u+%i+%i\n", loc.monitor->id, loc.desktop->id, e->window, r.width, r.height, r.x, r.y);
monitor_t *m = monitor_from_client(c);
xcb_enter_notify_event_t *e = (xcb_enter_notify_event_t *) evt;
xcb_window_t win = e->event;
- if (e->mode != XCB_NOTIFY_MODE_NORMAL) {
+ if (e->mode != XCB_NOTIFY_MODE_NORMAL || e->detail == XCB_NOTIFY_DETAIL_INFERIOR) {
+ return;
+ }
+
+ xcb_point_t pt = {e->root_x, e->root_y};
+ monitor_t *m = monitor_from_point(pt);
+
+ if (m == NULL) {
return;
}
- coordinates_t loc;
bool pff = pointer_follows_focus;
bool pfm = pointer_follows_monitor;
pointer_follows_focus = false;
pointer_follows_monitor = false;
auto_raise = false;
- if (locate_window(win, &loc)) {
- if (loc.monitor->desk == loc.desktop && loc.node != mon->desk->focus) {
- focus_node(loc.monitor, loc.desktop, loc.node);
+ desktop_t *d = m->desk;
+ node_t *n = NULL;
+
+ for (n = first_extrema(d->root); n != NULL; n = next_leaf(n, d->root)) {
+ if (n->id == win || (n->presel != NULL && n->presel->feedback == win)) {
+ break;
}
- } else {
- xcb_point_t pt = {e->root_x, e->root_y};
- monitor_t *m = monitor_from_point(pt);
- if (m != NULL && m != mon) {
+ }
+
+ if (n != mon->desk->focus) {
+ if (n != NULL) {
+ focus_node(m, d, n);
+ } else if (m != mon) {
focus_node(m, m->desk, m->desk->focus);
}
}
return;
}
focus_follows_pointer = b;
- uint32_t values[] = {CLIENT_EVENT_MASK | (focus_follows_pointer ? XCB_EVENT_MASK_ENTER_WINDOW : 0)};
for (monitor_t *m = mon_head; m != NULL; m = m->next) {
- for (desktop_t *d = m->desk_head; d != NULL; d = d->next) {
- for (node_t *n = first_extrema(d->root); n != NULL; n = next_leaf(n, d->root)) {
- if (n->client == NULL) {
- continue;
- }
- xcb_change_window_attributes(dpy, n->id, XCB_CW_EVENT_MASK, values);
- }
- }
- }
- if (focus_follows_pointer) {
- for (monitor_t *m = mon_head; m != NULL; m = m->next) {
+ if (b) {
window_show(m->root);
- }
- } else {
- for (monitor_t *m = mon_head; m != NULL; m = m->next) {
+ } else {
window_hide(m->root);
}
+ for (desktop_t *d = m->desk_head; d != NULL; d = d->next) {
+ listen_enter_notify(d->root, b);
+ }
}
return;
} else {
rect.height -= d->window_gap;
}
+ if (focus_follows_pointer) {
+ listen_enter_notify(d->root, false);
+ }
+
apply_layout(m, d, d->root, rect, rect);
+ if (focus_follows_pointer) {
+ listen_enter_notify(d->root, true);
+ }
+
d->layout = last_layout;
}
return;
}
+
+ if (focus_follows_pointer) {
+ listen_enter_notify(d->root, false);
+ }
+
bool held_focus = is_descendant(d->focus, n);
propagate_hidden_downward(m, d, n, value);
activate_node(m, d, d->focus);
}
}
+
+ if (focus_follows_pointer) {
+ listen_enter_notify(d->root, true);
+ }
}
void set_hidden_local(monitor_t *m, desktop_t *d, node_t *n, bool value)
}
}
+void listen_enter_notify(node_t *n, bool enable)
+{
+ uint32_t mask = CLIENT_EVENT_MASK | (enable ? XCB_EVENT_MASK_ENTER_WINDOW : 0);
+ for (node_t *f = first_extrema(n); f != NULL; f = next_leaf(f, n)) {
+ if (f->client == NULL) {
+ continue;
+ }
+ xcb_change_window_attributes(dpy, f->id, XCB_CW_EVENT_MASK, &mask);
+ if (f->presel != NULL) {
+ xcb_change_window_attributes(dpy, f->presel->feedback, XCB_CW_EVENT_MASK, &mask);
+ }
+ }
+}
+
#define DEF_FLAG_COUNT(flag) \
unsigned int flag##_count(node_t *n) \
{ \
bool contains(xcb_rectangle_t a, xcb_rectangle_t b);
xcb_rectangle_t get_rectangle(desktop_t *d, node_t *n);
void get_side_handle(desktop_t *d, node_t *n, direction_t dir, xcb_point_t *pt);
+void listen_enter_notify(node_t *n, bool enable);
unsigned int sticky_count(node_t *n);
unsigned int private_count(node_t *n);
}
xcb_window_t win = xcb_generate_id(dpy);
- uint32_t mask = XCB_CW_BACK_PIXEL | XCB_CW_SAVE_UNDER;
- uint32_t values[] = {get_color_pixel(presel_feedback_color), 1};
+ uint32_t mask = XCB_CW_BACK_PIXEL | XCB_CW_SAVE_UNDER | XCB_CW_EVENT_MASK;
+ uint32_t values[] = {get_color_pixel(presel_feedback_color), 1, XCB_EVENT_MASK_ENTER_WINDOW};
xcb_create_window(dpy, XCB_COPY_FROM_PARENT, win, root, 0, 0, 1, 1, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT,
XCB_COPY_FROM_PARENT, mask, values);
xcb_rectangle_t rect = c->floating_rectangle;
int16_t x = rect.x + dx;
int16_t y = rect.y + dy;
+
+ if (focus_follows_pointer) {
+ listen_enter_notify(loc->desktop->root, false);
+ }
+
window_move(n->id, x, y);
+
+ if (focus_follows_pointer) {
+ listen_enter_notify(loc->desktop->root, true);
+ }
+
c->floating_rectangle.x = x;
c->floating_rectangle.y = y;
if (!grabbing) {
}
n->client->floating_rectangle = (xcb_rectangle_t) {x, y, width, height};
if (n->client->state == STATE_FLOATING) {
+ if (focus_follows_pointer) {
+ listen_enter_notify(loc->desktop->root, false);
+ }
+
window_move_resize(n->id, x, y, width, height);
+
+ if (focus_follows_pointer) {
+ listen_enter_notify(loc->desktop->root, true);
+ }
+
if (!grabbing) {
put_status(SBSC_MASK_NODE_GEOMETRY, "node_geometry 0x%08X 0x%08X 0x%08X %ux%u+%i+%i\n", loc->monitor->id, loc->desktop->id, loc->node->id, width, height, x, y);
}