From 9f0d28e92101f13976d806835d5cd3717cad8587 Mon Sep 17 00:00:00 2001 From: Adi Oanca Date: Sat, 29 Oct 2005 10:19:23 +0000 Subject: [PATCH] Fixed a stupid bug when checking if the window order changed. Added support for BWindow::Activate(false). Added some debug support for Workspace::WMState. Simplified a bit code for sending a window to back. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14563 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/RootLayer.cpp | 11 +++++++---- src/servers/app/RootLayer.h | 2 +- src/servers/app/ServerWindow.cpp | 6 +++++- src/servers/app/WinBorder.cpp | 7 +------ src/servers/app/Workspace.cpp | 14 ++++++++++++++ src/servers/app/Workspace.h | 3 +++ 6 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/servers/app/RootLayer.cpp b/src/servers/app/RootLayer.cpp index 20127fcea9..1264089e4d 100644 --- a/src/servers/app/RootLayer.cpp +++ b/src/servers/app/RootLayer.cpp @@ -864,7 +864,7 @@ RootLayer::RevealNewWMState(Workspace::State &oldWMState) invalidate = true; } else if (memcmp(oldWMState.WindowList.Items(), fWMState.WindowList.Items(), - fWMState.WindowList.CountItems()) != 0) { + fWMState.WindowList.CountItems()*sizeof(void*)) != 0) { invalidate = true; } @@ -908,7 +908,7 @@ RootLayer::RevealNewWMState(Workspace::State &oldWMState) } bool -RootLayer::SetActive(WinBorder* newActive) +RootLayer::SetActive(WinBorder* newActive, bool activate) { bool returnValue = false; uint32 workspaceIndex = newActive->Workspaces(); @@ -921,7 +921,10 @@ RootLayer::SetActive(WinBorder* newActive) Workspace::State oldWMState; ActiveWorkspace()->GetState(&oldWMState); - returnValue = ActiveWorkspace()->AttemptToActivate(newActive); + if (activate) + returnValue = ActiveWorkspace()->AttemptToActivate(newActive); + else + returnValue = ActiveWorkspace()->AttemptToMoveToBack(newActive); RevealNewWMState(oldWMState); } @@ -935,7 +938,7 @@ RootLayer::SetActive(WinBorder* newActive) // If this WinBorder does not appear in current workspace, // change to the first one who does. - if (!(workspaceIndex & (0x00000001UL << fActiveWksIndex))) { + if (activate && !(workspaceIndex & (0x00000001UL << fActiveWksIndex))) { // find an workspace index in which this Layer appears for (int32 i = 0; i < kMaxWorkspaceCount; i++) { if (workspaceIndex & (0x00000001UL << i)) { diff --git a/src/servers/app/RootLayer.h b/src/servers/app/RootLayer.h index 92ad894e4b..2a7f9f5a1b 100644 --- a/src/servers/app/RootLayer.h +++ b/src/servers/app/RootLayer.h @@ -93,7 +93,7 @@ public: inline WinBorder* Focus() const { return fWMState.Focus; } inline WinBorder* Front() const { return fWMState.Front; } inline WinBorder* Active() const { return fWMState.Active; } - bool SetActive(WinBorder* newActive); + bool SetActive(WinBorder* newActive, bool activate = true); inline void SetWorkspaceCount(int32 wksCount); inline int32 WorkspaceCount() const { return fWsCount; } diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index 4c09f20daf..dc57efc1fd 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -1470,8 +1470,12 @@ myRootLayer->Unlock(); case AS_ACTIVATE_WINDOW: { DTRACE(("ServerWindow %s: Message AS_ACTIVATE_WINDOW: Layer: %s\n", Title(), fCurrentLayer->Name())); + bool activate = true; + + link.Read(&activate); + if (myRootLayer && myRootLayer->Lock()) { - myRootLayer->SetActive(fWinBorder); + myRootLayer->SetActive(fWinBorder, activate); myRootLayer->Unlock(); } break; diff --git a/src/servers/app/WinBorder.cpp b/src/servers/app/WinBorder.cpp index 7124c9dc02..58cfb91d8b 100644 --- a/src/servers/app/WinBorder.cpp +++ b/src/servers/app/WinBorder.cpp @@ -523,12 +523,7 @@ WinBorder::MouseDown(const BMessage *msg) // based on what the Decorator returned, properly place this window. if (action == DEC_MOVETOBACK) { - Workspace::State oldWMState; - GetRootLayer()->ActiveWorkspace()->GetState(&oldWMState); - - GetRootLayer()->ActiveWorkspace()->MoveToBack(this); - - GetRootLayer()->RevealNewWMState(oldWMState); + GetRootLayer()->SetActive(this, false); } else { GetRootLayer()->SetNotifyLayer(this, B_POINTER_EVENTS, 0UL); diff --git a/src/servers/app/Workspace.cpp b/src/servers/app/Workspace.cpp index ed36cdba2a..13da854ae8 100644 --- a/src/servers/app/Workspace.cpp +++ b/src/servers/app/Workspace.cpp @@ -91,6 +91,20 @@ # define STRACESTREAM() ; #endif +void +Workspace::State::PrintToStream() +{ + printf("WS::State - Front: %s\n", Front? Front->Name(): "NULL"); + printf("WS::State - Focus: %s\n", Focus? Focus->Name(): "NULL"); + printf("WS::State - Active: %s\n", Active? Active->Name(): "NULL"); + + for (int32 i = 0; i < WindowList.CountItems(); ++i) { + Layer *l = (Layer*)WindowList.ItemAt(i); + if (l) + printf("\t %ld - %s\n", i, l->Name()); + } +} + //---------------------------------------------------------------------------------- /*! \brief Creates a new Workspace object which has its own resolution and background color. diff --git a/src/servers/app/Workspace.h b/src/servers/app/Workspace.h index 15e1396cd4..4d4e9b1a82 100644 --- a/src/servers/app/Workspace.h +++ b/src/servers/app/Workspace.h @@ -52,6 +52,9 @@ class Workspace { class State { public: State() : Front(NULL), Focus(NULL), WindowList(50) { } + + void PrintToStream(); + WinBorder* Front; WinBorder* Focus; WinBorder* Active;