2 * Copyright (c) 2011 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.
18 #define LOG_TAG "TIZEN_N_EFL_UTIL"
25 #include <Elementary.h>
32 int efl_util_set_notification_window_level (Evas_Object* window, efl_util_notification_level_e level)
34 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
35 EINA_SAFETY_ON_FALSE_RETURN_VAL(level >= EFL_UTIL_NOTIFICATION_LEVEL_1 &&
36 level <= EFL_UTIL_NOTIFICATION_LEVEL_2,
37 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
40 Ecore_X_Window xwin = elm_win_xwindow_get(window);
43 Ecore_X_Window_Type window_type;
44 if(ecore_x_netwm_window_type_get(xwin, &window_type) == EINA_TRUE)
46 // success to get window type
47 if(window_type != ECORE_X_WINDOW_TYPE_NOTIFICATION)
49 // given EFL window's type is not notification type.
50 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
54 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
56 utilx_set_system_notification_level(ecore_x_display_get(), xwin,
58 return EFL_UTIL_ERROR_NONE;
62 #if ECORE_WAYLAND_FOUND
63 Ecore_Wl_Window wl_win = elm_win_wl_window_get(window);
66 printf("not implemented for wayland yet\n");
67 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
71 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
76 int efl_util_get_notification_window_level (Evas_Object* window, efl_util_notification_level_e* level)
79 EINA_SAFETY_ON_NULL_RETURN_VAL(window,
80 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
83 Ecore_X_Window_Type window_type;
84 Utilx_Notification_Level utilx_level;
85 Ecore_X_Window xwin = elm_win_xwindow_get(window);
88 if(ecore_x_netwm_window_type_get(xwin, &window_type) == EINA_TRUE)
90 // success to get window type
91 if(window_type != ECORE_X_WINDOW_TYPE_NOTIFICATION)
93 // given EFL window's type is not notification type.
94 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
97 utilx_level = utilx_get_system_notification_level (ecore_x_display_get(), xwin);
99 if(utilx_level == UTILX_NOTIFICATION_LEVEL_LOW)
101 *level = EFL_UTIL_NOTIFICATION_LEVEL_1;
103 else if(utilx_level == UTILX_NOTIFICATION_LEVEL_NORMAL)
105 *level = EFL_UTIL_NOTIFICATION_LEVEL_2;
107 else if(utilx_level == UTILX_NOTIFICATION_LEVEL_HIGH)
109 *level = EFL_UTIL_NOTIFICATION_LEVEL_2;
113 return EFL_UTIL_ERROR_INVALID_PARAMETER;
119 // fail to get window type
120 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
123 return EFL_UTIL_ERROR_NONE;
127 #if ECORE_WAYLAND_FOUND
128 Ecore_Wl_Window wl_win = elm_win_wl_window_get(window);
131 printf("not implemented for wayland yet\n");
132 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
135 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
138 int efl_util_grab_key (Evas_Object *obj, const char* key, int grab_mode)
140 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, 0);
143 Ecore_X_Window x_win;
144 Ecore_X_Display *x_disp;
146 x_win = elm_win_xwindow_get(obj);
149 x_disp = ecore_x_display_get();
150 return utilx_grab_key(x_disp, x_win, key, grab_mode);
155 #if ECORE_WAYLAND_FOUND
156 Ecore_Wl_Window wl_win = elm_win_wl_window_get(obj);
159 printf("not implemented for wayland yet\n");
167 int efl_util_ungrab_key (Evas_Object *obj, const char* key)
169 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, 0);
172 Ecore_X_Window x_win;
173 Ecore_X_Display *x_disp;
175 x_win = elm_win_xwindow_get(obj);
178 x_disp = ecore_x_display_get();
179 return utilx_ungrab_key (x_disp, x_win, key);
183 #if ECORE_WAYLAND_FOUND
184 Ecore_Wl_Window wl_win = elm_win_wl_window_get(obj);
187 printf("not implemented for wayland yet\n");
195 void efl_util_set_system_notification_level (Evas_Object *obj, Efl_Util_Notification_Level level)
197 EINA_SAFETY_ON_NULL_RETURN(obj);
198 EINA_SAFETY_ON_FALSE_RETURN(level >= EFL_UTIL_NOTIFICATION_LEVEL_LOW &&
199 level <= EFL_UTIL_NOTIFICATION_LEVEL_UNKNOWN);
202 Ecore_X_Window x_win;
203 Ecore_X_Display *x_disp;
205 x_win = elm_win_xwindow_get(obj);
208 x_disp = ecore_x_display_get();
209 utilx_set_system_notification_level(x_disp, x_win, level);
214 #if ECORE_WAYLAND_FOUND
215 Ecore_Wl_Window wl_win = elm_win_wl_window_get(obj);
218 printf("not implemented for wayland yet\n");
223 Efl_Util_Notification_Level efl_util_get_system_notification_level (Evas_Object *obj)
225 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EFL_UTIL_NOTIFICATION_LEVEL_UNKNOWN);
228 Ecore_X_Window x_win;
229 Ecore_X_Display *x_disp;
231 x_win = elm_win_xwindow_get(obj);
234 x_disp = ecore_x_display_get();
235 return utilx_get_system_notification_level(x_disp, x_win);
240 #if ECORE_WAYLAND_FOUND
241 Ecore_Wl_Window wl_win = elm_win_wl_window_get(obj);
244 printf("not implemented for wayland yet\n");
245 return EFL_UTIL_NOTIFICATION_LEVEL_UNKNOWN;
249 return EFL_UTIL_NOTIFICATION_LEVEL_UNKNOWN;
252 void efl_util_netwm_window_type_set(Evas_Object *obj, Efl_Util_Window_Type type)
254 EINA_SAFETY_ON_NULL_RETURN(obj);
255 EINA_SAFETY_ON_FALSE_RETURN(type == EFL_UTIL_WINDOW_TYPE_NORMAL ||
256 type == EFL_UTIL_WINDOW_TYPE_NOTIFICATION);
259 Ecore_X_Window x_win;
261 x_win = elm_win_xwindow_get(obj);
264 ecore_x_netwm_window_type_set(x_win, type);
270 #if ECORE_WAYLAND_FOUND
271 Ecore_Wl_Window wl_win = elm_win_wl_window_get(obj);
273 printf("not implemented for wayland yet\n");
277 void efl_util_set_window_effect_style(Evas_Object *win, Efl_Util_Effect_Type type, Efl_Util_Effect_Style style)
280 EINA_SAFETY_ON_NULL_RETURN(win);
283 Ecore_X_Window x_win;
284 Ecore_X_Display *x_disp;
286 x_win = elm_win_xwindow_get(win);
289 x_disp = ecore_x_display_get();
290 utilx_set_window_effect_style(x_disp, x_win, type, style);
295 #if ECORE_WAYLAND_FOUND
296 Ecore_Wl_Window wl_win = elm_win_wl_window_get(win);
298 printf("not implemented for wayland yet\n");
302 int efl_util_set_window_opaque_state (Evas_Object *win, Efl_Util_Opaque_State state)
304 EINA_SAFETY_ON_NULL_RETURN_VAL(win, 0);
307 Ecore_X_Window x_win;
308 Ecore_X_Display *x_disp;
310 x_win = elm_win_xwindow_get(win);
313 x_disp = ecore_x_display_get();
314 return utilx_set_window_opaque_state(x_disp, x_win, state);
318 #if ECORE_WAYLAND_FOUND
319 Ecore_Wl_Window wl_win = elm_win_wl_window_get(win);
321 printf("not implemented for wayland yet\n");