Some preparations to reactivate the workspace feature.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15239 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-11-30 11:19:20 +00:00
parent 15918e4fa5
commit 66fdfb907b
3 changed files with 66 additions and 28 deletions
+29 -20
View File
@@ -400,17 +400,42 @@ RootLayer::SetWorkspace(int32 index, Workspace& workspace)
_UpdateWorkspace(workspace); _UpdateWorkspace(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 // those that were not visible before (or whose position changed)
for (int32 i = 0; i < workspace.CountWindows(); i++) { for (int32 i = 0; i < workspace.CountWindows(); i++) {
WindowLayer* window = workspace.WindowAt(i); window_layer_info* info = workspace.WindowAt(i);
WindowLayer* window = info->window;
if (!window->IsHidden() if (window->IsHidden())
&& (window->Workspaces() & (1UL << previousIndex)) == 0) { continue;
if (info->position == kInvalidWindowPosition) {
// if you enter a workspace for the first time, the position
// of the window in the previous workspace is adopted
info->position = window->Frame().LeftTop();
}
if ((window->Workspaces() & (1UL << previousIndex)) == 0) {
// 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
BRegion region; BRegion region;
window->GetOnScreenRegion(region); window->GetOnScreenRegion(region);
changed.Include(&region); changed.Include(&region);
} else if (window->Frame().LeftTop() != info->position) {
// the window was visible before, but its on-screen location changed
BPoint offset = info->position - window->Frame().LeftTop();
window->MoveBy(offset.x, offset.y);
// 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
// will give us just that, we don't take any special measurement
// here
GetOnScreenRegion(changed);
} else {
// the window is still visible and on the same location
continue;
} }
_AddChildToList(window); _AddChildToList(window);
@@ -494,22 +519,6 @@ RootLayer::SetWindowLayerLook(WindowLayer *windowLayer, int32 newLook)
// TODO // TODO
} }
#if 0
void
RootLayer::RevealNewWMState(Workspace::State &oldWMState)
{
// send window activation messages
if (oldWMState.Focus != fWMState.Focus) {
if (oldWMState.Focus)
oldWMState.Focus->Activated(false);
if (fWMState.Focus) {
fWMState.Focus->Activated(true);
fDesktop->EventDispatcher().SetFocus(&fWMState.Focus->Window()->FocusMessenger());
} else
fDesktop->EventDispatcher().SetFocus(NULL);
}
}
#endif
void void
RootLayer::_WindowsChanged(BRegion& region) RootLayer::_WindowsChanged(BRegion& region)
+27 -5
View File
@@ -11,16 +11,19 @@
#include "Workspace.h" #include "Workspace.h"
#include "WindowLayer.h" #include "WindowLayer.h"
#include <math.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
static RGBColor kDefaultColor = RGBColor(51, 102, 152); static RGBColor kDefaultColor = RGBColor(51, 102, 152);
const BPoint kInvalidWindowPosition = BPoint(NAN, NAN);
Workspace::Workspace() Workspace::Workspace()
: :
fWindows(20) fWindows(20, true)
// this list owns its items
{ {
_SetDefaults(); _SetDefaults();
} }
@@ -32,24 +35,43 @@ Workspace::~Workspace()
void void
Workspace::SetWindows(const BObjectList<WindowLayer>& windows) Workspace::SetWindows(const BObjectList<window_layer_info>& windows)
{ {
fWindows.MakeEmpty(); fWindows.MakeEmpty();
fWindows.AddList((BObjectList<WindowLayer> *)&windows); fWindows.AddList((BObjectList<window_layer_info> *)&windows);
} }
bool bool
Workspace::AddWindow(WindowLayer* window) Workspace::AddWindow(WindowLayer* window)
{ {
return fWindows.AddItem(window); window_layer_info* info = new (nothrow) window_layer_info;
if (info == NULL)
return false;
info->position = kInvalidWindowPosition;
info->window = window;
bool success = fWindows.AddItem(info);
if (!success)
delete info;
return success;
} }
void void
Workspace::RemoveWindow(WindowLayer* window) Workspace::RemoveWindow(WindowLayer* window)
{ {
fWindows.RemoveItem(window); for (int32 i = fWindows.CountItems(); i-- > 0;) {
window_layer_info* info = fWindows.ItemAt(i);
if (info->window == window) {
fWindows.RemoveItemAt(i);
delete info;
return;
}
}
} }
+10 -3
View File
@@ -25,17 +25,22 @@ struct display_info {
display_mode mode; display_mode mode;
}; };
struct window_layer_info {
BPoint position;
WindowLayer* window;
};
class Workspace { class Workspace {
public: public:
Workspace(); Workspace();
~Workspace(); ~Workspace();
void SetWindows(const BObjectList<WindowLayer>& windows); void SetWindows(const BObjectList<window_layer_info>& windows);
bool AddWindow(WindowLayer* window); bool AddWindow(WindowLayer* window);
void RemoveWindow(WindowLayer* window); void RemoveWindow(WindowLayer* window);
int32 CountWindows() const { return fWindows.CountItems(); } int32 CountWindows() const { return fWindows.CountItems(); }
WindowLayer* WindowAt(int32 index) const { return fWindows.ItemAt(index); } window_layer_info* WindowAt(int32 index) const { return fWindows.ItemAt(index); }
// displays // displays
@@ -55,7 +60,7 @@ class Workspace {
private: private:
void _SetDefaults(); void _SetDefaults();
BObjectList<WindowLayer> fWindows; BObjectList<window_layer_info> fWindows;
WindowLayer* fFront; WindowLayer* fFront;
WindowLayer* fFocus; WindowLayer* fFocus;
@@ -64,4 +69,6 @@ class Workspace {
RGBColor fColor; RGBColor fColor;
}; };
extern const BPoint kInvalidWindowPosition;
#endif /* WORKSPACE_H */ #endif /* WORKSPACE_H */