* Added a new Workspace::GetPreviousWindow() method to allow traversing the window

list in the other direction.
* Since WorkspacesLayer now cuts out the current window from the clipping region,
  the window order was upside down; it now uses the new Workspace::GetPreviousWindow().
  This fixes bug #1105.
* WorkspacesLayer::MouseDown() now also uses GetPreviousWindow() which prevents it
  from needing to scan the whole window list for the top window at every click.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20382 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2007-03-13 16:53:19 +00:00
parent a3d758e369
commit 91d6453948
3 changed files with 30 additions and 8 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2005-2006, Haiku.
* Copyright 2005-2007, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
@ -138,6 +138,28 @@ Workspace::GetNextWindow(WindowLayer*& _window, BPoint& _leftTop)
}
status_t
Workspace::GetPreviousWindow(WindowLayer*& _window, BPoint& _leftTop)
{
if (fCurrent == NULL)
fCurrent = fWorkspace.Windows().LastWindow();
else
fCurrent = fCurrent->PreviousWindow(fWorkspace.Index());
if (fCurrent == NULL)
return B_ENTRY_NOT_FOUND;
_window = fCurrent;
if (fCurrentWorkspace)
_leftTop = fCurrent->Frame().LeftTop();
else
_leftTop = fCurrent->Anchor(fWorkspace.Index()).position;
return B_OK;
}
void
Workspace::RewindWindows()
{

View File

@ -1,5 +1,5 @@
/*
* Copyright 2005, Haiku.
* Copyright 2005-2007, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
@ -28,6 +28,7 @@ class Workspace {
{ return fCurrentWorkspace; }
status_t GetNextWindow(WindowLayer*& _window, BPoint& _leftTop);
status_t GetPreviousWindow(WindowLayer*& _window, BPoint& _leftTop);
void RewindWindows();
class Private;

View File

@ -262,16 +262,16 @@ WorkspacesLayer::_DrawWorkspace(DrawingEngine* drawingEngine,
backgroundRegion.IntersectWith(&workspaceRegion);
drawingEngine->ConstrainClippingRegion(&backgroundRegion);
// We draw from top down and cut the window out of the clipping region
// which reduces the flickering
WindowLayer* window;
BPoint leftTop;
while (workspace.GetNextWindow(window, leftTop) == B_OK) {
while (workspace.GetPreviousWindow(window, leftTop) == B_OK) {
_DrawWindow(drawingEngine, rect, screenFrame, window,
leftTop, backgroundRegion, active);
}
// draw background
//drawingEngine->ConstrainClippingRegion(&backgroundRegion);
drawingEngine->FillRect(rect, color);
drawingEngine->ConstrainClippingRegion(&redraw);
@ -376,15 +376,14 @@ WorkspacesLayer::MouseDown(BMessage* message, BPoint where)
WindowLayer* window;
BRect windowFrame;
BPoint leftTop;
while (workspace.GetNextWindow(window, leftTop) == B_OK) {
while (workspace.GetPreviousWindow(window, leftTop) == B_OK) {
BRect frame = _WindowFrame(workspaceFrame, screenFrame, window->Frame(),
leftTop);
if (frame.Contains(where) && window->Feel() != kDesktopWindowFeel
&& window->Feel() != kWindowScreenFeel) {
// We can't exit the loop here, as we traverse the window
// list in the wrong direction...
fSelectedWindow = window;
windowFrame = frame;
break;
}
}