diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index 5dd1e69aa1..22cae34289 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -238,6 +238,23 @@ MouseFilter::Filter(BMessage* message, EventTarget** _target, int32* _viewToken) // #pragma mark - +static inline uint32 +workspace_to_workspaces(int32 index) +{ + return 1UL << index; +} + + +static inline bool +workspaces_on_workspace(int32 index, uint32 workspaces) +{ + return (workspaces & (1UL << index)) != 0; +} + + +// #pragma mark - + + Desktop::Desktop(uid_t userID) : MessageLooper("desktop"), fUserID(userID), @@ -540,10 +557,6 @@ Desktop::BroadcastToAllApps(int32 code) for (int32 i = 0; i < fAppList.CountItems(); i++) { ServerApp *app = (ServerApp *)fAppList.ItemAt(i); - if (!app) { - printf("PANIC in Broadcast()\n"); - continue; - } app->PostMessage(code); } } @@ -555,10 +568,14 @@ Desktop::SetWorkspace(int32 index) BAutolock _(this); DesktopSettings settings(this); - if (index < 0 || index >= settings.WorkspacesCount()) + if (index < 0 || index >= settings.WorkspacesCount() || index == fCurrentWorkspace) return; - fRootLayer->SetWorkspace(index, fWorkspaces[index]); + int32 previousIndex = fCurrentWorkspace; + fCurrentWorkspace = index; + + fRootLayer->SetWorkspace(index, fWorkspaces[previousIndex], + fWorkspaces[index]); } @@ -604,8 +621,10 @@ Desktop::SendBehindWindow(WindowLayer* windowLayer, WindowLayer* front) void Desktop::ShowWindow(WindowLayer* window) { - if (!window->IsHidden()) + if (!window->IsHidden() || window->Parent() == NULL) { + window->Show(false); return; + } fRootLayer->ShowWindowLayer(window); @@ -635,64 +654,104 @@ Desktop::ShowWindow(WindowLayer* window) void Desktop::HideWindow(WindowLayer* window) { + if (window->IsHidden() || window->Parent() == NULL) { + window->Hide(false); + return; + } + fRootLayer->HideWindowLayer(window); } +/*! + \brief Adds or removes the window to or from the workspaces it's on. +*/ void -Desktop::SetWindowWorkspaces(WindowLayer* windowLayer, uint32 workspaces) +Desktop::_ChangeWindowWorkspaces(WindowLayer* window, uint32 oldWorkspaces, + uint32 newWorkspaces) { - BAutolock _(this); + // apply changes to the workspaces' window list + // (and RootLayer, for the current workspace) - windowLayer->SetWorkspaces(workspaces); - - // is the window still visible on screen? - bool remove = (workspaces & (1UL << CurrentWorkspace())) == 0; - - if (remove && windowLayer->Parent() != NULL) { - // the window is no longer visible on screen - fRootLayer->RemoveWindowLayer(windowLayer); - } else if (!remove && windowLayer->Parent() == NULL) { - // the window is now visible on screen - fRootLayer->AddWindowLayer(windowLayer); + for (int32 i = 0; i < kMaxWorkspaces; i++) { + if (workspaces_on_workspace(i, oldWorkspaces)) { + // window is on this workspace, is it anymore? + if (!workspaces_on_workspace(i, newWorkspaces)) { + if (i == CurrentWorkspace()) + RootLayer()->RemoveWindowLayer(window); + else + fWorkspaces[i].RemoveWindow(window); + } + } else { + // window was not on this workspace, is it now? + if (workspaces_on_workspace(i, newWorkspaces)) { + if (i == CurrentWorkspace()) + RootLayer()->AddWindowLayer(window); + else + fWorkspaces[i].AddWindow(window); + } + } } } void -Desktop::AddWindowLayer(WindowLayer *windowLayer) +Desktop::SetWindowWorkspaces(WindowLayer* window, uint32 workspaces) { - Lock(); + BAutolock _(this); + + if (workspaces == B_CURRENT_WORKSPACE) + workspaces = workspace_to_workspaces(CurrentWorkspace()); - if (fWindowLayerList.HasItem(windowLayer)) { + _ChangeWindowWorkspaces(window, window->Workspaces(), workspaces); + window->SetWorkspaces(workspaces); +} + + +void +Desktop::AddWindow(WindowLayer *window) +{ + BAutolock _(this); + + if (fWindowLayerList.HasItem(window)) { Unlock(); debugger("AddWindowLayer: WindowLayer already in Desktop list\n"); return; } - fWindowLayerList.AddItem(windowLayer); - Unlock(); + fWindowLayerList.AddItem(window); - RootLayer()->AddWindowLayer(windowLayer); + if (window->Workspaces() == B_CURRENT_WORKSPACE) + window->SetWorkspaces(workspace_to_workspaces(CurrentWorkspace())); + + _ChangeWindowWorkspaces(window, 0, window->Workspaces()); } void -Desktop::RemoveWindowLayer(WindowLayer *windowLayer) +Desktop::RemoveWindow(WindowLayer *window) { - Lock(); - fWindowLayerList.RemoveItem(windowLayer); - Unlock(); + BAutolock _(this); - RootLayer()->RemoveWindowLayer(windowLayer); + fWindowLayerList.RemoveItem(window); + _ChangeWindowWorkspaces(window, window->Workspaces(), 0); - if (windowLayer->Window() != NULL) - EventDispatcher().RemoveTarget(windowLayer->Window()->EventTarget()); + // make sure this window won't get any events anymore + + if (window->Window() != NULL) + EventDispatcher().RemoveTarget(window->Window()->EventTarget()); } void -Desktop::SetWindowLayerFeel(WindowLayer *winBorder, uint32 feel) +Desktop::SetWindowFeel(WindowLayer *window, uint32 feel) +{ + // TODO: implement +} + + +void +Desktop::SetWindowLook(WindowLayer *window, uint32 look) { // TODO: implement } diff --git a/src/servers/app/Desktop.h b/src/servers/app/Desktop.h index 48bd13d703..34ffa5fa0a 100644 --- a/src/servers/app/Desktop.h +++ b/src/servers/app/Desktop.h @@ -92,12 +92,13 @@ class Desktop : public MessageLooper, public ScreenOwner { void ShowWindow(WindowLayer* window); void HideWindow(WindowLayer* window); - void SetWindowWorkspaces(WindowLayer* window, uint32 workspaces); + void SetWindowWorkspaces(WindowLayer* window, + uint32 workspaces); - void AddWindowLayer(WindowLayer *windowLayer); - void RemoveWindowLayer(WindowLayer *windowLayer); - void SetWindowLayerFeel(WindowLayer *windowLayer, - uint32 feel); + void AddWindow(WindowLayer *window); + void RemoveWindow(WindowLayer *window); + void SetWindowFeel(WindowLayer *window, uint32 feel); + void SetWindowLook(WindowLayer *window, uint32 look); WindowLayer* FindWindowLayerByClientToken(int32 token, team_id teamID); //WindowLayer* FindWindowLayerByServerToken(int32 token); @@ -111,6 +112,8 @@ class Desktop : public MessageLooper, public ScreenOwner { BPrivate::LinkSender& sender); private: + void _ChangeWindowWorkspaces(WindowLayer* window, + uint32 oldWorkspaces, uint32 newWorkspaces); status_t _ActivateApp(team_id team); void _GetLooperName(char* name, size_t size); void _PrepareQuit(); diff --git a/src/servers/app/DesktopSettings.cpp b/src/servers/app/DesktopSettings.cpp index 525ba06b8b..581ebd645a 100644 --- a/src/servers/app/DesktopSettings.cpp +++ b/src/servers/app/DesktopSettings.cpp @@ -56,7 +56,7 @@ DesktopSettings::Private::_SetDefaults() fMenuInfo.click_to_open = true; fMenuInfo.triggers_always_shown = false; - fWorkspacesCount = 1; + fWorkspacesCount = 4; } diff --git a/src/servers/app/RootLayer.cpp b/src/servers/app/RootLayer.cpp index 2dbc241a5c..e1447f9c81 100644 --- a/src/servers/app/RootLayer.cpp +++ b/src/servers/app/RootLayer.cpp @@ -41,13 +41,11 @@ static const float kGoldenProportion = (sqrtf(5.0) - 1.0) / 2.0; #endif -//#define DEBUG_ROOT_LAYER -#define APPSERVER_ROOTLAYER_SHOW_WORKSPACE_NUMBER - -#ifdef DEBUG_ROOT_LAYER - #define STRACE(a) printf a +//#define TRACE_ROOT_LAYER +#ifdef TRACE_ROOT_LAYER +# define STRACE(a) printf a #else - #define STRACE(a) ; +# define STRACE(a) ; #endif @@ -367,30 +365,35 @@ RootLayer::_UpdateWorkspace(Workspace& workspace) { fColor = workspace.Color(); - // TODO: for on-screen debugging stuff only +#if ON_SCREEN_DEBUGGING_INFO fDrawState->SetLowColor(fColor); +#endif } void -RootLayer::SetWorkspace(int32 index, Workspace& workspace) +RootLayer::SetWorkspace(int32 index, Workspace& previousWorkspace, + Workspace& workspace) { BAutolock _(fAllRegionsLock); int32 previousIndex = fWorkspace; // build region of windows that are no longer visible in the new workspace + // and move windows to the previous workspace's window list BRegion changed; - for (Layer* layer = FirstChild(); layer != NULL; layer = layer->NextLayer()) { - _RemoveChildFromList(layer); + while (WindowLayer* window = (WindowLayer*)FirstChild()) { + // move the window into the workspace's window list + _RemoveChildFromList(window); - // TODO: we should only allow WindowLayer as our children, anyway - WindowLayer* window = dynamic_cast(layer); - if (window == NULL || window->IsHidden()) + BPoint position = window->Frame().LeftTop(); + previousWorkspace.AddWindow(window, &position); + + if (window->IsHidden()) continue; - if ((window->Workspaces() & (1UL << index)) == 0) { + if (!window->OnWorkspace(index)) { // this window will no longer be visible changed.Include(&window->FullVisible()); } @@ -402,20 +405,27 @@ RootLayer::SetWorkspace(int32 index, Workspace& workspace) // add new windows, and include them in the changed region - but only // those that were not visible before (or whose position changed) - for (int32 i = 0; i < workspace.CountWindows(); i++) { - window_layer_info* info = workspace.WindowAt(i); + while (workspace.CountWindows() != 0) { + window_layer_info* info = workspace.WindowAt(0); WindowLayer* window = info->window; + BPoint position = info->position; + + // move window into the RootLayer's list + workspace.RemoveWindowAt(0); + _AddChildToList(window); if (window->IsHidden()) continue; - if (info->position == kInvalidWindowPosition) { + if (position == kInvalidWindowPosition) { // if you enter a workspace for the first time, the position // of the window in the previous workspace is adopted - info->position = window->Frame().LeftTop(); + position = window->Frame().LeftTop(); + // TODO: make sure the window is still on-screen if it + // was before! } - if ((window->Workspaces() & (1UL << previousIndex)) == 0) { + if (!window->OnWorkspace(previousIndex)) { // this window was not visible before // TODO: what we really want here is the visible region of the window @@ -423,11 +433,11 @@ RootLayer::SetWorkspace(int32 index, Workspace& workspace) window->GetOnScreenRegion(region); changed.Include(®ion); - } else if (window->Frame().LeftTop() != info->position) { + } else if (window->Frame().LeftTop() != position) { // the window was visible before, but its on-screen location changed - BPoint offset = info->position - window->Frame().LeftTop(); + BPoint offset = position - window->Frame().LeftTop(); window->MoveBy(offset.x, offset.y); - + // TODO: we're playing dumb here - what we need is a MoveBy() that // gives us a dirty region back, and since the new clipping code // will give us just that, we don't take any special measurement @@ -437,10 +447,11 @@ RootLayer::SetWorkspace(int32 index, Workspace& workspace) // the window is still visible and on the same location continue; } - - _AddChildToList(window); } + _UpdateFronts(); + _SetFocus(Front(), changed); + MarkForRebuild(changed); TriggerRebuild(); @@ -459,6 +470,9 @@ RootLayer::HideWindowLayer(WindowLayer* windowLayer) windowLayer->Hide(); _UpdateFronts(); + if (dynamic_cast(windowLayer->TopLayer()) != NULL) + fWorkspacesLayer = NULL; + // TODO: if this window has any floating windows, remove them here MarkForRebuild(changed); @@ -499,6 +513,9 @@ RootLayer::ShowWindowLayer(WindowLayer* windowLayer, bool toFront) _WindowsChanged(changed); MarkForRedraw(changed); TriggerRedraw(); + + if (dynamic_cast(windowLayer->TopLayer()) != NULL) + fWorkspacesLayer = windowLayer->TopLayer(); } @@ -560,6 +577,8 @@ RootLayer::LayerRemoved(Layer* layer) { if (fMouseEventWindow == layer) fMouseEventWindow = NULL; + if (fWorkspacesLayer == layer) + fWorkspacesLayer = NULL; } @@ -577,7 +596,7 @@ RootLayer::SetDragMessage(BMessage* msg) BMessage * -RootLayer::DragMessage(void) const +RootLayer::DragMessage() const { return fDragMessage; } @@ -588,13 +607,6 @@ RootLayer::Draw(const BRect& rect) { fDriver->FillRect(rect, fColor); -#ifdef APPSERVER_ROOTLAYER_SHOW_WORKSPACE_NUMBER - char string[30]; - sprintf(string, "Workspace %ld", fWorkspace + 1); - fDriver->DrawString(string, strlen(string), BPoint(5, 15), - fDrawState); -#endif // APPSERVER_ROOTLAYER_SHOW_WORKSPACE_NUMBER - #if ON_SCREEN_DEBUGGING_INFO BPoint location(5, 40); float textHeight = 15.0; // be lazy diff --git a/src/servers/app/RootLayer.h b/src/servers/app/RootLayer.h index c0e2a5486a..b5648f04a9 100644 --- a/src/servers/app/RootLayer.h +++ b/src/servers/app/RootLayer.h @@ -62,9 +62,8 @@ class RootLayer : public Layer { WindowLayer* Front() const { return fFront; } WindowLayer* Back() const { return fBack; } - void SetWorkspace(int32 index, Workspace& workspace); - void SetWorkspacesLayer(Layer* layer) { fWorkspacesLayer = layer; } - Layer* WorkspacesLayer() const { return fWorkspacesLayer; } + void SetWorkspace(int32 index, Workspace& previousWorkspace, + Workspace& workspace); void SetDragMessage(BMessage *msg); BMessage* DragMessage() const; diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index 3801f98585..b87715f313 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -61,19 +61,19 @@ using std::nothrow; -//#define DEBUG_SERVERWINDOW -//#define DEBUG_SERVERWINDOW_GRAPHICS +//#define TRACE_SERVER_WINDOW +//#define TRACE_SERVER_WINDOW_MESSAGES //#define PROFILE_MESSAGE_LOOP -#ifdef DEBUG_SERVERWINDOW +#ifdef TRACE_SERVER_WINDOW # include # define STRACE(x) printf x #else # define STRACE(x) ; #endif -#ifdef DEBUG_SERVERWINDOW_GRAPHICS +#ifdef TRACE_SERVER_WINDOW_MESSAGES # include # define DTRACE(x) printf x #else @@ -168,10 +168,10 @@ ServerWindow::ServerWindow(const char *title, ServerApp *app, //! Tears down all connections the main app_server objects, and deletes some internals. ServerWindow::~ServerWindow() { - STRACE(("*ServerWindow(%s@%p):~ServerWindow()\n", fTitle, this)); + STRACE(("ServerWindow(%s@%p):~ServerWindow()\n", fTitle, this)); if (!fWindowLayer->IsOffscreenWindow()) - fDesktop->RemoveWindowLayer(fWindowLayer); + fDesktop->RemoveWindow(fWindowLayer); delete fWindowLayer; @@ -181,7 +181,7 @@ ServerWindow::~ServerWindow() BPrivate::gDefaultTokens.RemoveToken(fServerToken); delete fDirectWindowData; - STRACE(("#ServerWindow(%p) will exit NOW\n", this)); + STRACE(("ServerWindow(%p) will exit NOW\n", this)); delete_sem(fDeathSemaphore); @@ -217,7 +217,7 @@ ServerWindow::Init(BRect frame, uint32 look, uint32 feel, uint32 flags, uint32 w return B_NO_MEMORY; if (!fWindowLayer->IsOffscreenWindow()) - fDesktop->AddWindowLayer(fWindowLayer); + fDesktop->AddWindow(fWindowLayer); return B_OK; } @@ -544,7 +544,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) if ((fCurrentLayer == NULL || fCurrentLayer->CurrentState() == NULL) && code != AS_LAYER_CREATE_ROOT && code != AS_LAYER_CREATE) { - printf("ServerWindow %s received unexpected code - message offset %ld before top_view attached.\n", Title(), code - SERVER_TRUE); + printf("ServerWindow %s received unexpected code - message offset %ld before top_view attached.\n", Title(), code - B_OK); return; } @@ -713,7 +713,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) { DTRACE(("ServerWindow %s: Message AS_LAYER_GET_STATE: Layer name: %s\n", fTitle, fCurrentLayer->Name())); - fLink.StartMessage(SERVER_TRUE); + fLink.StartMessage(B_OK); // attach state data fCurrentLayer->CurrentState()->WriteToLink(fLink.Sender()); @@ -802,7 +802,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) case AS_LAYER_GET_COORD: { STRACE(("ServerWindow %s: Message AS_LAYER_GET_COORD: Layer: %s\n", Title(), fCurrentLayer->Name())); - fLink.StartMessage(SERVER_TRUE); + fLink.StartMessage(B_OK); // our offset in the parent -> will be originX and originY in BView fLink.Attach(fCurrentLayer->fFrame.left); fLink.Attach(fCurrentLayer->fFrame.top); @@ -824,7 +824,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) case AS_LAYER_GET_ORIGIN: { STRACE(("ServerWindow %s: Message AS_LAYER_GET_ORIGIN: Layer: %s\n", Title(), fCurrentLayer->Name())); - fLink.StartMessage(SERVER_TRUE); + fLink.StartMessage(B_OK); // TODO: rename this where it is used in the BView code! // (it wants to know scrolling offset, not drawing origin) fLink.Attach(fCurrentLayer->ScrollingOffset()); @@ -891,7 +891,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) case AS_LAYER_GET_LINE_MODE: { DTRACE(("ServerWindow %s: Message AS_LAYER_GET_LINE_MODE: Layer: %s\n", Title(), fCurrentLayer->Name())); - fLink.StartMessage(SERVER_TRUE); + fLink.StartMessage(B_OK); fLink.Attach((int8)(fCurrentLayer->CurrentState()->LineCapMode())); fLink.Attach((int8)(fCurrentLayer->CurrentState()->LineJoinMode())); fLink.Attach(fCurrentLayer->CurrentState()->MiterLimit()); @@ -928,7 +928,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) { DTRACE(("ServerWindow %s: Message AS_LAYER_GET_SCALE: Layer: %s\n", Title(), fCurrentLayer->Name())); - fLink.StartMessage(SERVER_TRUE); + fLink.StartMessage(B_OK); fLink.Attach(fCurrentLayer->CurrentState()->Scale()); fLink.Flush(); break; @@ -947,7 +947,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) case AS_LAYER_GET_PEN_LOC: { DTRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_LOC: Layer: %s\n", Title(), fCurrentLayer->Name())); - fLink.StartMessage(SERVER_TRUE); + fLink.StartMessage(B_OK); fLink.Attach(fCurrentLayer->CurrentState()->PenLocation()); fLink.Flush(); @@ -965,7 +965,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) case AS_LAYER_GET_PEN_SIZE: { DTRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_SIZE: Layer: %s\n", Title(), fCurrentLayer->Name())); - fLink.StartMessage(SERVER_TRUE); + fLink.StartMessage(B_OK); fLink.Attach(fCurrentLayer->CurrentState()->PenSize()); fLink.Flush(); @@ -994,7 +994,7 @@ if (rootLayer) DTRACE(("ServerWindow %s: Message AS_LAYER_GET_HIGH_COLOR: Layer: %s\n", Title(), fCurrentLayer->Name())); - fLink.StartMessage(SERVER_TRUE); + fLink.StartMessage(B_OK); fLink.Attach(fCurrentLayer->CurrentState()->HighColor().GetColor32()); fLink.Flush(); break; @@ -1003,7 +1003,7 @@ if (rootLayer) DTRACE(("ServerWindow %s: Message AS_LAYER_GET_LOW_COLOR: Layer: %s\n", Title(), fCurrentLayer->Name())); - fLink.StartMessage(SERVER_TRUE); + fLink.StartMessage(B_OK); fLink.Attach(fCurrentLayer->CurrentState()->LowColor().GetColor32()); fLink.Flush(); break; @@ -1012,7 +1012,7 @@ if (rootLayer) DTRACE(("ServerWindow %s: Message AS_LAYER_GET_VIEW_COLOR: Layer: %s\n", Title(), fCurrentLayer->Name())); - fLink.StartMessage(SERVER_TRUE); + fLink.StartMessage(B_OK); fLink.Attach(fCurrentLayer->ViewColor().GetColor32()); fLink.Flush(); break; @@ -1033,7 +1033,7 @@ if (rootLayer) case AS_LAYER_GET_BLEND_MODE: { DTRACE(("ServerWindow %s: Message AS_LAYER_GET_BLEND_MODE: Layer: %s\n", Title(), fCurrentLayer->Name())); - fLink.StartMessage(SERVER_TRUE); + fLink.StartMessage(B_OK); fLink.Attach((int8)(fCurrentLayer->CurrentState()->AlphaSrcMode())); fLink.Attach((int8)(fCurrentLayer->CurrentState()->AlphaFncMode())); fLink.Flush(); @@ -1054,7 +1054,7 @@ if (rootLayer) case AS_LAYER_GET_DRAW_MODE: { DTRACE(("ServerWindow %s: Message AS_LAYER_GET_DRAW_MODE: Layer: %s\n", Title(), fCurrentLayer->Name())); - fLink.StartMessage(SERVER_TRUE); + fLink.StartMessage(B_OK); fLink.Attach((int8)(fCurrentLayer->CurrentState()->GetDrawingMode())); fLink.Flush(); @@ -1118,14 +1118,14 @@ if (rootLayer) // if this Layer is hidden, it is clear that its visible region is void. if (fCurrentLayer->IsHidden()) { - fLink.StartMessage(SERVER_TRUE); + fLink.StartMessage(B_OK); fLink.Attach(0L); fLink.Flush(); } else { BRegion drawingRegion = fCurrentLayer->DrawingRegion(); int32 rectCount = drawingRegion.CountRects(); - fLink.StartMessage(SERVER_TRUE); + fLink.StartMessage(B_OK); fLink.Attach(rectCount); for (int32 i = 0; i < rectCount; i++) { @@ -1358,7 +1358,7 @@ if (rootLayer) case AS_GET_WORKSPACES: { STRACE(("ServerWindow %s: Message Get_Workspaces unimplemented\n", Title())); - fLink.StartMessage(SERVER_TRUE); + fLink.StartMessage(B_OK); fLink.Attach(fWindowLayer->Workspaces()); fLink.Flush(); break; @@ -1421,7 +1421,7 @@ if (rootLayer) // and now, sync the client to the limits that we were able to enforce fWindowLayer->GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight); - fLink.StartMessage(SERVER_TRUE); + fLink.StartMessage(B_OK); fLink.Attach(fWindowLayer->Frame()); fLink.Attach(minWidth); fLink.Attach(maxWidth); @@ -1541,7 +1541,7 @@ if (rootLayer) case AS_SYNC: { // TODO: AS_SYNC is a no-op for now, just to get things working - fLink.StartMessage(SERVER_TRUE); + fLink.StartMessage(B_OK); fLink.Flush(); break; } @@ -1585,7 +1585,7 @@ if (rootLayer) link.Read(&serverToken); if (_EnableDirectWindowMode() == B_OK) { - fLink.StartMessage(SERVER_TRUE); + fLink.StartMessage(B_OK); struct dw_sync_data syncData = { fDirectWindowData->direct_area, fDirectWindowData->direct_sem, @@ -1595,7 +1595,7 @@ if (rootLayer) fLink.Attach(&syncData, sizeof(syncData)); } else - fLink.StartMessage(SERVER_FALSE); + fLink.StartMessage(B_ERROR); fLink.Flush(); @@ -1982,11 +1982,11 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) default: printf("ServerWindow %s received unexpected code - message offset %ld\n", - Title(), code - SERVER_TRUE); + Title(), code - B_OK); if (link.NeedsReply()) { // the client is now blocking and waiting for a reply! - fLink.StartMessage(SERVER_FALSE); + fLink.StartMessage(B_ERROR); fLink.Flush(); } break; diff --git a/src/servers/app/ServerWindow.h b/src/servers/app/ServerWindow.h index ad2f78c21d..5ea7dd99da 100644 --- a/src/servers/app/ServerWindow.h +++ b/src/servers/app/ServerWindow.h @@ -88,6 +88,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; } void SetTitle(const char* newTitle); @@ -127,7 +128,7 @@ private: private: char* fTitle; - Desktop* fDesktop; + ::Desktop* fDesktop; ServerApp* fServerApp; WindowLayer* fWindowLayer; diff --git a/src/servers/app/WindowLayer.h b/src/servers/app/WindowLayer.h index a90db76ed4..306f4b5a33 100644 --- a/src/servers/app/WindowLayer.h +++ b/src/servers/app/WindowLayer.h @@ -109,9 +109,12 @@ class WindowLayer : public Layer { inline int32 Feel() const { return fFeel; } inline int32 Level() const { return fLevel; } inline uint32 WindowFlags() const { return fWindowFlags; } - inline uint32 Workspaces() const { return fWorkspaces; } + + uint32 Workspaces() const { return fWorkspaces; } void SetWorkspaces(uint32 workspaces) { fWorkspaces = workspaces; } + bool OnWorkspace(int32 index) const + { return (fWorkspaces & (1UL << index)) != 0; } bool SupportsFront(); diff --git a/src/servers/app/Workspace.cpp b/src/servers/app/Workspace.cpp index 9e5dec8949..f195a00ae0 100644 --- a/src/servers/app/Workspace.cpp +++ b/src/servers/app/Workspace.cpp @@ -17,7 +17,7 @@ static RGBColor kDefaultColor = RGBColor(51, 102, 152); -const BPoint kInvalidWindowPosition = BPoint(NAN, NAN); +const BPoint kInvalidWindowPosition = BPoint(INFINITY, INFINITY); Workspace::Workspace() @@ -34,22 +34,14 @@ Workspace::~Workspace() } -void -Workspace::SetWindows(const BObjectList& windows) -{ - fWindows.MakeEmpty(); - fWindows.AddList((BObjectList *)&windows); -} - - bool -Workspace::AddWindow(WindowLayer* window) +Workspace::AddWindow(WindowLayer* window, BPoint* position) { window_layer_info* info = new (nothrow) window_layer_info; if (info == NULL) return false; - info->position = kInvalidWindowPosition; + info->position = position ? *position : kInvalidWindowPosition; info->window = window; bool success = fWindows.AddItem(info); @@ -75,6 +67,14 @@ Workspace::RemoveWindow(WindowLayer* window) } +void +Workspace::RemoveWindowAt(int32 index) +{ + window_layer_info* info = fWindows.RemoveItemAt(index); + delete info; +} + + void Workspace::SetDisplaysFromDesktop(Desktop* desktop) { diff --git a/src/servers/app/Workspace.h b/src/servers/app/Workspace.h index dd510e6175..7b32a90a98 100644 --- a/src/servers/app/Workspace.h +++ b/src/servers/app/Workspace.h @@ -35,9 +35,9 @@ class Workspace { Workspace(); ~Workspace(); - void SetWindows(const BObjectList& windows); - bool AddWindow(WindowLayer* window); + bool AddWindow(WindowLayer* window, BPoint* point = NULL); void RemoveWindow(WindowLayer* window); + void RemoveWindowAt(int32 index); int32 CountWindows() const { return fWindows.CountItems(); } window_layer_info* WindowAt(int32 index) const { return fWindows.ItemAt(index); } diff --git a/src/servers/app/WorkspacesLayer.cpp b/src/servers/app/WorkspacesLayer.cpp index 5ed18d5e61..123fbf41d8 100644 --- a/src/servers/app/WorkspacesLayer.cpp +++ b/src/servers/app/WorkspacesLayer.cpp @@ -34,7 +34,8 @@ WorkspacesLayer::~WorkspacesLayer() void WorkspacesLayer::_GetGrid(int32& columns, int32& rows) { - int32 count = 4; //GetRootLayer()->WorkspaceCount(); + DesktopSettings settings(Window()->Desktop()); + int32 count = settings.WorkspacesCount(); rows = 1; for (int32 i = 2; i < count; i++) { @@ -141,7 +142,7 @@ WorkspacesLayer::_DrawWorkspace(int32 index) BRect rect = _WorkspaceAt(index); Workspace* workspace = NULL; - bool active = index == 0; + bool active = index == Window()->Desktop()->CurrentWorkspace(); if (active) { // draw active frame RGBColor black(0, 0, 0); @@ -244,7 +245,11 @@ WorkspacesLayer::Draw(const BRect& updateRect) // draw workspaces - int32 count = 4; //GetRootLayer()->WorkspaceCount(); + int32 count; + { + DesktopSettings settings(Window()->Desktop()); + count = settings.WorkspacesCount(); + } for (int32 i = 0; i < count; i++) { _DrawWorkspace(i);