diff --git a/src/apps/deskbar/TimeView.cpp b/src/apps/deskbar/TimeView.cpp index bdde5e0f8c..62f717262e 100644 --- a/src/apps/deskbar/TimeView.cpp +++ b/src/apps/deskbar/TimeView.cpp @@ -114,6 +114,7 @@ TTimeView::TTimeView(BMessage *data) TTimeView::~TTimeView() { + StopLongClickNotifier(); } @@ -237,6 +238,7 @@ TTimeView::MessageReceived(BMessage* message) case kMsgLongClick: { + StopLongClickNotifier(); BPoint where; message->FindPoint("where", &where); ShowCalendar(where); @@ -298,6 +300,31 @@ TTimeView::ShowCalendar(BPoint where) } +void +TTimeView::StartLongClickNotifier(BPoint where) +{ + StopLongClickNotifier(); + + BMessage longClickMessage(kMsgLongClick); + longClickMessage.AddPoint("where", where); + + bigtime_t longClickThreshold; + get_click_speed(&longClickThreshold); + // use the doubleClickSpeed as a threshold + + fLongClickMessageRunner = new BMessageRunner(BMessenger(this), + &longClickMessage, longClickThreshold, 1); +} + + +void +TTimeView::StopLongClickNotifier() +{ + delete fLongClickMessageRunner; + fLongClickMessageRunner = NULL; +} + + void TTimeView::GetCurrentTime() { @@ -376,16 +403,7 @@ TTimeView::MouseDown(BPoint point) ShowClockOptions(ConvertToScreen(point)); return; } else if (buttons == B_PRIMARY_MOUSE_BUTTON) { - BMessage longClickMessage(kMsgLongClick); - longClickMessage.AddPoint("where", point); - - bigtime_t longClickThreshold; - get_click_speed(&longClickThreshold); - // use the doubleClickSpeed as a threshold - - delete fLongClickMessageRunner; - fLongClickMessageRunner = new BMessageRunner(BMessenger(this), - &longClickMessage, longClickThreshold, 1); + StartLongClickNotifier(point); } // flip to/from showing date or time @@ -404,8 +422,7 @@ TTimeView::MouseDown(BPoint point) void TTimeView::MouseUp(BPoint point) { - delete fLongClickMessageRunner; - fLongClickMessageRunner = NULL; + StopLongClickNotifier(); } diff --git a/src/apps/deskbar/TimeView.h b/src/apps/deskbar/TimeView.h index c81f69adb2..ce0f1a311b 100644 --- a/src/apps/deskbar/TimeView.h +++ b/src/apps/deskbar/TimeView.h @@ -83,6 +83,8 @@ class TTimeView : public BView { bool ShowingEuroDate() {return fEuroDate; } void ShowEuroDate(bool); void ShowCalendar(BPoint where); + void StartLongClickNotifier(BPoint where); + void StopLongClickNotifier(); bool Orientation() const; void SetOrientation(bool o);