core: Guard MetaGroup usage

For now, we just guard part of the group header as it is
consumed by gnome-shell. Ideally, we would drop that use case and make
the whole header private.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3555>
This commit is contained in:
Bilal Elmoussaoui 2024-01-22 17:59:34 +01:00
parent 43351b483f
commit f0c22cb3bc
8 changed files with 61 additions and 36 deletions

View File

@ -1986,14 +1986,11 @@ in_tab_chain (MetaWindow *window,
gboolean in_normal_tab_chain_type; gboolean in_normal_tab_chain_type;
gboolean in_normal_tab_chain; gboolean in_normal_tab_chain;
gboolean in_dock_tab_chain; gboolean in_dock_tab_chain;
gboolean in_group_tab_chain; gboolean in_group_tab_chain = FALSE;
#ifdef HAVE_X11_CLIENT
MetaGroup *focus_group = NULL; MetaGroup *focus_group = NULL;
MetaGroup *window_group = NULL; MetaGroup *window_group = NULL;
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 && if (window->display->focus_window &&
window->display->focus_window->client_type == META_WINDOW_CLIENT_TYPE_X11) window->display->focus_window->client_type == META_WINDOW_CLIENT_TYPE_X11)
focus_group = meta_window_get_group (window->display->focus_window); focus_group = meta_window_get_group (window->display->focus_window);
@ -2002,6 +1999,11 @@ in_tab_chain (MetaWindow *window,
window_group = meta_window_get_group (window); window_group = meta_window_get_group (window);
in_group_tab_chain = meta_window_is_focusable (window) && (!focus_group || window_group == focus_group); in_group_tab_chain = meta_window_is_focusable (window) && (!focus_group || window_group == focus_group);
#endif
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);
return (type == META_TAB_LIST_NORMAL && in_normal_tab_chain) return (type == META_TAB_LIST_NORMAL && in_normal_tab_chain)
|| (type == META_TAB_LIST_DOCKS && in_dock_tab_chain) || (type == META_TAB_LIST_DOCKS && in_dock_tab_chain)

View File

