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 <pulkomandy@gmail.com>
This commit is contained in:
parent
53db2fc8cf
commit
dcf9675793
@ -297,26 +297,35 @@ TBarView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage)
|
|||||||
return;
|
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();
|
desk_settings* settings = fBarApp->Settings();
|
||||||
bool alwaysOnTop = settings->alwaysOnTop;
|
bool alwaysOnTop = settings->alwaysOnTop;
|
||||||
bool autoRaise = settings->autoRaise;
|
bool autoRaise = settings->autoRaise;
|
||||||
bool autoHide = settings->autoHide;
|
bool autoHide = settings->autoHide;
|
||||||
|
|
||||||
|
// exit if both auto-raise and auto-hide are off
|
||||||
if (!autoRaise && !autoHide) {
|
if (!autoRaise && !autoHide) {
|
||||||
if (transit == B_EXITED_VIEW || transit == B_OUTSIDE_VIEW)
|
// turn off mouse tracking
|
||||||
SetEventMask(0);
|
SetEventMask(0);
|
||||||
return;
|
|
||||||
|
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;
|
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();
|
BRect screenFrame = (BScreen(Window())).Frame();
|
||||||
|
|
||||||
|
// Auto-Raise and Auto-Hide
|
||||||
if ((whereScreen.x == screenFrame.left
|
if ((whereScreen.x == screenFrame.left
|
||||||
|| whereScreen.x == screenFrame.right
|
|| whereScreen.x == screenFrame.right
|
||||||
|| whereScreen.y == screenFrame.top
|
|| whereScreen.y == screenFrame.top
|
||||||
@ -324,63 +333,87 @@ TBarView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage)
|
|||||||
&& Window()->Frame().Contains(whereScreen)) {
|
&& Window()->Frame().Contains(whereScreen)) {
|
||||||
// cursor is on a screen edge within the window frame
|
// cursor is on a screen edge within the window frame
|
||||||
|
|
||||||
|
// raise Deskbar
|
||||||
if (!alwaysOnTop && autoRaise && !isTopMost)
|
if (!alwaysOnTop && autoRaise && !isTopMost)
|
||||||
RaiseDeskbar(true);
|
RaiseDeskbar(true);
|
||||||
|
|
||||||
|
// show Deskbar
|
||||||
if (autoHide && IsHidden())
|
if (autoHide && IsHidden())
|
||||||
HideDeskbar(false);
|
HideDeskbar(false);
|
||||||
} else {
|
} else {
|
||||||
TBarWindow* window = (TBarWindow*)Window();
|
// stop if menu is showing or calendar is showing
|
||||||
if (window->IsShowingMenu())
|
TBarWindow* window = dynamic_cast<TBarWindow*>(Window());
|
||||||
return;
|
if ((window != NULL && window->IsShowingMenu())
|
||||||
|
|| fReplicantTray->fTime->IsShowingCalendar()) {
|
||||||
// cursor is not on screen edge
|
return BView::MouseMoved(where, transit, dragMessage);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
HideDeskbar(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BView::MouseMoved(where, transit, dragMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TBarView::MouseDown(BPoint where)
|
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)) {
|
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
|
if ((modifiers() & (B_CONTROL_KEY | B_COMMAND_KEY | B_OPTION_KEY
|
||||||
| B_SHIFT_KEY)) == (B_CONTROL_KEY | B_COMMAND_KEY)) {
|
| B_SHIFT_KEY)) == (B_CONTROL_KEY | B_COMMAND_KEY)) {
|
||||||
// The window key was pressed - enter dragging code
|
// The window key was pressed - enter dragging code
|
||||||
fDragRegion->MouseDown(fDragRegion->DragRegion().LeftTop());
|
fDragRegion->MouseDown(fDragRegion->DragRegion().LeftTop());
|
||||||
return;
|
return BView::MouseDown(where);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// hide deskbar if required
|
// stop if menu is showing or calendar is showing
|
||||||
desk_settings* settings = fBarApp->Settings();
|
TBarWindow* window = dynamic_cast<TBarWindow*>(Window());
|
||||||
bool alwaysOnTop = settings->alwaysOnTop;
|
if ((window != NULL && window->IsShowingMenu())
|
||||||
bool autoRaise = settings->autoRaise;
|
|| fReplicantTray->fTime->IsShowingCalendar()) {
|
||||||
bool autoHide = settings->autoHide;
|
return BView::MouseDown(where);
|
||||||
bool isTopMost = Window()->Feel() == B_FLOATING_ALL_WINDOW_FEEL;
|
}
|
||||||
|
|
||||||
|
// lower deskbar
|
||||||
if (!alwaysOnTop && autoRaise && isTopMost)
|
if (!alwaysOnTop && autoRaise && isTopMost)
|
||||||
RaiseDeskbar(false);
|
RaiseDeskbar(false);
|
||||||
|
|
||||||
|
// hide deskbar
|
||||||
if (autoHide && !IsHidden())
|
if (autoHide && !IsHidden())
|
||||||
HideDeskbar(true);
|
HideDeskbar(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BView::MouseDown(where);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,8 +52,8 @@ All rights reserved.
|
|||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
#include "BarApp.h"
|
#include "BarApp.h"
|
||||||
#include "StatusView.h"
|
|
||||||
#include "CalendarMenuWindow.h"
|
#include "CalendarMenuWindow.h"
|
||||||
|
#include "StatusView.h"
|
||||||
|
|
||||||
|
|
||||||
static const float kHMargin = 2.0;
|
static const float kHMargin = 2.0;
|
||||||
@ -76,6 +76,7 @@ TTimeView::TTimeView(float maxWidth, float height)
|
|||||||
fShowSeconds(false),
|
fShowSeconds(false),
|
||||||
fShowDayOfWeek(false),
|
fShowDayOfWeek(false),
|
||||||
fShowTimeZone(false),
|
fShowTimeZone(false),
|
||||||
|
fCalendarWindow(NULL),
|
||||||
fTimeFormat(NULL),
|
fTimeFormat(NULL),
|
||||||
fDateFormat(NULL)
|
fDateFormat(NULL)
|
||||||
{
|
{
|
||||||
@ -106,6 +107,9 @@ TTimeView::TTimeView(BMessage* data)
|
|||||||
|
|
||||||
TTimeView::~TTimeView()
|
TTimeView::~TTimeView()
|
||||||
{
|
{
|
||||||
|
if (fCalendarWindow != NULL)
|
||||||
|
fCalendarWindow->Quit();
|
||||||
|
|
||||||
delete fTimeFormat;
|
delete fTimeFormat;
|
||||||
delete fDateFormat;
|
delete fDateFormat;
|
||||||
}
|
}
|
||||||
@ -369,13 +373,13 @@ TTimeView::SetShowTimeZone(bool show)
|
|||||||
void
|
void
|
||||||
TTimeView::ShowCalendar(BPoint where)
|
TTimeView::ShowCalendar(BPoint where)
|
||||||
{
|
{
|
||||||
if (fCalendarWindow.IsValid()) {
|
if (fCalendarWindowMessenger.IsValid()) {
|
||||||
// If the calendar is already shown, just activate it
|
// If the calendar is already shown, just activate it
|
||||||
BMessage activate(B_SET_PROPERTY);
|
BMessage activate(B_SET_PROPERTY);
|
||||||
activate.AddSpecifier("Active");
|
activate.AddSpecifier("Active");
|
||||||
activate.AddBool("data", true);
|
activate.AddBool("data", true);
|
||||||
|
|
||||||
if (fCalendarWindow.SendMessage(&activate) == B_OK)
|
if (fCalendarWindowMessenger.SendMessage(&activate) == B_OK)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,10 +389,16 @@ TTimeView::ShowCalendar(BPoint where)
|
|||||||
if (where.y >= BScreen().Frame().bottom)
|
if (where.y >= BScreen().Frame().bottom)
|
||||||
where.y -= (Bounds().Height() + 4.0);
|
where.y -= (Bounds().Height() + 4.0);
|
||||||
|
|
||||||
CalendarMenuWindow* window = new CalendarMenuWindow(where);
|
fCalendarWindow = new CalendarMenuWindow(where);
|
||||||
fCalendarWindow = BMessenger(window);
|
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());
|
fDateFormat = new BDateFormat(BLocale::Default());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TTimeView::GetCurrentTime()
|
TTimeView::GetCurrentTime()
|
||||||
{
|
{
|
||||||
|
@ -69,6 +69,7 @@ const uint32 kGetClockSettings = 'GCkS';
|
|||||||
|
|
||||||
class BCountry;
|
class BCountry;
|
||||||
class BMessageRunner;
|
class BMessageRunner;
|
||||||
|
class CalendarMenuWindow;
|
||||||
|
|
||||||
#ifdef AS_REPLICANT
|
#ifdef AS_REPLICANT
|
||||||
class _EXPORT TTimeView;
|
class _EXPORT TTimeView;
|
||||||
@ -108,6 +109,7 @@ public:
|
|||||||
void SetShowTimeZone(bool show);
|
void SetShowTimeZone(bool show);
|
||||||
|
|
||||||
void ShowCalendar(BPoint where);
|
void ShowCalendar(BPoint where);
|
||||||
|
bool IsShowingCalendar();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class TReplicantTray;
|
friend class TReplicantTray;
|
||||||
@ -147,7 +149,8 @@ private:
|
|||||||
BPoint fTimeLocation;
|
BPoint fTimeLocation;
|
||||||
BPoint fDateLocation;
|
BPoint fDateLocation;
|
||||||
|
|
||||||
BMessenger fCalendarWindow;
|
BMessenger fCalendarWindowMessenger;
|
||||||
|
CalendarMenuWindow* fCalendarWindow;
|
||||||
|
|
||||||
// For date and time localization purposes
|
// For date and time localization purposes
|
||||||
BDateTimeFormat* fTimeFormat;
|
BDateTimeFormat* fTimeFormat;
|
||||||
|
Loading…
Reference in New Issue
Block a user