4 Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
20 #ifndef __TIZEN_LINUX_UTIL_X11_H__
21 #define __TIZEN_LINUX_UTIL_X11_H__
24 #define DEPRECATED __attribute__((deprecated))
31 * @addtogroup CAPI_UI_UTILX_MODULE
35 #include <sys/types.h>
45 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Volume Up' key.
47 #define KEY_VOLUMEUP "XF86AudioRaiseVolume"
49 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Volume Down' key.
51 #define KEY_VOLUMEDOWN "XF86AudioLowerVolume"
53 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Half-Press of Camera' key.
55 #define KEY_CAMERA "XF86WebCam"
57 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Full-Press of Camera' key.
59 #define KEY_CONFIG "XF86Pictures"
62 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Power' key.
64 #define KEY_POWER "XF86PowerOff"
66 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Pause' key.
68 #define KEY_PAUSE "XF86Standby"
70 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Cancel' key.
72 #define KEY_CANCEL "Cancel"
74 // Earjack/BT Headset/Multimedia keys
76 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Play Audio' key.
78 #define KEY_PLAYCD "XF86AudioPlay"
80 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Stop Audio' key.
82 #define KEY_STOPCD "XF86AudioStop"
84 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Pause Audio' key.
86 #define KEY_PAUSECD "XF86AudioPause"
88 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Next Song' key.
90 #define KEY_NEXTSONG "XF86AudioNext"
92 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Previous Song' key.
94 #define KEY_PREVIOUSSONG "XF86AudioPrev"
96 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Rewind Song' key.
98 #define KEY_REWIND "XF86AudioRewind"
100 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Forward Song' key.
102 #define KEY_FASTFORWARD "XF86AudioForward"
104 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Media' key.
106 #define KEY_MEDIA "XF86AudioMedia"
108 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'PlayPause' key.
110 #define KEY_PLAYPAUSE "XF86AudioPlayPause"
112 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Mute' key.
114 #define KEY_MUTE "XF86AudioMute"
118 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Send' key.
120 #define KEY_SEND "XF86Send"
122 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Home' key.
124 #define KEY_SELECT "XF86Phone"
126 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'End' key.
128 #define KEY_END "XF86Stop"
130 // Renamed 3-Touch key
132 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Send' key.
134 #define KEY_MENU "XF86Send"
136 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Home' key.
138 #define KEY_HOME "XF86Phone"
140 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'End' key.
142 #define KEY_BACK "XF86Stop"
144 //Other functions keys
146 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'HomePage' key.
148 #define KEY_HOMEPAGE "XF86HomePage"
150 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'WWW' key.
152 #define KEY_WEBPAGE "XF86WWW"
154 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Mail' key.
156 #define KEY_MAIL "XF86Mail"
158 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'ScreenSaver' key.
160 #define KEY_SCREENSAVER "XF86ScreenSaver"
162 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'BrightnessUp' key.
164 #define KEY_BRIGHTNESSUP "XF86MonBrightnessUp"
166 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'BrightnessDown' key.
168 #define KEY_BRIGHTNESSDOWN "XF86MonBrightnessDown"
170 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Soft keyboard(toggle)' key.
172 #define KEY_SOFTKBD "XF86MenuKB"
174 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Quick panel(toggle)' key.
176 #define KEY_QUICKPANEL "XF86Tools"
178 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Task switcher(toggle)' key.
180 #define KEY_TASKSWITCH "XF86TaskPane"
182 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Apptray(toggle)' key.
184 #define KEY_APPS "XF86Launch0"
186 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Search(toggle)' key.
188 #define KEY_SEARCH "XF86Search"
190 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Voice(toggle)' key.
192 #define KEY_VOICE "XF86Launch2"
194 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Language(toggle)' key.
196 #define KEY_LANGUAGE "Hangul"
198 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Call(toggle)' key.
200 #define KEY_CONNECT "XF86Go"
202 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Play(toggle)' key.
204 #define KEY_GAMEPLAY "XF86Game"
206 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Voice Wakeup LPSD' key.
208 #define KEY_VOICEWAKEUP_LPSD "XF86Launch3"
210 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Voice Wakeup' key.
212 #define KEY_VOICEWAKEUP "XF86Launch4"
215 * @brief Definition for the length of a string corresponding to the 'Volume Up' key.
217 #define LEN_KEY_VOLUMEUP 20
219 * @brief Definition for the length of a string corresponding to the 'Volume Down' key.
221 #define LEN_KEY_VOLUMEDOWN 20
224 * @brief Definition for the length of a string corresponding to the 'Half-Press of Camera' key.
226 #define LEN_KEY_CAMERA 10
228 * @brief Definition for the length of a string corresponding to the 'Full-Press of Camera' key.
230 #define LEN_KEY_CONFIG 12
233 * @brief Definition for the length of a string corresponding to the 'Power' key.
235 #define LEN_KEY_POWER 12
237 * @brief Definition for the length of a string corresponding to the 'Pause' key.
239 #define LEN_KEY_PAUSE 11
241 // Earjack/BT Headset/Multimedia keys
243 * @brief Definition for the length of a string corresponding to the 'Play Audio' key.
245 #define LEN_KEY_PLAYCD 13
247 * @brief Definition for the length of a string corresponding to the 'Stop Audio' key.
249 #define LEN_KEY_STOPCD 13
251 * @brief Definition for the length of a string corresponding to the 'Pause Audio' key.
253 #define LEN_KEY_PAUSECD 14
255 * @brief Definition for the length of a string corresponding to the 'Next Song' key.
257 #define LEN_KEY_NEXTSONG 13
259 * @brief Definition for the length of a string corresponding to the 'Previous Song' key.
261 #define LEN_KEY_PREVIOUSSONG 13
263 * @brief Definition for the length of a string corresponding to the 'Rewind Song' key.
265 #define LEN_KEY_REWIND 15
267 * @brief Definition for the length of a string corresponding to the 'Forwand Song' key.
269 #define LEN_KEY_FASTFORWARD 16
271 * @brief Definition for the length of a string corresponding to the 'Media' key.
273 #define LEN_KEY_MEDIA 14
275 * @brief Definition for the length of a string corresponding to the 'PlayPause' key.
277 #define LEN_KEY_PLAYPAUSE 13
279 * @brief Definition for the length of a string corresponding to the 'Mute' key.
281 #define LEN_KEY_MUTE 13
285 * @brief Definition for the length of a string corresponding to the 'Send' key.
287 #define LEN_KEY_SEND 8
289 * @brief Definition for the length of a string corresponding to the 'Home' key.
291 #define LEN_KEY_SELECT 9
293 * @brief Definition for the length of a string corresponding to the 'End' key.
295 #define LEN_KEY_END 8
297 // Renamed 3-Touch key
299 * @brief Definition for the length of a string corresponding to the 'Send' key.
301 #define LEN_KEY_MENU 8
303 * @brief Definition for the length of a string corresponding to the 'Home' key.
305 #define LEN_KEY_HOME 9
307 * @brief Definition for the length of a string corresponding to the 'End' key.
309 #define LEN_KEY_BACK 8
311 //Other functions keys
313 * @brief Definition for the length of a string corresponding to the 'HomePage' key.
315 #define LEN_KEY_HOMEPAGE 12
317 * @brief Definition for the length of a string corresponding to the 'WWW' key.
319 #define LEN_KEY_WEBPAGE 7
321 * @brief Definition for the length of a string corresponding to the 'Mail' key.
323 #define LEN_KEY_MAIL 8
325 * @brief Definition for the length of a string corresponding to the 'ScreenSaver' key.
327 #define LEN_KEY_SCREENSAVER 15
329 * @brief Definition for the length of a string corresponding to the 'BrightnessUp' key.
331 #define LEN_KEY_BRIGHTNESSUP 19
333 * @brief Definition for the length of a string corresponding to the 'BrightnessDown' key.
335 #define LEN_KEY_BRIGHTNESSDOWN 21
337 * @brief Definition for the length of a string corresponding to the 'Soft keyboard(toggle)' key.
339 #define LEN_KEY_SOFTKBD 10
341 * @brief Definition for the length of a string corresponding to the 'Quick panel(toggle)' key.
343 #define LEN_KEY_QUICKPANEL 9
345 * @brief Definition for the length of a string corresponding to the 'Task switcher(toggle)' key.
347 #define LEN_KEY_TASKSWITCH 12
349 * @brief Definition for the length of a string corresponding to the 'Apptray(toggle)' key.
351 #define LEN_KEY_APPS 11
353 * @brief Definition for the length of a string corresponding to the 'Search(toggle)' key.
355 #define LEN_KEY_SEARCH 10
357 * @brief Definition for the length of a string corresponding to the 'Voice(toggle)' key.
359 #define LEN_KEY_VOICE 11
361 * @brief Definition for the length of a string corresponding to the 'Language(toggle)' key.
363 #define LEN_KEY_LANGUAGE 6
365 * @brief Definition for the length of a string corresponding to the 'Call(toggle)' key.
367 #define LEN_KEY_CONNECT 6
369 * @brief Definition for the length of a string corresponding to the 'Play(toggle)' key.
371 #define LEN_KEY_GAMEPLAY 8
373 * @brief Definition for the length of a string corresponding to the 'Voice Wakeup LPSD' key.
375 #define LEN_KEY_VOICEWAKEUP_LPSD 11
377 * @brief Definition for the length of a string corresponding to the 'Voice Wakeup' key.
379 #define LEN_KEY_VOICEWAKEUP 11
382 * @brief Definition for getting the grabbed-key exclusively regardless of its position on the window stack with the possibility of overriding the grab by the other client window mode.
384 #define OR_EXCLUSIVE_GRAB 0xf00000
386 * @brief Definition for getting the grabbed-key exclusively regardless of its position on the window stack mode.
388 #define EXCLUSIVE_GRAB 0x0f0000
390 * @brief Definition for getting the grabbed-key only when on the top of the grabbing-window stack mode.
392 #define TOP_POSITION_GRAB 0x00f000
394 * @brief Definition for getting the grabbed-key together with the other client window(s) mode.
396 #define SHARED_GRAB 0x000f00
398 * @brief Definition for getting the key-grab mode of a client window.
400 #define GRAB_MODE_MASK 0xffff00
403 * @brief Definition for the client window grabbing the key which is already in the EXCLUSIVE mode.
405 #define EXCLUSIVE_GRABBED_ALREADY 1
408 * @brief Definition for getting/setting the property while grabbing a key for a window.
410 #define STR_ATOM_GRAB_KEY "_GRAB_KEY"
412 * @brief Definition for the key grabbed by a client window in the EXCLUSIVE mode.
414 #define STR_ATOM_GRAB_EXCL_WIN "_GRAB_EXCL_WIN_KEYCODE"
416 * @brief Definition for the key grabbed by a client window in the OR_EXCLUSIVE mode.
418 #define STR_ATOM_GRAB_OR_EXCL_WIN "_GRAB_OR_EXCL_WIN_KEYCODE"
421 * @brief Enumeration for notification window's priority level.
423 typedef enum _Utilx_Notification_Level
425 UTILX_NOTIFICATION_LEVEL_LOW, /**< Low level notification */
426 UTILX_NOTIFICATION_LEVEL_NORMAL, /**< Normal level notification*/
427 UTILX_NOTIFICATION_LEVEL_HIGH /**< High level notification */
428 } Utilx_Notification_Level;
431 * @brief Enumeration for the opaque state.
433 typedef enum _Utilx_Opaque_State
435 UTILX_OPAQUE_STATE_OFF = 0, /**< Transparent state */
436 UTILX_OPAQUE_STATE_ON = 1, /**< Opaque state */
437 } Utilx_Opaque_State;
440 * @brief Sets the priority level for the specified notification window, asynchronously.
442 * @details This function sets the priority level of notification windows.\n
443 * Every notification window has a base priority level by the notification window's priority value (default priority is #UTILX_NOTIFICATION_LEVEL_LOW).
445 * The priority is used for ordering of notification windows.\n
446 * The notification window with the priority set to #UTILX_NOTIFICATION_LEVEL_HIGH will be placed at the top of the notification windows.\n
447 * If there are notification windows which have same priorities, the last created notification window will be placed on the other window.
450 * @remarks This is used only for notification windows.
451 * @param[in] dpy The connection to the X server
452 * @param[in] win The window to set
453 * @param[in] level The level (#UTILX_NOTIFICATION_LEVEL_LOW, #UTILX_NOTIFICATION_LEVEL_NORMAL, #UTILX_NOTIFICATION_LEVEL_HIGH)
454 * @pre The window should be a notification type window.
455 * @see #Utilx_Notification_Level
456 * @see utilx_get_system_notification_level()
467 xwin = elm_win_xwindow_get(win);
469 // Set Notification type
470 ecore_x_netwm_window_type_set (xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
472 // Set Notification's priority
473 utilx_set_system_notification_level (ecore_x_display_get(), xwin, UTILX_NOTIFICATION_LEVEL_HIGH);
478 void utilx_set_system_notification_level (Display* dpy, Window win, Utilx_Notification_Level level);
481 * @brief Gets the priority level for the specified notification window.
483 * @details This function returns the priority level of notification windows.\n
484 * If a user didn't set the notification's priority level, this function returns the default value (#UTILX_NOTIFICATION_LEVEL_LOW).
486 * This function is a synchronous call.
489 * @remarks This is used only for notification windows.
490 * @param[in] dpy The connection to the X server
491 * @param[in] win The window to get
492 * @return The current notification level (#UTILX_NOTIFICATION_LEVEL_LOW, #UTILX_NOTIFICATION_LEVEL_NORMAL, #UTILX_NOTIFICATION_LEVEL_HIGH)
493 * @pre The window should be a notification type window.
494 * @see utilx_set_system_notification_level()
503 Utilx_Notification_Level level;
505 win = elm_win_add (NULL, "test", ELM_WIN_NOTIFICATION);
506 xwin = elm_win_xwindow_get(win);
508 level = utilx_get_system_notification_level (ecore_x_display_get(), xwin);
513 Utilx_Notification_Level utilx_get_system_notification_level (Display* dpy, Window win);
516 * @brief Gets the string list and count of available key-names to grab.
517 * @details This function returns the newly-allocated list and count of available key-names to grab for a target device.
518 * The key-name is unchangeable whatever you develope in different target.
519 * However, key-symbol got by utilx_get_key_symbol() is changeable in different target.
521 * @remarks You should free the pointer of name list by free() to avoid memory-leak
522 * @param[out] count The number of avaiable keys for a target device
523 * @return newly-allocated list of available key strings, otherwise NULL.
524 * @see utilx_get_key_symbol()
531 main (int argc, char* argv[])
537 names = utilx_get_available_key_names (&count);
541 for (i = 0; i < count; i++)
543 const char *symbol = utilx_get_key_symbol (names[i]);
544 printf ("name: %s, symbol: %s\n", names[i], symbol);
555 const char** utilx_get_available_key_names (int *count);
558 * @brief Gets a key-symbol string for a available key-name string to grab.
559 * @details This function returns a key-symbol string for a available key-name to grab for a target device.
560 * The key-name got by utilx_get_available_key_names() is unchangeable whatever you develope in different target.
561 * However, key-symbol is changeable in different target.
563 * @param[in] key_name The name of a key got by utilx_get_available_key_names()
564 * @return key-symbol string if success, otherwise NULL.
565 * @see utilx_get_available_key_names(), utilx_grab_key(), utilx_ungrab_key()
572 main (int argc, char* argv[])
578 names = utilx_get_available_key_names (&count);
582 for (i = 0; i < count; i++)
584 const char *symbol = utilx_get_key_symbol (names[i]);
585 printf ("name: %s, symbol: %s\n", names[i], symbol);
596 const char* utilx_get_key_symbol (const char *key_name);
599 * @brief Grabs the key specfied by @a key_symbol for a window in the @a grab_mode.
601 * @details This function establishes a grab of the specified key for the specified window.\n
602 * Once a key is grabbed, all events originating from the key will only be reported to the specfied window.\n
603 * The grab of the key can be released by calling utilx_ungrab_key().
605 * This function is synchronous.
608 * @remarks If utilx_grab_key() returns @c 0, the specified window will get the events of the specified key.\n
609 * However, delivery of a key can always be changed by other applications grabbing the key with higher priority.\n
610 * It can also be changed by the changes of window stacks.\n
611 * A trial for choosing a proper grab mode will be needed.
612 * @param[in] dpy The connection to the X server
613 * @param[in] win The window to grab a key
614 * @param[in] key_symbol The symbol of a key in the string
615 * @param[in] grab_mode The grab mode (such as #EXCLUSIVE_GRAB, #TOP_POSITION_GRAB, and #SHARED_GRAB)
616 * @return @c 0 on success,
618 * @pre This API must be called after the window 'win' has been mapped.
619 * @post This API adds/changes the window property related to the grabbed key.
620 * @see utilx_ungrab_key(), utilx_get_available_key_names(), utilx_get_key_symbol()
621 * @par Example (using X11 APIs)
623 #include <X11/Xlib.h>
626 static const char* key_symbol;
629 get_key_symbol (void)
634 names = utilx_get_available_key_names (&count);
638 for (i = 0; i < count; i++)
639 if (!strcmp (names[i], "KEY_UP"))
641 key_symbol = utilx_get_key_symbol ("KEY_UP");
642 printf ("found: key(%s,%s)\n", "KEY_UP", key_symbol);
643 free (names); // should free
647 free (names); // should free
653 Display *disp = XOpenDisplay(NULL);
656 Window w = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 5,5, 470, 780, 2, BlackPixel(disp,0), WhitePixel(disp,0));
657 XSelectInput(disp, w, StructureNotifyMask | KeyPressMask | KeyReleaseMask | ExposureMask);
660 if (!get_key_symbol ())
665 XNextEvent(disp, &e);
671 grab_result = utilx_grab_key(disp, w, key_symbol, EXCLUSIVE_GRAB);
672 if( EXCLUSIVE_GRABBED_ALREADY == grab_result )
675 //utilx_grab_key(disp, w, key_symbol, TOP_POSITION_GRAB);
676 //utilx_grab_key(disp, w, key_symbol, SHARED_GRAB);
685 utilx_ungrab_key(disp, w, key_symbol);
690 * @par Example (using EFL APIs)
693 #include <Ecore_Evas.h>
696 static const char* key_symbol;
699 get_key_symbol (void)
704 names = utilx_get_available_key_names (&count);
708 for (i = 0; i < count; i++)
709 if (!strcmp (names[i], "KEY_UP"))
711 key_symbol = utilx_get_key_symbol ("KEY_UP");
712 printf ("found: key(%s,%s)\n", "KEY_UP", key_symbol);
713 free (names); // should free
717 free (names); // should free
725 Ecore_X_Display* disp = ecore_x_display_get();
726 Ecore_X_Window w = ecore_evas_software_x11_window_get(ee);
732 grab_result = utilx_grab_key(disp, w, key_symbol, EXCLUSIVE_GRAB);
733 if( EXCLUSIVE_GRABBED_ALREADY == grab_result )
736 //utilx_grab_key(disp, w, key_symbol, TOP_POSITION_GRAB);
737 //utilx_grab_key(disp, w, key_symbol, SHARED_GRAB);
741 utilx_ungrab_key(disp, w, key_symbol); //Ungrab whenever a user wants to
747 int utilx_grab_key (Display* dpy, Window win, const char* key_symbol, int grab_mode);
750 * @brief Ungrabs the key specfied by @a key_symbol for a window.
752 * @details This function releases the already established grab of the specfied key for the specified window.\n
753 * Once the grab of the key is released, delivery of the key events for the specfied window is going to be stopped.
755 * This function is synchronous.
758 * @param[in] dpy The connection to the X server
759 * @param[in] win The window to grab a key
760 * @param[in] key_symbol The symbol of a key in the string got by utilx_get_key_symbol()
761 * @return @c 0 on success,
763 * @pre This API must be called after the window 'win' is mapped.
764 * @post This API changes/removes the window property related to the grabbed key.
765 * @see utilx_grab_key(), utilx_get_available_key_names(), utilx_get_key_symbol()
766 * @par Example (using X11 APIs)
768 #include <X11/Xlib.h>
771 static const char* key_symbol;
774 get_key_symbol (void)
779 names = utilx_get_available_key_names (&count);
783 for (i = 0; i < count; i++)
784 if (!strcmp (names[i], "KEY_UP"))
786 key_symbol = utilx_get_key_symbol ("KEY_UP");
787 printf ("found: key(%s,%s)\n", "KEY_UP", key_symbol);
788 free (names); // should free
792 free (names); // should free
798 Display *disp = XOpenDisplay(NULL);
801 Window w = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 5,5, 470, 780, 2, BlackPixel(disp,0), WhitePixel(disp,0));
802 XSelectInput(disp, w, StructureNotifyMask | KeyPressMask | KeyReleaseMask | ExposureMask);
805 if (!get_key_symbol ())
810 XNextEvent(disp, &e);
816 grab_result = utilx_grab_key(disp, w, key_symbol, EXCLUSIVE_GRAB);
817 if( EXCLUSIVE_GRABBED_ALREADY == grab_result )
820 //utilx_grab_key(disp, w, key_symbol, TOP_POSITION_GRAB);
821 //utilx_grab_key(disp, w, key_symbol, SHARED_GRAB);
830 utilx_ungrab_key(disp, w, key_symbol);
835 * @par Example (using EFL APIs)
838 #include <Ecore_Evas.h>
841 static const char* key_symbol;
844 get_key_symbol (void)
849 names = utilx_get_available_key_names (&count);
853 for (i = 0; i < count; i++)
854 if (!strcmp (names[i], "KEY_UP"))
856 key_symbol = utilx_get_key_symbol ("KEY_UP");
857 printf ("found: key(%s,%s)\n", "KEY_UP", key_symbol);
858 free (names); // should free
862 free (names); // should free
870 Ecore_X_Display* disp = ecore_x_display_get();
871 Ecore_X_Window w = ecore_evas_software_x11_window_get(ee);
877 grab_result = utilx_grab_key(disp, w, key_symbol, EXCLUSIVE_GRAB);
878 if( EXCLUSIVE_GRABBED_ALREADY == grab_result )
881 //utilx_grab_key(disp, w, key_symbol, TOP_POSITION_GRAB);
882 //utilx_grab_key(disp, w, key_symbol, SHARED_GRAB);
886 utilx_ungrab_key(disp, w, key_symbol); //Ungrab whenever a user wants to
892 int utilx_ungrab_key (Display* dpy, Window win, const char* key_symbol);
895 * @brief Sets the window's opaque state.
897 * @details This function sets the window's visibility to opaque even if the window is an alpha window.
898 * This function is available only for an alpha window.
899 * An alpha window's default opaque state is #UTILX_OPAQUE_STATE_OFF.
901 * This function is an asynchronous call.
904 * @remarks This is used only for alpha windows.
905 * @param[in] dpy The connection to the X server
906 * @param[in] win The window handle
907 * @param[in] state The value that indicates whether the window has set a visible state to opaque(#UTILX_OPAQUE_STATE_ON) or not(#UTILX_OPAQUE_STATE_OFF)
908 * @return @c 1 on success,
912 #include <X11/Xlib.h>
921 dpy = XOpenDisplay (NULL);
922 root = XDefaultRootWindow (dpy);
924 win = XCreateSimpleWindow (dpy, root, 0, 0, 480, 800, 2, BlackPixel (dpy,0), WhitePixel(dpy,0));
925 XMapWindow (dpy, win);
927 ret = utilx_set_window_opaque_state (dpy, win, UTILX_OPAQUE_STATE_ON);
930 printf ("Error! Failed to set opaque state.\n");
938 int utilx_set_window_opaque_state (Display* dpy, Window win, Utilx_Opaque_State state);
941 * @brief Creates a screenshot image.
943 * @details This function creates a screenshot image of the display.\n
944 * To use this function, you should get the permission first.\n
945 * In addition, device LCD must be turned on; otherwise, this function fails.\n
946 * Once this functions is called, utilx_release_screen_shot() should be called after it.
949 * @privlevel platform
950 * @privilege %http://tizen.org/privilege/screenshot
951 * @remarks You should get the permission to use. Device LCD must be on.
952 * @param[in] dpy The connection to the X server
953 * @param[in] width The root window handle
954 * @param[in] height The root window handle
955 * @see utilx_release_screen_shot()
962 dpy = XOpenDisplay (NULL);
963 width = DisplayWidth (dpy, DefaultScreen (dpy));
964 height = DisplayHeight (dpy, DefaultScreen (dpy));
966 dump = utilx_create_screen_shot (dpy, width, height);
969 // do_something (dump);
973 // utilx_create_screen_shot can return NULL in some cases.
974 // Even if it returns NULL, utilx_release_screen_shot should be called.
977 utilx_release_screen_shot ();
980 void* utilx_create_screen_shot (Display* dpy, int width, int height);
983 * @brief Releases screenshot resources.
985 * @details This function releases resources associated with screenshot
986 * image of the display. utilx_release_screen_shot() should be called once
987 * utilx_create_screen_shot() is called.
990 * @privlevel platform
991 * @privilege %http://tizen.org/privilege/screenshot
992 * @see utilx_create_screen_shot()
999 dpy = XOpenDisplay (NULL);
1000 width = DisplayWidth (dpy, DefaultScreen (dpy));
1001 height = DisplayHeight (dpy, DefaultScreen (dpy));
1003 dump = utilx_create_screen_shot (dpy, width, height);
1006 // do_something (dump);
1010 // utilx_create_screen_shot can return NULL in some cases.
1011 // Even if it returns NULL, utilx_release_screen_shot should be called.
1014 utilx_release_screen_shot ();
1017 void utilx_release_screen_shot (void);
1027 #endif /* __TIZEN_LINUX_UTIL_X11_H__ */