From cc4612fe3f8b65d6c9dd9a52e880bbf98c51ff54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 13 Apr 2006 13:56:01 +0000 Subject: [PATCH] * Modal windows are now correctly taken into account: no click go through to a window with a modal window. This also completes the fix for bug #439. * Made some methods const that should have been const in the first place. * Note, there is now a Desktop::_WindowHasModal() and WindowLayer::HasModal() - the latter only works in the current workspace. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17121 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/WindowLayer.cpp | 28 +++++++++++++++++++++++++--- src/servers/app/WindowLayer.h | 8 +++++--- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/servers/app/WindowLayer.cpp b/src/servers/app/WindowLayer.cpp index 0d30904be6..790b5b94ac 100644 --- a/src/servers/app/WindowLayer.cpp +++ b/src/servers/app/WindowLayer.cpp @@ -532,14 +532,14 @@ WindowLayer::Anchor(int32 index) WindowLayer* -WindowLayer::NextWindow(int32 index) +WindowLayer::NextWindow(int32 index) const { return fAnchor[index].next; } WindowLayer* -WindowLayer::PreviousWindow(int32 index) +WindowLayer::PreviousWindow(int32 index) const { return fAnchor[index].previous; } @@ -793,6 +793,9 @@ WindowLayer::MouseDown(BMessage* message, BPoint where, int32* _viewToken) } } else { if (ViewLayer* view = ViewAt(where)) { + if (HasModal()) + return; + // clicking a simple ViewLayer if (!IsFocus()) { DesktopSettings desktopSettings(fDesktop); @@ -865,6 +868,9 @@ WindowLayer::MouseUp(BMessage* message, BPoint where, int32* _viewToken) fIsSlidingTab = false; if (ViewLayer* view = ViewAt(where)) { + if (HasModal()) + return; + *_viewToken = view->Token(); view->MouseUp(message, where); } @@ -1316,6 +1322,22 @@ WindowLayer::IsNormal() const } +bool +WindowLayer::HasModal() const +{ + for (WindowLayer* window = NextWindow(fCurrentWorkspace); window != NULL; + window = window->NextWindow(fCurrentWorkspace)) { + if (window->IsHidden() || !window->IsModal()) + continue; + + if (window->HasInSubset(this)) + return true; + } + + return false; +} + + /*! \brief Returns the windows that's in behind of the backmost position this window can get. @@ -1399,7 +1421,7 @@ WindowLayer::RemoveFromSubset(WindowLayer* window) bool -WindowLayer::HasInSubset(WindowLayer* window) +WindowLayer::HasInSubset(const WindowLayer* window) const { if (fFeel == window->Feel() || fFeel == B_NORMAL_WINDOW_FEEL) return false; diff --git a/src/servers/app/WindowLayer.h b/src/servers/app/WindowLayer.h index cc67133d42..99eb5936bb 100644 --- a/src/servers/app/WindowLayer.h +++ b/src/servers/app/WindowLayer.h @@ -49,8 +49,8 @@ class WindowLayer { const char* Title() const { return fTitle.String(); } window_anchor& Anchor(int32 index); - WindowLayer* NextWindow(int32 index); - WindowLayer* PreviousWindow(int32 index); + WindowLayer* NextWindow(int32 index) const; + WindowLayer* PreviousWindow(int32 index) const; ::Desktop* Desktop() const { return fDesktop; } ::Decorator* Decorator() const { return fDecorator; } @@ -188,12 +188,14 @@ class WindowLayer { bool IsFloating() const; bool IsNormal() const; + bool HasModal() const; + WindowLayer* Frontmost(WindowLayer* first = NULL, int32 workspace = -1); WindowLayer* Backmost(WindowLayer* first = NULL, int32 workspace = -1); bool AddToSubset(WindowLayer* window); void RemoveFromSubset(WindowLayer* window); - bool HasInSubset(WindowLayer* window); + bool HasInSubset(const WindowLayer* window) const; bool SameSubset(WindowLayer* window); uint32 SubsetWorkspaces() const;