Gnome hack

Za każdym razem staramy się przełączyć na inne środowisko graficzne/menedżer okien, jest jedna prosta funkcja – możliwość szybkiego przełączania się do poprzedniego wirtualnego pulpitu. Prosta ale niezwykle wciągająca funkcja, którą oferuje/oferowało tylko xfwm4.

… Aż do wczoraj! Zmęczony tym, że metacity nie oferuje tej funkcji, wdrożyłem ją u siebie.

Jeśli komuś brakuje tej funkcji – może pobrać ten patch i zastosować go do źródła metacity. W zasadzie, to dodać nowy wpis gconf (switch_to_previous_workspace) i jeszcze metacity ma zapamiętać ostatni obszar roboczy. Naciskamy Ctrl-F2 aby przełączyć się z 1 obszaru roboczego do 2 obszaru roboczego i po naciśnięciu ctrl-f2 metacity ponownie zorientuje się, że chcesz powrócić do obszaru roboczego i on to zrobi.

Jeśli jest coś czego potrzebujesz ale nikt nie wprowadził tego w życie zawsze można po prostu zrobić to samemu. To jest piękno Open Source! Przynajmniej czasami:)

diff -p -up metacity-2.30.1/src/core/prefs.c.switch metacity-2.30.1/src/core/prefs.c
— metacity-2.30.1/src/core/prefs.c.switch 2010-03-30 11:35:40.000000000 -0300
+++ metacity-2.30.1/src/core/prefs.c 2010-05-06 17:47:14.000000000 -0300
@@ -97,6 +97,7 @@ static char *cursor_theme = NULL;
static int cursor_size = 24;
static gboolean compositing_manager = FALSE;
static gboolean resize_with_right_button = FALSE;
+static gboolean switch_to_previous_workspace = TRUE;
static gboolean force_fullscreen = TRUE;

static MetaVisualBellType visual_bell_type = META_VISUAL_BELL_FULLSCREEN_FLASH;
@@ -412,6 +413,11 @@ static MetaBoolPreference preferences_bo
&resize_with_right_button,
FALSE,
},
+ { “/apps/metacity/general/switch_to_previous_workspace”,
+ META_PREF_SWITCH_TO_PREVIOUS_WORKSPACE,
+ &switch_to_previous_workspace,
+ FALSE,
+ },
{ NULL, 0, NULL, FALSE },
};

@@ -1757,6 +1763,9 @@ meta_preference_to_string (MetaPreferenc

case META_PREF_FORCE_FULLSCREEN:
return “FORCE_FULLSCREEN”;
+
+ case META_PREF_SWITCH_TO_PREVIOUS_WORKSPACE:
+ return “SWITCH_TO_PREVIOUS_WORKSPACE”;
}

return “(unknown)”;
@@ -2719,6 +2728,12 @@ meta_prefs_get_mouse_button_menu (void)
return resize_with_right_button ? 2: 3;
}

