diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp index 1450463857..6d8fd6ba44 100644 --- a/src/apps/deskbar/BarView.cpp +++ b/src/apps/deskbar/BarView.cpp @@ -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(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(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); } diff --git a/src/apps/deskbar/TimeView.cpp b/src/apps/deskbar/TimeView.cpp index af13ce9294..ce462fd2fc 100644 --- a/src/apps/deskbar/TimeView.cpp +++ b/src/apps/deskbar/TimeView.cpp @@ -52,8 +52,8 @@ All rights reserved. #include #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() { diff --git a/src/apps/deskbar/TimeView.h b/src/apps/deskbar/TimeView.h index 415c3883bd..db269519c5 100644 --- a/src/apps/deskbar/TimeView.h +++ b/src/apps/deskbar/TimeView.h @@ -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;