2 * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 #include <Ecore_Input.h>
26 #include "noti_util.h"
29 #define KEY_BACK "XF86Back"
30 #define KEY_CANCEL "Cancel"
31 #define KEY_MENU "XF86Menu"
32 #define KEY_QUICKPANEL "XF86QuickPanel"
33 #define KEY_HOME "XF86Home"
35 static Eina_Bool _service_hardkey_up_cb(void *data, int type, void *event)
37 struct appdata *ad = NULL;
38 Ecore_Event_Key *key_event = NULL;
40 retif(data == NULL || event == NULL, EINA_FALSE, "Invalid parameter!");
44 if (!strcmp(key_event->keyname, KEY_HOME)) {
45 if (ad->is_hardkey_cancel == EINA_FALSE) {
46 quickpanel_uic_close_quickpanel(false, 0);
48 DBG("Cancel status, do nothing");
50 } else if (!strcmp(key_event->keyname, KEY_CANCEL)) {
51 ad->is_hardkey_cancel = EINA_FALSE;
52 } else if (!strcmp(key_event->keyname, KEY_BACK)) {
53 if (ad->popup != NULL) {
54 Evas_Smart_Cb back_cb = evas_object_data_get(ad->popup, EDATA_BACKKEY_CB);
55 if (back_cb != NULL) {
56 back_cb(ad->popup, ad->popup, NULL);
59 quickpanel_uic_close_quickpanel(false, 0);
65 static Eina_Bool _service_hardkey_down_cb(void *data, int type, void *event)
67 Ecore_Event_Key *key_event = event;
68 struct appdata *ad = data;
69 retif(key_event == NULL, EINA_FALSE, "Invalid parameter!");
70 retif(ad == NULL, EINA_FALSE, "Invalid parameter!");
72 if (!strcmp(key_event->keyname, KEY_CANCEL)) {
73 ad->is_hardkey_cancel = EINA_TRUE;
74 } else if (!strcmp(key_event->keyname, KEY_QUICKPANEL)) {
75 quickpanel_uic_toggle_openning_quickpanel();
80 HAPI void quickpanel_keyboard_init(void *data)
82 struct appdata *ad = data;
83 Ecore_Event_Handler *hdl_key_down = NULL;
84 Ecore_Event_Handler *hdl_key_up = NULL;
85 retif(ad == NULL, , "Invalid parameter!");
87 if (elm_win_keygrab_set(elm_win_xwindow_get(ad->win), KEY_QUICKPANEL, 0, 0, 0, ELM_WIN_KEYGRAB_SHARED) != 0) {
88 ERR("failed to grab KEY_QUICKPANEL");
91 hdl_key_down = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _service_hardkey_down_cb, ad);
92 if (hdl_key_down == NULL) {
93 ERR("failed to add handler(ECORE_EVENT_KEY_DOWN)");
95 ad->hdl_hardkey_down = hdl_key_down;
97 hdl_key_up = ecore_event_handler_add(ECORE_EVENT_KEY_UP, _service_hardkey_up_cb, ad);
98 if (hdl_key_up == NULL) {
99 ERR("failed to add handler(ECORE_EVENT_KEY_UP)");
101 ad->hdl_hardkey_up = hdl_key_up;
102 ad->is_hardkey_cancel = EINA_FALSE;
105 HAPI void quickpanel_keyboard_fini(void *data)
107 struct appdata *ad = data;
108 retif(ad == NULL, , "Invalid parameter!");
110 if (ad->hdl_hardkey_up != NULL) {
111 ecore_event_handler_del(ad->hdl_hardkey_up);
112 ad->hdl_hardkey_up = NULL;
115 if (ad->hdl_hardkey_down != NULL) {
116 ecore_event_handler_del(ad->hdl_hardkey_down);
117 ad->hdl_hardkey_down = NULL;
120 if (elm_win_keygrab_unset(elm_win_xwindow_get(ad->win), KEY_QUICKPANEL, 0, 0) != 0) {
121 ERR("failed to ungrab KEY_QUICKPANEL");
126 HAPI void quickpanel_keyboard_openning_init(void *data)
128 struct appdata *ad = data;
129 retif(ad == NULL, , "Invalid parameter!");
131 if (elm_win_keygrab_set(elm_win_xwindow_get(ad->win), KEY_BACK, 0, 0, 0, ELM_WIN_KEYGRAB_EXCLUSIVE ) != 0) {
132 ERR("failed to grab KEY_BACK");
135 if (elm_win_keygrab_set(elm_win_xwindow_get(ad->win), KEY_MENU, 0, 0, 0, ELM_WIN_KEYGRAB_EXCLUSIVE ) != 0) {
136 ERR("failed to grab KEY_MENU");
139 if (elm_win_keygrab_set(elm_win_xwindow_get(ad->win), KEY_HOME, 0, 0, 0, ELM_WIN_KEYGRAB_SHARED) != 0) {
140 ERR("failed to grab KEY_HOME");
144 HAPI void quickpanel_keyboard_closing_fini(void *data)
146 struct appdata *ad = data;
147 retif(ad == NULL, , "Invalid parameter!");
149 if (elm_win_keygrab_unset(elm_win_xwindow_get(ad->win), KEY_BACK ,0 ,0) != 0) {
150 ERR("failed to ungrab KEY_BACK");
153 if (elm_win_keygrab_unset(elm_win_xwindow_get(ad->win), KEY_MENU ,0 ,0) != 0) {
154 ERR("failed to ungrab KEY_MENU");
157 if (elm_win_keygrab_unset(elm_win_xwindow_get(ad->win), KEY_HOME ,0 ,0) != 0) {
158 ERR("failed to ungrab KEY_HOME");