[haiku-commits] Change in haiku[master]: Deskbar: Set window limits to hidden dimension in auto-hide mode.

  • From: Gerrit <review@xxxxxxxxxxxxxxxxxxx>
  • To: waddlesplash <waddlesplash@xxxxxxxxx>, haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 18 Feb 2020 19:10:41 +0000

From John Scipione <jscipione@xxxxxxxxx>:

John Scipione has uploaded this change for review. ( 
https://review.haiku-os.org/c/haiku/+/2252 ;)


Change subject: Deskbar: Set window limits to hidden dimension in auto-hide 
mode.
......................................................................

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.
---
M src/apps/deskbar/BarView.cpp
M src/apps/deskbar/BarWindow.cpp
M src/apps/deskbar/StatusView.cpp
3 files changed, 35 insertions(+), 13 deletions(-)



  git pull ssh://git.haiku-os.org:22/haiku refs/changes/52/2252/1

diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp
index 6d8fd6b..dcea99e 100644
--- a/src/apps/deskbar/BarView.cpp
+++ b/src/apps/deskbar/BarView.cpp
@@ -184,6 +184,9 @@
        // If mini mode, hide the application menubar
        if (state == kMiniState)
                fInlineScrollView->Hide();
+
+       if (fBarApp->Settings()->autoHide && !IsHidden())
+               Hide();
 }


@@ -292,10 +295,10 @@
 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 @@
 TBarView::HideDeskbar(bool hide)
 {
        BRect screenFrame = (BScreen(Window())).Frame();
+       TBarWindow* barWindow = dynamic_cast<TBarWindow*>(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 388846b..db65d94 100644
--- a/src/apps/deskbar/BarWindow.cpp
+++ b/src/apps/deskbar/BarWindow.cpp
@@ -654,12 +654,24 @@
 TBarWindow::SetSizeLimits()
 {
        BRect screenFrame = (BScreen(this)).Frame();
-       if (fBarView->Vertical()) {
-               BWindow::SetSizeLimits(gMinimumWindowWidth, gMaximumWindowWidth,
-                       kMenuBarHeight - 1, screenFrame.Height());
+       bool setToHiddenSize = 
static_cast<TBarApp*>(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 5ff13b4..35d8ed5 100644
--- a/src/apps/deskbar/StatusView.cpp
+++ b/src/apps/deskbar/StatusView.cpp
@@ -237,7 +237,7 @@
        } 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 @@
                        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 @@

        // 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 @@
                                loc.x + 
static_cast<TBarApp*>(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;

--
To view, visit https://review.haiku-os.org/c/haiku/+/2252
To unsubscribe, or for help writing mail filters, visit 
https://review.haiku-os.org/settings

Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I58de02e0cdd4e4cdccc15594992f11bf8c7f3a26
Gerrit-Change-Number: 2252
Gerrit-PatchSet: 1
Gerrit-Owner: John Scipione <jscipione@xxxxxxxxx>
Gerrit-MessageType: newchange

Other related posts:

  • » [haiku-commits] Change in haiku[master]: Deskbar: Set window limits to hidden dimension in auto-hide mode. - Gerrit