From c6f9f65dff468f7f1a495f49b547f2833ace03dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 4 Jan 2007 12:28:31 +0000 Subject: [PATCH] At least temporary fix for the Deskbar not updating additional items (unless you resize it). The problem was that the view's screen clipping was not updated if its frame did not change because of a resized parent - but that might be needed if the new parent frame reveals a new portion of that view. I added a TODO so that if there is a way to test for this case, we only need to invalidate the clipping if really needed. For now, we always do it. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19695 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/CursorManager.cpp | 14 +++++++++++--- src/servers/app/CursorManager.h | 2 +- src/servers/app/ServerCursor.cpp | 7 +++---- src/servers/app/ServerCursor.h | 3 ++- src/servers/app/ViewLayer.cpp | 6 ++++++ 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/servers/app/CursorManager.cpp b/src/servers/app/CursorManager.cpp index 2b7a41cbf7..464e359eef 100644 --- a/src/servers/app/CursorManager.cpp +++ b/src/servers/app/CursorManager.cpp @@ -133,19 +133,27 @@ CursorManager::AddCursor(ServerCursor* cursor, int32 token) /*! - \brief Releases a reference to a cursor + \brief Removes a cursor if it's not referenced anymore. If this was the last reference to this cursor, it will be deleted. + Only if the cursor is deleted, \c true is returned. */ -void +bool CursorManager::RemoveCursor(ServerCursor* cursor) { if (!Lock()) - return; + return false; + + if (cursor->ReferenceCount() > 0) { + // cursor has been referenced again in the mean time + Unlock(); + return false; + } _RemoveCursor(cursor); Unlock(); + return true; } diff --git a/src/servers/app/CursorManager.h b/src/servers/app/CursorManager.h index 16d8a21b71..0a39faf07b 100644 --- a/src/servers/app/CursorManager.h +++ b/src/servers/app/CursorManager.h @@ -39,7 +39,7 @@ class CursorManager : public BLocker { int32 AddCursor(ServerCursor* cursor, int32 token = -1); void DeleteCursors(team_id team); - void RemoveCursor(ServerCursor* cursor); + bool RemoveCursor(ServerCursor* cursor); void SetCursorSet(const char* path); ServerCursor* GetCursor(cursor_which which); diff --git a/src/servers/app/ServerCursor.cpp b/src/servers/app/ServerCursor.cpp index 14ddcccaa9..a82d994ee9 100644 --- a/src/servers/app/ServerCursor.cpp +++ b/src/servers/app/ServerCursor.cpp @@ -197,11 +197,10 @@ ServerCursor::Release() return false; } - if (fManager) { - fManager->RemoveCursor(this); - } - delete this; + if (fManager && !fManager->RemoveCursor(this)) + return false; + delete this; return true; } return false; diff --git a/src/servers/app/ServerCursor.h b/src/servers/app/ServerCursor.h index 3977321a82..80c22a1607 100644 --- a/src/servers/app/ServerCursor.h +++ b/src/servers/app/ServerCursor.h @@ -50,6 +50,7 @@ class ServerCursor : public ServerBitmap { void Acquire() { atomic_add(&fReferenceCount, 1); } bool Release(); + int32 ReferenceCount() { return fReferenceCount; } void SetPendingViewCursor(bool pending); @@ -63,7 +64,7 @@ class ServerCursor : public ServerBitmap { BPoint fHotSpot; team_id fOwningTeam; - int32 fReferenceCount; + vint32 fReferenceCount; uint8* fCursorData; CursorManager* fManager; vint32 fPendingViewCursor; diff --git a/src/servers/app/ViewLayer.cpp b/src/servers/app/ViewLayer.cpp index 82910c2742..eb5319bd43 100644 --- a/src/servers/app/ViewLayer.cpp +++ b/src/servers/app/ViewLayer.cpp @@ -900,6 +900,12 @@ ViewLayer::ParentResized(int32 x, int32 y, BRegion* dirtyRegion) newFrame.top - fFrame.top, dirtyRegion); ResizeBy(widthDiff, heightDiff, dirtyRegion); + } else { + // TODO: this covers the fact that our screen clipping might change + // when the parent changes its size, even though our frame stays + // the same - there might be a way to test for this, but axeld doesn't + // know, stippi should look into this when he's back :) + InvalidateScreenClipping(); } }