@@ -257,12 +257,16 @@ void SystemTask::Work() {
257257 settingsController.isWakeUpModeOn (Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) ||
258258 (gesture == Pinetime::Applications::TouchEvents::Tap &&
259259 settingsController.isWakeUpModeOn (Pinetime::Controllers::Settings::WakeUpMode::SingleTap)))) {
260+ ignoreNextTouchEvent = true ;
261+ wokenBy = WokenBy::WakeUpAction;
260262 GoToRunning ();
261263 }
262264 }
263265 break ;
264266 }
265267 case Messages::GoToSleep:
268+ ignoreTouchPopupHidden = true ;
269+ displayApp.PushMessage (Pinetime::Applications::Display::Messages::HideIgnoreTouchPopup);
266270 if (doNotGoToSleep) {
267271 break ;
268272 }
@@ -341,18 +345,40 @@ void SystemTask::Work() {
341345 // TODO add intent of fs access icon or something
342346 break ;
343347 case Messages::OnTouchEvent:
344- if (touchHandler.GetNewTouchInfo ()) {
345- touchHandler.UpdateLvglTouchPoint ();
348+ // if the watch was just woken by touch and button must be used to unlock, ignore the first touch event which
349+ // is the touch event that woke the watch. Otherwise the lock-popup will be displayed
350+ if (settingsController.isWakeUpModeOn (Pinetime::Controllers::Settings::WakeUpMode::ButtonUnlocks) && ignoreNextTouchEvent) {
351+ ignoreNextTouchEvent = false ;
352+
353+ // Ignore touchevents if ButtonUnlocks setting is active and the watch was woken with wakeup actions (touch etc)
354+ } else if (!settingsController.isWakeUpModeOn (Pinetime::Controllers::Settings::WakeUpMode::ButtonUnlocks) ||
355+ wokenBy != WokenBy::WakeUpAction) {
356+ if (touchHandler.GetNewTouchInfo ()) {
357+ touchHandler.UpdateLvglTouchPoint ();
358+ }
359+ ReloadIdleTimer ();
360+ displayApp.PushMessage (Pinetime::Applications::Display::Messages::TouchEvent);
361+ // if we get to here TouchEvents is allowed and the "ButtonUnlocks" requirement can be overridden
362+ wokenBy = WokenBy::Other;
363+ } else {
364+ ignoreTouchPopupHidden = false ;
365+ displayApp.PushMessage (Pinetime::Applications::Display::Messages::ShowIgnoreTouchPopup);
346366 }
347- ReloadIdleTimer ();
348- displayApp.PushMessage (Pinetime::Applications::Display::Messages::TouchEvent);
349367 break ;
350368 case Messages::HandleButtonEvent: {
369+ // if the IgnoreTouchPopup is active the first button event unlocks the device
370+ if (!ignoreTouchPopupHidden) {
371+ wokenBy = WokenBy::Button;
372+ ignoreTouchPopupHidden = true ;
373+ displayApp.PushMessage (Pinetime::Applications::Display::Messages::HideIgnoreTouchPopup);
374+ break ;
375+ }
351376 Controllers::ButtonActions action;
352377 if (nrf_gpio_pin_read (Pinetime::PinMap::Button) == 0 ) {
353378 action = buttonHandler.HandleEvent (Controllers::ButtonHandler::Events::Release);
354379 } else {
355380 action = buttonHandler.HandleEvent (Controllers::ButtonHandler::Events::Press);
381+ wokenBy = WokenBy::Button;
356382 // This is for faster wakeup, sacrificing special longpress and doubleclick handling while sleeping
357383 if (IsSleeping ()) {
358384 fastWakeUpDone = true ;
@@ -381,6 +407,7 @@ void SystemTask::Work() {
381407 }
382408
383409 state = SystemTaskState::Sleeping;
410+ wokenBy = WokenBy::Other;
384411 break ;
385412 case Messages::OnNewDay:
386413 // We might be sleeping (with TWI device disabled.
@@ -491,6 +518,7 @@ void SystemTask::UpdateMotion() {
491518 motionController.Should_RaiseWake (state == SystemTaskState::Sleeping)) ||
492519 (settingsController.isWakeUpModeOn (Pinetime::Controllers::Settings::WakeUpMode::Shake) &&
493520 motionController.Should_ShakeWake (settingsController.GetShakeThreshold ()))) {
521+ wokenBy = WokenBy::WakeUpAction;
494522 GoToRunning ();
495523 }
496524 }
0 commit comments