From bfe698736ddb0a6dabeb8688120c2b1d20bcbf0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 28 Feb 2006 18:31:16 +0000 Subject: [PATCH] * Implemented private do_window_action() function, used by the Deskbar to bring windows to front (or minimize them). * Desktop::ActivateWindow() no longer crashes in case the window to be activated is not on the current workspace - instead, it doesn't do anything at this point. IOW it doesn't handle workspace activation at all, yet. * Renamed ServerWindow::GetWindowLayer() to ServerWindow::Window(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16550 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/app/ServerProtocol.h | 3 ++- src/kits/interface/InterfaceDefs.cpp | 11 +++++++++-- src/servers/app/Desktop.cpp | 29 ++++++++++++++++++++++++++++ src/servers/app/Desktop.h | 1 + src/servers/app/ServerApp.cpp | 23 +++++++++++++++++----- src/servers/app/ServerWindow.cpp | 11 +++++++++++ src/servers/app/ServerWindow.h | 2 +- 7 files changed, 71 insertions(+), 9 deletions(-) diff --git a/headers/private/app/ServerProtocol.h b/headers/private/app/ServerProtocol.h index 6fd75a7bd2..79092483d6 100644 --- a/headers/private/app/ServerProtocol.h +++ b/headers/private/app/ServerProtocol.h @@ -33,11 +33,12 @@ enum { AS_REGISTER_INPUT_SERVER = 1, AS_GET_DESKTOP, - // Desktop definitions + // Desktop definitions (through the ServerApp, though) AS_GET_WINDOW_LIST, AS_GET_WINDOW_INFO, AS_MINIMIZE_TEAM, AS_BRING_TEAM_TO_FRONT, + AS_WINDOW_ACTION, // Application definitions AS_CREATE_APP, diff --git a/src/kits/interface/InterfaceDefs.cpp b/src/kits/interface/InterfaceDefs.cpp index 1272f264e1..82e7cfac6c 100644 --- a/src/kits/interface/InterfaceDefs.cpp +++ b/src/kits/interface/InterfaceDefs.cpp @@ -999,10 +999,17 @@ void do_minimize_team(BRect zoomRect, team_id team, bool zoom); void -do_window_action(int32 window_id, int32 action, +do_window_action(int32 windowToken, int32 action, BRect zoomRect, bool zoom) { - // ToDo: implement me, needed for Deskbar! + BPrivate::AppServerLink link; + + link.StartMessage(AS_WINDOW_ACTION); + link.Attach(windowToken); + link.Attach(action); + // we don't have any zooming effect + + link.Flush(); } diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index 6ca95b1cd2..af862aef43 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -1103,6 +1103,11 @@ Desktop::ActivateWindow(WindowLayer* window) { // printf("ActivateWindow(%p, %s)\n", window, window ? window->Title() : ""); + // TODO: handle this case correctly! (ie. honour B_NOT_ANCHORED_ON_ACTIVATE, + // B_NO_WORKSPACE_ACTIVATION, switch workspaces, ...) + if (!window->InWorkspace(fCurrentWorkspace)) + return; + if (window == NULL) { fBack = NULL; fFront = NULL; @@ -1808,6 +1813,30 @@ Desktop::BringApplicationToFront(team_id team) } +void +Desktop::WindowAction(int32 windowToken, int32 action) +{ + if (action != B_MINIMIZE_WINDOW && action != B_BRING_TO_FRONT) + return; + + LockAllWindows(); + + ::ServerWindow* serverWindow; + if (BPrivate::gDefaultTokens.GetToken(windowToken, + B_SERVER_TOKEN, (void**)&serverWindow) != B_OK) + return; + + if (action == B_BRING_TO_FRONT + && !serverWindow->Window()->IsMinimized()) { + // the window is visible, we just need to make it the front window + ActivateWindow(serverWindow->Window()); + } else + serverWindow->NotifyMinimize(action == B_MINIMIZE_WINDOW); + + UnlockAllWindows(); +} + + void Desktop::WriteWindowList(team_id team, BPrivate::LinkSender& sender) { diff --git a/src/servers/app/Desktop.h b/src/servers/app/Desktop.h index a7cd51fc1e..72d1e3e1e3 100644 --- a/src/servers/app/Desktop.h +++ b/src/servers/app/Desktop.h @@ -162,6 +162,7 @@ class Desktop : public MessageLooper, public ScreenOwner { void MinimizeApplication(team_id team); void BringApplicationToFront(team_id team); + void WindowAction(int32 windowToken, int32 action); void WriteWindowList(team_id team, BPrivate::LinkSender& sender); diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index 9402d6d8c9..e31d0cb508 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -455,6 +455,19 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) break; } + case AS_WINDOW_ACTION: + { + int32 token; + int32 action; + + link.Read(&token); + if (link.Read(&action) != B_OK) + break; + + fDesktop->WindowAction(token, action); + break; + } + case AS_UPDATE_COLORS: { // NOTE: R2: Eventually we will have windows which will notify their children of changes in @@ -466,7 +479,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) for(int32 i = 0; i < fWindowList.CountItems(); i++) { win=(ServerWindow*)fWindowList.ItemAt(i); - win->GetWindowLayer()->UpdateColors(); + win->Window()->UpdateColors(); win->SendMessageToClient(AS_UPDATE_COLORS, msg); } */ break; @@ -483,7 +496,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) for(int32 i=0; iCountItems(); i++) { win=(ServerWindow*)fSWindowList->ItemAt(i); - win->GetWindowLayer()->UpdateFont(); + win->Window()->UpdateFont(); win->SendMessageToClient(AS_UPDATE_FONTS, msg); } */ break; @@ -598,7 +611,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) /* for (int32 i = 0; i < fWindowList.CountItems(); i++) { ServerWindow *window = fWindowList.ItemAt(i); window->Lock(); - const_cast(window->GetWindowLayer())->UpdateDecorator(); + const_cast(window->Window())->UpdateDecorator(); window->Unlock(); } */ break; @@ -2564,7 +2577,7 @@ ServerApp::InWorkspace(int32 index) const for (int32 i = fWindowList.CountItems(); i-- > 0;) { ServerWindow* window = fWindowList.ItemAt(i); - const WindowLayer* layer = window->GetWindowLayer(); + const WindowLayer* layer = window->Window(); // only normal and unhidden windows count @@ -2588,7 +2601,7 @@ ServerApp::Workspaces() const for (int32 i = fWindowList.CountItems(); i-- > 0;) { ServerWindow* window = fWindowList.ItemAt(i); - const WindowLayer* layer = window->GetWindowLayer(); + const WindowLayer* layer = window->Window(); // only normal and unhidden windows count diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index 724f504a2d..7c63968c66 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -407,6 +407,9 @@ ServerWindow::NotifyQuitRequested() void ServerWindow::NotifyMinimize(bool minimize) { + if (fWindowLayer->Feel() != B_NORMAL_WINDOW_FEEL) + return; + // The client is responsible for the actual minimization BMessage msg(B_MINIMIZE); @@ -451,6 +454,14 @@ ServerWindow::GetInfo(window_info& info) } +WindowLayer* +ServerWindow::Window() const +{ + // TODO: ensure desktop is locked! + return fWindowLayer; +} + + ViewLayer* ServerWindow::_CreateLayerTree(BPrivate::LinkReceiver &link, ViewLayer **_parent) { diff --git a/src/servers/app/ServerWindow.h b/src/servers/app/ServerWindow.h index ee730b70fa..dafebca033 100644 --- a/src/servers/app/ServerWindow.h +++ b/src/servers/app/ServerWindow.h @@ -82,7 +82,7 @@ public: // to who we belong. who do we own. our title. inline ServerApp* App() const { return fServerApp; } ::Desktop* Desktop() const { return fDesktop; } - inline const WindowLayer* GetWindowLayer() const { return fWindowLayer; } + ::WindowLayer* Window() const; void SetTitle(const char* newTitle); inline const char* Title() const { return fTitle; }