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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3351>
This commit is contained in:
Zander Brown 2023-10-26 23:29:17 +01:00 committed by Marge Bot
parent 5ffeb34251
commit b1dd6973df
2 changed files with 24 additions and 2 deletions

View File

@ -75,10 +75,10 @@ meta_workspace_manager_get_property (GObject *object,
switch (prop_id) switch (prop_id)
{ {
case PROP_LAYOUT_COLUMNS: 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; break;
case PROP_LAYOUT_ROWS: 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; break;
case PROP_N_WORKSPACES: case PROP_N_WORKSPACES:
g_value_set_int (value, meta_workspace_manager_get_n_workspaces (workspace_manager)); 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); 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;
}

View File

@ -74,3 +74,9 @@ void meta_workspace_manager_override_workspace_layout (MetaWorkspaceManager *wor
gboolean vertical_layout, gboolean vertical_layout,
int n_rows, int n_rows,
int n_columns); 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);