From 46fb2d73bed519b7712918568b5aeda5cd7ef54d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Wed, 24 May 2006 11:05:25 +0000 Subject: [PATCH] sorry, I couldn't resist... * added a few very small changes to make the tab sliding work perfectly * added a comment on the purpose of WindowLayer::fLastMousePosition and how it is supposed to be used to have the mouse cursor stick to what is being dragged * TODO: the tab offset doesn't necessarily have to be on [0..1], as long as we update it during window resizing to keep the relative position git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17577 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/DefaultDecorator.cpp | 5 +++++ src/servers/app/Desktop.cpp | 10 ++++++---- src/servers/app/Desktop.h | 2 +- src/servers/app/WindowLayer.cpp | 16 +++++++++++++--- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/servers/app/DefaultDecorator.cpp b/src/servers/app/DefaultDecorator.cpp index 760e462d53..dbe8d4dd33 100644 --- a/src/servers/app/DefaultDecorator.cpp +++ b/src/servers/app/DefaultDecorator.cpp @@ -343,11 +343,16 @@ DefaultDecorator::SetTabLocation(float location, BRegion* updateRegion) STRACE(("DefaultDecorator: Set Tab Location(%.1f)\n", location)); if (!_tabrect.IsValid()) return false; + if (location < 0) location = 0; if (location > (fRightBorder.right - fLeftBorder.left - _tabrect.Width())) location = (fRightBorder.right - fLeftBorder.left - _tabrect.Width()); + float delta = location - fTabOffset; + if (delta == 0.0) + return false; + // redraw old rect (1 pix on the border also must be updated) BRect trect(_tabrect); trect.bottom++; diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index b409839794..4f663b01e5 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -1575,16 +1575,16 @@ Desktop::ResizeWindowBy(WindowLayer* window, float x, float y) UnlockAllWindows(); } -void +bool Desktop::SetWindowTabLocation(WindowLayer* window, float location) { if (!LockAllWindows()) - return; + return false; BRegion dirty; - window->SetTabLocation(location, dirty); + bool changed = window->SetTabLocation(location, dirty); - if (window->IsVisible() && dirty.CountRects() > 0) { + if (changed && window->IsVisible() && dirty.CountRects() > 0) { BRegion stillAvailableOnScreen; _RebuildClippingForAllWindows(stillAvailableOnScreen); _SetBackground(stillAvailableOnScreen); @@ -1593,6 +1593,8 @@ Desktop::SetWindowTabLocation(WindowLayer* window, float location) } UnlockAllWindows(); + + return changed; } diff --git a/src/servers/app/Desktop.h b/src/servers/app/Desktop.h index 10a7d550f6..47bec86c18 100644 --- a/src/servers/app/Desktop.h +++ b/src/servers/app/Desktop.h @@ -111,7 +111,7 @@ class Desktop : public MessageLooper, public ScreenOwner { void MoveWindowBy(WindowLayer* window, float x, float y, int32 workspace = -1); void ResizeWindowBy(WindowLayer* window, float x, float y); - void SetWindowTabLocation(WindowLayer* window, float location); + bool SetWindowTabLocation(WindowLayer* window, float location); void SetWindowWorkspaces(WindowLayer* window, uint32 workspaces); diff --git a/src/servers/app/WindowLayer.cpp b/src/servers/app/WindowLayer.cpp index bd9ab0793a..1933a9d308 100644 --- a/src/servers/app/WindowLayer.cpp +++ b/src/servers/app/WindowLayer.cpp @@ -975,6 +975,14 @@ WindowLayer::MouseMoved(BMessage *message, BPoint where, int32* _viewToken, } BPoint delta = where - fLastMousePosition; + // NOTE: "delta" is later used to change fLastMousePosition. + // If for some reason no change should take effect, delta + // is to be set to (0, 0) so that fLastMousePosition is not + // adjusted. This way the relative mouse position to the + // item being changed (border during resizing, tab during + // sliding...) stays fixed when the mouse is moved so that + // changes are taking effect again. + // moving if (fIsDragging) { if (!(Flags() & B_NOT_MOVABLE)) { @@ -1009,8 +1017,10 @@ WindowLayer::MouseMoved(BMessage *message, BPoint where, int32* _viewToken, float loc = TabLocation(); // TODO: change to [0:1] loc += delta.x; - fDesktop->SetWindowTabLocation(this, loc); - delta.y = 0; + if (fDesktop->SetWindowTabLocation(this, loc)) + delta.y = 0; + else + delta = BPoint(0, 0); } // NOTE: fLastMousePosition is currently only @@ -1210,7 +1220,7 @@ WindowLayer::SetTabLocation(float location, BRegion& dirty) bool ret = false; if (fDecorator) { ret = fDecorator->SetTabLocation(location, &dirty); - fBorderRegionValid = false; + fBorderRegionValid = fBorderRegionValid && !ret; // the border very likely changed } return ret;