From e17d20191eeb06aa5d1d070d046ee077179a7a4d Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Mon, 22 Jan 2024 18:04:45 +0100 Subject: [PATCH] display: Refactor IN_TAB_CHAIN macro The macro used to call into a bunch of other macros so let us turn it into a single function. This would simplify things for the next commit that puts the MetaGroup usage behind a X11 ifdef Part-of: --- src/core/display.c | 48 +++++++++++++++++++++++---------------- src/core/window-private.h | 9 -------- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/core/display.c b/src/core/display.c index d5a448f82..b29d75a7a 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -1979,19 +1979,29 @@ meta_display_pong_for_serial (MetaDisplay *display, } } -static MetaGroup * -get_focused_group (MetaDisplay *display) +static gboolean +in_tab_chain (MetaWindow *window, + MetaTabList type) { - if (display->focus_window) - return display->focus_window->group; - else - return NULL; -} + gboolean in_normal_tab_chain_type; + gboolean in_normal_tab_chain; + gboolean in_dock_tab_chain; + gboolean in_group_tab_chain; + MetaGroup *focus_group = NULL; -#define IN_TAB_CHAIN(w,t) (((t) == META_TAB_LIST_NORMAL && META_WINDOW_IN_NORMAL_TAB_CHAIN (w)) \ - || ((t) == META_TAB_LIST_DOCKS && META_WINDOW_IN_DOCK_TAB_CHAIN (w)) \ - || ((t) == META_TAB_LIST_GROUP && META_WINDOW_IN_GROUP_TAB_CHAIN (w, get_focused_group (w->display))) \ - || ((t) == META_TAB_LIST_NORMAL_ALL && META_WINDOW_IN_NORMAL_TAB_CHAIN_TYPE (w))) + in_normal_tab_chain_type = window->type != META_WINDOW_DOCK && window->type != META_WINDOW_DESKTOP; + in_normal_tab_chain = meta_window_is_focusable (window) && in_normal_tab_chain_type && !window->skip_taskbar; + in_dock_tab_chain = meta_window_is_focusable (window) && (!in_normal_tab_chain_type || window->skip_taskbar); + + if (window->display->focus_window) + focus_group = window->display->focus_window->group; + in_group_tab_chain = meta_window_is_focusable (window) && (!focus_group || meta_window_get_group (window) == focus_group); + + return (type == META_TAB_LIST_NORMAL && in_normal_tab_chain) + || (type == META_TAB_LIST_DOCKS && in_dock_tab_chain) + || (type == META_TAB_LIST_GROUP && in_group_tab_chain) + || (type == META_TAB_LIST_NORMAL_ALL && in_normal_tab_chain_type); +} static MetaWindow* find_tab_forward (MetaDisplay *display, @@ -2013,7 +2023,7 @@ find_tab_forward (MetaDisplay *display, { MetaWindow *window = tmp->data; - if (IN_TAB_CHAIN (window, type)) + if (in_tab_chain (window, type)) return window; tmp = tmp->next; @@ -2024,7 +2034,7 @@ find_tab_forward (MetaDisplay *display, { MetaWindow *window = tmp->data; - if (IN_TAB_CHAIN (window, type)) + if (in_tab_chain (window, type)) return window; tmp = tmp->next; @@ -2052,7 +2062,7 @@ find_tab_backward (MetaDisplay *display, { MetaWindow *window = tmp->data; - if (IN_TAB_CHAIN (window, type)) + if (in_tab_chain (window, type)) return window; tmp = tmp->prev; @@ -2063,7 +2073,7 @@ find_tab_backward (MetaDisplay *display, { MetaWindow *window = tmp->data; - if (IN_TAB_CHAIN (window, type)) + if (in_tab_chain (window, type)) return window; tmp = tmp->prev; @@ -2156,7 +2166,7 @@ meta_display_get_tab_list (MetaDisplay *display, { MetaWindow *window = tmp->data; - if (!window->minimized && IN_TAB_CHAIN (window, type)) + if (!window->minimized && in_tab_chain (window, type)) tab_list = g_list_prepend (tab_list, window); } @@ -2164,7 +2174,7 @@ meta_display_get_tab_list (MetaDisplay *display, { MetaWindow *window = tmp->data; - if (window->minimized && IN_TAB_CHAIN (window, type)) + if (window->minimized && in_tab_chain (window, type)) tab_list = g_list_prepend (tab_list, window); } @@ -2180,7 +2190,7 @@ meta_display_get_tab_list (MetaDisplay *display, if (l_window->wm_state_demands_attention && !meta_window_located_on_workspace (l_window, workspace) && - IN_TAB_CHAIN (l_window, type)) + in_tab_chain (l_window, type)) tab_list = g_list_prepend (tab_list, l_window); } @@ -2263,7 +2273,7 @@ meta_display_get_tab_current (MetaDisplay *display, window = display->focus_window; if (window != NULL && - IN_TAB_CHAIN (window, type) && + in_tab_chain (window, type) && (workspace == NULL || meta_window_located_on_workspace (window, workspace))) return window; diff --git a/src/core/window-private.h b/src/core/window-private.h index 4116fe23e..54f7f1f4e 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -724,15 +724,6 @@ void meta_window_get_tile_area (MetaWindow *window, gboolean meta_window_same_application (MetaWindow *window, MetaWindow *other_window); -#define META_WINDOW_IN_NORMAL_TAB_CHAIN_TYPE(w) \ - ((w)->type != META_WINDOW_DOCK && (w)->type != META_WINDOW_DESKTOP) -#define META_WINDOW_IN_NORMAL_TAB_CHAIN(w) \ - (meta_window_is_focusable (w) && META_WINDOW_IN_NORMAL_TAB_CHAIN_TYPE (w) && (!(w)->skip_taskbar)) -#define META_WINDOW_IN_DOCK_TAB_CHAIN(w) \ - (meta_window_is_focusable (w) && (! META_WINDOW_IN_NORMAL_TAB_CHAIN_TYPE (w) || (w)->skip_taskbar)) -#define META_WINDOW_IN_GROUP_TAB_CHAIN(w, g) \ - (meta_window_is_focusable (w) && (!g || meta_window_get_group(w)==g)) - void meta_window_free_delete_dialog (MetaWindow *window); MetaStackLayer meta_window_get_default_layer (MetaWindow *window);