From 91d6453948960c4793a82b238ab5ca2caef73e04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 13 Mar 2007 16:53:19 +0000 Subject: [PATCH] * 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 --- src/servers/app/Workspace.cpp | 24 +++++++++++++++++++++++- src/servers/app/Workspace.h | 3 ++- src/servers/app/WorkspacesLayer.cpp | 11 +++++------ 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/servers/app/Workspace.cpp b/src/servers/app/Workspace.cpp index 99d0de1221..6824c97275 100644 --- a/src/servers/app/Workspace.cpp +++ b/src/servers/app/Workspace.cpp @@ -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() { diff --git a/src/servers/app/Workspace.h b/src/servers/app/Workspace.h index 5adba0e391..7e801597a6 100644 --- a/src/servers/app/Workspace.h +++ b/src/servers/app/Workspace.h @@ -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; diff --git a/src/servers/app/WorkspacesLayer.cpp b/src/servers/app/WorkspacesLayer.cpp index 30e1d2a28f..df24b23d55 100644 --- a/src/servers/app/WorkspacesLayer.cpp +++ b/src/servers/app/WorkspacesLayer.cpp @@ -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; } }