* When switching Terminals via Command-G, we now also take the workspace

information into account, ie. we now behave like the Terminal on BeOS, and only
  allow to switch between the Terminal windows of one workspace.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28130 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-10-15 12:48:19 +00:00
parent 628808166c
commit 6a63492f6c
2 changed files with 29 additions and 21 deletions
+27 -19
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2007, Haiku. * Copyright 2001-2008, Haiku.
* Copyright (c) 2003-2004 Kian Duffy <[email protected]> * Copyright (c) 2003-2004 Kian Duffy <[email protected]>
* Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. * Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
* *
@@ -37,7 +37,7 @@ static bool sUsageRequested = false;
const ulong MSG_ACTIVATE_TERM = 'msat'; const ulong MSG_ACTIVATE_TERM = 'msat';
const ulong MSG_TERM_IS_MINIMIZE = 'mtim'; const ulong MSG_TERM_WINDOW_INFO = 'mtwi';
TermApp::TermApp() TermApp::TermApp()
@@ -132,7 +132,7 @@ TermApp::AboutRequested()
BAlert *alert = new BAlert("about", "Terminal\n" BAlert *alert = new BAlert("about", "Terminal\n"
"\twritten by Kazuho Okui and Takashi Murai\n" "\twritten by Kazuho Okui and Takashi Murai\n"
"\tupdated by Kian Duffy and others\n\n" "\tupdated by Kian Duffy and others\n\n"
"\tCopyright " B_UTF8_COPYRIGHT "2003-2005, Haiku.\n", "Ok"); "\tCopyright " B_UTF8_COPYRIGHT "2003-2008, Haiku.\n", "Ok");
BTextView *view = alert->TextView(); BTextView *view = alert->TextView();
view->SetStylable(true); view->SetStylable(true);
@@ -159,10 +159,11 @@ TermApp::MessageReceived(BMessage* msg)
fTermWindow->Activate(); fTermWindow->Activate();
break; break;
case MSG_TERM_IS_MINIMIZE: case MSG_TERM_WINDOW_INFO:
{ {
BMessage reply(B_REPLY); BMessage reply(B_REPLY);
reply.AddBool("result", fTermWindow->IsMinimized()); reply.AddBool("minimized", fTermWindow->IsMinimized());
reply.AddInt32("workspaces", fTermWindow->Workspaces());
msg->SendReply(&reply); msg->SendReply(&reply);
break; break;
} }
@@ -265,15 +266,15 @@ TermApp::_ActivateTermWindow(team_id id)
void void
TermApp::_SwitchTerm() TermApp::_SwitchTerm()
{ {
team_id myId = be_app->Team(); // My id team_id myId = be_app->Team();
BList teams; BList teams;
be_roster->GetAppList(TERM_SIGNATURE, &teams); be_roster->GetAppList(TERM_SIGNATURE, &teams);
int32 numTerms = teams.CountItems(); int32 numTerms = teams.CountItems();
if (numTerms <= 1)
return;
if (numTerms <= 1 ) // Find our position in the app teams.
return; //Can't Switch !!
// Find position of mine in app teams.
int32 i; int32 i;
for (i = 0; i < numTerms; i++) { for (i = 0; i < numTerms; i++) {
@@ -284,7 +285,7 @@ TermApp::_SwitchTerm()
do { do {
if (--i < 0) if (--i < 0)
i = numTerms - 1; i = numTerms - 1;
} while (_IsMinimized(reinterpret_cast<team_id>(teams.ItemAt(i)))); } while (!_IsSwitchTarget(reinterpret_cast<team_id>(teams.ItemAt(i))));
// Activate switched terminal. // Activate switched terminal.
_ActivateTermWindow(reinterpret_cast<team_id>(teams.ItemAt(i))); _ActivateTermWindow(reinterpret_cast<team_id>(teams.ItemAt(i)));
@@ -292,19 +293,26 @@ TermApp::_SwitchTerm()
bool bool
TermApp::_IsMinimized(team_id id) TermApp::_IsSwitchTarget(team_id id)
{ {
BMessenger app(TERM_SIGNATURE, id); BMessenger app(TERM_SIGNATURE, id);
if (app.IsTargetLocal()) if (app.IsTargetLocal()) {
return fTermWindow->IsMinimized(); return !fTermWindow->IsMinimized()
&& (fTermWindow->Workspaces() & (1L << current_workspace())) != 0;
}
BMessage reply; BMessage reply;
if (app.SendMessage(MSG_TERM_IS_MINIMIZE, &reply) != B_OK) if (app.SendMessage(MSG_TERM_WINDOW_INFO, &reply) != B_OK)
return true; return false;
bool hidden; bool minimized;
reply.FindBool("result", &hidden); int32 workspaces;
return hidden; if (reply.FindBool("minimized", &minimized) != B_OK
|| reply.FindInt32("workspaces", &workspaces) != B_OK)
return false;
return !minimized
&& (workspaces & (1L << current_workspace())) != 0;
} }
+2 -2
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2007, Haiku. * Copyright 2001-2008, Haiku.
* Copyright (c) 2003-4 Kian Duffy <[email protected]> * Copyright (c) 2003-4 Kian Duffy <[email protected]>
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai. * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
* *
@@ -55,7 +55,7 @@ class TermApp : public BApplication {
status_t _MakeTermWindow(BRect& frame); status_t _MakeTermWindow(BRect& frame);
void _SwitchTerm(); void _SwitchTerm();
void _ActivateTermWindow(team_id id); void _ActivateTermWindow(team_id id);
bool _IsMinimized(team_id id); bool _IsSwitchTarget(team_id id);
void _SanitizeIDs(BMessage* data, uint8* windows, ssize_t length); void _SanitizeIDs(BMessage* data, uint8* windows, ssize_t length);
bool _UpdateIDs(bool set, uint8* windows, ssize_t maxLength, bool _UpdateIDs(bool set, uint8* windows, ssize_t maxLength,
ssize_t* _length); ssize_t* _length);