Round the the window move target positions, this should fix jumping windows.

Coding style.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38789 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Clemens Zeidler 2010-09-22 22:27:31 +00:00
parent 9503cf19be
commit a2336b86cc
6 changed files with 261 additions and 242 deletions

View File

@ -6,6 +6,7 @@
* Clemens Zeidler <haiku@clemens-zeidler.de>
*/
#include "SATGroup.h"
#include <Debug.h>

View File

@ -8,6 +8,7 @@
#ifndef SAT_GROUP_H
#define SAT_GROUP_H
#include <Rect.h>
#include "ObjectList.h"
@ -50,21 +51,22 @@ public:
class Crossing : public BReferenceable {
public:
Crossing(Tab* vertical, Tab* horizontal);
~Crossing();
Crossing(Tab* vertical, Tab* horizontal);
~Crossing();
Corner* GetCorner(Corner::position_t corner) const;
Corner* GetOppositeCorner(Corner::position_t corner) const;
Corner* GetCorner(Corner::position_t corner) const;
Corner* GetOppositeCorner(
Corner::position_t corner) const;
Corner* LeftTopCorner() { return &fLeftTop; }
Corner* RightTopCorner() { return &fRightTop; }
Corner* LeftBottomCorner() { return &fLeftBottom; }
Corner* RightBottomCorner() { return &fRightBottom; }
Corner* LeftTopCorner() { return &fLeftTop; }
Corner* RightTopCorner() { return &fRightTop; }
Corner* LeftBottomCorner() { return &fLeftBottom; }
Corner* RightBottomCorner() { return &fRightBottom; }
Tab* VerticalTab() const;
Tab* HorizontalTab() const;
Tab* VerticalTab() const;
Tab* HorizontalTab() const;
void Trace() const;
void Trace() const;
private:
Corner* _GetCorner(Corner::position_t corner) const;
@ -92,34 +94,35 @@ public:
kHorizontal
};
Tab(SATGroup* group, Variable* variable,
orientation_t orientation);
~Tab();
Tab(SATGroup* group, Variable* variable,
orientation_t orientation);
~Tab();
float Position() const;
void SetPosition(float position);
orientation_t Orientation() const;
float Position() const;
void SetPosition(float position);
orientation_t Orientation() const;
//! Caller takes ownership of the constraint.
Constraint* Connect(Variable* variable);
//! Caller takes ownership of the constraint.
Constraint* Connect(Variable* variable);
BReference<Crossing> AddCrossing(Tab* tab);
bool RemoveCrossing(Crossing* crossing);
int32 FindCrossingIndex(Tab* tab);
int32 FindCrossingIndex(float tabPosition);
Crossing* FindCrossing(Tab* tab);
Crossing* FindCrossing(float tabPosition);
BReference<Crossing> AddCrossing(Tab* tab);
bool RemoveCrossing(Crossing* crossing);
int32 FindCrossingIndex(Tab* tab);
int32 FindCrossingIndex(float tabPosition);
Crossing* FindCrossing(Tab* tab);
Crossing* FindCrossing(float tabPosition);
const CrossingList* GetCrossingList() const;
const CrossingList* GetCrossingList() const;
static int CompareFunction(const Tab* tab1, const Tab* tab2);
static int CompareFunction(const Tab* tab1,
const Tab* tab2);
private:
SATGroup* fGroup;
Variable* fVariable;
orientation_t fOrientation;
SATGroup* fGroup;
Variable* fVariable;
orientation_t fOrientation;
CrossingList fCrossingList;
CrossingList fCrossingList;
};
@ -130,66 +133,67 @@ public:
Crossing* rightBottom);
~WindowArea();
bool SetGroup(SATGroup* group);
bool SetGroup(SATGroup* group);
const SATWindowList& WindowList() { return fWindowList; }
const SATWindowList& LayerOrder() { return fWindowLayerOrder; }
bool MoveWindowToPosition(SATWindow* window,
const SATWindowList& WindowList() { return fWindowList; }
const SATWindowList& LayerOrder() { return fWindowLayerOrder; }
bool MoveWindowToPosition(SATWindow* window,
int32 index);
void UpdateSizeLimits();
void UpdateSizeLimits();
Crossing* LeftTopCrossing()
Crossing* LeftTopCrossing()
{ return fLeftTopCrossing.Get(); }
Crossing* RightTopCrossing()
Crossing* RightTopCrossing()
{ return fRightTopCrossing.Get(); }
Crossing* LeftBottomCrossing()
Crossing* LeftBottomCrossing()
{ return fLeftBottomCrossing.Get(); }
Crossing* RightBottomCrossing()
Crossing* RightBottomCrossing()
{ return fRightBottomCrossing.Get(); }
Tab* LeftTab();
Tab* RightTab();
Tab* TopTab();
Tab* BottomTab();
Tab* LeftTab();
Tab* RightTab();
Tab* TopTab();
Tab* BottomTab();
BRect Frame();
BRect Frame();
bool PropagateToGroup(SATGroup* group);
bool PropagateToGroup(SATGroup* group);
bool MoveToTopLayer(SATWindow* window);
bool MoveToTopLayer(SATWindow* window);
private:
friend class SATGroup;
/*! SATGroup adds new windows to the area. */
bool _AddWindow(SATWindow* window,
/*! SATGroup adds new windows to the area. */
bool _AddWindow(SATWindow* window,
SATWindow* after = NULL);
/*! After the last window has been removed the WindowArea delete himself
and clean up all crossings. */
bool _RemoveWindow(SATWindow* window);
/*! After the last window has been removed the WindowArea delete
himself and clean up all crossings. */
bool _RemoveWindow(SATWindow* window);
inline void _InitCorners();
inline void _CleanupCorners();
inline void _SetToWindowCorner(Corner* corner);
inline void _SetToNeighbourCorner(Corner* neighbour);
inline void _UnsetWindowCorner(Corner* corner);
inline void _InitCorners();
inline void _CleanupCorners();
inline void _SetToWindowCorner(Corner* corner);
inline void _SetToNeighbourCorner(Corner* neighbour);
inline void _UnsetWindowCorner(Corner* corner);
//! opponent is the other neighbour of the neighbour
inline void _UnsetNeighbourCorner(Corner* neighbour,
inline void _UnsetNeighbourCorner(Corner* neighbour,
Corner* opponent);
// Find crossing by tab position in group and if not exist create it.
BReference<Crossing> _CrossingByPosition(Crossing* crossing,
SATGroup* group);
// Find crossing by tab position in group and if not exist create
// it.
BReference<Crossing> _CrossingByPosition(Crossing* crossing,
SATGroup* group);
SATGroup* fGroup;
SATGroup* fGroup;
SATWindowList fWindowList;
SATWindowList fWindowList;
SATWindowList fWindowLayerOrder;
SATWindowList fWindowLayerOrder;
BReference<Crossing> fLeftTopCrossing;
BReference<Crossing> fRightTopCrossing;
BReference<Crossing> fLeftBottomCrossing;
BReference<Crossing> fRightBottomCrossing;
BReference<Crossing> fLeftTopCrossing;
BReference<Crossing> fRightTopCrossing;
BReference<Crossing> fLeftBottomCrossing;
BReference<Crossing> fRightBottomCrossing;
};
@ -203,77 +207,83 @@ public:
friend class WindowArea;
friend class GroupCookie;
SATGroup();
~SATGroup();
SATGroup();
~SATGroup();
LinearSpec* GetLinearSpec() { return &fLinearSpec; }
LinearSpec* GetLinearSpec() { return &fLinearSpec; }
void AdjustWindows(SATWindow* triggerWindow);
void AdjustWindows(SATWindow* triggerWindow);
/*! Create a new WindowArea from the crossing and add the window. */
bool AddWindow(SATWindow* window, Tab* left, Tab* top,
Tab* right, Tab* bottom);
/*! Add a window to an existing window area. */
bool AddWindow(SATWindow* window, WindowArea* area,
SATWindow* after = NULL);
bool RemoveWindow(SATWindow* window);
int32 CountItems();
SATWindow* WindowAt(int32 index);
/*! Create a new WindowArea from the crossing and add the window. */
bool AddWindow(SATWindow* window, Tab* left, Tab* top,
Tab* right, Tab* bottom);
/*! Add a window to an existing window area. */
bool AddWindow(SATWindow* window, WindowArea* area,
SATWindow* after = NULL);
bool RemoveWindow(SATWindow* window);
int32 CountItems();
SATWindow* WindowAt(int32 index);
const WindowAreaList& GetAreaList() { return fWindowAreaList; }
/*! \return a sorted tab list. */
const TabList* HorizontalTabs();
const TabList* VerticalTabs();
const WindowAreaList& GetAreaList() { return fWindowAreaList; }
/*! \return a sorted tab list. */
const TabList* HorizontalTabs();
const TabList* VerticalTabs();
Tab* FindHorizontalTab(float position);
Tab* FindVerticalTab(float position);
Tab* FindHorizontalTab(float position);
Tab* FindVerticalTab(float position);
private:
BReference<Tab> _AddHorizontalTab(float position = 0);
BReference<Tab> _AddVerticalTab(float position = 0);
BReference<Tab> _AddHorizontalTab(float position = 0);
BReference<Tab> _AddVerticalTab(float position = 0);
bool _RemoveHorizontalTab(Tab* tab);
bool _RemoveVerticalTab(Tab* tab);
bool _RemoveHorizontalTab(Tab* tab);
bool _RemoveVerticalTab(Tab* tab);
Tab* _FindTab(const TabList& list, float position);
Tab* _FindTab(const TabList& list, float position);
void _SplitGroupIfNecessary(SATWindow* removedWindow);
void _FillNeighbourList(WindowAreaList& neighbourWindows,
WindowArea* area);
void _LeftNeighbours(WindowAreaList& neighbourWindows,
WindowArea* window);
void _TopNeighbours(WindowAreaList& neighbourWindows,
WindowArea* window);
void _RightNeighbours(WindowAreaList& neighbourWindows,
WindowArea* window);
void _BottomNeighbours(WindowAreaList& neighbourWindows,
WindowArea* window);
bool _FindConnectedGroup(WindowAreaList& seedList,
SATWindow* removedWindow,
WindowAreaList& newGroup);
void _FollowSeed(WindowArea* area, WindowArea* veto,
WindowAreaList& seedList,
WindowAreaList& newGroup);
void _SpawnNewGroup(const WindowAreaList& newGroup);
void _SplitGroupIfNecessary(
SATWindow* removedWindow);
void _FillNeighbourList(
WindowAreaList& neighbourWindows,
WindowArea* area);
void _LeftNeighbours(
WindowAreaList& neighbourWindows,
WindowArea* window);
void _TopNeighbours(
WindowAreaList& neighbourWindows,
WindowArea* window);
void _RightNeighbours(
WindowAreaList& neighbourWindows,
WindowArea* window);
void _BottomNeighbours(
WindowAreaList& neighbourWindows,
WindowArea* window);
bool _FindConnectedGroup(WindowAreaList& seedList,
SATWindow* removedWindow,
WindowAreaList& newGroup);
void _FollowSeed(WindowArea* area, WindowArea* veto,
WindowAreaList& seedList,
WindowAreaList& newGroup);
void _SpawnNewGroup(const WindowAreaList& newGroup);
void _EnsureGroupIsOnScreen(SATGroup* group);
inline void _CallculateXOffset(BPoint& offset, BRect& frame,
BRect& screen);
inline void _CallculateYOffset(BPoint& offset, BRect& frame,
BRect& screen);
void _EnsureGroupIsOnScreen(SATGroup* group);
inline void _CallculateXOffset(BPoint& offset, BRect& frame,
BRect& screen);
inline void _CallculateYOffset(BPoint& offset, BRect& frame,
BRect& screen);
protected:
WindowAreaList fWindowAreaList;
SATWindowList fSATWindowList;
WindowAreaList fWindowAreaList;
SATWindowList fSATWindowList;
LinearSpec fLinearSpec;
LinearSpec fLinearSpec;
private:
TabList fHorizontalTabs;
bool fHorizontalTabsSorted;
TabList fVerticalTabs;
bool fVerticalTabsSorted;
TabList fHorizontalTabs;
bool fHorizontalTabsSorted;
TabList fVerticalTabs;
bool fVerticalTabsSorted;
};

View File

@ -6,6 +6,7 @@
* Clemens Zeidler <haiku@clemens-zeidler.de>
*/
#include "SATWindow.h"
#include <Debug.h>
@ -118,14 +119,14 @@ GroupCookie::MoveWindow(int32 workspace)
Desktop* desktop = window->Desktop();
BRect frame = fSATWindow->CompleteWindowFrame();
desktop->MoveWindowBy(window, fLeftBorder->Value() - frame.left,
fTopBorder->Value() - frame.top, workspace);
desktop->MoveWindowBy(window, round(fLeftBorder->Value() - frame.left),
round(fTopBorder->Value() - frame.top), workspace);
// Update frame to the new position
frame.OffsetBy(fLeftBorder->Value() - frame.left,
fTopBorder->Value() - frame.top);
desktop->ResizeWindowBy(window, fRightBorder->Value() - frame.right,
fBottomBorder->Value() - frame.bottom);
frame.OffsetBy(round(fLeftBorder->Value() - frame.left),
round(fTopBorder->Value() - frame.top));
desktop->ResizeWindowBy(window, round(fRightBorder->Value() - frame.right),
round(fBottomBorder->Value() - frame.bottom));
_UpdateWindowSize(frame);
}

