Use the mouse x position and the candidate tab top when searching for a stacking parent. I think this makes the stacking detection more intuitive.
The candidate window is the dragged window and the parent window is the window that accept the SAT operation. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39003 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -203,7 +203,7 @@ StackingEventHandler::HandleMessage(SATWindow* sender,
|
|||||||
SATStacking::SATStacking(SATWindow* window)
|
SATStacking::SATStacking(SATWindow* window)
|
||||||
:
|
:
|
||||||
fSATWindow(window),
|
fSATWindow(window),
|
||||||
fStackingCandidate(NULL)
|
fStackingParent(NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -221,16 +221,24 @@ SATStacking::FindSnappingCandidates(SATGroup* group)
|
|||||||
_ClearSearchResult();
|
_ClearSearchResult();
|
||||||
|
|
||||||
Window* window = fSATWindow->GetWindow();
|
Window* window = fSATWindow->GetWindow();
|
||||||
BPoint leftTop = window->Decorator()->TabRect().LeftTop();
|
if (!window->Decorator())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
BPoint mousePosition;
|
||||||
|
int32 buttons;
|
||||||
|
fSATWindow->GetDesktop()->GetLastMouseState(&mousePosition, &buttons);
|
||||||
|
// use the upper edge of the candidate window to find the parent window
|
||||||
|
mousePosition.y = window->Decorator()->TabRect().top;
|
||||||
|
|
||||||
for (int i = 0; i < group->CountItems(); i++) {
|
for (int i = 0; i < group->CountItems(); i++) {
|
||||||
SATWindow* satWindow = group->WindowAt(i);
|
SATWindow* satWindow = group->WindowAt(i);
|
||||||
// search for stacking candidate
|
// search for stacking parent
|
||||||
Window* win = satWindow->GetWindow();
|
Window* win = satWindow->GetWindow();
|
||||||
if (win != window && win->Decorator()
|
if (win == window || !win->Decorator())
|
||||||
&& win->Decorator()->TabRect().Contains(leftTop)) {
|
continue;
|
||||||
// remember window as the candidate for stacking
|
if (win->Decorator()->TabRect().Contains(mousePosition)) {
|
||||||
fStackingCandidate = satWindow;
|
// remember window as the parent for stacking
|
||||||
|
fStackingParent = satWindow;
|
||||||
_HighlightWindows(true);
|
_HighlightWindows(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -243,10 +251,10 @@ SATStacking::FindSnappingCandidates(SATGroup* group)
|
|||||||
bool
|
bool
|
||||||
SATStacking::JoinCandidates()
|
SATStacking::JoinCandidates()
|
||||||
{
|
{
|
||||||
if (!fStackingCandidate)
|
if (!fStackingParent)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool result = fStackingCandidate->StackWindow(fSATWindow);
|
bool result = fStackingParent->StackWindow(fSATWindow);
|
||||||
|
|
||||||
_ClearSearchResult();
|
_ClearSearchResult();
|
||||||
return result;
|
return result;
|
||||||
@@ -317,11 +325,11 @@ SATStacking::TabLocationMoved(float location, bool shifting)
|
|||||||
void
|
void
|
||||||
SATStacking::_ClearSearchResult()
|
SATStacking::_ClearSearchResult()
|
||||||
{
|
{
|
||||||
if (!fStackingCandidate)
|
if (!fStackingParent)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_HighlightWindows(false);
|
_HighlightWindows(false);
|
||||||
fStackingCandidate = NULL;
|
fStackingParent = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -331,7 +339,7 @@ SATStacking::_HighlightWindows(bool highlight)
|
|||||||
Desktop* desktop = fSATWindow->GetWindow()->Desktop();
|
Desktop* desktop = fSATWindow->GetWindow()->Desktop();
|
||||||
if (!desktop)
|
if (!desktop)
|
||||||
return;
|
return;
|
||||||
fStackingCandidate->HighlightTab(highlight);
|
fStackingParent->HighlightTab(highlight);
|
||||||
fSATWindow->HighlightTab(highlight);
|
fSATWindow->HighlightTab(highlight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ private:
|
|||||||
|
|
||||||
SATWindow* fSATWindow;
|
SATWindow* fSATWindow;
|
||||||
|
|
||||||
SATWindow* fStackingCandidate;
|
SATWindow* fStackingParent;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user