@ -36,6 +36,10 @@
#include "meta/prefs.h" #include "meta/prefs.h"
#include "meta/workspace.h" #include "meta/workspace.h"
#ifdef HAVE_X11_CLIENT
#include "x11/window-x11-private.h"
#endif
typedef enum typedef enum
{ {
META_LEFT, META_LEFT,
@ -410,7 +414,9 @@ avoid_being_obscured_as_second_modal_dialog (MetaWindow *window,
if (window->denied_focus_and_not_transient && if (window->denied_focus_and_not_transient &&
window->type == META_WINDOW_MODAL_DIALOG && window->type == META_WINDOW_MODAL_DIALOG &&
meta_window_same_application (window, focus_window) && #ifdef HAVE_X11_CLIENT
meta_window_x11_same_application (window, focus_window) &&
#endif
window_overlaps_focus_window (window)) window_overlaps_focus_window (window))
{ {
find_most_freespace (window, focus_window, *x, *y, x, y); find_most_freespace (window, focus_window, *x, *y, x, y);

View File

@ -36,11 +36,14 @@
#include "core/meta-workspace-manager-private.h" #include "core/meta-workspace-manager-private.h"
#include "core/window-private.h" #include "core/window-private.h"
#include "core/workspace-private.h" #include "core/workspace-private.h"
#include "meta/group.h"
#include "meta/prefs.h" #include "meta/prefs.h"
#include "meta/workspace.h" #include "meta/workspace.h"
#ifdef HAVE_X11_CLIENT
#include "meta/group.h"
#include "x11/meta-x11-display-private.h" #include "x11/meta-x11-display-private.h"
#include "x11/window-x11.h" #include "x11/window-x11.h"
#endif
#define WINDOW_TRANSIENT_FOR_WHOLE_GROUP(w) \ #define WINDOW_TRANSIENT_FOR_WHOLE_GROUP(w) \
(meta_window_has_transient_type (w) && w->transient_for == NULL) (meta_window_has_transient_type (w) && w->transient_for == NULL)
@ -502,6 +505,7 @@ create_constraints (Constraint **constraints,
continue; continue;
} }
#ifdef HAVE_X11_CLIENT
if (WINDOW_TRANSIENT_FOR_WHOLE_GROUP (w)) if (WINDOW_TRANSIENT_FOR_WHOLE_GROUP (w))
{ {
GSList *group_windows; GSList *group_windows;
@ -550,7 +554,9 @@ create_constraints (Constraint **constraints,
g_slist_free (group_windows); g_slist_free (group_windows);
} }
else if (w->transient_for != NULL) else
#endif
if (w->transient_for != NULL)
{ {
MetaWindow *parent; MetaWindow *parent;

View File

@ -717,10 +717,6 @@ void meta_window_get_tile_area (MetaWindow *window,
MetaTileMode mode, MetaTileMode mode,
MtkRectangle *tile_area); MtkRectangle *tile_area);
gboolean meta_window_same_application (MetaWindow *window,
MetaWindow *other_window);
void meta_window_free_delete_dialog (MetaWindow *window); void meta_window_free_delete_dialog (MetaWindow *window);
MetaStackLayer meta_window_get_default_layer (MetaWindow *window); MetaStackLayer meta_window_get_default_layer (MetaWindow *window);

View File

@ -79,13 +79,13 @@
#include "core/util-private.h" #include "core/util-private.h"
#include "core/workspace-private.h" #include "core/workspace-private.h"
#include "meta/compositor-mutter.h" #include "meta/compositor-mutter.h"
#include "meta/group.h"
#include "meta/meta-cursor-tracker.h" #include "meta/meta-cursor-tracker.h"
#include "meta/meta-enum-types.h" #include "meta/meta-enum-types.h"
#include "meta/prefs.h" #include "meta/prefs.h"
#include "mtk/mtk-x11.h" #include "mtk/mtk-x11.h"
#ifdef HAVE_X11_CLIENT #ifdef HAVE_X11_CLIENT
#include "meta/group.h"
#include "x11/meta-x11-display-private.h" #include "x11/meta-x11-display-private.h"
#include "x11/window-props.h" #include "x11/window-props.h"
#include "x11/window-x11-private.h" #include "x11/window-x11-private.h"
@ -1444,10 +1444,10 @@ meta_window_unmanage (MetaWindow *window,
if (meta_prefs_get_workspaces_only_on_primary ()) if (meta_prefs_get_workspaces_only_on_primary ())
meta_window_on_all_workspaces_changed (window); meta_window_on_all_workspaces_changed (window);
#ifdef HAVE_X11_CLIENT
if (window->fullscreen) if (window->fullscreen)
{ {
MetaGroup *group; MetaGroup *group = NULL;
/* If the window is fullscreen, it may be forcing /* If the window is fullscreen, it may be forcing
* other windows in its group to a higher layer * other windows in its group to a higher layer
*/ */
@ -1459,16 +1459,18 @@ meta_window_unmanage (MetaWindow *window,
if (group) if (group)
meta_group_update_layers (group); meta_group_update_layers (group);
} }
meta_stack_thaw (window->display->stack); meta_stack_thaw (window->display->stack);
} }
#endif
meta_display_remove_pending_pings_for_window (window->display, window); meta_display_remove_pending_pings_for_window (window->display, window);
/* safe to do this early as group.c won't re-add to the /* safe to do this early as group.c won't re-add to the
* group if window->unmanaging */ * group if window->unmanaging */
#ifdef HAVE_X11_CLIENT
if (window->client_type == META_WINDOW_CLIENT_TYPE_X11) if (window->client_type == META_WINDOW_CLIENT_TYPE_X11)
meta_window_shutdown_group (window); meta_window_shutdown_group (window);
#endif
/* If we have the focus, focus some other window. /* If we have the focus, focus some other window.
* This is done first, so that if the unmap causes * This is done first, so that if the unmap causes
@ -4463,6 +4465,7 @@ meta_window_get_titlebar_rect (MetaWindow *window,
const char* const char*
meta_window_get_startup_id (MetaWindow *window) meta_window_get_startup_id (MetaWindow *window)
{ {
#ifdef HAVE_X11_CLIENT
if (window->startup_id == NULL && window->client_type == META_WINDOW_CLIENT_TYPE_X11) if (window->startup_id == NULL && window->client_type == META_WINDOW_CLIENT_TYPE_X11)
{ {
MetaGroup *group; MetaGroup *group;
@ -4472,6 +4475,7 @@ meta_window_get_startup_id (MetaWindow *window)
if (group != NULL) if (group != NULL)
return meta_group_get_startup_id (group); return meta_group_get_startup_id (group);
} }
#endif
return window->startup_id; return window->startup_id;
} }
@ -5928,19 +5932,6 @@ meta_window_get_tile_area (MetaWindow *window,
tile_area->x += work_area.width - tile_area->width; tile_area->x += work_area.width - tile_area->width;
} }
gboolean
meta_window_same_application (MetaWindow *window,
MetaWindow *other_window)
{
MetaGroup *group = meta_window_get_group (window);
MetaGroup *other_group = meta_window_get_group (other_window);
return
group!=NULL &&
other_group!=NULL &&
group==other_group;
}
/** /**
* meta_window_is_client_decorated: * meta_window_is_client_decorated:
* *
@ -6119,18 +6110,23 @@ meta_window_get_default_layer (MetaWindow *window)
void void
meta_window_update_layer (MetaWindow *window) meta_window_update_layer (MetaWindow *window)
{ {
#ifdef HAVE_X11_CLIENT
MetaGroup *group = NULL; MetaGroup *group = NULL;
meta_stack_freeze (window->display->stack);
if (window->client_type == META_WINDOW_CLIENT_TYPE_X11) if (window->client_type == META_WINDOW_CLIENT_TYPE_X11)
group = meta_window_get_group (window); group = meta_window_get_group (window);
meta_stack_freeze (window->display->stack);
if (group) if (group)
meta_group_update_layers (group); meta_group_update_layers (group);
else else
meta_stack_update_layer (window->display->stack, window); meta_stack_update_layer (window->display->stack, window);
meta_stack_thaw (window->display->stack); meta_stack_thaw (window->display->stack);
#else
meta_stack_freeze (window->display->stack);
meta_stack_update_layer (window->display->stack, window);
meta_stack_thaw (window->display->stack);
#endif
} }
/* ensure_mru_position_after ensures that window appears after /* ensure_mru_position_after ensures that window appears after

View File

@ -21,7 +21,9 @@
#pragma once #pragma once
#ifdef HAVE_X11_CLIENT
#include <X11/Xlib.h> #include <X11/Xlib.h>
#endif
#include <glib.h> #include <glib.h>
#include "meta/common.h" #include "meta/common.h"
@ -40,14 +42,15 @@ void meta_window_shutdown_group (MetaWindow *window);
META_EXPORT META_EXPORT
void meta_window_group_leader_changed (MetaWindow *window); void meta_window_group_leader_changed (MetaWindow *window);
META_EXPORT
GSList* meta_group_list_windows (MetaGroup *group);
#ifdef HAVE_X11_CLIENT
/* note, can return NULL */ /* note, can return NULL */
META_EXPORT META_EXPORT
MetaGroup *meta_x11_display_lookup_group (MetaX11Display *x11_display, MetaGroup *meta_x11_display_lookup_group (MetaX11Display *x11_display,
Window group_leader); Window group_leader);
META_EXPORT
GSList* meta_group_list_windows (MetaGroup *group);
META_EXPORT META_EXPORT
void meta_group_update_layers (MetaGroup *group); void meta_group_update_layers (MetaGroup *group);
@ -60,3 +63,4 @@ int meta_group_get_size (MetaGroup *group);
META_EXPORT META_EXPORT
gboolean meta_group_property_notify (MetaGroup *group, gboolean meta_group_property_notify (MetaGroup *group,
XEvent *event); XEvent *event);
#endif

View File

@ -105,4 +105,7 @@ Window meta_window_x11_get_xtransient_for (MetaWindow *window);
gboolean meta_window_x11_has_pointer (MetaWindow *window); gboolean meta_window_x11_has_pointer (MetaWindow *window);
gboolean meta_window_x11_same_application (MetaWindow *window,
MetaWindow *other_window);
G_END_DECLS G_END_DECLS

View File

@ -2564,7 +2564,7 @@ meta_window_x11_update_shape_region (MetaWindow *window)
meta_window_set_shape_region (window, region); meta_window_set_shape_region (window, region);
} }
/* Generally meta_window_same_application() is a better idea /* Generally meta_window_x11_same_application() is a better idea
* of "sameness", since it handles the case where multiple apps * of "sameness", since it handles the case where multiple apps
* want to look like the same app or the same app wants to look * want to look like the same app or the same app wants to look
* like multiple apps, but in the case of workarounds for legacy * like multiple apps, but in the case of workarounds for legacy
@ -2841,7 +2841,7 @@ meta_window_x11_configure_request (MetaWindow *window,
window->desc); window->desc);
} }
else if (active_window && else if (active_window &&
!meta_window_same_application (window, active_window) && !meta_window_x11_same_application (window, active_window) &&
!meta_window_same_client (window, active_window) && !meta_window_same_client (window, active_window) &&
XSERVER_TIME_IS_BEFORE (window->net_wm_user_time, XSERVER_TIME_IS_BEFORE (window->net_wm_user_time,
active_window->net_wm_user_time)) active_window->net_wm_user_time))
@ -4486,3 +4486,15 @@ meta_window_x11_has_pointer (MetaWindow *window)
return meta_x11_display_lookup_x_window (x11_display, child) == window; return meta_x11_display_lookup_x_window (x11_display, child) == window;
} }
gboolean
meta_window_x11_same_application (MetaWindow *window,
MetaWindow *other_window)
{
MetaGroup *group = meta_window_get_group (window);
MetaGroup *other_group = meta_window_get_group (other_window);
return (group != NULL &&
other_group != NULL &&
group == other_group);
}