Deskbar: Improve auto-raise and auto-hide
Activate auto-raise on the screen edge inside the Deskbar window
frame. Set the event mask to B_POINTER_EVENTS when auto-raise or
auto-hide is on and set the event mask back to 0 when we turn off
auto-raise and auto-hide. Before this change you had to click a
window twice to get it to rise above of a raised Deskbar, with
this change you only have to click once to make the window rise
above Deskbar.
The auto-hide show and hide bounds are unchanged.
There was another bug where the window was not hiding correctly in
auto-hide mode when you moused over the status bar in horizontal
mode. This was happening because the where parameter of
TBarView::MouseMoved and TBarView::MouseDown was yielding
coordinates relative to the status tray when the mouse was over
the status tray and not the current view meaning that
TBarView::Frame().Contains(where) would return false over the
status tray. Inspecting the where parameter showed that the x-
coordinate was reset back to 0 when you mouse over the status tray.
To fix this issue I pulled the screen_where field out of
CurrentMessage() instead since this yields the correct value.
The calendar window input focus has been fixed in auto-raise mode
so that you can click on calendar even when it is above Deskbar.
You may also click a window on top of Deskbar in auto-raise mode
without the Deskbar window being raised.
Don't hide Deskbar when Calendar is showing in auto-hide mode.
Put comment inside else block inside { }.
Return from TBarView::MouseDown() calling ansestor method.
Quit fCalendarWindow on TimeView deconstructor if it exists (even if
it is not curently being shown.)
Fixes #8923 #14493
Change-Id: I7ed67fdbc30a93d2782b3ab6b6738b86ec5e4043
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1966
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
committed by
Adrien Destugues
parent
53db2fc8cf
commit
dcf9675793
@@ -297,26 +297,35 @@ TBarView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage)
|
||||
return;
|
||||
}
|
||||
|
||||
if (transit == B_ENTERED_VIEW && EventMask() == 0)
|
||||
SetEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY);
|
||||
|
||||
BPoint whereScreen = ConvertToScreen(where);
|
||||
|
||||
desk_settings* settings = fBarApp->Settings();
|
||||
bool alwaysOnTop = settings->alwaysOnTop;
|
||||
bool autoRaise = settings->autoRaise;
|
||||
bool autoHide = settings->autoHide;
|
||||
|
||||
// exit if both auto-raise and auto-hide are off
|
||||
if (!autoRaise && !autoHide) {
|
||||
if (transit == B_EXITED_VIEW || transit == B_OUTSIDE_VIEW)
|
||||
SetEventMask(0);
|
||||
return;
|
||||
// turn off mouse tracking
|
||||
SetEventMask(0);
|
||||
|
||||
return BView::MouseMoved(where, transit, dragMessage);
|
||||
} else {
|
||||
// track mouse outside view
|
||||
SetEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY);
|
||||
}
|
||||
|
||||
bool isTopMost = Window()->Feel() == B_FLOATING_ALL_WINDOW_FEEL;
|
||||
|
||||
// Auto-Raise
|
||||
// where is relative to status tray while mouse is over it so pull
|
||||
// the screen point out of the message instead
|
||||
BMessage* currentMessage = Window()->CurrentMessage();
|
||||
if (currentMessage == NULL)
|
||||
return BView::MouseMoved(where, transit, dragMessage);
|
||||
|
||||
BPoint whereScreen = currentMessage->GetPoint("screen_where",
|
||||
ConvertToScreen(where));
|
||||
BRect screenFrame = (BScreen(Window())).Frame();
|
||||
|
||||
// Auto-Raise and Auto-Hide
|
||||
if ((whereScreen.x == screenFrame.left
|
||||
|| whereScreen.x == screenFrame.right
|
||||
|| whereScreen.y == screenFrame.top
|
||||
@@ -324,63 +333,87 @@ TBarView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage)
|
||||
&& Window()->Frame().Contains(whereScreen)) {
|
||||
// cursor is on a screen edge within the window frame
|
||||
|
||||
// raise Deskbar
|
||||
if (!alwaysOnTop && autoRaise && !isTopMost)
|
||||
RaiseDeskbar(true);
|
||||
|
||||
// show Deskbar
|
||||
if (autoHide && IsHidden())
|
||||
HideDeskbar(false);
|
||||
} else {
|
||||
TBarWindow* window = (TBarWindow*)Window();
|
||||
if (window->IsShowingMenu())
|
||||
return;
|
||||
|
||||
// cursor is not on screen edge
|
||||
BRect preventHideArea = Window()->Frame().InsetByCopy(
|
||||
-kMaxPreventHidingDist, -kMaxPreventHidingDist);
|
||||
|
||||
if (preventHideArea.Contains(whereScreen))
|
||||
return;
|
||||
|
||||
// cursor to bar distance above threshold
|
||||
if (!alwaysOnTop && autoRaise && isTopMost) {
|
||||
RaiseDeskbar(false);
|
||||
SetEventMask(0);
|
||||
// stop if menu is showing or calendar is showing
|
||||
TBarWindow* window = dynamic_cast<TBarWindow*>(Window());
|
||||
if ((window != NULL && window->IsShowingMenu())
|
||||
|| fReplicantTray->fTime->IsShowingCalendar()) {
|
||||
return BView::MouseMoved(where, transit, dragMessage);
|
||||
}
|
||||
|
||||
if (autoHide && !IsHidden())
|
||||
// lower Deskbar
|
||||
if (!alwaysOnTop && autoRaise && isTopMost)
|
||||
RaiseDeskbar(false);
|
||||
|
||||
// check if cursor to bar distance is below threshold
|
||||
BRect preventHideArea = Window()->Frame().InsetByCopy(
|
||||
-kMaxPreventHidingDist, -kMaxPreventHidingDist);
|
||||
if (!preventHideArea.Contains(whereScreen)
|
||||
&& autoHide && !IsHidden()) {
|
||||
// hide Deskbar
|
||||
HideDeskbar(true);
|
||||
}
|
||||
}
|
||||
|
||||
BView::MouseMoved(where, transit, dragMessage);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarView::MouseDown(BPoint where)
|
||||
{
|
||||
BPoint whereScreen = ConvertToScreen(where);
|
||||
// where is relative to status tray while mouse is over it so pull
|
||||
// the screen point out of the message instead
|
||||
BMessage* currentMessage = Window()->CurrentMessage();
|
||||
if (currentMessage == NULL)
|
||||
return BView::MouseDown(where);
|
||||
|
||||
desk_settings* settings = fBarApp->Settings();
|
||||
bool alwaysOnTop = settings->alwaysOnTop;
|
||||
bool autoRaise = settings->autoRaise;
|
||||
bool autoHide = settings->autoHide;
|
||||
bool isTopMost = Window()->Feel() == B_FLOATING_ALL_WINDOW_FEEL;
|
||||
|
||||
BPoint whereScreen = currentMessage->GetPoint("screen_where",
|
||||
ConvertToScreen(where));
|
||||
if (Window()->Frame().Contains(whereScreen)) {
|
||||
Window()->Activate();
|
||||
// don't activate window if calendar is showing
|
||||
if (!fReplicantTray->fTime->IsShowingCalendar()
|
||||
&& (alwaysOnTop || (autoRaise && isTopMost))) {
|
||||
Window()->Activate();
|
||||
}
|
||||
|
||||
if ((modifiers() & (B_CONTROL_KEY | B_COMMAND_KEY | B_OPTION_KEY
|
||||
| B_SHIFT_KEY)) == (B_CONTROL_KEY | B_COMMAND_KEY)) {
|
||||
// The window key was pressed - enter dragging code
|
||||
fDragRegion->MouseDown(fDragRegion->DragRegion().LeftTop());
|
||||
return;
|
||||
return BView::MouseDown(where);
|
||||
}
|
||||
} else {
|
||||
// hide deskbar if required
|
||||
desk_settings* settings = fBarApp->Settings();
|
||||
bool alwaysOnTop = settings->alwaysOnTop;
|
||||
bool autoRaise = settings->autoRaise;
|
||||
bool autoHide = settings->autoHide;
|
||||
bool isTopMost = Window()->Feel() == B_FLOATING_ALL_WINDOW_FEEL;
|
||||
// stop if menu is showing or calendar is showing
|
||||
TBarWindow* window = dynamic_cast<TBarWindow*>(Window());
|
||||
if ((window != NULL && window->IsShowingMenu())
|
||||
|| fReplicantTray->fTime->IsShowingCalendar()) {
|
||||
return BView::MouseDown(where);
|
||||
}
|
||||
|
||||
// lower deskbar
|
||||
if (!alwaysOnTop && autoRaise && isTopMost)
|
||||
RaiseDeskbar(false);
|
||||
|
||||
// hide deskbar
|
||||
if (autoHide && !IsHidden())
|
||||
HideDeskbar(true);
|
||||
}
|
||||
|
||||
BView::MouseDown(where);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -52,8 +52,8 @@ All rights reserved.
|
||||
#include <Window.h>
|
||||
|
||||
#include "BarApp.h"
|
||||
#include "StatusView.h"
|
||||
#include "CalendarMenuWindow.h"
|
||||
#include "StatusView.h"
|
||||
|
||||
|
||||
static const float kHMargin = 2.0;
|
||||
@@ -76,6 +76,7 @@ TTimeView::TTimeView(float maxWidth, float height)
|
||||
fShowSeconds(false),
|
||||
fShowDayOfWeek(false),
|
||||
fShowTimeZone(false),
|
||||
fCalendarWindow(NULL),
|
||||
fTimeFormat(NULL),
|
||||
fDateFormat(NULL)
|
||||
{
|
||||
@@ -106,6 +107,9 @@ TTimeView::TTimeView(BMessage* data)
|
||||
|
||||
TTimeView::~TTimeView()
|
||||
{
|
||||
if (fCalendarWindow != NULL)
|
||||
fCalendarWindow->Quit();
|
||||
|
||||
delete fTimeFormat;
|
||||
delete fDateFormat;
|
||||
}
|
||||
@@ -369,13 +373,13 @@ TTimeView::SetShowTimeZone(bool show)
|
||||
void
|
||||
TTimeView::ShowCalendar(BPoint where)
|
||||
{
|
||||
if (fCalendarWindow.IsValid()) {
|
||||
if (fCalendarWindowMessenger.IsValid()) {
|
||||
// If the calendar is already shown, just activate it
|
||||
BMessage activate(B_SET_PROPERTY);
|
||||
activate.AddSpecifier("Active");
|
||||
activate.AddBool("data", true);
|
||||
|
||||
if (fCalendarWindow.SendMessage(&activate) == B_OK)
|
||||
if (fCalendarWindowMessenger.SendMessage(&activate) == B_OK)
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -385,10 +389,16 @@ TTimeView::ShowCalendar(BPoint where)
|
||||
if (where.y >= BScreen().Frame().bottom)
|
||||
where.y -= (Bounds().Height() + 4.0);
|
||||
|
||||
CalendarMenuWindow* window = new CalendarMenuWindow(where);
|
||||
fCalendarWindow = BMessenger(window);
|
||||
fCalendarWindow = new CalendarMenuWindow(where);
|
||||
fCalendarWindowMessenger = BMessenger(fCalendarWindow);
|
||||
fCalendarWindow->Show();
|
||||
}
|
||||
|
||||
window->Show();
|
||||
|
||||
bool
|
||||
TTimeView::IsShowingCalendar()
|
||||
{
|
||||
return fCalendarWindow != NULL && !fCalendarWindow->IsHidden();
|
||||
}
|
||||
|
||||
|
||||
@@ -414,6 +424,7 @@ TTimeView::UpdateTimeFormat()
|
||||
fDateFormat = new BDateFormat(BLocale::Default());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTimeView::GetCurrentTime()
|
||||
{
|
||||
|
||||
@@ -69,6 +69,7 @@ const uint32 kGetClockSettings = 'GCkS';
|
||||
|
||||
class BCountry;
|
||||
class BMessageRunner;
|
||||
class CalendarMenuWindow;
|
||||
|
||||
#ifdef AS_REPLICANT
|
||||
class _EXPORT TTimeView;
|
||||
@@ -108,6 +109,7 @@ public:
|
||||
void SetShowTimeZone(bool show);
|
||||
|
||||
void ShowCalendar(BPoint where);
|
||||
bool IsShowingCalendar();
|
||||
|
||||
private:
|
||||
friend class TReplicantTray;
|
||||
@@ -147,7 +149,8 @@ private:
|
||||
BPoint fTimeLocation;
|
||||
BPoint fDateLocation;
|
||||
|
||||
BMessenger fCalendarWindow;
|
||||
BMessenger fCalendarWindowMessenger;
|
||||
CalendarMenuWindow* fCalendarWindow;
|
||||
|
||||
// For date and time localization purposes
|
||||
BDateTimeFormat* fTimeFormat;
|
||||
|
||||
Reference in New Issue
Block a user