From f877af82fefb0143773ffcfadff86058f38cc578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 9 Feb 2006 18:53:36 +0000 Subject: [PATCH] * Implemented private functions do_minimize_team(), and do_bring_to_front_team() used by the Deskbar (for "Hide All" and "Show All"). The latter doesn't work correctly yet, though, it just maximizes all windows of that application. * Added a TODO to ServerWindow AS_MINIMIZE_WINDOW on how to make it work correctly. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16315 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/app/ServerProtocol.h | 2 ++ src/kits/interface/InterfaceDefs.cpp | 18 ++++++++++++--- src/servers/app/Desktop.cpp | 34 ++++++++++++++++++++++++++++ src/servers/app/Desktop.h | 3 +++ src/servers/app/ServerApp.cpp | 24 ++++++++++++++++---- src/servers/app/ServerWindow.cpp | 1 + 6 files changed, 74 insertions(+), 8 deletions(-) diff --git a/headers/private/app/ServerProtocol.h b/headers/private/app/ServerProtocol.h index caa3288bed..efc4aa1f79 100644 --- a/headers/private/app/ServerProtocol.h +++ b/headers/private/app/ServerProtocol.h @@ -36,6 +36,8 @@ enum { // Desktop definitions AS_GET_WINDOW_LIST, AS_GET_WINDOW_INFO, + AS_MINIMIZE_TEAM, + AS_BRING_TEAM_TO_FRONT, // Application definitions AS_CREATE_APP, diff --git a/src/kits/interface/InterfaceDefs.cpp b/src/kits/interface/InterfaceDefs.cpp index 8c290428b1..91fbb8acb6 100644 --- a/src/kits/interface/InterfaceDefs.cpp +++ b/src/kits/interface/InterfaceDefs.cpp @@ -1055,16 +1055,28 @@ get_token_list(team_id team, int32 *_count) void -do_bring_to_front_team(BRect zoomRect, team_id app, bool zoom) +do_bring_to_front_team(BRect zoomRect, team_id team, bool zoom) { - // ToDo: implement me, needed for Deskbar! + BPrivate::AppServerLink link; + + link.StartMessage(AS_BRING_TEAM_TO_FRONT); + link.Attach(team); + // we don't have any zooming effect + + link.Flush(); } void do_minimize_team(BRect zoomRect, team_id team, bool zoom) { - // ToDo: implement me, needed for Deskbar! + BPrivate::AppServerLink link; + + link.StartMessage(AS_MINIMIZE_TEAM); + link.Attach(team); + // we don't have any zooming effect + + link.Flush(); } diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index 196dab8c3b..1806c8a19c 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -1710,6 +1710,40 @@ Desktop::FindWindowLayerByClientToken(int32 token, team_id teamID) } +void +Desktop::MinimizeApplication(team_id team) +{ + BAutolock locker(fWindowLock); + + // Just minimize all windows of that application + + for (WindowLayer *window = fAllWindows.FirstWindow(); window != NULL; + window = window->NextWindow(kAllWindowList)) { + if (window->ServerWindow()->ClientTeam() != team) + continue; + + window->ServerWindow()->NotifyMinimize(true); + } +} + + +void +Desktop::BringApplicationToFront(team_id team) +{ + BAutolock locker(fWindowLock); + + // TODO: for now, just maximize all windows of that application + + for (WindowLayer *window = fAllWindows.FirstWindow(); window != NULL; + window = window->NextWindow(kAllWindowList)) { + if (window->ServerWindow()->ClientTeam() != team) + continue; + + window->ServerWindow()->NotifyMinimize(false); + } +} + + void Desktop::WriteWindowList(team_id team, BPrivate::LinkSender& sender) { diff --git a/src/servers/app/Desktop.h b/src/servers/app/Desktop.h index fad10e599f..ab410c1a84 100644 --- a/src/servers/app/Desktop.h +++ b/src/servers/app/Desktop.h @@ -158,6 +158,9 @@ class Desktop : public MessageLooper, public ScreenOwner { BRegion& BackgroundRegion() { return fBackgroundRegion; } + void MinimizeApplication(team_id team); + void BringApplicationToFront(team_id team); + void WriteWindowList(team_id team, BPrivate::LinkSender& sender); void WriteWindowInfo(int32 serverToken, diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index cbcf7ecd52..5e537b079f 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -426,18 +426,32 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) case AS_GET_WINDOW_LIST: { team_id team; - link.Read(&team); - - fDesktop->WriteWindowList(team, fLink.Sender()); + if (link.Read(&team) == B_OK) + fDesktop->WriteWindowList(team, fLink.Sender()); break; } case AS_GET_WINDOW_INFO: { int32 serverToken; - link.Read(&serverToken); + if (link.Read(&serverToken) == B_OK) + fDesktop->WriteWindowInfo(serverToken, fLink.Sender()); + break; + } - fDesktop->WriteWindowInfo(serverToken, fLink.Sender()); + case AS_MINIMIZE_TEAM: + { + team_id team; + if (link.Read(&team) == B_OK) + fDesktop->MinimizeApplication(team); + break; + } + + case AS_BRING_TEAM_TO_FRONT: + { + team_id team; + if (link.Read(&team) == B_OK) + fDesktop->BringApplicationToFront(team); break; } diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index a03294b64e..fb272ffd29 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -574,6 +574,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) DTRACE(("ServerWindow %s: Message AS_MINIMIZE_WINDOW\n", Title())); bool minimize; if (link.Read(&minimize) == B_OK) { + // TODO: this actually needs to take the window's show/hide counter into account if (minimize && !fWindowLayer->IsHidden()) Hide(); else if (!minimize && fWindowLayer->IsHidden())