Escape frame using EventGenerator in RowScanner 41/157441/2
authorPawel Kurowski <p.kurowski2@samsung.com>
Tue, 24 Oct 2017 11:47:16 +0000 (13:47 +0200)
committerPawel Kurowski <p.kurowski2@samsung.com>
Tue, 24 Oct 2017 11:53:11 +0000 (13:53 +0200)
Change-Id: I8106c8a1567f4e323f163f50bf16b5d9cb395041

src/RowScanner.cpp

index 8cca5a9..9ca4384 100644 (file)
@@ -8,6 +8,7 @@
 #include "UniversalSwitch.hpp"
 #include "UniversalSwitchLog.hpp"
 #include "Window.hpp"
+#include "utils.hpp"
 
 #include <Elementary.h>
 
@@ -27,6 +28,8 @@ namespace
                }
                Sound::playSoundFeedback(Sound::ID::NAVIGATION_ITERATED);
        }
+
+       static const std::string BACK_BUTTON_CODE = "XF86Back";
 }
 
 class RowScannerImpl : public ScreenScanner
@@ -139,16 +142,25 @@ void RowScannerImpl::acceptAutoscanningPhase(std::function<void(Optional<std::sh
 {
        bool continueScanning = false;
        if (possibleMoveUpInHierarchy) {
-               possibleMoveUpInHierarchy = false;
                DEBUG("execute move up in hierarchy");
+               possibleMoveUpInHierarchy = false;
                continueScanning = true;
                stopScanning();
-               if (state == State::ITEMS)
+               switch (state) {
+               case State::ITEMS:
                        state = State::START;
-               else if (state == State::END)
+                       break;
+               case State::END:
                        state = State::ROWS;
-               else
+                       break;
+               case State::ROWS:
+                       DEBUG("Escape UI");
+                       state = State::START;
+                       utils::EventGenerator::generateKeyPress(BACK_BUTTON_CODE);
+                       return;
+               default:
                        ASSERT(0, "Should not be reached");
+               }
        }
 
        switch (state) {