summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen W. Taylor <otaylor@fishsoup.net>2011-01-24 15:40:30 -0500
committerOwen W. Taylor <otaylor@fishsoup.net>2011-02-01 11:34:56 -0500
commit8b220079d0aef9d61a1f3ef052c52eb46c0c7501 (patch)
treeb0ce9ac3efb4d28cdd572dd991f1fa7c08690d5d
parent2df95970d9b5d2c8e3b9c4308c26f670a5c2621c (diff)
downloadmutter-8b220079d0aef9d61a1f3ef052c52eb46c0c7501.tar.gz
Add ability to override workspace layout
A plugin that does workspace management on its on may want to set the workspace layout without having to deal with putting a property on the root window to be read back and parsed. Add meta_screen_override_window_layout() that allows the same types of layouts as _NET_DESKTOP_LAYOUT but without setting a property. https://bugzilla.gnome.org/show_bug.cgi?id=640552
-rw-r--r--src/core/screen-private.h9
-rw-r--r--src/core/screen.c40
-rw-r--r--src/include/screen.h13
3 files changed, 54 insertions, 8 deletions
diff --git a/src/core/screen-private.h b/src/core/screen-private.h
index f64f7458c..c7373e258 100644
--- a/src/core/screen-private.h
+++ b/src/core/screen-private.h
@@ -52,14 +52,6 @@ typedef void (* MetaScreenWindowFunc) (MetaScreen *screen, MetaWindow *window,
typedef enum
{
- META_SCREEN_TOPLEFT,
- META_SCREEN_TOPRIGHT,
- META_SCREEN_BOTTOMLEFT,
- META_SCREEN_BOTTOMRIGHT
-} MetaScreenCorner;
-
-typedef enum
-{
META_SCREEN_UP,
META_SCREEN_DOWN,
META_SCREEN_LEFT,
@@ -127,6 +119,7 @@ struct _MetaScreen
int columns_of_workspaces;
MetaScreenCorner starting_corner;
guint vertical_workspaces : 1;
+ guint workspace_layout_overridden : 1;
guint keys_grabbed : 1;
guint all_keys_grabbed : 1;
diff --git a/src/core/screen.c b/src/core/screen.c
index 502d149c8..b656c25f0 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -2163,6 +2163,9 @@ meta_screen_update_workspace_layout (MetaScreen *screen)
{
gulong *list;
int n_items;
+
+ if (screen->workspace_layout_overridden)
+ return;
list = NULL;
n_items = 0;
@@ -2249,6 +2252,43 @@ meta_screen_update_workspace_layout (MetaScreen *screen)
screen->starting_corner);
}
+/**
+ * meta_screen_override_workspace_layout:
+ * @screen: a #MetaScreen
+ * @starting_corner: the corner at which the first workspace is found
+ * @vertical_layout: if %TRUE the workspaces are laid out in columns rather than rows
+ * @n_rows: number of rows of workspaces, or -1 to determine the number of rows from
+ * @n_columns and the total number of workspaces
+ * @n_columns: number of columns of workspaces, or -1 to determine the number of columns from
+ * @n_rows and the total number of workspaces
+ *
+ * Explicitly set the layout of workspaces. Once this has been called, the contents of the
+ * _NET_DESKTOP_LAYOUT property on the root window are completely ignored.
+ */
+void
+meta_screen_override_workspace_layout (MetaScreen *screen,
+ MetaScreenCorner starting_corner,
+ gboolean vertical_layout,
+ int n_rows,
+ int n_columns)
+{
+ g_return_if_fail (META_IS_SCREEN (screen));
+ g_return_if_fail (n_rows > 0 || n_columns > 0);
+ g_return_if_fail (n_rows != 0 && n_columns != 0);
+
+ screen->workspace_layout_overridden = TRUE;
+ screen->vertical_workspaces = vertical_layout != FALSE;
+ screen->starting_corner = starting_corner;
+ screen->rows_of_workspaces = n_rows;
+ screen->columns_of_workspaces = n_columns;
+
+ /* 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
+ * a race condition. And it's hard to implement with the code in set_supported_hint()
+ */
+}
+
static void
set_workspace_names (MetaScreen *screen)
{
diff --git a/src/include/screen.h b/src/include/screen.h
index d3f816e81..9b5de83dc 100644
--- a/src/include/screen.h
+++ b/src/include/screen.h
@@ -80,4 +80,17 @@ void meta_screen_get_monitor_geometry (MetaScreen *screen,
int monitor,
MetaRectangle *geometry);
+typedef enum
+{
+ META_SCREEN_TOPLEFT,
+ META_SCREEN_TOPRIGHT,
+ META_SCREEN_BOTTOMLEFT,
+ META_SCREEN_BOTTOMRIGHT
+} MetaScreenCorner;
+
+void meta_screen_override_workspace_layout (MetaScreen *screen,
+ MetaScreenCorner starting_corner,
+ gboolean vertical_layout,
+ int n_rows,
+ int n_columns);
#endif