From 1c765f5b62820d833dfa2acca312336f5b3065e4 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Tue, 18 Feb 2020 02:03:58 -0500 Subject: [PATCH] Deskbar: Set window limits to hidden dimension in auto-hide mode. This fixes a bug where the window size limits were not set correctly causing the window not to be hidden properly in some cases while Deskbar is in auto-hide mode. This bug was introduced in hrev53585: Update window resize size limits. A couple of other auto-hide related bugs were also fixed: Hide TBarView in constructor if auto-hide is on. This is needed to size and position the window correctly on Deskbar startup in auto- hide mode. Always Check fTime->IsHidden() from the perspective of fTime instead of the parent view because we were getting false positives that the clock was hidden in auto-hide mode which caused the replicants not to realign themselves around the clock on Deskbar startup. The clock thought it was hidden because the parent view was hidden but that's not what is needed here. Bail out of BarView::MouseMoved if resizing. This fixes a bug where if you resized the window in auto-hide mode once the window had become as wide as possible dragging beyond the window hidden area slop limit would confusingly cause the window to hide itself in the middle of your resize operation. Fixes #15067 better. Fixes problems related to #8641 and #9469. Change-Id: I58de02e0cdd4e4cdccc15594992f11bf8c7f3a26 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2252 Reviewed-by: waddlesplash --- src/apps/deskbar/BarView.cpp | 18 ++++++++++++++---- src/apps/deskbar/BarWindow.cpp | 22 +++++++++++++++++----- src/apps/deskbar/StatusView.cpp | 8 ++++---- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp index 6d8fd6ba44..dcea99ed31 100644 --- a/src/apps/deskbar/BarView.cpp +++ b/src/apps/deskbar/BarView.cpp @@ -184,6 +184,9 @@ TBarView::TBarView(BRect frame, bool vertical, bool left, bool top, // If mini mode, hide the application menubar if (state == kMiniState) fInlineScrollView->Hide(); + + if (fBarApp->Settings()->autoHide && !IsHidden()) + Hide(); } @@ -292,10 +295,10 @@ TBarView::MessageReceived(BMessage* message) void TBarView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage) { - if (fDragRegion->IsDragging()) { - fDragRegion->MouseMoved(where, transit, dragMessage); - return; - } + if (fDragRegion->IsDragging()) + return fDragRegion->MouseMoved(where, transit, dragMessage); + else if (fResizeControl->IsResizing()) + return BView::MouseMoved(where, transit, dragMessage); desk_settings* settings = fBarApp->Settings(); bool alwaysOnTop = settings->alwaysOnTop; @@ -805,13 +808,20 @@ void TBarView::HideDeskbar(bool hide) { BRect screenFrame = (BScreen(Window())).Frame(); + TBarWindow* barWindow = dynamic_cast(Window()); if (hide) { Hide(); + if (barWindow != NULL) + barWindow->SetSizeLimits(); + PositionWindow(screenFrame); SizeWindow(screenFrame); } else { Show(); + if (barWindow != NULL) + barWindow->SetSizeLimits(); + SizeWindow(screenFrame); PositionWindow(screenFrame); } diff --git a/src/apps/deskbar/BarWindow.cpp b/src/apps/deskbar/BarWindow.cpp index 388846bf5c..db65d94e13 100644 --- a/src/apps/deskbar/BarWindow.cpp +++ b/src/apps/deskbar/BarWindow.cpp @@ -654,12 +654,24 @@ void TBarWindow::SetSizeLimits() { BRect screenFrame = (BScreen(this)).Frame(); - if (fBarView->Vertical()) { - BWindow::SetSizeLimits(gMinimumWindowWidth, gMaximumWindowWidth, - kMenuBarHeight - 1, screenFrame.Height()); + bool setToHiddenSize = static_cast(be_app)->Settings()->autoHide + && fBarView->IsHidden() && !fBarView->DragRegion()->IsDragging(); + + if (setToHiddenSize) { + if (fBarView->Vertical()) + BWindow::SetSizeLimits(0, kHiddenDimension, 0, kHiddenDimension); + else { + BWindow::SetSizeLimits(screenFrame.Width(), screenFrame.Width(), + 0, kHiddenDimension); + } } else { - BWindow::SetSizeLimits(screenFrame.Width(), screenFrame.Width(), - kMenuBarHeight - 1, kMaximumIconSize + 4); + if (fBarView->Vertical()) { + BWindow::SetSizeLimits(gMinimumWindowWidth, gMaximumWindowWidth, + kMenuBarHeight - 1, screenFrame.Height()); + } else { + BWindow::SetSizeLimits(screenFrame.Width(), screenFrame.Width(), + kMenuBarHeight - 1, kMaximumIconSize + 4); + } } } diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp index 5ff13b4d58..35d8ed5ebb 100644 --- a/src/apps/deskbar/StatusView.cpp +++ b/src/apps/deskbar/StatusView.cpp @@ -237,7 +237,7 @@ TReplicantTray::GetPreferredSize(float* preferredWidth, float* preferredHeight) } else { // if last replicant overruns clock then resize to accomodate if (ReplicantCount() > 0) { - if (!fTime->IsHidden() && Bounds().right - kTrayPadding - 2 + if (!fTime->IsHidden(fTime) && Bounds().right - kTrayPadding - 2 - fTime->Frame().Width() - kClockMargin < fRightBottomReplicant.right + kClockMargin) { width = fRightBottomReplicant.right + kClockMargin @@ -329,7 +329,7 @@ TReplicantTray::MessageReceived(BMessage* message) if (fTime == NULL) return; - bool showClock = !fTime->IsHidden(); + bool showClock = !fTime->IsHidden(fTime); bool showSeconds = fTime->ShowSeconds(); bool showDayOfWeek = fTime->ShowDayOfWeek(); bool showTimeZone = fTime->ShowTimeZone(); @@ -409,7 +409,7 @@ TReplicantTray::ShowReplicantMenu(BPoint point) // If clock is visible show the extended menu, otherwise show "Show clock" - if (!fTime->IsHidden()) + if (!fTime->IsHidden(fTime)) fTime->ShowTimeOptions(ConvertToScreen(point)); else { BMenuItem* item = new BMenuItem(B_TRANSLATE("Show clock"), @@ -1177,7 +1177,7 @@ TReplicantTray::LocationForReplicant(int32 index, float replicantWidth) loc.x + static_cast(be_app)->Settings()->width - (kTrayPadding + kDragWidth + kGutter) * 2, loc.y + fMaxReplicantHeight); - if (row == 0 && !fTime->IsHidden()) + if (row == 0 && !fTime->IsHidden(fTime)) rowRect.right -= kClockMargin + fTime->Frame().Width(); BRect replicantRect = rowRect;