From 4932bc5ea8b223dcce5214aa5d8485d703ae84df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 22 Oct 2008 12:02:49 +0000 Subject: [PATCH] * Added the BeOS feature that Command-~ (with American keymap) will switch workspaces between this and the previous one. * Note that this is mapped to a specific key on the keyboard (key 17), so it will differ with the keymap, but will usually be the key below the escape key. * This closes ticket #2766. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28282 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/Desktop.cpp | 11 +++++++++-- src/servers/app/Desktop.h | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index 68d8a84ac1..593bb52e8d 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -173,6 +173,9 @@ KeyboardFilter::Filter(BMessage* message, EventTarget** _target, fDesktop->SetWorkspaceAsync(key - 2); return B_SKIP_MESSAGE; } + } if (key == 0x11 && (modifiers & B_COMMAND_KEY) != 0) { + // switch to previous workspace + fDesktop->SetWorkspaceAsync(-1); } } @@ -296,6 +299,7 @@ Desktop::Desktop(uid_t userID) fApplicationsLock("application list"), fShutdownSemaphore(-1), fCurrentWorkspace(0), + fPreviousWorkspace(0), fAllWindows(kAllWindowList), fSubsetWindows(kSubsetList), fFocusList(kFocusList), @@ -633,6 +637,9 @@ Desktop::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) int32 index; link.Read(&index); + if (index == -1) + index = fPreviousWorkspace; + SetWorkspace(index); break; } @@ -885,8 +892,7 @@ Desktop::SetWorkspace(int32 index) } -/*! - Changes the current workspace to the one specified by \a index. +/*! Changes the current workspace to the one specified by \a index. You must hold the all window lock when calling this method. */ void @@ -946,6 +952,7 @@ Desktop::_SetWorkspace(int32 index) window->SetCurrentWorkspace(-1); } + fPreviousWorkspace = fCurrentWorkspace; fCurrentWorkspace = index; // show windows, and include them in the changed region - but only diff --git a/src/servers/app/Desktop.h b/src/servers/app/Desktop.h index 7009962617..710bdda189 100644 --- a/src/servers/app/Desktop.h +++ b/src/servers/app/Desktop.h @@ -279,6 +279,7 @@ class Desktop : public MessageLooper, public ScreenOwner { ::Workspace::Private fWorkspaces[kMaxWorkspaces]; int32 fCurrentWorkspace; + int32 fPreviousWorkspace; WindowList fAllWindows; WindowList fSubsetWindows;