2004-06-26 06:15:48 +04:00
|
|
|
/*
|
2006-02-06 16:36:46 +03:00
|
|
|
* Copyright 2005-2006, Haiku.
|
2005-11-29 02:36:59 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Axel Dörfler, axeld@pinc-software.de
|
|
|
|
*/
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
#include "Desktop.h"
|
2005-11-29 02:36:59 +03:00
|
|
|
#include "Workspace.h"
|
2005-12-08 15:41:19 +03:00
|
|
|
#include "WorkspacePrivate.h"
|
2005-11-29 02:36:59 +03:00
|
|
|
#include "WindowLayer.h"
|
2004-07-10 14:54:20 +04:00
|
|
|
|
2005-11-30 14:19:20 +03:00
|
|
|
#include <math.h>
|
2005-11-29 02:36:59 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
|
2005-11-29 02:36:59 +03:00
|
|
|
static RGBColor kDefaultColor = RGBColor(51, 102, 152);
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2004-07-10 14:54:20 +04:00
|
|
|
|
2005-11-30 22:56:44 +03:00
|
|
|
Workspace::Private::Private()
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2005-11-29 02:36:59 +03:00
|
|
|
_SetDefaults();
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
|
2005-11-30 22:56:44 +03:00
|
|
|
Workspace::Private::~Private()
|
2005-07-07 00:19:22 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-11-26 23:22:30 +03:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
void
|
2005-11-30 22:56:44 +03:00
|
|
|
Workspace::Private::SetDisplaysFromDesktop(Desktop* desktop)
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
|
|
|
|
void
|
2005-11-30 22:56:44 +03:00
|
|
|
Workspace::Private::SetColor(const RGBColor& color)
|
2004-06-26 06:15:48 +04:00
|
|
|
{
|
2005-11-29 02:36:59 +03:00
|
|
|
fColor = color;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
2004-06-26 06:15:48 +04:00
|
|
|
|
2005-07-07 00:19:22 +04:00
|
|
|
|
|
|
|
void
|
2006-02-06 16:36:46 +03:00
|
|
|
Workspace::Private::RestoreConfiguration(const BMessage& settings)
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
2006-02-06 16:36:46 +03:00
|
|
|
rgb_color color;
|
|
|
|
if (settings.FindInt32("color", (int32 *)&color) == B_OK)
|
|
|
|
fColor.SetColor(color);
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-14 13:55:00 +04:00
|
|
|
/*!
|
2006-04-14 14:50:47 +04:00
|
|
|
\brief Store the workspace configuration in a message
|
2006-04-14 13:55:00 +04:00
|
|
|
*/
|
2005-06-23 21:40:35 +04:00
|
|
|
void
|
2006-02-06 16:36:46 +03:00
|
|
|
Workspace::Private::StoreConfiguration(BMessage& settings)
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
2006-02-06 16:36:46 +03:00
|
|
|
rgb_color color = fColor.GetColor32();
|
2006-04-14 14:50:47 +04:00
|
|
|
settings.RemoveName("color");
|
2006-02-06 16:36:46 +03:00
|
|
|
settings.AddInt32("color", *(int32 *)&color);
|
2004-07-10 14:54:20 +04:00
|
|
|
}
|
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-11-24 20:45:26 +03:00
|
|
|
void
|
2005-11-30 22:56:44 +03:00
|
|
|
Workspace::Private::_SetDefaults()
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
2005-11-29 02:36:59 +03:00
|
|
|
fColor.SetColor(kDefaultColor);
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
|
|
|
|
2005-11-30 22:56:44 +03:00
|
|
|
|
|
|
|
// #pragma mark -
|
|
|
|
|
|
|
|
|
|
|
|
Workspace::Workspace(Desktop& desktop, int32 index)
|
|
|
|
:
|
|
|
|
fWorkspace(desktop.WorkspaceAt(index)),
|
|
|
|
fDesktop(desktop),
|
|
|
|
fCurrentWorkspace(index == desktop.CurrentWorkspace())
|
|
|
|
{
|
2006-04-07 23:14:25 +04:00
|
|
|
// fDesktop.LockSingleWindow();
|
|
|
|
// TODO: in which threads is this being used?
|
|
|
|
// from my investigations, it is used in the
|
|
|
|
// WorkspacesLayer::Draw(), which would have
|
|
|
|
// to hold the read lock already
|
2005-11-30 22:56:44 +03:00
|
|
|
RewindWindows();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Workspace::~Workspace()
|
|
|
|
{
|
2006-04-07 23:14:25 +04:00
|
|
|
// fDesktop.UnlockSingleWindow();
|
2005-11-30 22:56:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const RGBColor&
|
|
|
|
Workspace::Color() const
|
|
|
|
{
|
|
|
|
return fWorkspace.Color();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-29 21:09:07 +03:00
|
|
|
void
|
|
|
|
Workspace::SetColor(const RGBColor& color, bool makeDefault)
|
|
|
|
{
|
2006-02-13 16:12:10 +03:00
|
|
|
if (color == Color())
|
|
|
|
return;
|
|
|
|
|
2005-12-29 21:09:07 +03:00
|
|
|
fWorkspace.SetColor(color);
|
2006-02-13 16:12:10 +03:00
|
|
|
fDesktop.RedrawBackground();
|
2006-04-12 20:52:41 +04:00
|
|
|
if (makeDefault)
|
2006-04-13 00:55:36 +04:00
|
|
|
fDesktop.StoreWorkspaceConfiguration(fWorkspace.Index());
|
2005-12-29 21:09:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-30 22:56:44 +03:00
|
|
|
status_t
|
|
|
|
Workspace::GetNextWindow(WindowLayer*& _window, BPoint& _leftTop)
|
|
|
|
{
|
2005-12-08 15:41:19 +03:00
|
|
|
if (fCurrent == NULL)
|
|
|
|
fCurrent = fWorkspace.Windows().FirstWindow();
|
|
|
|
else
|
|
|
|
fCurrent = fCurrent->NextWindow(fWorkspace.Index());
|
2005-11-30 22:56:44 +03:00
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
if (fCurrent == NULL)
|
2005-11-30 22:56:44 +03:00
|
|
|
return B_ENTRY_NOT_FOUND;
|
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
_window = fCurrent;
|
|
|
|
|
|
|
|
if (fCurrentWorkspace)
|
|
|
|
_leftTop = fCurrent->Frame().LeftTop();
|
|
|
|
else
|
|
|
|
_leftTop = fCurrent->Anchor(fWorkspace.Index()).position;
|
|
|
|
|
2005-11-30 22:56:44 +03:00
|
|
|
return B_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
Workspace::RewindWindows()
|
|
|
|
{
|
|
|
|
fCurrent = NULL;
|
|
|
|
}
|
|
|
|
|