From 31f38a6786ee16e490b76e5e983f9f5f32d5814f Mon Sep 17 00:00:00 2001 From: Dariusz Frankiewicz Date: Wed, 21 Oct 2015 10:15:59 +0200 Subject: [PATCH] Fix D-pad navigation between URI bar and Webview. [Issue] https://bugs.tizen.org/jira/browse/TT-211 [Problem] Navigation on webview elements is not possible because focus go to URI bar when UP is pressed. [Cause] No webview focus lock implemented. [Solution] Implement focus auto lock on webview. [Verify] Load sample page, go by D-pad to webview, navigate on webview elements, to back to URI bar press RED button [F4 on keyboard]. Change-Id: Ia24378ac090364e43b85fba89f5fd3a42f48cc26 Signed-off-by: Dariusz Frankiewicz --- .../PlatformInputManager/PlatformInputManager.cpp | 9 ++++ .../PlatformInputManager/PlatformInputManager.h | 4 ++ services/SimpleUI/SimpleUI.cpp | 6 +++ services/SimpleUI/SimpleUI.h | 1 + services/WebPageUI/WebPageUI.cpp | 53 ++++++++++++++++++++++ services/WebPageUI/WebPageUI.h | 6 +++ 6 files changed, 79 insertions(+) diff --git a/services/PlatformInputManager/PlatformInputManager.cpp b/services/PlatformInputManager/PlatformInputManager.cpp index 8a552e9..a03efb3 100644 --- a/services/PlatformInputManager/PlatformInputManager.cpp +++ b/services/PlatformInputManager/PlatformInputManager.cpp @@ -87,6 +87,15 @@ Eina_Bool PlatformInputManager::__filter(void *data, void */*loop_data*/, int ty self->backPressed(); else if(!keyName.compare("Escape")) self->escapePressed(); + else if(!keyName.compare("XF86Red")) // F4 - Red + self->redPressed(); + else if(!keyName.compare("XF86Green")) // F5 - Green + self->greenPressed(); + else if(!keyName.compare("XF86Yellow")) // F6 - Yellow + self->yellowPressed(); + else if(!keyName.compare("XF86Blue")) // F7 - Blue + self->bluePressed(); + } else if(type == ECORE_EVENT_KEY_UP) { M_ASSERT(event); Ecore_Event_Key *ev = static_cast(event); diff --git a/services/PlatformInputManager/PlatformInputManager.h b/services/PlatformInputManager/PlatformInputManager.h index 4533561..feb97b1 100644 --- a/services/PlatformInputManager/PlatformInputManager.h +++ b/services/PlatformInputManager/PlatformInputManager.h @@ -55,6 +55,10 @@ public: boost::signals2::signal rightPressed; boost::signals2::signal backPressed; boost::signals2::signal escapePressed; + boost::signals2::signal redPressed; + boost::signals2::signal greenPressed; + boost::signals2::signal yellowPressed; + boost::signals2::signal bluePressed; boost::signals2::signal mouseClicked; /** diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index 36d9230..ab890cb 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -416,6 +416,7 @@ void SimpleUI::connectModelSignals() m_platformInputManager->escapePressed.connect(boost::bind(&SimpleUI::onEscapePressed, this)); m_platformInputManager->mouseClicked.connect( boost::bind(&SimpleUI::onMouseClick, this)); + m_platformInputManager->redPressed.connect(boost::bind(&SimpleUI::onRedKeyPressed, this)); } @@ -748,6 +749,11 @@ void SimpleUI::onMouseClick() m_webPageUI->getUrlHistoryList()->onMouseClick(); } +void SimpleUI::onRedKeyPressed() +{ + m_webPageUI->onRedKeyPressed(); +} + void SimpleUI::webEngineURLChanged(const std::string url) { BROWSER_LOGD("webEngineURLChanged:%s", url.c_str()); diff --git a/services/SimpleUI/SimpleUI.h b/services/SimpleUI/SimpleUI.h index f50db74..1539a19 100644 --- a/services/SimpleUI/SimpleUI.h +++ b/services/SimpleUI/SimpleUI.h @@ -147,6 +147,7 @@ private: void onActionTriggered(const Action& action); void onMouseClick(); + void onRedKeyPressed(); void setwvIMEStatus(bool status); sharedAction m_showBookmarkManagerUI; diff --git a/services/WebPageUI/WebPageUI.cpp b/services/WebPageUI/WebPageUI.cpp index fef4f9d..f60578c 100644 --- a/services/WebPageUI/WebPageUI.cpp +++ b/services/WebPageUI/WebPageUI.cpp @@ -38,6 +38,7 @@ WebPageUI::WebPageUI() , m_URIEntry(new URIEntry()) , m_urlHistoryList(std::make_shared()) , m_homePageActive(false) + , m_webviewLocked(false) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); } @@ -84,6 +85,12 @@ void WebPageUI::showUI() showQuickAccess(); else m_URIEntry->showPageTitle(); + + m_WebPageUIvisible = true; + + elm_object_event_callback_add(m_leftButtonBar->getContent(), _cb_down_pressed_on_urlbar, this); + elm_object_event_callback_add(m_rightButtonBar->getContent(), _cb_down_pressed_on_urlbar, this); + elm_object_event_callback_add(m_URIEntry->getContent(), _cb_down_pressed_on_urlbar, this); } @@ -102,6 +109,12 @@ void WebPageUI::hideUI() evas_object_hide(m_URIEntry->getContent()); evas_object_hide(elm_object_part_content_get(m_mainLayout, "uri_bar_buttons_left")); evas_object_hide(elm_object_part_content_get(m_mainLayout, "uri_bar_buttons_right")); + + m_WebPageUIvisible = false; + + elm_object_event_callback_del(m_leftButtonBar->getContent(), _cb_down_pressed_on_urlbar, this); + elm_object_event_callback_del(m_rightButtonBar->getContent(), _cb_down_pressed_on_urlbar, this); + elm_object_event_callback_del(m_URIEntry->getContent(), _cb_down_pressed_on_urlbar, this); } void WebPageUI::loadStarted() @@ -244,6 +257,20 @@ void WebPageUI::faviconClicked(void* data, Evas_Object*, const char*, const char } } +Eina_Bool WebPageUI::_cb_down_pressed_on_urlbar(void *data, Evas_Object */*obj*/, Evas_Object */*src*/, Evas_Callback_Type type, void *event_info) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + WebPageUI* self = reinterpret_cast(data); + if(type == EVAS_CALLBACK_KEY_DOWN) { + Ecore_Event_Key *ev = static_cast(event_info); + const std::string keyName = ev->keyname; + if(!keyName.compare("Down")){ + self->lockWebview(); + } + } + return EINA_FALSE; +} + void WebPageUI::setTabsNumber(int tabs) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); @@ -254,6 +281,32 @@ void WebPageUI::setTabsNumber(int tabs) } } +void WebPageUI::lockWebview() +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if(isWebPageUIvisible()) { + if(!isHomePageActive() && !isErrorPageActive()) { + elm_object_focus_custom_chain_unset(m_mainLayout); + elm_object_focus_custom_chain_append(m_mainLayout, elm_object_part_content_get(m_mainLayout, "web_view"), NULL); + m_webviewLocked = true; + } + } +} + +void WebPageUI::onRedKeyPressed() +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if(isWebPageUIvisible()) { + if(!isHomePageActive()) { + if(m_webviewLocked) { + refreshFocusChain(); + m_URIEntry->setFocus(); + m_webviewLocked = false; + } + } + } +} + void WebPageUI::createLayout() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); diff --git a/services/WebPageUI/WebPageUI.h b/services/WebPageUI/WebPageUI.h index 712203a..0e88f30 100644 --- a/services/WebPageUI/WebPageUI.h +++ b/services/WebPageUI/WebPageUI.h @@ -49,6 +49,7 @@ public: bool isErrorPageActive(); bool isIncognitoPageActive(); bool isHomePageActive() { return m_homePageActive; } + bool isWebPageUIvisible() { return m_WebPageUIvisible; } void toIncognito(bool); void switchViewToErrorPage(); void switchViewToWebPage(Evas_Object* content, const std::string uri, const std::string title); @@ -62,6 +63,8 @@ public: void setReloadButtonEnabled(bool enabled) { m_reload->setEnabled(enabled); } void setStopButtonEnabled(bool enabled) { m_stopLoading->setEnabled(enabled); } void setMoreMenuButtonEnabled(bool enabled) { m_showMoreMenu->setEnabled(enabled); } + void lockWebview(); + void onRedKeyPressed(); boost::signals2::signal backPage; boost::signals2::signal forwardPage; @@ -75,6 +78,7 @@ public: boost::signals2::signal showZoomNavigation; static void faviconClicked(void* data, Evas_Object* obj, const char* emission, const char* source); + static Eina_Bool _cb_down_pressed_on_urlbar(void *data, Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info); private: void createLayout(); @@ -113,6 +117,8 @@ private: std::unique_ptr m_URIEntry; UrlHistoryPtr m_urlHistoryList; bool m_homePageActive; + bool m_webviewLocked; + bool m_WebPageUIvisible; sharedAction m_back; sharedAction m_forward; -- 2.7.4