View File

@ -24,129 +24,131 @@ class Window;
class GroupCookie
{
public:
GroupCookie(SATWindow* satWindow);
~GroupCookie();
GroupCookie(SATWindow* satWindow);
~GroupCookie();
bool Init(SATGroup* group, WindowArea* area);
void Uninit();
bool Init(SATGroup* group, WindowArea* area);
void Uninit();
void DoGroupLayout(SATWindow* triggerWindow);
void MoveWindow(int32 workspace);
void SetSizeLimits(int32 minWidth, int32 maxWidth,
int32 minHeight, int32 maxHeight);
void DoGroupLayout(SATWindow* triggerWindow);
void MoveWindow(int32 workspace);
void SetSizeLimits(int32 minWidth, int32 maxWidth,
int32 minHeight, int32 maxHeight);
SATGroup* GetGroup() { return fSATGroup.Get(); }
SATGroup* GetGroup() { return fSATGroup.Get(); }
WindowArea* GetWindowArea() { return fWindowArea; }
WindowArea* GetWindowArea() { return fWindowArea; }
bool PropagateToGroup(SATGroup* group, WindowArea* area);
bool PropagateToGroup(SATGroup* group,
WindowArea* area);
private:
void _UpdateWindowSize(const BRect& frame);
void _UpdateWindowSize(const BRect& frame);
SATWindow* fSATWindow;
SATWindow* fSATWindow;
BReference<SATGroup> fSATGroup;
BReference<SATGroup> fSATGroup;
WindowArea* fWindowArea;
WindowArea* fWindowArea;
Variable* fLeftBorder;
Variable* fTopBorder;
Variable* fRightBorder;
Variable* fBottomBorder;
Variable* fLeftBorder;
Variable* fTopBorder;
Variable* fRightBorder;
Variable* fBottomBorder;
Constraint* fLeftBorderConstraint;
Constraint* fTopBorderConstraint;
Constraint* fRightBorderConstraint;
Constraint* fBottomBorderConstraint;
Constraint* fLeftBorderConstraint;
Constraint* fTopBorderConstraint;
Constraint* fRightBorderConstraint;
Constraint* fBottomBorderConstraint;
Constraint* fLeftConstraint;
Constraint* fTopConstraint;
Constraint* fMinWidthConstraint;
Constraint* fMinHeightConstraint;
Constraint* fMaxWidthConstraint;
Constraint* fMaxHeightConstraint;
Constraint* fWidthConstraint;
Constraint* fHeightConstraint;
Constraint* fLeftConstraint;
Constraint* fTopConstraint;
Constraint* fMinWidthConstraint;
Constraint* fMinHeightConstraint;
Constraint* fMaxWidthConstraint;
Constraint* fMaxHeightConstraint;
Constraint* fWidthConstraint;
Constraint* fHeightConstraint;
};
class SATWindow {
public:
SATWindow(StackAndTile* sat, Window* window);
~SATWindow();
SATWindow(StackAndTile* sat, Window* window);
~SATWindow();
Window* GetWindow() { return fWindow; }
SATDecorator* GetDecorator();
StackAndTile* GetStackAndTile() { return fStackAndTile; }
Desktop* GetDesktop() { return fDesktop; }
//! Can be NULL if memory allocation failed!
SATGroup* GetGroup();
WindowArea* GetWindowArea() {
return fGroupCookie->GetWindowArea(); }
Window* GetWindow() { return fWindow; }
SATDecorator* GetDecorator();
StackAndTile* GetStackAndTile() { return fStackAndTile; }
Desktop* GetDesktop() { return fDesktop; }
//! Can be NULL if memory allocation failed!
SATGroup* GetGroup();
WindowArea* GetWindowArea() {
return fGroupCookie->GetWindowArea(); }
bool HandleMessage(SATWindow* sender,
BPrivate::ServerLink& link);
bool HandleMessage(SATWindow* sender,
BPrivate::ServerLink& link);
bool PropagateToGroup(SATGroup* group, WindowArea* area);
bool PropagateToGroup(SATGroup* group,
WindowArea* area);
//! Move the window to the tab's position.
void MoveWindowToSAT(int32 workspace);
//! Move the window to the tab's position.
void MoveWindowToSAT(int32 workspace);
// hook function called from SATGroup
bool AddedToGroup(SATGroup* group, WindowArea* area);
bool RemovedFromGroup(SATGroup* group);
void RemovedFromArea(WindowArea* area);
// hook function called from SATGroup
bool AddedToGroup(SATGroup* group, WindowArea* area);
bool RemovedFromGroup(SATGroup* group);
void RemovedFromArea(WindowArea* area);
bool StackWindow(SATWindow* child);
bool StackWindow(SATWindow* child);
void FindSnappingCandidates();
bool JoinCandidates();
void DoWindowLayout();
void DoGroupLayout();
void FindSnappingCandidates();
bool JoinCandidates();
void DoWindowLayout();
void DoGroupLayout();
void SetSizeLimits(int32 minWidth, int32 maxWidth,
int32 minHeight, int32 maxHeight);
void SetSizeLimits(int32 minWidth, int32 maxWidth,
int32 minHeight, int32 maxHeight);
//! \return the complete window frame including the Decorator
BRect CompleteWindowFrame();
void GetSizeLimits(int32* minWidth, int32* maxWidth,
int32* minHeight, int32* maxHeight) const;
//! \return the complete window frame including the Decorator
BRect CompleteWindowFrame();
void GetSizeLimits(int32* minWidth, int32* maxWidth,
int32* minHeight, int32* maxHeight) const;
//! \return true if window is in a group with a least another window
bool PositionManagedBySAT();
//! \return true if window is in a group with a least another window
bool PositionManagedBySAT();
bool HighlightTab(bool active);
bool HighlightBorders(bool active);
bool IsTabHighlighted();
bool IsBordersHighlighted();
bool HighlightTab(bool active);
bool HighlightBorders(bool active);
bool IsTabHighlighted();
bool IsBordersHighlighted();
bool SetStackedMode(bool stacked = true);
bool SetStackedTabLength(float length);
bool SetStackedTabMoving(bool moving = true);
void TabLocationMoved(float location, bool shifting);
bool SetStackedMode(bool stacked = true);
bool SetStackedTabLength(float length);
bool SetStackedTabMoving(bool moving = true);
void TabLocationMoved(float location, bool shifting);
private:
void _InitGroup();
void _InitGroup();
Window* fWindow;
StackAndTile* fStackAndTile;
Desktop* fDesktop;
Window* fWindow;
StackAndTile* fStackAndTile;
Desktop* fDesktop;
//! Current group.
GroupCookie* fGroupCookie;
/*! If the window is added to another group the own group is cached
here. */
GroupCookie fOwnGroupCookie;
GroupCookie fForeignGroupCookie;
//! Current group.
GroupCookie* fGroupCookie;
/*! If the window is added to another group the own group is cached
here. */
GroupCookie fOwnGroupCookie;
GroupCookie fForeignGroupCookie;
SATSnappingBehaviour* fOngoingSnapping;
SATStacking fSATStacking;
SATTiling fSATTiling;
SATSnappingBehaviour* fOngoingSnapping;
SATStacking fSATStacking;
SATTiling fSATTiling;
SATSnappingBehaviourList fSATSnappingBehaviourList;
SATSnappingBehaviourList fSATSnappingBehaviourList;
bool fShutdown;
bool fShutdown;
};

