Reenabled most of the workspaces functionality - the Workspaces window doesn't

show any windows, but everything else seems to work fine.


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