From df0be9e990c8c3e55a9dfc2e8e9c50da2976385f Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Mon, 6 Apr 2020 20:24:16 +0100 Subject: [PATCH] Move find_client_win to win.c Signed-off-by: Yuxuan Shui --- src/picom.c | 28 ---------------------------- src/picom.h | 2 -- src/win.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 30 deletions(-) diff --git a/src/picom.c b/src/picom.c index a7bc763..b4a4d49 100644 --- a/src/picom.c +++ b/src/picom.c @@ -374,34 +374,6 @@ static void recheck_focus(session_t *ps) { } } -/** - * Look for the client window of a particular window. - */ -xcb_window_t find_client_win(session_t *ps, xcb_window_t w) { - if (wid_has_prop(ps, w, ps->atoms->aWM_STATE)) { - return w; - } - - xcb_query_tree_reply_t *reply = - xcb_query_tree_reply(ps->c, xcb_query_tree(ps->c, w), NULL); - if (!reply) - return 0; - - xcb_window_t *children = xcb_query_tree_children(reply); - int nchildren = xcb_query_tree_children_length(reply); - int i; - xcb_window_t ret = 0; - - for (i = 0; i < nchildren; ++i) { - if ((ret = find_client_win(ps, children[i]))) - break; - } - - free(reply); - - return ret; -} - /** * Rebuild cached screen_reg. */ diff --git a/src/picom.h b/src/picom.h index fb64fda..fe39ded 100644 --- a/src/picom.h +++ b/src/picom.h @@ -42,8 +42,6 @@ void add_damage(session_t *ps, const region_t *damage); uint32_t determine_evmask(session_t *ps, xcb_window_t wid, win_evmode_t mode); -xcb_window_t find_client_win(session_t *ps, xcb_window_t w); - void circulate_win(session_t *ps, xcb_circulate_notify_event_t *ce); void update_refresh_rate(session_t *ps); diff --git a/src/win.c b/src/win.c index 2da27eb..a27643c 100644 --- a/src/win.c +++ b/src/win.c @@ -1046,6 +1046,34 @@ void win_unmark_client(session_t *ps, struct managed_win *w) { (const uint32_t[]){determine_evmask(ps, client, WIN_EVMODE_UNKNOWN)}); } +/** + * Look for the client window of a particular window. + */ +static xcb_window_t find_client_win(session_t *ps, xcb_window_t w) { + if (wid_has_prop(ps, w, ps->atoms->aWM_STATE)) { + return w; + } + + xcb_query_tree_reply_t *reply = + xcb_query_tree_reply(ps->c, xcb_query_tree(ps->c, w), NULL); + if (!reply) + return 0; + + xcb_window_t *children = xcb_query_tree_children(reply); + int nchildren = xcb_query_tree_children_length(reply); + int i; + xcb_window_t ret = 0; + + for (i = 0; i < nchildren; ++i) { + if ((ret = find_client_win(ps, children[i]))) + break; + } + + free(reply); + + return ret; +} + /** * Recheck client window of a window. *