From b1dd6973df03d3b960f31206572ebb6456c30462 Mon Sep 17 00:00:00 2001 From: Zander Brown Date: Thu, 26 Oct 2023 23:29:17 +0100 Subject: [PATCH] workspace-manager: Accessors for layout-{columns,rows} This will allow C code in shell to avoid going though `g_object_get`, and in future GJS will also be able to take advantage giving a slender yet not unwelcome boost to perf in some animations (Semi relates to https://gitlab.gnome.org/GNOME/mutter/-/issues/3083) Part-of: --- src/core/meta-workspace-manager.c | 20 ++++++++++++++++++-- src/meta/meta-workspace-manager.h | 6 ++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/core/meta-workspace-manager.c b/src/core/meta-workspace-manager.c index 5896fd8c5..614fa96f3 100644 --- a/src/core/meta-workspace-manager.c +++ b/src/core/meta-workspace-manager.c @@ -75,10 +75,10 @@ meta_workspace_manager_get_property (GObject *object, switch (prop_id) { case PROP_LAYOUT_COLUMNS: - g_value_set_int (value, workspace_manager->columns_of_workspaces); + g_value_set_int (value, meta_workspace_manager_get_layout_columns (workspace_manager)); break; case PROP_LAYOUT_ROWS: - g_value_set_int (value, workspace_manager->rows_of_workspaces); + g_value_set_int (value, meta_workspace_manager_get_layout_rows (workspace_manager)); break; case PROP_N_WORKSPACES: g_value_set_int (value, meta_workspace_manager_get_n_workspaces (workspace_manager)); @@ -1047,3 +1047,19 @@ prefs_changed_callback (MetaPreference pref, timestamp, new_num); } } + +int +meta_workspace_manager_get_layout_columns (MetaWorkspaceManager *workspace_manager) +{ + g_return_val_if_fail (META_IS_WORKSPACE_MANAGER (workspace_manager), -1); + + return workspace_manager->columns_of_workspaces; +} + +int +meta_workspace_manager_get_layout_rows (MetaWorkspaceManager *workspace_manager) +{ + g_return_val_if_fail (META_IS_WORKSPACE_MANAGER (workspace_manager), -1); + + return workspace_manager->rows_of_workspaces; +} diff --git a/src/meta/meta-workspace-manager.h b/src/meta/meta-workspace-manager.h index d068fa1ac..777447dcc 100644 --- a/src/meta/meta-workspace-manager.h +++ b/src/meta/meta-workspace-manager.h @@ -74,3 +74,9 @@ void meta_workspace_manager_override_workspace_layout (MetaWorkspaceManager *wor gboolean vertical_layout, int n_rows, int n_columns); + +META_EXPORT +int meta_workspace_manager_get_layout_columns (MetaWorkspaceManager *workspace_manager); + +META_EXPORT +int meta_workspace_manager_get_layout_rows (MetaWorkspaceManager *workspace_manager);