keyboard: refresh navigation interface after show/hide 69/186269/7
authorTomasz Jeschke <t.jeschke@samsung.com>
Wed, 8 Aug 2018 11:18:46 +0000 (13:18 +0200)
committerTomasz Jeschke <t.jeschke@samsung.com>
Wed, 8 Aug 2018 13:54:29 +0000 (15:54 +0200)
Change-Id: Iefc060b4bcb9300765b0530f36394234a9f0d26e

src/NavigationInterface.cpp

index 8d57555..d3ad2a0 100644 (file)
@@ -24,7 +24,9 @@
 #include "utils.hpp"
 #include "Window.hpp"
 #include "UniversalSwitchLog.hpp"
+#include "VConf.hpp"
 
+#include <vconf.h>
 #include <glib.h>
 #include <glib-object.h>
 #include <tuple>
@@ -96,6 +98,12 @@ class NavigationImpl : public NavigationInterface
 public:
        NavigationImpl()
        {
+               isfPanelStateChangeHandle = Singleton<VConfInterface>::instance().registerKeyChangedCb<int>(
+               VCONFKEY_ISF_INPUT_PANEL_STATE, [this](auto val) {
+                       isfPanelStateValue = val;
+                       this->initializeRebuildingContext(true, 0.5f);
+               });
+
                watchHandle = Singleton<UniversalSwitch>::instance().getAtspi()->registerWatcherForAllObjects(
                [this](const auto & src, auto eventType) {
                        this->onAtspiEvent(src, eventType);
@@ -119,6 +127,9 @@ public:
        }
 
 private:
+       VConfInterface::CallbackHandle isfPanelStateChangeHandle;
+       int isfPanelStateValue = VCONFKEY_ISF_INPUT_PANEL_STATE_HIDE;
+
        std::shared_ptr<NavigationElement> currentRootElement;
        std::shared_ptr<UIElement> currentVisibleRootUIElement;
        std::unique_ptr<Atspi::WatchHandler> watchHandle;
@@ -756,24 +767,48 @@ private:
                        std::unordered_map<int32_t, AtspiAccessiblePtr> pidToAtspi;
                        std::unordered_map<AtspiAccessiblePtr, int32_t> atspiToPid;
                        std::unordered_map<AtspiAccessiblePtr, std::string> names;
+                       std::vector<Atspi::VisibleWindowInfo> wins;
                        int32_t ourPid;
-                       std::vector<int32_t> pids;
                };
                using ExecHelper = ParallerExecHelper<Empty, All>;
                auto windowsParser = [ = ](ExecHelper & wins) {
+                       std::vector<int32_t> pids;
+                       static const std::string keyboardRootName = "ise-default";
+                       static const std::string homescreenRootName = "homescreen-efl";
+                       {
+                               bool foundFocused = false;
+                               for (auto &w : wins.all.wins) {
+                                       auto ptr = wins.all.pidToAtspi[w.pid];
+                                       auto name = wins.all.names[ptr];
+                                       if (name == keyboardRootName) {
+                                               w.visibility = this->isfPanelStateValue == VCONFKEY_ISF_INPUT_PANEL_STATE_SHOW
+                                                               ? Atspi::WindowVisibility::unobscured : Atspi::WindowVisibility::fully_obscured;
+                                       }
+                                       bool visibility =
+                                               w.visibility == Atspi::WindowVisibility::unobscured ||
+                                               w.visibility == Atspi::WindowVisibility::partially_obscured ||
+                                               w.focused;
+                                       DEBUG("got pid %6d visibility %d (%2d %d)", w.pid, visibility ? 1 : 0, (int)w.visibility, (int)w.focused);
+                                       if (visibility) {
+                                               if (!foundFocused)
+                                                       pids.push_back(w.pid);
+                                               if (w.focused) {
+                                                       foundFocused = true;
+                                               }
+                                       }
+                               }
+                       }
                        for (auto it : wins.all.names) {
                                auto id = Atspi::getUniqueId(it.first);
                                auto pid = wins.all.atspiToPid[it.first];
                                DEBUG("got %6d   %s %s", pid, id.c_str(), it.second.c_str());
                        }
-                       for (auto pid : wins.all.pids) {
+                       for (auto pid : pids) {
                                DEBUG("got pid %d", pid);
                        }
                        AtspiAccessiblePtr root, keyboardRoot;
                        UIElement::ApplicationCategory application = UIElement::ApplicationCategory::OTHER;
-                       static const std::string keyboardRootName = "ise-default";
-                       static const std::string homescreenRootName = "homescreen-efl";
-                       for (auto pid : wins.all.pids) {
+                       for (auto pid : pids) {
                                DEBUG("checking pid %d", pid);
                                auto ptr = wins.all.pidToAtspi[pid];
                                auto name = wins.all.names[ptr];
@@ -826,24 +861,6 @@ private:
                atspi->getVisibleWindowInfos([ = ](DBus::ValueOrError<std::vector<Atspi::VisibleWindowInfo>> wins_) {
                        if (continueProcessing(wins_)) {
                                auto &wins = std::get<0>(wins_);
-                               std::vector<int> pids;
-                               {
-                                       bool foundFocused = false;
-                                       for (auto &w : wins) {
-                                               bool visibility =
-                                                       w.visibility == Atspi::WindowVisibility::unobscured ||
-                                                       w.visibility == Atspi::WindowVisibility::partially_obscured ||
-                                                       w.focused;
-                                               DEBUG("got pid %6d visibility %d (%2d %d)", w.pid, visibility ? 1 : 0, (int)w.visibility, (int)w.focused);
-                                               if (visibility) {
-                                                       if (!foundFocused)
-                                                               pids.push_back(w.pid);
-                                                       if (w.focused) {
-                                                               foundFocused = true;
-                                                       }
-                                               }
-                                       }
-                               }
 
                                auto atspi = Singleton<UniversalSwitch>::instance().getAtspi();
                                auto desktop = atspi->getDesktop();
@@ -853,8 +870,8 @@ private:
                                        if (continueProcessing(desktopChildren)) {
                                                auto atspi = Singleton<UniversalSwitch>::instance().getAtspi();
 
-                                               auto ptr = std::make_shared<ExecHelper>(std::move(windowsParser), pids.size());
-                                               ptr->all.pids = std::move(pids);
+                                               auto ptr = std::make_shared<ExecHelper>(std::move(windowsParser), wins.size());
+                                               ptr->all.wins = std::move(wins);
                                                ptr->all.ourPid = getpid();
 
                                                for (auto app : std::get<0>(desktopChildren)) {