* 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
This commit is contained in:
Axel Dörfler 2006-02-28 18:31:16 +00:00
parent 3b723f7914
commit bfe698736d
7 changed files with 71 additions and 9 deletions

View File

@ -33,11 +33,12 @@ enum {
AS_REGISTER_INPUT_SERVER = 1, AS_REGISTER_INPUT_SERVER = 1,
AS_GET_DESKTOP, AS_GET_DESKTOP,
// Desktop definitions // Desktop definitions (through the ServerApp, though)
AS_GET_WINDOW_LIST, AS_GET_WINDOW_LIST,
AS_GET_WINDOW_INFO, AS_GET_WINDOW_INFO,
AS_MINIMIZE_TEAM, AS_MINIMIZE_TEAM,
AS_BRING_TEAM_TO_FRONT, AS_BRING_TEAM_TO_FRONT,
AS_WINDOW_ACTION,
// Application definitions // Application definitions
AS_CREATE_APP, AS_CREATE_APP,

View File

@ -999,10 +999,17 @@ void do_minimize_team(BRect zoomRect, team_id team, bool zoom);
void void
do_window_action(int32 window_id, int32 action, do_window_action(int32 windowToken, int32 action,
BRect zoomRect, bool zoom) BRect zoomRect, bool zoom)
{ {
// ToDo: implement me, needed for Deskbar! BPrivate::AppServerLink link;
link.StartMessage(AS_WINDOW_ACTION);
link.Attach<int32>(windowToken);
link.Attach<int32>(action);
// we don't have any zooming effect
link.Flush();
} }

View File

@ -1103,6 +1103,11 @@ Desktop::ActivateWindow(WindowLayer* window)
{ {
// printf("ActivateWindow(%p, %s)\n", window, window ? window->Title() : "<none>"); // printf("ActivateWindow(%p, %s)\n", window, window ? window->Title() : "<none>");
// 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) { if (window == NULL) {
fBack = NULL; fBack = NULL;
fFront = 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 void
Desktop::WriteWindowList(team_id team, BPrivate::LinkSender& sender) Desktop::WriteWindowList(team_id team, BPrivate::LinkSender& sender)
{ {

View File

@ -162,6 +162,7 @@ class Desktop : public MessageLooper, public ScreenOwner {
void MinimizeApplication(team_id team); void MinimizeApplication(team_id team);
void BringApplicationToFront(team_id team); void BringApplicationToFront(team_id team);
void WindowAction(int32 windowToken, int32 action);
void WriteWindowList(team_id team, void WriteWindowList(team_id team,
BPrivate::LinkSender& sender); BPrivate::LinkSender& sender);

View File

@ -455,6 +455,19 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
break; break;
} }
case AS_WINDOW_ACTION:
{
int32 token;
int32 action;
link.Read<int32>(&token);
if (link.Read<int32>(&action) != B_OK)
break;
fDesktop->WindowAction(token, action);
break;
}
case AS_UPDATE_COLORS: case AS_UPDATE_COLORS:
{ {
// NOTE: R2: Eventually we will have windows which will notify their children of changes in // 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++) { for(int32 i = 0; i < fWindowList.CountItems(); i++) {
win=(ServerWindow*)fWindowList.ItemAt(i); win=(ServerWindow*)fWindowList.ItemAt(i);
win->GetWindowLayer()->UpdateColors(); win->Window()->UpdateColors();
win->SendMessageToClient(AS_UPDATE_COLORS, msg); win->SendMessageToClient(AS_UPDATE_COLORS, msg);
} }
*/ break; */ break;
@ -483,7 +496,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
for(int32 i=0; i<fSWindowList->CountItems(); i++) for(int32 i=0; i<fSWindowList->CountItems(); i++)
{ {
win=(ServerWindow*)fSWindowList->ItemAt(i); win=(ServerWindow*)fSWindowList->ItemAt(i);
win->GetWindowLayer()->UpdateFont(); win->Window()->UpdateFont();
win->SendMessageToClient(AS_UPDATE_FONTS, msg); win->SendMessageToClient(AS_UPDATE_FONTS, msg);
} }
*/ break; */ break;
@ -598,7 +611,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
/* for (int32 i = 0; i < fWindowList.CountItems(); i++) { /* for (int32 i = 0; i < fWindowList.CountItems(); i++) {
ServerWindow *window = fWindowList.ItemAt(i); ServerWindow *window = fWindowList.ItemAt(i);
window->Lock(); window->Lock();
const_cast<WindowLayer *>(window->GetWindowLayer())->UpdateDecorator(); const_cast<WindowLayer *>(window->Window())->UpdateDecorator();
window->Unlock(); window->Unlock();
} }
*/ break; */ break;
@ -2564,7 +2577,7 @@ ServerApp::InWorkspace(int32 index) const
for (int32 i = fWindowList.CountItems(); i-- > 0;) { for (int32 i = fWindowList.CountItems(); i-- > 0;) {
ServerWindow* window = fWindowList.ItemAt(i); ServerWindow* window = fWindowList.ItemAt(i);
const WindowLayer* layer = window->GetWindowLayer(); const WindowLayer* layer = window->Window();
// only normal and unhidden windows count // only normal and unhidden windows count
@ -2588,7 +2601,7 @@ ServerApp::Workspaces() const
for (int32 i = fWindowList.CountItems(); i-- > 0;) { for (int32 i = fWindowList.CountItems(); i-- > 0;) {
ServerWindow* window = fWindowList.ItemAt(i); ServerWindow* window = fWindowList.ItemAt(i);
const WindowLayer* layer = window->GetWindowLayer(); const WindowLayer* layer = window->Window();
// only normal and unhidden windows count // only normal and unhidden windows count

View File

@ -407,6 +407,9 @@ ServerWindow::NotifyQuitRequested()
void void
ServerWindow::NotifyMinimize(bool minimize) ServerWindow::NotifyMinimize(bool minimize)
{ {
if (fWindowLayer->Feel() != B_NORMAL_WINDOW_FEEL)
return;
// The client is responsible for the actual minimization // The client is responsible for the actual minimization
BMessage msg(B_MINIMIZE); 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* ViewLayer*
ServerWindow::_CreateLayerTree(BPrivate::LinkReceiver &link, ViewLayer **_parent) ServerWindow::_CreateLayerTree(BPrivate::LinkReceiver &link, ViewLayer **_parent)
{ {

View File

@ -82,7 +82,7 @@ public:
// to who we belong. who do we own. our title. // to who we belong. who do we own. our title.
inline ServerApp* App() const { return fServerApp; } inline ServerApp* App() const { return fServerApp; }
::Desktop* Desktop() const { return fDesktop; } ::Desktop* Desktop() const { return fDesktop; }
inline const WindowLayer* GetWindowLayer() const { return fWindowLayer; } ::WindowLayer* Window() const;
void SetTitle(const char* newTitle); void SetTitle(const char* newTitle);
inline const char* Title() const { return fTitle; } inline const char* Title() const { return fTitle; }