* Added AS_GET_WORKSPACE_LAYOUT to get the number of columns/rows of the

workspaces.
* Added shortcuts Ctrl-Alt-{Left|Right|Up|Down} to switch to adjacent
  workspaces.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31824 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-07-27 17:22:11 +00:00
parent f2a3f51996
commit 47d9ed62d3
3 changed files with 87 additions and 3 deletions
+2 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2001-2008, Haiku.
* Copyright 2001-2009, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -181,6 +181,7 @@ enum {
AS_SET_WORKSPACE_COUNT,
AS_CURRENT_WORKSPACE,
AS_ACTIVATE_WORKSPACE,
AS_GET_WORKSPACE_LAYOUT,
AS_GET_SCROLLBAR_INFO,
AS_SET_SCROLLBAR_INFO,
AS_GET_MENU_INFO,
+60 -1
View File
@@ -61,7 +61,8 @@
// if we ever move this to a public namespace, we should also move the
// handling of this message into BApplication
#define _MINIMIZE_ '_WMZ'
#define _MINIMIZE_ '_WMZ'
#define _SWITCH_WORKSPACE_ '_SWS'
void do_minimize_team(BRect zoomRect, team_id team, bool zoom);
@@ -861,6 +862,47 @@ BWindow::DispatchMessage(BMessage* msg, BHandler* target)
break;
}
case _SWITCH_WORKSPACE_:
{
int32 deltaX = 0;
msg->FindInt32("delta_x", &deltaX);
int32 deltaY = 0;
msg->FindInt32("delta_y", &deltaY);
if (deltaX == 0 && deltaY == 0)
break;
BPrivate::AppServerLink link;
link.StartMessage(AS_GET_WORKSPACE_LAYOUT);
status_t status;
int32 columns;
int32 rows;
if (link.FlushWithReply(status) != B_OK || status != B_OK)
break;
link.Read<int32>(&columns);
link.Read<int32>(&rows);
int32 current = current_workspace();
int32 nextColumn = current % columns + deltaX;
int32 nextRow = current / columns + deltaY;
if (nextColumn >= columns)
nextColumn = columns - 1;
else if (nextColumn < 0)
nextColumn = 0;
if (nextRow >= rows)
nextRow = rows - 1;
else if (nextRow < 0)
nextRow = 0;
int32 next = nextColumn + nextRow * columns;
if (next != current)
activate_workspace(next);
break;
}
case B_MINIMIZE:
{
bool minimize;
@@ -2575,6 +2617,23 @@ BWindow::_InitData(BRect frame, const char* title, window_look look,
AddShortcut('H', B_COMMAND_KEY | B_CONTROL_KEY,
new BMessage(B_HIDE_APPLICATION), NULL);
// Workspace modifier keys
BMessage* message = new BMessage(_SWITCH_WORKSPACE_);
message->AddInt32("delta_x", -1);
AddShortcut(B_LEFT_ARROW, B_COMMAND_KEY | B_CONTROL_KEY, message, NULL);
message = new BMessage(_SWITCH_WORKSPACE_);
message->AddInt32("delta_x", 1);
AddShortcut(B_RIGHT_ARROW, B_COMMAND_KEY | B_CONTROL_KEY, message, NULL);
message = new BMessage(_SWITCH_WORKSPACE_);
message->AddInt32("delta_y", -1);
AddShortcut(B_UP_ARROW, B_COMMAND_KEY | B_CONTROL_KEY, message, NULL);
message = new BMessage(_SWITCH_WORKSPACE_);
message->AddInt32("delta_y", 1);
AddShortcut(B_DOWN_ARROW, B_COMMAND_KEY | B_CONTROL_KEY, message, NULL);
// We set the default pulse rate, but we don't start the pulse
fPulseRate = 500000;
fPulseRunner = NULL;
+25 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2001-2008, Haiku.
* Copyright 2001-2009, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -845,6 +845,30 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
break;
}
case AS_GET_WORKSPACE_LAYOUT:
{
// TODO: this is taken from WorkspacesView::_GetGrid() - this is
// only a temporary solution
DesktopSettings settings(fDesktop);
int32 count = settings.WorkspacesCount();
int32 squareRoot = (int32)sqrt(count);
int32 rows = 1;
for (int32 i = 2; i <= squareRoot; i++) {
if (count % i == 0)
rows = i;
}
int32 columns = count / rows;
fLink.StartMessage(B_OK);
fLink.Attach<int32>(columns);
fLink.Attach<int32>(rows);
fLink.Flush();
break;
}
case AS_IDLE_TIME:
STRACE(("ServerApp %s: idle time\n", Signature()));