1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Copyright 2014 Samsung Electronics. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
6 #include "tw_webview_evas_event_handler.h"
8 #include "tizen_webview/public/tw_webview_delegate.h"
10 #include "eweb_view.h"
12 using content::SelectionControllerEfl;
15 inline bool isHardwareBackKey(const Evas_Event_Key_Down *event) {
17 return (strcmp(event->key, "XF86Stop") == 0);
19 return (strcmp(event->key, "Escape") == 0);
24 namespace tizen_webview {
26 WebViewEvasEventHandler::WebViewEvasEventHandler(EWebView* wv)
30 bool WebViewEvasEventHandler::HandleEvent_FocusIn() {
31 WebViewDelegate* wvd = WebViewDelegate::GetInstance();
34 return wvd->RequestHandleEvent_FocusIn(webview_);
37 bool WebViewEvasEventHandler::HandleEvent_FocusOut() {
38 WebViewDelegate* wvd = WebViewDelegate::GetInstance();
41 return wvd->RequestHandleEvent_FocusOut(webview_);
44 bool WebViewEvasEventHandler::HandleEvent_KeyDown(const Evas_Event_Key_Down* event_info) {
47 WebViewDelegate* wvd = WebViewDelegate::GetInstance();
49 handled = wvd->RequestHandleEvent_KeyDown(webview_, event_info);
54 if (isHardwareBackKey(event_info)) {
55 if (webview_->GetContextMenuController()) {
56 DVLOG(1) << "Hiding context menu due to back key press";
57 webview_->ResetContextMenuController();
58 if (SelectionControllerEfl* selection_controller = webview_->GetSelectionController())
59 selection_controller->HideHandles();
62 if (webview_->GetSelectionController()->IsAnyHandleVisible()) {
63 DVLOG(1) << "Clearing text selection due to back key press";
64 webview_->GetSelectionController()->ClearSelection();
71 bool WebViewEvasEventHandler::HandleEvent_KeyUp(const Evas_Event_Key_Up* event_info) {
73 WebViewDelegate* wvd = WebViewDelegate::GetInstance();
76 return wvd->RequestHandleEvent_KeyUp(webview_, event_info);
79 bool WebViewEvasEventHandler::HandleEvent_MouseDown(const Evas_Event_Mouse_Down* event_info) {
80 WebViewDelegate* wvd = WebViewDelegate::GetInstance();
83 return wvd->RequestHandleEvent_MouseDown(webview_, event_info);
86 bool WebViewEvasEventHandler::HandleEvent_MouseUp(const Evas_Event_Mouse_Up* event_info) {
87 WebViewDelegate* wvd = WebViewDelegate::GetInstance();
90 return wvd->RequestHandleEvent_MouseUp(webview_, event_info);
93 bool WebViewEvasEventHandler::HandleEvent_MouseMove(const Evas_Event_Mouse_Move* event_info) {
94 WebViewDelegate* wvd = WebViewDelegate::GetInstance();
97 return wvd->RequestHandleEvent_MouseMove(webview_, event_info);
100 bool WebViewEvasEventHandler::HandleEvent_MouseWheel(const Evas_Event_Mouse_Wheel* event_info) {
101 WebViewDelegate* wvd = WebViewDelegate::GetInstance();
104 return wvd->RequestHandleEvent_MouseWheel(webview_, event_info);
107 } // namespace tizen_webview