* 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:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2008, Haiku.
|
* Copyright 2001-2009, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -181,6 +181,7 @@ enum {
|
|||||||
AS_SET_WORKSPACE_COUNT,
|
AS_SET_WORKSPACE_COUNT,
|
||||||
AS_CURRENT_WORKSPACE,
|
AS_CURRENT_WORKSPACE,
|
||||||
AS_ACTIVATE_WORKSPACE,
|
AS_ACTIVATE_WORKSPACE,
|
||||||
|
AS_GET_WORKSPACE_LAYOUT,
|
||||||
AS_GET_SCROLLBAR_INFO,
|
AS_GET_SCROLLBAR_INFO,
|
||||||
AS_SET_SCROLLBAR_INFO,
|
AS_SET_SCROLLBAR_INFO,
|
||||||
AS_GET_MENU_INFO,
|
AS_GET_MENU_INFO,
|
||||||
|
|||||||
@@ -61,7 +61,8 @@
|
|||||||
// if we ever move this to a public namespace, we should also move the
|
// if we ever move this to a public namespace, we should also move the
|
||||||
// handling of this message into BApplication
|
// 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);
|
void do_minimize_team(BRect zoomRect, team_id team, bool zoom);
|
||||||
@@ -861,6 +862,47 @@ BWindow::DispatchMessage(BMessage* msg, BHandler* target)
|
|||||||
break;
|
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:
|
case B_MINIMIZE:
|
||||||
{
|
{
|
||||||
bool 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,
|
AddShortcut('H', B_COMMAND_KEY | B_CONTROL_KEY,
|
||||||
new BMessage(B_HIDE_APPLICATION), NULL);
|
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
|
// We set the default pulse rate, but we don't start the pulse
|
||||||
fPulseRate = 500000;
|
fPulseRate = 500000;
|
||||||
fPulseRunner = NULL;
|
fPulseRunner = NULL;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2008, Haiku.
|
* Copyright 2001-2009, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -845,6 +845,30 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
break;
|
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:
|
case AS_IDLE_TIME:
|
||||||
STRACE(("ServerApp %s: idle time\n", Signature()));
|
STRACE(("ServerApp %s: idle time\n", Signature()));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user