+guint
+meta_prefs_switch_to_previous_workspace (void)
+{
+ return switch_to_previous_workspace;
+}
+
gboolean
meta_prefs_get_force_fullscreen (void)
{
diff -p -up metacity-2.30.1/src/core/screen-private.h.switch metacity-2.30.1/src/core/screen-private.h
— metacity-2.30.1/src/core/screen-private.h.switch 2010-01-14 22:31:32.000000000 -0200
+++ metacity-2.30.1/src/core/screen-private.h 2010-05-06 17:47:14.000000000 -0300
@@ -80,7 +80,7 @@ struct _MetaScreen
MetaUI *ui;
MetaTabPopup *tab_popup;

- MetaWorkspace *active_workspace;
+ MetaWorkspace *active_workspace, *last_workspace;

/* This window holds the focus when we don’t want to focus
* any actual clients
diff -p -up metacity-2.30.1/src/core/workspace.c.switch metacity-2.30.1/src/core/workspace.c
— metacity-2.30.1/src/core/workspace.c.switch 2010-01-14 22:31:32.000000000 -0200
+++ metacity-2.30.1/src/core/workspace.c 2010-05-06 18:00:39.000000000 -0300
@@ -377,7 +377,31 @@ meta_workspace_activate_with_focus (Meta
meta_workspace_index (workspace));

if (workspace->screen->active_workspace == workspace)
- return;
+ {
+ meta_verbose(“Switching to same workspace detected, going back to previous one!!\n”);
+ if (meta_prefs_switch_to_previous_workspace()) {
+ if (workspace->screen->last_workspace) {
+ meta_verbose(“Going to desktop %d\n”, meta_workspace_index(workspace));
+ meta_workspace_activate_with_focus(workspace->screen->last_workspace,
+ NULL, timestamp);
+ return;
+ } else {
+ meta_verbose(“No old workspace..\n”);
+ return;
+ }
+ } else {
+ meta_verbose(“Last workspace switching disabled..\n”);
+ return;
+ }
+ }
+ else
+ {
+ if (workspace->screen->active_workspace)
+ meta_verbose(“Updating last workspace.. current: %d, new: %d\n”,
+ meta_workspace_index(workspace->screen->active_workspace),
+ meta_workspace_index(workspace));
+ workspace->screen->last_workspace = workspace->screen->active_workspace;
+ }

if (workspace->screen->active_workspace)
workspace_switch_sound(workspace->screen->active_workspace, workspace);
diff -p -up metacity-2.30.1/src/include/prefs.h.switch metacity-2.30.1/src/include/prefs.h
— metacity-2.30.1/src/include/prefs.h.switch 2010-01-14 22:31:32.000000000 -0200
+++ metacity-2.30.1/src/include/prefs.h 2010-05-06 17:47:14.000000000 -0300
@@ -60,7 +60,8 @@ typedef enum
META_PREF_CURSOR_SIZE,
META_PREF_COMPOSITING_MANAGER,
META_PREF_RESIZE_WITH_RIGHT_BUTTON,
- META_PREF_FORCE_FULLSCREEN
+ META_PREF_FORCE_FULLSCREEN,
+ META_PREF_SWITCH_TO_PREVIOUS_WORKSPACE
} MetaPreference;

typedef void (* MetaPrefsChangedFunc) (MetaPreference pref,
diff -p -up metacity-2.30.1/src/metacity.schemas.in.in.switch metacity-2.30.1/src/metacity.schemas.in.in
— metacity-2.30.1/src/metacity.schemas.in.in.switch 2010-05-06 17:47:14.000000000 -0300
+++ metacity-2.30.1/src/metacity.schemas.in.in 2010-05-06 18:01:16.000000000 -0300
@@ -4,6 +4,24 @@
<!– General preferences –>

<schema>
+ <key>/schemas/apps/metacity/general/switch_to_previous_workspace</key>
+ <applyto>/apps/metacity/general/switch_to_previous_workspace</applyto>
+ <owner>metacity</owner>
+ <type>bool</type>
+ <default>false</default>
+ <locale name=”C”>
+ <short>Remember and recall previous workspace when switching via keyboard shortcuts</short>
+ <long>
+ Set this to true to allow to switch to previous workspace when
+ using the current workspace keybinding. For example, if you switched
+ from workspace 2 to workspace 1 by pressing keyboard shortcut for
+ workspace 1, pressing the same shortcut again while on workspace 1
+ will switch to workspace 2.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
<key>/schemas/apps/metacity/general/mouse_button_modifier</key>
<applyto>/apps/metacity/general/mouse_button_modifier</applyto>
<owner>metacity</owner>
diff -p -up metacity-2.30.1/src/metacity.schemas.in.switch metacity-2.30.1/src/metacity.schemas.in
— metacity-2.30.1/src/metacity.schemas.in.switch 2010-04-06 07:10:38.000000000 -0300
+++ metacity-2.30.1/src/metacity.schemas.in 2010-05-06 18:01:06.000000000 -0300
@@ -4,6 +4,24 @@
<!– General preferences –>

<schema>
+ <key>/schemas/apps/metacity/general/switch_to_previous_workspace</key>
+ <applyto>/apps/metacity/general/switch_to_previous_workspace</applyto>
+ <owner>metacity</owner>
+ <type>bool</type>
+ <default>false</default>
+ <locale name=”C”>
+ <short>Remember and recall previous workspace when switching via keyboard shortcuts</short>
+ <long>
+ Set this to true to allow to switch to previous workspace when
+ using the current workspace keybinding. For example, if you switched
+ from workspace 2 to workspace 1 by pressing keyboard shortcut for
+ workspace 1, pressing the same shortcut again while on workspace 1
+ will switch to workspace 2.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
<key>/schemas/apps/metacity/general/mouse_button_modifier</key>
<applyto>/apps/metacity/general/mouse_button_modifier</applyto>
<owner>metacity</owner>
@@ -247,7 +265,7 @@
<applyto>/apps/metacity/general/theme</applyto>
<owner>metacity</owner>
<type>string</type>
- <default>Clearlooks</default>
+ <default>Ia Ora Steel</default>
<locale name=”C”>
<short>Current theme</short>
<long>