View File

@ -6,6 +6,7 @@
* Clemens Zeidler <haiku@clemens-zeidler.de>
*/
#include "StackAndTile.h"
#include <Debug.h>

View File

@ -8,6 +8,7 @@
#ifndef STACK_AND_TILE_H
#define STACK_AND_TILE_H
#include <map>
#include <Message.h>
@ -107,60 +108,63 @@ private:
class GroupIterator {
public:
GroupIterator(StackAndTile* sat, Desktop* desktop);
GroupIterator(StackAndTile* sat,
Desktop* desktop);
void RewindToFront();
SATGroup* NextGroup();
void RewindToFront();
SATGroup* NextGroup();
private:
StackAndTile* fStackAndTile;
Desktop* fDesktop;
Window* fCurrentWindow;
SATGroup* fCurrentGroup;
StackAndTile* fStackAndTile;
Desktop* fDesktop;
Window* fCurrentWindow;
SATGroup* fCurrentGroup;
};
class WindowIterator {
public:
WindowIterator(SATGroup* group,
bool reverseLayerOrder = false);
WindowIterator(SATGroup* group,
bool reverseLayerOrder = false);
void Rewind();
/*! Iterates over all areas in the group and return the windows in the
areas. Within one area the windows are ordered by their layer position.
If reverseLayerOrder is false the bottommost window comes first. */
SATWindow* NextWindow();
void Rewind();
/*! Iterates over all areas in the group and return the windows in
the areas. Within one area the windows are ordered by their layer
position. If reverseLayerOrder is false the bottommost window comes
first. */
SATWindow* NextWindow();
private:
SATWindow* _ReverseNextWindow();
void _ReverseRewind();
SATWindow* _ReverseNextWindow();
void _ReverseRewind();
SATGroup* fGroup;
bool fReverseLayerOrder;
SATGroup* fGroup;
bool fReverseLayerOrder;
WindowArea* fCurrentArea;
int32 fAreaIndex;
int32 fWindowIndex;
WindowArea* fCurrentArea;
int32 fAreaIndex;
int32 fWindowIndex;
};
class SATSnappingBehaviour {
public:
virtual ~SATSnappingBehaviour();
virtual ~SATSnappingBehaviour();
/*! Find all window candidates which possibly can join the group. Found
candidates are marked here visual. */
virtual bool FindSnappingCandidates(SATGroup* group) = 0;
virtual bool FindSnappingCandidates(SATGroup* group) = 0;
/*! Join all candidates found in FindSnappingCandidates to the group.
Previously visually mark should be removed here. \return true if
integration has been succeed. */
virtual bool JoinCandidates() = 0;
virtual bool JoinCandidates() = 0;
/*! Update the window tab values, solve the layout and move all windows in
the group accordantly. */
virtual void DoWindowLayout() = 0;
virtual void RemovedFromArea(WindowArea* area) {}
virtual void TabLocationMoved(float location, bool shifting) {}
virtual void DoWindowLayout() = 0;
virtual void RemovedFromArea(WindowArea* area) {}
virtual void TabLocationMoved(float location, bool shifting)
{}
};