Using UrlHistoryList do display history list (on urientry edition).
[profile/tv/apps/web/browser.git] / services / PlatformInputManager / PlatformInputManager.cpp
1
2 /*
3  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Apache License, Version 2.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an AS IS BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #include "PlatformInputManager.h"
19
20 #include <Ecore.h>
21 #include <Ecore_Evas.h>
22 #include <Ecore_Input.h>
23 #include <unistd.h>
24
25 #include "BrowserAssert.h"
26 #include "BrowserLogger.h"
27
28 #define E_PROP_DEVICEMGR_INPUTWIN "DeviceMgr Input Window"
29 #define E_PROP_NOT_CURSOR_HIDE "E_NOT_CURSOR_HIDE"
30
31 #define MOUSE_POINTER_MOVE_DELAY 0.015f
32 #define MOUSE_POINTER_STEPS 10
33
34 namespace tizen_browser
35 {
36 namespace services
37 {
38
39 EXPORT_SERVICE(PlatformInputManager, "org.tizen.browser.platforminputmanager")
40
41 PlatformInputManager::PlatformInputManager()
42 {
43
44 }
45
46 void PlatformInputManager::init(Evas_Object* mainWindow)
47 {
48     M_ASSERT(mainWindow);
49     ecore_event_filter_add(NULL, __filter, NULL, this);
50 }
51
52 Eina_Bool PlatformInputManager::__filter(void *data, void */*loop_data*/, int type, void *event)
53 {
54     PlatformInputManager *self = static_cast<PlatformInputManager*>(data);
55
56     if (type == ECORE_EVENT_KEY_DOWN) {
57         M_ASSERT(event);
58         Ecore_Event_Key *ev = static_cast<Ecore_Event_Key *>(event);
59
60         if(!ev->keyname)
61             return EINA_TRUE;
62
63         BROWSER_LOGD("Pressed key: %s", ev->keyname);
64         const std::string keyName = ev->keyname;
65
66         /**
67          * Because MENU button launches org.tizen.menu
68          * we use blue 'D' button on remote control or F4 on keyboard as substitution of MENU button
69          */
70         if(!keyName.compare("KEY_MENU") || !keyName.compare("KEY_BLUE")) {
71             self->menuPressed();
72             return EINA_FALSE;
73         }
74
75         if(!keyName.compare("KEY_RETURN"))
76             self->returnPressed();
77         else if(!keyName.compare("KEY_LEFT"))
78             self->leftPressed();
79         else if(!keyName.compare("KEY_RIGHT"))
80             self->rightPressed();
81         else if(!keyName.compare("KEY_ENTER"))
82             self->enterPressed();
83             // MERGE_ME dont know if should be commented out
84         else if(!keyName.compare("BackSpace") || !keyName.compare("XF86Back"))
85             self->backPressed();
86     } else if(type == ECORE_EVENT_KEY_UP) {
87         M_ASSERT(event);
88         Ecore_Event_Key *ev = static_cast<Ecore_Event_Key *>(event);
89
90         if(!ev->keyname)
91             return EINA_TRUE;
92
93         BROWSER_LOGD("Released key: %s", ev->keyname);
94     } else if (type == ECORE_EVENT_MOUSE_BUTTON_DOWN) {
95         self->mouseClicked();
96     }
97     return EINA_TRUE;
98 }
99
100 }
101 }