* First steps towards a more flexible workspaces view handling: the
workspaces view can now be any view in the hierarchy. * Added private view flag kWorkspacesViewFlag that identifies such a view - note though, that you must not remove a view before closing or hiding its window for now (and that you still need to set the kWorkspacesWindowFlag, too). * Fixed Workspaces check for valid screen coordinates; after a crash, it managed to open its window offscreen for me. * Added a ViewLayer method FindView() that finds a view with the specified flags set. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24090 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2006, Haiku.
|
* Copyright 2003-2008, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -10,8 +10,6 @@
|
|||||||
#define VIEW_PRIVATE_H
|
#define VIEW_PRIVATE_H
|
||||||
|
|
||||||
|
|
||||||
#include <PortLink.h>
|
|
||||||
|
|
||||||
#include <Font.h>
|
#include <Font.h>
|
||||||
#include <InterfaceDefs.h>
|
#include <InterfaceDefs.h>
|
||||||
#include <Point.h>
|
#include <Point.h>
|
||||||
@@ -20,6 +18,9 @@
|
|||||||
|
|
||||||
const static uint32 kDeleteReplicant = 'JAHA';
|
const static uint32 kDeleteReplicant = 'JAHA';
|
||||||
|
|
||||||
|
const static uint32 kWorkspacesViewFlag = 0x40000000UL;
|
||||||
|
// was/is _B_RESERVED1_ in View.h
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
B_VIEW_FONT_BIT = 0x00000001,
|
B_VIEW_FONT_BIT = 0x00000001,
|
||||||
B_VIEW_HIGH_COLOR_BIT = 0x00000002,
|
B_VIEW_HIGH_COLOR_BIT = 0x00000002,
|
||||||
@@ -48,6 +49,8 @@ enum {
|
|||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
|
class PortLink;
|
||||||
|
|
||||||
class ViewState {
|
class ViewState {
|
||||||
public:
|
public:
|
||||||
ViewState();
|
ViewState();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2007, Haiku, Inc.
|
* Copyright 2002-2008, Haiku, Inc.
|
||||||
* Copyright 2002, François Revol, [email protected].
|
* Copyright 2002, François Revol, [email protected].
|
||||||
* This file is distributed under the terms of the MIT License.
|
* This file is distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
@@ -32,7 +32,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "WindowPrivate.h"
|
#include <ViewPrivate.h>
|
||||||
|
#include <WindowPrivate.h>
|
||||||
|
|
||||||
|
|
||||||
static const char *kWorkspacesSignature = "application/x-vnd.Be-WORK";
|
static const char *kWorkspacesSignature = "application/x-vnd.Be-WORK";
|
||||||
static const char *kWorkspacesSettingFile = "Workspace_data";
|
static const char *kWorkspacesSettingFile = "Workspace_data";
|
||||||
@@ -63,6 +65,7 @@ class WorkspacesView : public BView {
|
|||||||
|
|
||||||
virtual void MouseMoved(BPoint where, uint32 transit,
|
virtual void MouseMoved(BPoint where, uint32 transit,
|
||||||
const BMessage* dragMessage);
|
const BMessage* dragMessage);
|
||||||
|
virtual void MouseDown(BPoint where);
|
||||||
};
|
};
|
||||||
|
|
||||||
class WorkspacesWindow : public BWindow {
|
class WorkspacesWindow : public BWindow {
|
||||||
@@ -126,9 +129,10 @@ WorkspacesPreferences::WorkspacesPreferences()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check if loaded values are valid
|
// check if loaded values are valid
|
||||||
if (screen.Frame().right >= fWindowFrame.right
|
if (screen.Frame().right + 5 >= fWindowFrame.right
|
||||||
&& screen.Frame().bottom >= fWindowFrame.bottom
|
&& screen.Frame().bottom + 5 >= fWindowFrame.bottom
|
||||||
&& fWindowFrame.right > 0 && fWindowFrame.bottom > 0)
|
&& screen.Frame().left - 5 <= fWindowFrame.left
|
||||||
|
&& screen.Frame().top - 5 <= fWindowFrame.top)
|
||||||
settingsValid = true;
|
settingsValid = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -200,7 +204,7 @@ WorkspacesPreferences::SetWindowFrame(BRect frame)
|
|||||||
|
|
||||||
|
|
||||||
WorkspacesView::WorkspacesView(BRect frame)
|
WorkspacesView::WorkspacesView(BRect frame)
|
||||||
: BView(frame, "workspaces", 0, B_FOLLOW_NONE)
|
: BView(frame, "workspaces", B_FOLLOW_NONE, kWorkspacesViewFlag)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,6 +235,20 @@ WorkspacesView::MouseMoved(BPoint where, uint32 transit,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
WorkspacesView::MouseDown(BPoint where)
|
||||||
|
{
|
||||||
|
int32 buttons = 0;
|
||||||
|
if (Window() != NULL && Window()->CurrentMessage() != NULL)
|
||||||
|
Window()->CurrentMessage()->FindInt32("buttons", &buttons);
|
||||||
|
|
||||||
|
if ((buttons & B_SECONDARY_MOUSE_BUTTON) == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// TODO: open menu
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
@@ -241,7 +259,7 @@ WorkspacesWindow::WorkspacesWindow(WorkspacesPreferences *preferences)
|
|||||||
B_ALL_WORKSPACES),
|
B_ALL_WORKSPACES),
|
||||||
fPreferences(preferences)
|
fPreferences(preferences)
|
||||||
{
|
{
|
||||||
AddChild(new WorkspacesView(BRect(-10, -10, -5, -5)));
|
AddChild(new WorkspacesView(Bounds()));
|
||||||
fPreviousFrame = Frame();
|
fPreviousFrame = Frame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2007, Haiku.
|
* Copyright 2001-2008, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -29,6 +29,7 @@
|
|||||||
#include "Workspace.h"
|
#include "Workspace.h"
|
||||||
#include "WorkspacesLayer.h"
|
#include "WorkspacesLayer.h"
|
||||||
|
|
||||||
|
#include <ViewPrivate.h>
|
||||||
#include <WindowInfo.h>
|
#include <WindowInfo.h>
|
||||||
#include <ServerProtocol.h>
|
#include <ServerProtocol.h>
|
||||||
|
|
||||||
@@ -1598,8 +1599,11 @@ Desktop::ShowWindow(WindowLayer* window)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WorkspacesLayer* layer = dynamic_cast<WorkspacesLayer*>(window->TopLayer()))
|
if ((window->Flags() & kWorkspacesWindowFlag) != 0) {
|
||||||
fWorkspacesLayer = layer;
|
// find workspaces layer in view hierarchy
|
||||||
|
fWorkspacesLayer = dynamic_cast<WorkspacesLayer*>(
|
||||||
|
window->TopLayer()->FindView(kWorkspacesViewFlag));
|
||||||
|
}
|
||||||
|
|
||||||
UnlockAllWindows();
|
UnlockAllWindows();
|
||||||
|
|
||||||
@@ -1637,7 +1641,7 @@ Desktop::HideWindow(WindowLayer* window)
|
|||||||
if (fWorkspacesLayer != NULL)
|
if (fWorkspacesLayer != NULL)
|
||||||
fWorkspacesLayer->WindowRemoved(window);
|
fWorkspacesLayer->WindowRemoved(window);
|
||||||
|
|
||||||
if (dynamic_cast<WorkspacesLayer*>(window->TopLayer()) != NULL)
|
if ((window->Flags() & kWorkspacesWindowFlag) != 0)
|
||||||
fWorkspacesLayer = NULL;
|
fWorkspacesLayer = NULL;
|
||||||
|
|
||||||
UnlockAllWindows();
|
UnlockAllWindows();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2007, Haiku.
|
* Copyright 2001-2008, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -44,6 +44,7 @@
|
|||||||
#include <DirectWindowPrivate.h>
|
#include <DirectWindowPrivate.h>
|
||||||
#include <MessagePrivate.h>
|
#include <MessagePrivate.h>
|
||||||
#include <PortLink.h>
|
#include <PortLink.h>
|
||||||
|
#include <ViewPrivate.h>
|
||||||
#include <WindowInfo.h>
|
#include <WindowInfo.h>
|
||||||
#include <WindowPrivate.h>
|
#include <WindowPrivate.h>
|
||||||
|
|
||||||
@@ -561,9 +562,10 @@ ServerWindow::_CreateLayerTree(BPrivate::LinkReceiver &link, ViewLayer **_parent
|
|||||||
|
|
||||||
ViewLayer* newLayer;
|
ViewLayer* newLayer;
|
||||||
|
|
||||||
if (link.Code() == AS_LAYER_CREATE_ROOT
|
if ((fWindowLayer->Flags() & kWorkspacesWindowFlag) != 0
|
||||||
&& (fWindowLayer->Flags() & kWorkspacesWindowFlag) != 0) {
|
&& (flags & kWorkspacesViewFlag) != 0) {
|
||||||
// this is a workspaces window!
|
// TODO: there can currently only be one of these views per desktop!
|
||||||
|
// TODO: get rid of the kWorkspacesWindowFlag
|
||||||
newLayer = new (nothrow) WorkspacesLayer(frame, scrollingOffset, name,
|
newLayer = new (nothrow) WorkspacesLayer(frame, scrollingOffset, name,
|
||||||
token, resizeMask, flags);
|
token, resizeMask, flags);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -376,6 +376,22 @@ ViewLayer::MarkAt(DrawingEngine* engine, const BPoint& where, int32 level)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
ViewLayer*
|
||||||
|
ViewLayer::FindView(uint32 flags)
|
||||||
|
{
|
||||||
|
if ((Flags() & flags) == flags)
|
||||||
|
return this;
|
||||||
|
|
||||||
|
for (ViewLayer* child = FirstChild(); child; child = child->NextSibling()) {
|
||||||
|
ViewLayer* layer = child->FindView(flags);
|
||||||
|
if (layer != NULL)
|
||||||
|
return layer;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ViewLayer*
|
ViewLayer*
|
||||||
ViewLayer::ViewAt(const BPoint& where)
|
ViewLayer::ViewAt(const BPoint& where)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ class ViewLayer {
|
|||||||
|
|
||||||
uint32 CountChildren(bool deep = false) const;
|
uint32 CountChildren(bool deep = false) const;
|
||||||
void CollectTokensForChildren(BList* tokenMap) const;
|
void CollectTokensForChildren(BList* tokenMap) const;
|
||||||
|
ViewLayer* FindView(uint32 flags);
|
||||||
|
|
||||||
ViewLayer* ViewAt(const BPoint& where);
|
ViewLayer* ViewAt(const BPoint& where);
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ WorkspacesLayer::WorkspacesLayer(BRect frame, BPoint scrollingOffset,
|
|||||||
|
|
||||||
WorkspacesLayer::~WorkspacesLayer()
|
WorkspacesLayer::~WorkspacesLayer()
|
||||||
{
|
{
|
||||||
|
// TODO: we actually need to tell the Desktop that we're gone
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -74,21 +75,25 @@ WorkspacesLayer::_WorkspaceAt(int32 i)
|
|||||||
int32 columns, rows;
|
int32 columns, rows;
|
||||||
_GetGrid(columns, rows);
|
_GetGrid(columns, rows);
|
||||||
|
|
||||||
int32 width = Frame().IntegerWidth() / columns;
|
BRect frame = Bounds();
|
||||||
int32 height = Frame().IntegerHeight() / rows;
|
ConvertToScreen(&frame);
|
||||||
|
|
||||||
|
int32 width = frame.IntegerWidth() / columns;
|
||||||
|
int32 height = frame.IntegerHeight() / rows;
|
||||||
|
|
||||||
int32 column = i % columns;
|
int32 column = i % columns;
|
||||||
int32 row = i / columns;
|
int32 row = i / columns;
|
||||||
|
|
||||||
BRect rect(column * width, row * height, (column + 1) * width, (row + 1) * height);
|
BRect rect(column * width, row * height, (column + 1) * width,
|
||||||
|
(row + 1) * height);
|
||||||
|
|
||||||
rect.OffsetBy(Frame().LeftTop());
|
rect.OffsetBy(frame.LeftTop());
|
||||||
|
|
||||||
// make sure there is no gap anywhere
|
// make sure there is no gap anywhere
|
||||||
if (column == columns - 1)
|
if (column == columns - 1)
|
||||||
rect.right = Frame().right;
|
rect.right = frame.right;
|
||||||
if (row == rows - 1)
|
if (row == rows - 1)
|
||||||
rect.bottom = Frame().bottom;
|
rect.bottom = frame.bottom;
|
||||||
|
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
@@ -288,7 +293,10 @@ WorkspacesLayer::_DarkenColor(rgb_color& color) const
|
|||||||
void
|
void
|
||||||
WorkspacesLayer::_Invalidate() const
|
WorkspacesLayer::_Invalidate() const
|
||||||
{
|
{
|
||||||
BRegion region((BRect)Frame());
|
BRect frame = Bounds();
|
||||||
|
ConvertToScreen(&frame);
|
||||||
|
|
||||||
|
BRegion region(frame);
|
||||||
Window()->MarkContentDirty(region);
|
Window()->MarkContentDirty(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,8 +322,8 @@ WorkspacesLayer::Draw(DrawingEngine* drawingEngine, BRegion* effectiveClipping,
|
|||||||
gridRegion.Exclude(activeRect);
|
gridRegion.Exclude(activeRect);
|
||||||
drawingEngine->ConstrainClippingRegion(&gridRegion);
|
drawingEngine->ConstrainClippingRegion(&gridRegion);
|
||||||
|
|
||||||
BRect frame = Frame();
|
BRect frame = Bounds();
|
||||||
// top ViewLayer frame is in screen coordinates
|
ConvertToScreen(&frame);
|
||||||
|
|
||||||
// horizontal lines
|
// horizontal lines
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user