mirror of https://github.com/yshui/picom.git
core: let's not do ancestry lookups
Always assume WM frames are direct children of the root window, and client windows are direct children of their respective frames. Also WM frames must have a one-to-one relationship with client windows. We already assume this in most places, but it's inconsistent. Let's make this assumption official. If something breaks we can then figure out a principled way of dealing with that. Instead of having things "happen to work" which is the situation now. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
21777fce05
commit
54fb0c7ac0
|
@ -402,12 +402,12 @@ static inline void ev_reparent_notify(session_t *ps, xcb_reparent_notify_event_t
|
||||||
ev->window);
|
ev->window);
|
||||||
evmask |= XCB_EVENT_MASK_PROPERTY_CHANGE;
|
evmask |= XCB_EVENT_MASK_PROPERTY_CHANGE;
|
||||||
} else {
|
} else {
|
||||||
auto w_real_top = find_managed_window_or_parent(ps, ev->parent);
|
auto w = find_managed_win(ps, ev->parent);
|
||||||
if (w_real_top) {
|
if (w) {
|
||||||
log_debug("Mark window %#010x (%s) as having a stale "
|
log_debug("Mark window %#010x (%s) as having a stale "
|
||||||
"client",
|
"client",
|
||||||
w_real_top->base.id, w_real_top->name);
|
w->base.id, w->name);
|
||||||
win_set_flags(w_real_top, WIN_FLAGS_CLIENT_STALE);
|
win_set_flags(w, WIN_FLAGS_CLIENT_STALE);
|
||||||
ps->pending_updates = true;
|
ps->pending_updates = true;
|
||||||
} else {
|
} else {
|
||||||
log_debug("parent %#010x not found", ev->parent);
|
log_debug("parent %#010x not found", ev->parent);
|
||||||
|
|
24
src/picom.c
24
src/picom.c
|
@ -146,26 +146,6 @@ static inline int64_t get_time_ms(void) {
|
||||||
return (int64_t)tp.tv_sec * 1000 + (int64_t)tp.tv_nsec / 1000000;
|
return (int64_t)tp.tv_sec * 1000 + (int64_t)tp.tv_nsec / 1000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Find matched window.
|
|
||||||
*
|
|
||||||
* XXX move to win.c
|
|
||||||
*/
|
|
||||||
static inline struct managed_win *find_win_all(session_t *ps, const xcb_window_t wid) {
|
|
||||||
if (!wid || PointerRoot == wid || wid == ps->c.screen_info->root || wid == ps->overlay) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto w = find_managed_win(ps, wid);
|
|
||||||
if (!w) {
|
|
||||||
w = find_toplevel(ps, wid);
|
|
||||||
}
|
|
||||||
if (!w) {
|
|
||||||
w = find_managed_window_or_parent(ps, wid);
|
|
||||||
}
|
|
||||||
return w;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum vblank_callback_action check_render_finish(struct vblank_event *e attr_unused, void *ud) {
|
enum vblank_callback_action check_render_finish(struct vblank_event *e attr_unused, void *ud) {
|
||||||
auto ps = (session_t *)ud;
|
auto ps = (session_t *)ud;
|
||||||
if (!ps->backend_busy) {
|
if (!ps->backend_busy) {
|
||||||
|
@ -556,7 +536,7 @@ void update_ewmh_active_win(session_t *ps) {
|
||||||
// Search for the window
|
// Search for the window
|
||||||
xcb_window_t wid = wid_get_prop_window(&ps->c, ps->c.screen_info->root,
|
xcb_window_t wid = wid_get_prop_window(&ps->c, ps->c.screen_info->root,
|
||||||
ps->atoms->a_NET_ACTIVE_WINDOW);
|
ps->atoms->a_NET_ACTIVE_WINDOW);
|
||||||
auto w = find_win_all(ps, wid);
|
auto w = find_toplevel(ps, wid);
|
||||||
|
|
||||||
// Mark the window focused. No need to unfocus the previous one.
|
// Mark the window focused. No need to unfocus the previous one.
|
||||||
if (w) {
|
if (w) {
|
||||||
|
@ -589,7 +569,7 @@ static void recheck_focus(session_t *ps) {
|
||||||
free(reply);
|
free(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto w = find_win_all(ps, wid);
|
auto w = find_managed_window_or_parent(ps, wid);
|
||||||
|
|
||||||
log_trace("%#010" PRIx32 " (%#010lx \"%s\") focused.", wid,
|
log_trace("%#010" PRIx32 " (%#010lx \"%s\") focused.", wid,
|
||||||
(w ? w->base.id : XCB_NONE), (w ? w->name : NULL));
|
(w ? w->base.id : XCB_NONE), (w ? w->name : NULL));
|
||||||
|
|
15
src/win.c
15
src/win.c
|
@ -1507,24 +1507,19 @@ void win_unmark_client(session_t *ps, struct managed_win *w) {
|
||||||
*/
|
*/
|
||||||
static xcb_window_t
|
static xcb_window_t
|
||||||
find_client_win(struct x_connection *c, struct atom *atoms, xcb_window_t w) {
|
find_client_win(struct x_connection *c, struct atom *atoms, xcb_window_t w) {
|
||||||
if (wid_has_prop(c->c, w, atoms->aWM_STATE)) {
|
|
||||||
return w;
|
|
||||||
}
|
|
||||||
|
|
||||||
xcb_query_tree_reply_t *reply =
|
xcb_query_tree_reply_t *reply =
|
||||||
xcb_query_tree_reply(c->c, xcb_query_tree(c->c, w), NULL);
|
xcb_query_tree_reply(c->c, xcb_query_tree(c->c, w), NULL);
|
||||||
if (!reply) {
|
if (!reply) {
|
||||||
return 0;
|
return XCB_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
xcb_window_t *children = xcb_query_tree_children(reply);
|
xcb_window_t *children = xcb_query_tree_children(reply);
|
||||||
int nchildren = xcb_query_tree_children_length(reply);
|
int nchildren = xcb_query_tree_children_length(reply);
|
||||||
int i;
|
xcb_window_t ret = XCB_NONE;
|
||||||
xcb_window_t ret = 0;
|
|
||||||
|
|
||||||
for (i = 0; i < nchildren; ++i) {
|
for (int i = 0; i < nchildren; ++i) {
|
||||||
ret = find_client_win(c, atoms, children[i]);
|
if (wid_has_prop(c->c, children[i], atoms->aWM_STATE)) {
|
||||||
if (ret) {
|
ret = children[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue