diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/prefs.c | 25 | ||||
-rw-r--r-- | src/core/workspace.c | 87 |
2 files changed, 102 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); } |