summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenjamin Valentin <[email protected]>2012-01-09 17:47:29 +0100
committerBenjamin Valentin <benpicco@rechenknecht2k7.(none)>2012-03-16 00:29:11 +0100
commitdacdbd19b2d6037235aa4ed1bd28f89286236046 (patch)
treea63d9ea17ddd2f772bc64819cc348c644d5746b8 /src
parent3f122b87a866edb62d0402058f83974cf8a8fd54 (diff)
downloadmarco-dacdbd19b2d6037235aa4ed1bd28f89286236046.tar.bz2
marco-dacdbd19b2d6037235aa4ed1bd28f89286236046.tar.xz
implement option for classic and toroidal workspace switching, based on https://bugzilla.gnome.org/show_bug.cgi?id=89315
Diffstat (limited to 'src')
-rw-r--r--src/core/prefs.c25
-rw-r--r--src/core/workspace.c87
-rw-r--r--src/include/common.h7
-rw-r--r--src/include/prefs.h2
-rw-r--r--src/marco.schemas.in.in23
5 files changed, 134 insertions, 10 deletions
diff --git a/src/core/prefs.c b/src/core/prefs.c
index 494d3da1..5b546f57 100644
--- a/src/core/prefs.c
+++ b/src/core/prefs.c
@@ -81,6 +81,7 @@ static MetaFocusNewWindows focus_new_windows = META_FOCUS_NEW_WINDOWS_SMART;
static gboolean raise_on_click = TRUE;
static char* current_theme = NULL;
static int num_workspaces = 4;
+static MetaWrapStyle wrap_style = META_WRAP_NONE;
static MetaActionTitlebar action_double_click_titlebar = META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE;
static MetaActionTitlebar action_middle_click_titlebar = META_ACTION_TITLEBAR_LOWER;
static MetaActionTitlebar action_right_click_titlebar = META_ACTION_TITLEBAR_MENU;
@@ -188,6 +189,14 @@ static MateConfEnumStringPair symtab_focus_new_windows[] =
{ 0, NULL },
};
+static MateConfEnumStringPair symtab_wrap_style[] =
+ {
+ { META_WRAP_NONE, "no wrap" },
+ { META_WRAP_CLASSIC, "classic" },
+ { META_WRAP_TOROIDAL, "toroidal" },
+ { 0, NULL },
+ };
+
static MateConfEnumStringPair symtab_visual_bell_type[] =
{
/* Note to the reader: 0 is an invalid value; these start at 1. */
@@ -327,6 +336,11 @@ static MetaEnumPreference preferences_enum[] =
symtab_focus_mode,
&focus_mode,
},
+ { "/apps/marco/general/wrap_style",
+ META_PREF_WRAP_STYLE,
+ symtab_wrap_style,
+ &wrap_style,
+ },
{ "/apps/marco/general/visual_bell_type",
META_PREF_VISUAL_BELL_TYPE,
symtab_visual_bell_type,
@@ -1642,6 +1656,12 @@ meta_prefs_get_num_workspaces (void)
return num_workspaces;
}
+MetaWrapStyle
+meta_prefs_get_wrap_style (void)
+{
+ return wrap_style;
+}
+
gboolean
meta_prefs_get_application_based (void)
{
@@ -1679,7 +1699,7 @@ meta_preference_to_string (MetaPreference pref)
case META_PREF_RAISE_ON_CLICK:
return "RAISE_ON_CLICK";
-
+
case META_PREF_THEME:
return "THEME";
@@ -1689,6 +1709,9 @@ meta_preference_to_string (MetaPreference pref)
case META_PREF_NUM_WORKSPACES:
return "NUM_WORKSPACES";
+ case META_PREF_WRAP_STYLE:
+ return "WRAP_STYLE";
+
case META_PREF_APPLICATION_BASED:
return "APPLICATION_BASED";
diff --git a/src/core/workspace.c b/src/core/workspace.c
index 2b28fe0b..9694c1f9 100644
--- a/src/core/workspace.c
+++ b/src/core/workspace.c
@@ -809,21 +809,23 @@ MetaWorkspace*
meta_workspace_get_neighbor (MetaWorkspace *workspace,
MetaMotionDirection direction)
{
- MetaWorkspaceLayout layout;
+ MetaWorkspaceLayout layout;
int i, current_space, num_workspaces;
gboolean ltr;
+ MetaWrapStyle wrap;
current_space = meta_workspace_index (workspace);
num_workspaces = meta_screen_get_n_workspaces (workspace->screen);
meta_screen_calc_workspace_layout (workspace->screen, num_workspaces,
current_space, &layout);
+ wrap = meta_prefs_get_wrap_style();
meta_verbose ("Getting neighbor of %d in direction %s\n",
current_space, meta_motion_direction_to_string (direction));
-
+
ltr = meta_ui_get_direction() == META_UI_DIRECTION_LTR;
- switch (direction)
+ switch (direction)
{
case META_MOTION_LEFT:
layout.current_col -= ltr ? 1 : -1;
@@ -839,14 +841,81 @@ meta_workspace_get_neighbor (MetaWorkspace *workspace,
break;
}
+ /* LEFT */
if (layout.current_col < 0)
- layout.current_col = 0;
+ switch (wrap)
+ {
+ case META_WRAP_NONE:
+ layout.current_col = 0;
+ break;
+ case META_WRAP_TOROIDAL:
+ layout.current_row = layout.current_row > 0 ? layout.current_row - 1 : layout.rows - 1;
+ /* fall through */
+ case META_WRAP_CLASSIC:
+ layout.current_col = layout.cols - 1;
+ }
+ /* RIGHT */
if (layout.current_col >= layout.cols)
- layout.current_col = layout.cols - 1;
+ switch (wrap)
+ {
+ case META_WRAP_NONE:
+ layout.current_col = layout.cols - 1;
+ break;
+ case META_WRAP_TOROIDAL:
+ layout.current_row = layout.current_row < layout.rows - 1 ? layout.current_row + 1 : 0;
+ /* fall through */
+ case META_WRAP_CLASSIC:
+ layout.current_col = 0;
+ }
+ /* UP */
if (layout.current_row < 0)
- layout.current_row = 0;
+ switch (wrap)
+ {
+ case META_WRAP_NONE:
+ layout.current_row = 0;
+ break;
+ case META_WRAP_TOROIDAL:
+ layout.current_col = layout.current_col > 0 ? layout.current_col - 1 : layout.cols - 1;
+ /* fall through */
+ case META_WRAP_CLASSIC:
+ layout.current_row = layout.rows - 1;
+ }
+ /* DOWN */
if (layout.current_row >= layout.rows)
- layout.current_row = layout.rows - 1;
+ switch (wrap)
+ {
+ case META_WRAP_NONE:
+ layout.current_row = layout.rows - 1;
+ break;
+ case META_WRAP_TOROIDAL:
+ layout.current_col = layout.current_col < layout.cols - 1 ? layout.current_col + 1 : 0;
+ /* fall through */
+ case META_WRAP_CLASSIC:
+ layout.current_row = 0;
+ }
+
+ /* If we have an uneven arrangement of workspaces, (layout.cols - n, layout.rows - 1) may be an invalid workspace
+ e.g. we have 7 workspaces on a 3x3 pane */
+ if (wrap != META_WRAP_NONE && (layout.current_row * layout.cols + layout.current_col >= num_workspaces))
+ switch (direction)
+ {
+ case META_MOTION_LEFT:
+ layout.current_col = num_workspaces - (layout.current_row * layout.cols + 1);
+ break;
+ case META_MOTION_RIGHT:
+ layout.current_col = 0;
+ if (wrap == META_WRAP_TOROIDAL)
+ layout.current_row = 0;
+ break;
+ case META_MOTION_UP:
+ layout.current_row -= 1;
+ break;
+ case META_MOTION_DOWN:
+ layout.current_row = 0;
+ if (wrap == META_WRAP_TOROIDAL)
+ layout.current_col = layout.current_col < layout.cols - 1 ? layout.current_col + 1 : 0;
+ break;
+ }
i = layout.grid[layout.current_row * layout.cols + layout.current_col];
@@ -856,12 +925,12 @@ meta_workspace_get_neighbor (MetaWorkspace *workspace,
if (i >= num_workspaces)
meta_bug ("calc_workspace_layout left an invalid (too-high) workspace number %d in the grid\n",
i);
-
+
meta_verbose ("Neighbor workspace is %d at row %d col %d\n",
i, layout.current_row, layout.current_col);
meta_screen_free_workspace_layout (&layout);
-
+
return meta_screen_get_workspace_by_index (workspace->screen, i);
}
diff --git a/src/include/common.h b/src/include/common.h
index b0308f42..73611e36 100644
--- a/src/include/common.h
+++ b/src/include/common.h
@@ -177,6 +177,13 @@ typedef enum
typedef enum
{
+ META_WRAP_NONE,
+ META_WRAP_CLASSIC,
+ META_WRAP_TOROIDAL
+} MetaWrapStyle;
+
+typedef enum
+{
META_ACTION_TITLEBAR_TOGGLE_SHADE,
META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE,
META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE_HORIZONTALLY,
diff --git a/src/include/prefs.h b/src/include/prefs.h
index 39597f9f..58814130 100644
--- a/src/include/prefs.h
+++ b/src/include/prefs.h
@@ -43,6 +43,7 @@ typedef enum
META_PREF_THEME,
META_PREF_TITLEBAR_FONT,
META_PREF_NUM_WORKSPACES,
+ META_PREF_WRAP_STYLE,
META_PREF_APPLICATION_BASED,
META_PREF_KEYBINDINGS,
META_PREF_DISABLE_WORKAROUNDS,
@@ -88,6 +89,7 @@ gboolean meta_prefs_get_application_based (void);
gboolean meta_prefs_get_disable_workarounds (void);
gboolean meta_prefs_get_auto_raise (void);
int meta_prefs_get_auto_raise_delay (void);
+MetaWrapStyle meta_prefs_get_wrap_style (void);
gboolean meta_prefs_get_reduced_resources (void);
gboolean meta_prefs_get_mate_accessibility (void);
gboolean meta_prefs_get_mate_animations (void);
diff --git a/src/marco.schemas.in.in b/src/marco.schemas.in.in
index acd342b4..ca03ab70 100644
--- a/src/marco.schemas.in.in
+++ b/src/marco.schemas.in.in
@@ -307,6 +307,29 @@
</schema>
<schema>
+ <key>/schemas/apps/marco/general/wrap_style</key>
+ <applyto>/apps/marco/general/wrap_style</applyto>
+ <owner>marco</owner>
+ <type>string</type>
+ <default>no wrap</default>
+ <locale name="C">
+ <short>Workspace wrap style</short>
+ <long>
+ The wrap style is used to determine how to switch from one
+ workspace to another at the border of the workspace switcher.
+ When set to "no wrap", nothing will happen if you try to
+ switch to a workspace past the border of the workspace switcher.
+ If set to "classic", the old marco behavior is used:
+ the end of one row leads to the beginning of the next and
+ the end of a column leads to the beginning of the next.
+ If set to "toroidal", workspaces are connected like a doughnut:
+ the end of each row leads to its own beginning and the
+ end of each column leads to its own beginning.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
<key>/schemas/apps/marco/general/visual_bell</key>
<applyto>/apps/marco/general/visual_bell</applyto>
<owner>marco</owner>