2 * Copyright 2005-2009, Haiku.
3 * Distributed under the terms of the MIT License.
6 * Axel Dörfler, axeld@pinc-software.de
10 #include "Workspace.h"
19 #include "WorkspacePrivate.h"
23 static rgb_color kDefaultColor
= (rgb_color
){ 51, 102, 152, 255 };
26 Workspace::Private::Private()
32 Workspace::Private::~Private()
38 Workspace::Private::SetDisplaysFromDesktop(Desktop
* desktop
)
44 Workspace::Private::SetColor(const rgb_color
& color
)
51 Workspace::Private::RestoreConfiguration(const BMessage
& settings
)
54 if (settings
.FindInt32("color", (int32
*)&color
) == B_OK
)
57 fStoredScreenConfiguration
.Restore(settings
);
58 fCurrentScreenConfiguration
.Restore(settings
);
62 /*! \brief Store the workspace configuration in a message
65 Workspace::Private::StoreConfiguration(BMessage
& settings
)
67 fStoredScreenConfiguration
.Store(settings
);
68 settings
.AddInt32("color", *(int32
*)&fColor
);
73 Workspace::Private::_SetDefaults()
75 fColor
= kDefaultColor
;
82 Workspace::Workspace(Desktop
& desktop
, int32 index
, bool readOnly
)
84 fWorkspace(desktop
.WorkspaceAt(index
)),
86 fCurrentWorkspace(index
== desktop
.CurrentWorkspace())
88 ASSERT(desktop
.WindowLocker().IsWriteLocked()
89 || ( readOnly
&& desktop
.WindowLocker().IsReadLocked()));
94 Workspace::~Workspace()
100 Workspace::Color() const
102 return fWorkspace
.Color();
107 Workspace::SetColor(const rgb_color
& color
, bool makeDefault
)
109 if (color
== Color())
112 fWorkspace
.SetColor(color
);
113 fDesktop
.RedrawBackground();
115 fDesktop
.StoreWorkspaceConfiguration(fWorkspace
.Index());
120 Workspace::GetNextWindow(Window
*& _window
, BPoint
& _leftTop
)
122 if (fCurrent
== NULL
)
123 fCurrent
= fWorkspace
.Windows().FirstWindow();
125 fCurrent
= fCurrent
->NextWindow(fWorkspace
.Index());
127 if (fCurrent
== NULL
)
128 return B_ENTRY_NOT_FOUND
;
132 if (fCurrentWorkspace
)
133 _leftTop
= fCurrent
->Frame().LeftTop();
135 _leftTop
= fCurrent
->Anchor(fWorkspace
.Index()).position
;
142 Workspace::GetPreviousWindow(Window
*& _window
, BPoint
& _leftTop
)
144 if (fCurrent
== NULL
)
145 fCurrent
= fWorkspace
.Windows().LastWindow();
147 fCurrent
= fCurrent
->PreviousWindow(fWorkspace
.Index());
149 if (fCurrent
== NULL
)
150 return B_ENTRY_NOT_FOUND
;
154 if (fCurrentWorkspace
)
155 _leftTop
= fCurrent
->Frame().LeftTop();
157 _leftTop
= fCurrent
->Anchor(fWorkspace
.Index()).position
;
164 Workspace::RewindWindows()