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 <[email protected]>
This commit is contained in:
John Scipione
2020-02-19 16:20:01 +00:00
committed by waddlesplash
parent cce89fa82f
commit 1c765f5b62
3 changed files with 35 additions and 13 deletions
+14 -4
View File
@@ -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<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);
}
+17 -5
View File
@@ -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<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);
}
}
}
+4 -4
View File
@@ -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<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;