* Made the Alt-Shift-Fx behaviour consistent with Ctrl-Alt-Shift-Arrow (ie.

take the active window to the new workspace).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34114 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-11-18 15:03:58 +00:00
parent 916b34101c
commit 47212dddf5
2 changed files with 43 additions and 31 deletions
+37 -28
View File
@@ -171,19 +171,23 @@ KeyboardFilter::Filter(BMessage* message, EventTarget** _target,
// workspace change // workspace change
#if !TEST_MODE #if !TEST_MODE
if (modifiers & B_COMMAND_KEY) if ((modifiers & (B_COMMAND_KEY | B_CONTROL_KEY | B_OPTION_KEY))
== B_COMMAND_KEY)
#else #else
if (modifiers & B_CONTROL_KEY) if ((modifiers & B_CONTROL_KEY) != 0)
#endif #endif
{ {
STRACE(("Set Workspace %ld\n", key - 1)); STRACE(("Set Workspace %ld\n", key - 1));
fDesktop->SetWorkspaceAsync(key - 2); fDesktop->SetWorkspaceAsync(key - 2,
(modifiers & B_SHIFT_KEY) != 0);
return B_SKIP_MESSAGE; return B_SKIP_MESSAGE;
} }
} if (key == 0x11 && (modifiers & B_COMMAND_KEY) != 0) { } if (key == 0x11
&& (modifiers & (B_COMMAND_KEY | B_CONTROL_KEY | B_OPTION_KEY))
== B_COMMAND_KEY) {
// switch to previous workspace (command + `) // switch to previous workspace (command + `)
fDesktop->SetWorkspaceAsync(-1); fDesktop->SetWorkspaceAsync(-1, (modifiers & B_SHIFT_KEY) != 0);
return B_SKIP_MESSAGE; return B_SKIP_MESSAGE;
} }
} }
@@ -726,11 +730,12 @@ Desktop::UnlockDirectScreen(team_id team)
/*! Changes the current workspace to the one specified by \a index. /*! Changes the current workspace to the one specified by \a index.
*/ */
void void
Desktop::SetWorkspaceAsync(int32 index) Desktop::SetWorkspaceAsync(int32 index, bool moveFocusWindow)
{ {
BPrivate::LinkSender link(MessagePort()); BPrivate::LinkSender link(MessagePort());
link.StartMessage(AS_ACTIVATE_WORKSPACE); link.StartMessage(AS_ACTIVATE_WORKSPACE);
link.Attach<int32>(index); link.Attach<int32>(index);
link.Attach<bool>(moveFocusWindow);
link.Flush(); link.Flush();
} }
@@ -739,7 +744,7 @@ Desktop::SetWorkspaceAsync(int32 index)
You must not hold any window lock when calling this method. You must not hold any window lock when calling this method.
*/ */
void void
Desktop::SetWorkspace(int32 index) Desktop::SetWorkspace(int32 index, bool moveFocusWindow)
{ {
LockAllWindows(); LockAllWindows();
DesktopSettings settings(this); DesktopSettings settings(this);
@@ -750,7 +755,7 @@ Desktop::SetWorkspace(int32 index)
return; return;
} }
_SetWorkspace(index); _SetWorkspace(index, moveFocusWindow);
UnlockAllWindows(); UnlockAllWindows();
_SendFakeMouseMoved(); _SendFakeMouseMoved();
@@ -2324,11 +2329,13 @@ Desktop::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
{ {
int32 index; int32 index;
link.Read<int32>(&index); link.Read<int32>(&index);
if (index == -1) if (index == -1)
index = fPreviousWorkspace; index = fPreviousWorkspace;
SetWorkspace(index); bool moveFocusWindow;
link.Read<bool>(&moveFocusWindow);
SetWorkspace(index, moveFocusWindow);
break; break;
} }
@@ -3070,25 +3077,28 @@ Desktop::_SetCurrentWorkspaceConfiguration()
You must hold the all window lock when calling this method. You must hold the all window lock when calling this method.
*/ */
void void
Desktop::_SetWorkspace(int32 index) Desktop::_SetWorkspace(int32 index, bool moveFocusWindow)
{ {
ASSERT_MULTI_WRITE_LOCKED(fWindowLock); ASSERT_MULTI_WRITE_LOCKED(fWindowLock);
int32 previousIndex = fCurrentWorkspace; int32 previousIndex = fCurrentWorkspace;
rgb_color previousColor = fWorkspaces[fCurrentWorkspace].Color(); rgb_color previousColor = fWorkspaces[fCurrentWorkspace].Color();
bool movedMouseEventWindow = false; bool movedMouseEventWindow = false;
Window* movedWindow = fMouseEventWindow;
if (movedWindow == NULL && moveFocusWindow)
movedWindow = FocusWindow();
if (fMouseEventWindow != NULL) { if (movedWindow != NULL) {
if (fMouseEventWindow->IsNormal()) { if (movedWindow->IsNormal()) {
if (!fMouseEventWindow->InWorkspace(index)) { if (!movedWindow->InWorkspace(index)) {
// The window currently being dragged will follow us to this // The window currently being dragged will follow us to this
// workspace if it's not already on it. // workspace if it's not already on it.
// But only normal windows are following // But only normal windows are following
uint32 oldWorkspaces = fMouseEventWindow->Workspaces(); uint32 oldWorkspaces = movedWindow->Workspaces();
_Windows(previousIndex).RemoveWindow(fMouseEventWindow); _Windows(previousIndex).RemoveWindow(movedWindow);
_Windows(index).AddWindow(fMouseEventWindow, _Windows(index).AddWindow(movedWindow,
fMouseEventWindow->Frontmost(_Windows(index).FirstWindow(), movedWindow->Frontmost(_Windows(index).FirstWindow(),
index)); index));
// TODO: subset windows will always flicker this way // TODO: subset windows will always flicker this way
@@ -3096,19 +3106,18 @@ Desktop::_SetWorkspace(int32 index)
movedMouseEventWindow = true; movedMouseEventWindow = true;
// send B_WORKSPACES_CHANGED message // send B_WORKSPACES_CHANGED message
fMouseEventWindow->WorkspacesChanged(oldWorkspaces, movedWindow->WorkspacesChanged(oldWorkspaces,
fMouseEventWindow->Workspaces()); movedWindow->Workspaces());
} else { } else {
// make sure it's frontmost // make sure it's frontmost
_Windows(index).RemoveWindow(fMouseEventWindow); _Windows(index).RemoveWindow(movedWindow);
_Windows(index).AddWindow(fMouseEventWindow, _Windows(index).AddWindow(movedWindow,
fMouseEventWindow->Frontmost(_Windows(index).FirstWindow(), movedWindow->Frontmost(_Windows(index).FirstWindow(),
index)); index));
} }
} }
fMouseEventWindow->Anchor(index).position movedWindow->Anchor(index).position = movedWindow->Frame().LeftTop();
= fMouseEventWindow->Frame().LeftTop();
} }
// build region of windows that are no longer visible in the new workspace // build region of windows that are no longer visible in the new workspace
@@ -3197,7 +3206,7 @@ Desktop::_SetWorkspace(int32 index)
_UpdateFronts(false); _UpdateFronts(false);
_UpdateFloating(previousIndex, index, _UpdateFloating(previousIndex, index,
movedMouseEventWindow ? fMouseEventWindow : NULL); movedMouseEventWindow ? movedWindow : NULL);
BRegion stillAvailableOnScreen; BRegion stillAvailableOnScreen;
_RebuildClippingForAllWindows(stillAvailableOnScreen); _RebuildClippingForAllWindows(stillAvailableOnScreen);
@@ -3215,9 +3224,9 @@ Desktop::_SetWorkspace(int32 index)
} }
if (window->InWorkspace(previousIndex) || window->IsHidden() if (window->InWorkspace(previousIndex) || window->IsHidden()
|| (window == fMouseEventWindow && fMouseEventWindow->IsNormal()) || (window == movedWindow && movedWindow->IsNormal())
|| (!window->IsNormal() || (!window->IsNormal()
&& window->HasInSubset(fMouseEventWindow))) { && window->HasInSubset(movedWindow))) {
// This window was visible before, and is already handled in the // This window was visible before, and is already handled in the
// above loop // above loop
continue; continue;
+6 -3
View File
@@ -146,8 +146,10 @@ public:
// Workspace methods // Workspace methods
void SetWorkspaceAsync(int32 index); void SetWorkspaceAsync(int32 index,
void SetWorkspace(int32 index); bool moveFocusWindow = false);
void SetWorkspace(int32 index,
bool moveFocusWindow = false);
int32 CurrentWorkspace() int32 CurrentWorkspace()
{ return fCurrentWorkspace; } { return fCurrentWorkspace; }
Workspace::Private& WorkspaceAt(int32 index) Workspace::Private& WorkspaceAt(int32 index)
@@ -292,7 +294,8 @@ private:
void _ScreenChanged(Screen* screen); void _ScreenChanged(Screen* screen);
void _SetCurrentWorkspaceConfiguration(); void _SetCurrentWorkspaceConfiguration();
void _SetWorkspace(int32 index); void _SetWorkspace(int32 index,
bool moveFocusWindow = false);
private: private:
friend class DesktopSettings; friend class DesktopSettings;