Blob Blame History Raw
From 5efefc0e46963749a53a8d81ff6641fd6f9e6e1f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
Date: Tue, 4 Jun 2019 21:21:37 +0200
Subject: [PATCH] screen: Expose workspace layout properties

gnome-shell hardcodes a vertical one-column workspace layout, and
while not supporting arbitrary grids is very much by design, it
currently doesn't have a choice: We simply don't expose the workspace
layout we use.

Change that to allow gnome-shell to be a bit more flexible with the
workspace layouts it supports.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/618
---
 src/core/screen.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/src/core/screen.c b/src/core/screen.c
index c14bba0cf..090baecda 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -81,6 +81,9 @@ static void on_monitors_changed          (MetaMonitorManager *manager,
 enum
 {
   PROP_N_WORKSPACES = 1,
+
+  PROP_LAYOUT_COLUMNS,
+  PROP_LAYOUT_ROWS,
 };
 
 enum
@@ -138,6 +141,12 @@ meta_screen_get_property (GObject      *object,
 
   switch (prop_id)
     {
+    case PROP_LAYOUT_COLUMNS:
+      g_value_set_int (value, screen->columns_of_workspaces);
+      break;
+    case PROP_LAYOUT_ROWS:
+      g_value_set_int (value, screen->rows_of_workspaces);
+      break;
     case PROP_N_WORKSPACES:
       g_value_set_int (value, meta_screen_get_n_workspaces (screen));
       break;
@@ -261,6 +270,22 @@ meta_screen_class_init (MetaScreenClass *klass)
                   NULL, NULL, NULL,
 		  G_TYPE_NONE, 0);
 
+  g_object_class_install_property (object_class,
+                                   PROP_LAYOUT_COLUMNS,
+                                   g_param_spec_int ("layout-columns",
+                                                     "Layout columns",
+                                                     "Number of columns in layout",
+                                                     -1, G_MAXINT, 1,
+                                                     G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_property (object_class,
+                                   PROP_LAYOUT_ROWS,
+                                   g_param_spec_int ("layout-rows",
+                                                     "Layout rows",
+                                                     "Number of rows in layout",
+                                                     -1, G_MAXINT, 1,
+                                                     G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
   g_object_class_install_property (object_class,
                                    PROP_N_WORKSPACES,
                                    pspec);
@@ -1753,6 +1778,8 @@ meta_screen_update_workspace_layout (MetaScreen *screen)
                 screen->columns_of_workspaces,
                 screen->vertical_workspaces,
                 screen->starting_corner);
+  g_object_notify (G_OBJECT (screen), "layout-columns");
+  g_object_notify (G_OBJECT (screen), "layout-rows");
 }
 
 /**
@@ -1785,6 +1812,9 @@ meta_screen_override_workspace_layout (MetaScreen      *screen,
   screen->rows_of_workspaces = n_rows;
   screen->columns_of_workspaces = n_columns;
 
+  g_object_notify (G_OBJECT (screen), "layout-columns");
+  g_object_notify (G_OBJECT (screen), "layout-rows");
+
   /* In theory we should remove _NET_DESKTOP_LAYOUT from _NET_SUPPORTED at this
    * point, but it's unlikely that anybody checks that, and it's unlikely that
    * anybody who checks that handles changes, so we'd probably just create
-- 
2.26.2