From d392ddc266251bca30a7df1a4060f5dbda3a4cf6 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Mon, 5 Dec 2022 18:08:29 +0100 Subject: Refactor logic to ignore certain clients. * schewm.c: Extract client-ignoring logic into the dpy_should_ignore_window function. --- schewm.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'schewm.c') diff --git a/schewm.c b/schewm.c index 8a03fd7..87cfbab 100644 --- a/schewm.c +++ b/schewm.c @@ -1351,8 +1351,8 @@ dpy_fetch_cursor_position(struct Point *p) { return true; } -struct Client * -dpy_make_client(xcb_window_t window) { +static bool +dpy_should_ignore_window(xcb_window_t window) { xcb_ewmh_get_atoms_reply_t window_type; xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_window_type(dpy.ewmh, window); @@ -1361,9 +1361,9 @@ dpy_make_client(xcb_window_t window) { cookie, &window_type, NULL); + bool should_ignore = false; if (reply) { // Figure out from window type if we should ignore it - bool should_ignore = false; for (uint32_t i = 0; i < window_type.atoms_len; i++) { xcb_atom_t atom = window_type.atoms[i]; if (atom == dpy.ewmh->_NET_WM_WINDOW_TYPE_TOOLBAR @@ -1375,9 +1375,14 @@ dpy_make_client(xcb_window_t window) { } } xcb_ewmh_get_atoms_reply_wipe(&window_type); - if (should_ignore) { - return NULL; - } + } + return should_ignore; +} + +struct Client * +dpy_make_client(xcb_window_t window) { + if (dpy_should_ignore_window(window)) { + return NULL; } uint32_t event_mask[] = { XCB_EVENT_MASK_ENTER_WINDOW, XCB_NONE }; -- cgit v1.2.3