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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3555>
This commit is contained in:
Bilal Elmoussaoui 2024-01-22 18:04:45 +01:00
parent 467120d5aa
commit e17d20191e
2 changed files with 29 additions and 28 deletions

View File

@ -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;

View File

@ -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);