* the Workspace class is now hidden and put into Workspace::Private; the new
Workspace class is a simple accessor to this class that takes care about locking (currently, it's just the desktop lock, maybe it'll stay that way). * WorkspacesLayer now displays the window thumbs again. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15250 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -802,7 +802,7 @@ Desktop::WriteWindowList(team_id team, BPrivate::LinkSender& sender)
|
|||||||
|
|
||||||
// write list
|
// write list
|
||||||
|
|
||||||
sender.StartMessage(SERVER_TRUE);
|
sender.StartMessage(B_OK);
|
||||||
sender.Attach<int32>(count);
|
sender.Attach<int32>(count);
|
||||||
|
|
||||||
for (int32 i = 0; i < fWindowLayerList.CountItems(); i++) {
|
for (int32 i = 0; i < fWindowLayerList.CountItems(); i++) {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "DesktopSettings.h"
|
#include "DesktopSettings.h"
|
||||||
#include "MessageLooper.h"
|
#include "MessageLooper.h"
|
||||||
#include "Workspace.h"
|
#include "Workspace.h"
|
||||||
|
#include "WorkspacePrivate.h"
|
||||||
|
|
||||||
#include <InterfaceDefs.h>
|
#include <InterfaceDefs.h>
|
||||||
#include <List.h>
|
#include <List.h>
|
||||||
@@ -81,7 +82,7 @@ class Desktop : public MessageLooper, public ScreenOwner {
|
|||||||
void SetWorkspace(int32 index);
|
void SetWorkspace(int32 index);
|
||||||
int32 CurrentWorkspace()
|
int32 CurrentWorkspace()
|
||||||
{ return fCurrentWorkspace; }
|
{ return fCurrentWorkspace; }
|
||||||
::Workspace& WorkspaceAt(int32 index)
|
Workspace::Private& WorkspaceAt(int32 index)
|
||||||
{ return fWorkspaces[index]; }
|
{ return fWorkspaces[index]; }
|
||||||
|
|
||||||
// WindowLayer methods
|
// WindowLayer methods
|
||||||
@@ -136,7 +137,7 @@ class Desktop : public MessageLooper, public ScreenOwner {
|
|||||||
sem_id fShutdownSemaphore;
|
sem_id fShutdownSemaphore;
|
||||||
int32 fShutdownCount;
|
int32 fShutdownCount;
|
||||||
|
|
||||||
::Workspace fWorkspaces[32];//kMaxWorkspaces];
|
::Workspace::Private fWorkspaces[32];
|
||||||
int32 fCurrentWorkspace;
|
int32 fCurrentWorkspace;
|
||||||
|
|
||||||
BObjectList<WindowLayer> fWindowLayerList;
|
BObjectList<WindowLayer> fWindowLayerList;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
#include "ServerScreen.h"
|
#include "ServerScreen.h"
|
||||||
#include "ServerWindow.h"
|
#include "ServerWindow.h"
|
||||||
#include "WindowLayer.h"
|
#include "WindowLayer.h"
|
||||||
#include "Workspace.h"
|
#include "WorkspacePrivate.h"
|
||||||
#include "WorkspacesLayer.h"
|
#include "WorkspacesLayer.h"
|
||||||
|
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
@@ -361,7 +361,7 @@ RootLayer::RemoveWindowLayer(WindowLayer* windowLayer)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
RootLayer::_UpdateWorkspace(Workspace& workspace)
|
RootLayer::_UpdateWorkspace(Workspace::Private& workspace)
|
||||||
{
|
{
|
||||||
fColor = workspace.Color();
|
fColor = workspace.Color();
|
||||||
|
|
||||||
@@ -372,8 +372,8 @@ RootLayer::_UpdateWorkspace(Workspace& workspace)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
RootLayer::SetWorkspace(int32 index, Workspace& previousWorkspace,
|
RootLayer::SetWorkspace(int32 index, Workspace::Private& previousWorkspace,
|
||||||
Workspace& workspace)
|
Workspace::Private& workspace)
|
||||||
{
|
{
|
||||||
BAutolock _(fAllRegionsLock);
|
BAutolock _(fAllRegionsLock);
|
||||||
|
|
||||||
|
|||||||
@@ -62,8 +62,9 @@ class RootLayer : public Layer {
|
|||||||
WindowLayer* Front() const { return fFront; }
|
WindowLayer* Front() const { return fFront; }
|
||||||
WindowLayer* Back() const { return fBack; }
|
WindowLayer* Back() const { return fBack; }
|
||||||
|
|
||||||
void SetWorkspace(int32 index, Workspace& previousWorkspace,
|
void SetWorkspace(int32 index,
|
||||||
Workspace& workspace);
|
Workspace::Private& previousWorkspace,
|
||||||
|
Workspace::Private& workspace);
|
||||||
|
|
||||||
void SetDragMessage(BMessage *msg);
|
void SetDragMessage(BMessage *msg);
|
||||||
BMessage* DragMessage() const;
|
BMessage* DragMessage() const;
|
||||||
@@ -104,7 +105,7 @@ class RootLayer : public Layer {
|
|||||||
void _UpdateFronts();
|
void _UpdateFronts();
|
||||||
|
|
||||||
void _WindowsChanged(BRegion& region);
|
void _WindowsChanged(BRegion& region);
|
||||||
void _UpdateWorkspace(Workspace& workspace);
|
void _UpdateWorkspace(Workspace::Private& workspace);
|
||||||
|
|
||||||
Desktop* fDesktop;
|
Desktop* fDesktop;
|
||||||
BMessage* fDragMessage;
|
BMessage* fDragMessage;
|
||||||
|
|||||||
@@ -2189,7 +2189,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
if (index >= (uint32)kMaxWorkspaces)
|
if (index >= (uint32)kMaxWorkspaces)
|
||||||
index = fDesktop->CurrentWorkspace();
|
index = fDesktop->CurrentWorkspace();
|
||||||
|
|
||||||
Workspace& workspace = fDesktop->WorkspaceAt(index);
|
Workspace workspace(*fDesktop, index);
|
||||||
fLink.Attach<rgb_color>(workspace.Color().GetColor32());
|
fLink.Attach<rgb_color>(workspace.Color().GetColor32());
|
||||||
|
|
||||||
fDesktop->Unlock();
|
fDesktop->Unlock();
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ static RGBColor kDefaultColor = RGBColor(51, 102, 152);
|
|||||||
const BPoint kInvalidWindowPosition = BPoint(INFINITY, INFINITY);
|
const BPoint kInvalidWindowPosition = BPoint(INFINITY, INFINITY);
|
||||||
|
|
||||||
|
|
||||||
Workspace::Workspace()
|
Workspace::Private::Private()
|
||||||
:
|
:
|
||||||
fWindows(20, true)
|
fWindows(20, true)
|
||||||
// this list owns its items
|
// this list owns its items
|
||||||
@@ -29,13 +29,13 @@ Workspace::Workspace()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Workspace::~Workspace()
|
Workspace::Private::~Private()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Workspace::AddWindow(WindowLayer* window, BPoint* position)
|
Workspace::Private::AddWindow(WindowLayer* window, BPoint* position)
|
||||||
{
|
{
|
||||||
window_layer_info* info = new (nothrow) window_layer_info;
|
window_layer_info* info = new (nothrow) window_layer_info;
|
||||||
if (info == NULL)
|
if (info == NULL)
|
||||||
@@ -53,7 +53,7 @@ Workspace::AddWindow(WindowLayer* window, BPoint* position)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Workspace::RemoveWindow(WindowLayer* window)
|
Workspace::Private::RemoveWindow(WindowLayer* window)
|
||||||
{
|
{
|
||||||
for (int32 i = fWindows.CountItems(); i-- > 0;) {
|
for (int32 i = fWindows.CountItems(); i-- > 0;) {
|
||||||
window_layer_info* info = fWindows.ItemAt(i);
|
window_layer_info* info = fWindows.ItemAt(i);
|
||||||
@@ -68,7 +68,7 @@ Workspace::RemoveWindow(WindowLayer* window)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Workspace::RemoveWindowAt(int32 index)
|
Workspace::Private::RemoveWindowAt(int32 index)
|
||||||
{
|
{
|
||||||
window_layer_info* info = fWindows.RemoveItemAt(index);
|
window_layer_info* info = fWindows.RemoveItemAt(index);
|
||||||
delete info;
|
delete info;
|
||||||
@@ -76,33 +76,95 @@ Workspace::RemoveWindowAt(int32 index)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Workspace::SetDisplaysFromDesktop(Desktop* desktop)
|
Workspace::Private::SetDisplaysFromDesktop(Desktop* desktop)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Workspace::SetColor(const RGBColor& color)
|
Workspace::Private::SetColor(const RGBColor& color)
|
||||||
{
|
{
|
||||||
fColor = color;
|
fColor = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Workspace::SetSettings(BMessage& settings)
|
Workspace::Private::SetSettings(BMessage& settings)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Workspace::GetSettings(BMessage& settings)
|
Workspace::Private::GetSettings(BMessage& settings)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Workspace::_SetDefaults()
|
Workspace::Private::_SetDefaults()
|
||||||
{
|
{
|
||||||
fColor.SetColor(kDefaultColor);
|
fColor.SetColor(kDefaultColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
Workspace::Workspace(Desktop& desktop, int32 index)
|
||||||
|
:
|
||||||
|
fWorkspace(desktop.WorkspaceAt(index)),
|
||||||
|
fDesktop(desktop),
|
||||||
|
fCurrentWorkspace(index == desktop.CurrentWorkspace())
|
||||||
|
{
|
||||||
|
fDesktop.Lock();
|
||||||
|
RewindWindows();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Workspace::~Workspace()
|
||||||
|
{
|
||||||
|
fDesktop.Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const RGBColor&
|
||||||
|
Workspace::Color() const
|
||||||
|
{
|
||||||
|
return fWorkspace.Color();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
Workspace::GetNextWindow(WindowLayer*& _window, BPoint& _leftTop)
|
||||||
|
{
|
||||||
|
if (fCurrentWorkspace) {
|
||||||
|
if (fCurrent == NULL)
|
||||||
|
fCurrent = (WindowLayer*)fDesktop.RootLayer()->FirstChild();
|
||||||
|
else
|
||||||
|
fCurrent = (WindowLayer*)fCurrent->NextLayer();
|
||||||
|
|
||||||
|
if (fCurrent == NULL)
|
||||||
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
|
_window = fCurrent;
|
||||||
|
_leftTop = fCurrent->Frame().LeftTop();
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
window_layer_info* info = fWorkspace.WindowAt(fIndex++);
|
||||||
|
if (info == NULL)
|
||||||
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
|
_window = info->window;
|
||||||
|
_leftTop = info->position;
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Workspace::RewindWindows()
|
||||||
|
{
|
||||||
|
fIndex = 0;
|
||||||
|
fCurrent = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
+15
-46
@@ -9,66 +9,35 @@
|
|||||||
#define WORKSPACE_H
|
#define WORKSPACE_H
|
||||||
|
|
||||||
|
|
||||||
#include "RGBColor.h"
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
#include <ObjectList.h>
|
|
||||||
#include <String.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
class Desktop;
|
||||||
|
class RGBColor;
|
||||||
class RootLayer;
|
class RootLayer;
|
||||||
class WindowLayer;
|
class WindowLayer;
|
||||||
|
|
||||||
|
|
||||||
struct display_info {
|
|
||||||
BString identifier;
|
|
||||||
BPoint origin;
|
|
||||||
display_mode mode;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct window_layer_info {
|
|
||||||
BPoint position;
|
|
||||||
WindowLayer* window;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Workspace {
|
class Workspace {
|
||||||
public:
|
public:
|
||||||
Workspace();
|
Workspace(Desktop& desktop, int32 index);
|
||||||
~Workspace();
|
~Workspace();
|
||||||
|
|
||||||
bool AddWindow(WindowLayer* window, BPoint* point = NULL);
|
const RGBColor& Color() const;
|
||||||
void RemoveWindow(WindowLayer* window);
|
bool IsCurrent() const
|
||||||
void RemoveWindowAt(int32 index);
|
{ return fCurrentWorkspace; }
|
||||||
|
|
||||||
int32 CountWindows() const { return fWindows.CountItems(); }
|
status_t GetNextWindow(WindowLayer*& _window, BPoint& _leftTop);
|
||||||
window_layer_info* WindowAt(int32 index) const { return fWindows.ItemAt(index); }
|
void RewindWindows();
|
||||||
|
|
||||||
// displays
|
class Private;
|
||||||
|
|
||||||
void SetDisplaysFromDesktop(Desktop* desktop);
|
|
||||||
|
|
||||||
int32 CountDisplays() const { return fDisplays.CountItems(); }
|
|
||||||
const display_info* DisplayAt(int32 index) const { return fDisplays.ItemAt(index); }
|
|
||||||
|
|
||||||
// configuration
|
|
||||||
|
|
||||||
const RGBColor& Color() const { return fColor; }
|
|
||||||
void SetColor(const RGBColor& color);
|
|
||||||
|
|
||||||
void SetSettings(BMessage& settings);
|
|
||||||
void GetSettings(BMessage& settings);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _SetDefaults();
|
Workspace::Private& fWorkspace;
|
||||||
|
Desktop& fDesktop;
|
||||||
BObjectList<window_layer_info> fWindows;
|
int32 fIndex;
|
||||||
WindowLayer* fFront;
|
WindowLayer* fCurrent;
|
||||||
WindowLayer* fFocus;
|
bool fCurrentWorkspace;
|
||||||
|
|
||||||
BObjectList<display_info> fDisplays;
|
|
||||||
|
|
||||||
RGBColor fColor;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const BPoint kInvalidWindowPosition;
|
|
||||||
|
|
||||||
#endif /* WORKSPACE_H */
|
#endif /* WORKSPACE_H */
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2005, Haiku.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Axel Dörfler, [email protected]
|
||||||
|
*/
|
||||||
|
#ifndef WORKSPACE_PRIVATE_H
|
||||||
|
#define WORKSPACE_PRIVATE_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "RGBColor.h"
|
||||||
|
#include "Workspace.h"
|
||||||
|
|
||||||
|
#include <ObjectList.h>
|
||||||
|
#include <String.h>
|
||||||
|
|
||||||
|
|
||||||
|
class RootLayer;
|
||||||
|
class WindowLayer;
|
||||||
|
|
||||||
|
|
||||||
|
struct display_info {
|
||||||
|
BString identifier;
|
||||||
|
BPoint origin;
|
||||||
|
display_mode mode;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct window_layer_info {
|
||||||
|
BPoint position;
|
||||||
|
WindowLayer* window;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Workspace::Private {
|
||||||
|
public:
|
||||||
|
Private();
|
||||||
|
~Private();
|
||||||
|
|
||||||
|
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); }
|
||||||
|
|
||||||
|
// displays
|
||||||
|
|
||||||
|
void SetDisplaysFromDesktop(Desktop* desktop);
|
||||||
|
|
||||||
|
int32 CountDisplays() const { return fDisplays.CountItems(); }
|
||||||
|
const display_info* DisplayAt(int32 index) const { return fDisplays.ItemAt(index); }
|
||||||
|
|
||||||
|
// configuration
|
||||||
|
|
||||||
|
const RGBColor& Color() const { return fColor; }
|
||||||
|
void SetColor(const RGBColor& color);
|
||||||
|
|
||||||
|
void SetSettings(BMessage& settings);
|
||||||
|
void GetSettings(BMessage& settings);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void _SetDefaults();
|
||||||
|
|
||||||
|
BObjectList<window_layer_info> fWindows;
|
||||||
|
WindowLayer* fFront;
|
||||||
|
WindowLayer* fFocus;
|
||||||
|
|
||||||
|
BObjectList<display_info> fDisplays;
|
||||||
|
|
||||||
|
RGBColor fColor;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern const BPoint kInvalidWindowPosition;
|
||||||
|
|
||||||
|
#endif /* WORKSPACE_PRIVATE_H */
|
||||||
@@ -76,9 +76,11 @@ WorkspacesLayer::_WorkspaceAt(int32 i)
|
|||||||
|
|
||||||
BRect
|
BRect
|
||||||
WorkspacesLayer::_WindowFrame(const BRect& workspaceFrame,
|
WorkspacesLayer::_WindowFrame(const BRect& workspaceFrame,
|
||||||
const BRect& screenFrame, const BRect& windowFrame)
|
const BRect& screenFrame, const BRect& windowFrame,
|
||||||
|
BPoint windowPosition)
|
||||||
{
|
{
|
||||||
BRect frame = windowFrame;
|
BRect frame = windowFrame;
|
||||||
|
frame.OffsetTo(windowPosition);
|
||||||
|
|
||||||
float factor = workspaceFrame.Width() / screenFrame.Width();
|
float factor = workspaceFrame.Width() / screenFrame.Width();
|
||||||
frame.left = rintf(frame.left * factor);
|
frame.left = rintf(frame.left * factor);
|
||||||
@@ -95,15 +97,18 @@ WorkspacesLayer::_WindowFrame(const BRect& workspaceFrame,
|
|||||||
|
|
||||||
void
|
void
|
||||||
WorkspacesLayer::_DrawWindow(const BRect& workspaceFrame,
|
WorkspacesLayer::_DrawWindow(const BRect& workspaceFrame,
|
||||||
const BRect& screenFrame, WindowLayer* window,
|
const BRect& screenFrame, WindowLayer* window, BPoint windowPosition,
|
||||||
BRegion& backgroundRegion, bool active)
|
BRegion& backgroundRegion, bool active)
|
||||||
{
|
{
|
||||||
if (window->Feel() == kDesktopWindowFeel)
|
if (window->Feel() == kDesktopWindowFeel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BRect frame = _WindowFrame(workspaceFrame, screenFrame, window->Frame());
|
BPoint offset = window->Frame().LeftTop() - windowPosition;
|
||||||
BRect tabFrame = _WindowFrame(workspaceFrame, screenFrame,
|
BRect frame = _WindowFrame(workspaceFrame, screenFrame, window->Frame(),
|
||||||
window->GetDecorator()->GetTabRect());
|
windowPosition);
|
||||||
|
BRect tabFrame = window->GetDecorator()->GetTabRect();
|
||||||
|
tabFrame = _WindowFrame(workspaceFrame, screenFrame,
|
||||||
|
tabFrame, tabFrame.LeftTop() - offset);
|
||||||
|
|
||||||
// ToDo: let decorator do this!
|
// ToDo: let decorator do this!
|
||||||
RGBColor yellow = window->GetDecorator()->GetColors().window_tab;
|
RGBColor yellow = window->GetDecorator()->GetColors().window_tab;
|
||||||
@@ -141,56 +146,46 @@ WorkspacesLayer::_DrawWorkspace(int32 index)
|
|||||||
{
|
{
|
||||||
BRect rect = _WorkspaceAt(index);
|
BRect rect = _WorkspaceAt(index);
|
||||||
|
|
||||||
Workspace* workspace = NULL;
|
Workspace workspace(*Window()->Desktop(), index);
|
||||||
bool active = index == Window()->Desktop()->CurrentWorkspace();
|
bool active = workspace.IsCurrent();
|
||||||
if (active) {
|
if (active) {
|
||||||
// draw active frame
|
// draw active frame
|
||||||
RGBColor black(0, 0, 0);
|
RGBColor black(0, 0, 0);
|
||||||
GetDrawingEngine()->StrokeRect(rect, black);
|
GetDrawingEngine()->StrokeRect(rect, black);
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw background
|
|
||||||
|
|
||||||
rect.InsetBy(1, 1);
|
rect.InsetBy(1, 1);
|
||||||
RGBColor color;
|
|
||||||
|
|
||||||
// ToDo: fix me - workspaces must always exist, not only on first visit!
|
RGBColor color = workspace.Color();
|
||||||
if (workspace != NULL)
|
if (!active)
|
||||||
color = workspace->Color();
|
|
||||||
else
|
|
||||||
color.SetColor(51, 102, 152);
|
|
||||||
|
|
||||||
if (!active) {
|
|
||||||
_DarkenColor(color);
|
_DarkenColor(color);
|
||||||
}
|
|
||||||
|
|
||||||
// draw windows
|
// draw windows
|
||||||
|
|
||||||
BRegion backgroundRegion = VisibleRegion();
|
BRegion backgroundRegion = VisibleRegion();
|
||||||
|
|
||||||
// ToDo: would be nice to get the real update region here
|
// ToDo: would be nice to get the real update region here
|
||||||
|
|
||||||
if (workspace != NULL) {
|
uint16 width, height;
|
||||||
WindowLayer* windows[256];
|
uint32 colorSpace;
|
||||||
int32 count = 0;
|
float frequency;
|
||||||
// if (!workspace->GetWindowLayerList((void **)&windows, &count))
|
Window()->Desktop()->ScreenAt(0)->GetMode(width, height,
|
||||||
// return;
|
colorSpace, frequency);
|
||||||
|
BRect screenFrame(0, 0, width - 1, height - 1);
|
||||||
|
|
||||||
uint16 width, height;
|
BRegion workspaceRegion(rect);
|
||||||
uint32 colorSpace;
|
backgroundRegion.IntersectWith(&workspaceRegion);
|
||||||
float frequency;
|
GetDrawingEngine()->ConstrainClippingRegion(&backgroundRegion);
|
||||||
GetRootLayer()->GetDesktop()->ScreenAt(0)->GetMode(width, height, colorSpace, frequency);
|
|
||||||
BRect screenFrame(0, 0, width - 1, height - 1);
|
|
||||||
|
|
||||||
BRegion workspaceRegion(rect);
|
WindowLayer* window;
|
||||||
backgroundRegion.IntersectWith(&workspaceRegion);
|
BPoint leftTop;
|
||||||
GetDrawingEngine()->ConstrainClippingRegion(&backgroundRegion);
|
while (workspace.GetNextWindow(window, leftTop) == B_OK) {
|
||||||
|
_DrawWindow(rect, screenFrame, window, leftTop,
|
||||||
for (int32 i = count; i-- > 0;) {
|
backgroundRegion, active);
|
||||||
_DrawWindow(rect, screenFrame, windows[i], backgroundRegion, active);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// draw background
|
||||||
|
|
||||||
GetDrawingEngine()->ConstrainClippingRegion(&backgroundRegion);
|
GetDrawingEngine()->ConstrainClippingRegion(&backgroundRegion);
|
||||||
GetDrawingEngine()->FillRect(rect, color);
|
GetDrawingEngine()->FillRect(rect, color);
|
||||||
|
|
||||||
@@ -245,14 +240,28 @@ WorkspacesLayer::Draw(const BRect& updateRect)
|
|||||||
|
|
||||||
// draw workspaces
|
// draw workspaces
|
||||||
|
|
||||||
int32 count;
|
for (int32 i = rows * columns; i-- > 0;) {
|
||||||
{
|
|
||||||
DesktopSettings settings(Window()->Desktop());
|
|
||||||
count = settings.WorkspacesCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32 i = 0; i < count; i++) {
|
|
||||||
_DrawWorkspace(i);
|
_DrawWorkspace(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
WorkspacesLayer::MouseDown(BMessage* message, BPoint where, int32* _viewToken)
|
||||||
|
{
|
||||||
|
int32 columns, rows;
|
||||||
|
_GetGrid(columns, rows);
|
||||||
|
|
||||||
|
for (int32 i = columns * rows; i-- > 0;) {
|
||||||
|
BRect rect = _WorkspaceAt(i);
|
||||||
|
|
||||||
|
if (rect.Contains(where)) {
|
||||||
|
Window()->Desktop()->SetWorkspace(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Layer::MouseDown(message, where, _viewToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,16 +21,19 @@ class WorkspacesLayer : public Layer {
|
|||||||
virtual ~WorkspacesLayer();
|
virtual ~WorkspacesLayer();
|
||||||
|
|
||||||
virtual void Draw(const BRect& updateRect);
|
virtual void Draw(const BRect& updateRect);
|
||||||
|
virtual void MouseDown(BMessage* message, BPoint where, int32* _viewToken);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _GetGrid(int32& columns, int32& rows);
|
void _GetGrid(int32& columns, int32& rows);
|
||||||
BRect _WorkspaceAt(int32 i);
|
BRect _WorkspaceAt(int32 i);
|
||||||
BRect _WindowFrame(const BRect& workspaceFrame,
|
BRect _WindowFrame(const BRect& workspaceFrame,
|
||||||
const BRect& screenFrame, const BRect& windowFrame);
|
const BRect& screenFrame, const BRect& windowFrame,
|
||||||
|
BPoint windowPosition);
|
||||||
|
|
||||||
void _DrawWindow(const BRect& workspaceFrame,
|
void _DrawWindow(const BRect& workspaceFrame,
|
||||||
const BRect& screenFrame, WindowLayer* window,
|
const BRect& screenFrame, WindowLayer* window,
|
||||||
BRegion& backgroundRegion, bool active);
|
BPoint windowPosition, BRegion& backgroundRegion,
|
||||||
|
bool active);
|
||||||
void _DrawWorkspace(int32 index);
|
void _DrawWorkspace(int32 index);
|
||||||
|
|
||||||
void _DarkenColor(RGBColor& color) const;
|
void _DarkenColor(RGBColor& color) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user