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"
214 // Hauppauge remocon keys
216 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Channel Up' key.
218 #define KEY_CHANNELUP "XF86KbdBrightnessUp"
220 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Channel Down' key.
222 #define KEY_CHANNELDOWN "XF86KbdBrightnessDown"
224 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Close' key.
226 #define KEY_CLOSE "XF86Close"
228 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Video Pause' key.
230 #define KEY_VIDEOPAUSE "Pause"
232 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Audio Record' key.
234 #define KEY_RECORD "XF86AudioRecord"
237 * @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'TV(toggle)' key.
239 #define KEY_TV "XF86Display"
243 * @brief Definition for the length of a string corresponding to the 'Volume Up' key.
245 #define LEN_KEY_VOLUMEUP 20
247 * @brief Definition for the length of a string corresponding to the 'Volume Down' key.
249 #define LEN_KEY_VOLUMEDOWN 20
252 * @brief Definition for the length of a string corresponding to the 'Half-Press of Camera' key.
254 #define LEN_KEY_CAMERA 10
256 * @brief Definition for the length of a string corresponding to the 'Full-Press of Camera' key.
258 #define LEN_KEY_CONFIG 12
261 * @brief Definition for the length of a string corresponding to the 'Power' key.
263 #define LEN_KEY_POWER 12
265 * @brief Definition for the length of a string corresponding to the 'Pause' key.
267 #define LEN_KEY_PAUSE 11
269 // Earjack/BT Headset/Multimedia keys
271 * @brief Definition for the length of a string corresponding to the 'Play Audio' key.
273 #define LEN_KEY_PLAYCD 13
275 * @brief Definition for the length of a string corresponding to the 'Stop Audio' key.
277 #define LEN_KEY_STOPCD 13
279 * @brief Definition for the length of a string corresponding to the 'Pause Audio' key.
281 #define LEN_KEY_PAUSECD 14
283 * @brief Definition for the length of a string corresponding to the 'Next Song' key.
285 #define LEN_KEY_NEXTSONG 13
287 * @brief Definition for the length of a string corresponding to the 'Previous Song' key.
289 #define LEN_KEY_PREVIOUSSONG 13
291 * @brief Definition for the length of a string corresponding to the 'Rewind Song' key.
293 #define LEN_KEY_REWIND 15
295 * @brief Definition for the length of a string corresponding to the 'Forwand Song' key.
297 #define LEN_KEY_FASTFORWARD 16
299 * @brief Definition for the length of a string corresponding to the 'Media' key.
301 #define LEN_KEY_MEDIA 14
303 * @brief Definition for the length of a string corresponding to the 'PlayPause' key.
305 #define LEN_KEY_PLAYPAUSE 13
307 * @brief Definition for the length of a string corresponding to the 'Mute' key.
309 #define LEN_KEY_MUTE 13
313 * @brief Definition for the length of a string corresponding to the 'Send' key.
315 #define LEN_KEY_SEND 8
317 * @brief Definition for the length of a string corresponding to the 'Home' key.
319 #define LEN_KEY_SELECT 9
321 * @brief Definition for the length of a string corresponding to the 'End' key.
323 #define LEN_KEY_END 8
325 // Renamed 3-Touch key
327 * @brief Definition for the length of a string corresponding to the 'Send' key.
329 #define LEN_KEY_MENU 8
331 * @brief Definition for the length of a string corresponding to the 'Home' key.
333 #define LEN_KEY_HOME 9
335 * @brief Definition for the length of a string corresponding to the 'End' key.
337 #define LEN_KEY_BACK 8
339 //Other functions keys
341 * @brief Definition for the length of a string corresponding to the 'HomePage' key.
343 #define LEN_KEY_HOMEPAGE 12
345 * @brief Definition for the length of a string corresponding to the 'WWW' key.
347 #define LEN_KEY_WEBPAGE 7
349 * @brief Definition for the length of a string corresponding to the 'Mail' key.
351 #define LEN_KEY_MAIL 8
353 * @brief Definition for the length of a string corresponding to the 'ScreenSaver' key.
355 #define LEN_KEY_SCREENSAVER 15
357 * @brief Definition for the length of a string corresponding to the 'BrightnessUp' key.
359 #define LEN_KEY_BRIGHTNESSUP 19
361 * @brief Definition for the length of a string corresponding to the 'BrightnessDown' key.
363 #define LEN_KEY_BRIGHTNESSDOWN 21
365 * @brief Definition for the length of a string corresponding to the 'Soft keyboard(toggle)' key.
367 #define LEN_KEY_SOFTKBD 10
369 * @brief Definition for the length of a string corresponding to the 'Quick panel(toggle)' key.
371 #define LEN_KEY_QUICKPANEL 9
373 * @brief Definition for the length of a string corresponding to the 'Task switcher(toggle)' key.
375 #define LEN_KEY_TASKSWITCH 12
377 * @brief Definition for the length of a string corresponding to the 'Apptray(toggle)' key.
379 #define LEN_KEY_APPS 11
381 * @brief Definition for the length of a string corresponding to the 'Search(toggle)' key.
383 #define LEN_KEY_SEARCH 10
385 * @brief Definition for the length of a string corresponding to the 'Voice(toggle)' key.
387 #define LEN_KEY_VOICE 11
389 * @brief Definition for the length of a string corresponding to the 'Language(toggle)' key.
391 #define LEN_KEY_LANGUAGE 6
393 * @brief Definition for the length of a string corresponding to the 'Call(toggle)' key.
395 #define LEN_KEY_CONNECT 6
397 * @brief Definition for the length of a string corresponding to the 'Play(toggle)' key.
399 #define LEN_KEY_GAMEPLAY 8
401 * @brief Definition for the length of a string corresponding to the 'Voice Wakeup LPSD' key.
403 #define LEN_KEY_VOICEWAKEUP_LPSD 11
405 * @brief Definition for the length of a string corresponding to the 'Voice Wakeup' key.
407 #define LEN_KEY_VOICEWAKEUP 11
409 // Hauppauge remocon keys
411 * @brief Definition for the length of a string corresponding to the 'Channel Up' key.
413 #define LEN_KEY_CHANNELUP 19
415 * @brief Definition for the length of a string corresponding to the 'Channel Down' key.
417 #define LEN_KEY_CHANNELDOWN 21
419 * @brief Definition for the length of a string corresponding to the 'Close' key.
421 #define LEN_KEY_CLOSE 9
423 * @brief Definition for the length of a string corresponding to the 'Video Pause' key.
425 #define LEN_KEY_VIDEOPAUSE 5
427 * @brief Definition for the length of a string corresponding to the 'Audio Record' key.
429 #define LEN_KEY_RECORD 15
431 * @brief Definition for the length of a string corresponding to the 'TV(toggle)' key.
433 #define LEN_KEY_TV 11
437 * @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.
439 #define OR_EXCLUSIVE_GRAB 0xf00000
441 * @brief Definition for getting the grabbed-key exclusively regardless of its position on the window stack mode.
443 #define EXCLUSIVE_GRAB 0x0f0000
445 * @brief Definition for getting the grabbed-key only when on the top of the grabbing-window stack mode.
447 #define TOP_POSITION_GRAB 0x00f000
449 * @brief Definition for getting the grabbed-key together with the other client window(s) mode.
451 #define SHARED_GRAB 0x000f00
453 * @brief Definition for getting the key-grab mode of a client window.
455 #define GRAB_MODE_MASK 0xffff00
458 * @brief Definition for the client window grabbing the key which is already in the EXCLUSIVE mode.
460 #define EXCLUSIVE_GRABBED_ALREADY 1
463 * @brief Definition for getting/setting the property while grabbing a key for a window.
465 #define STR_ATOM_GRAB_KEY "_GRAB_KEY"
467 * @brief Definition for the key grabbed by a client window in the EXCLUSIVE mode.
469 #define STR_ATOM_GRAB_EXCL_WIN "_GRAB_EXCL_WIN_KEYCODE"
471 * @brief Definition for the key grabbed by a client window in the OR_EXCLUSIVE mode.
473 #define STR_ATOM_GRAB_OR_EXCL_WIN "_GRAB_OR_EXCL_WIN_KEYCODE"
476 * @brief Enumeration for notification window's priority level.
478 typedef enum _Utilx_Notification_Level
480 UTILX_NOTIFICATION_LEVEL_LOW, /**< Low level notification */
481 UTILX_NOTIFICATION_LEVEL_NORMAL, /**< Normal level notification*/
482 UTILX_NOTIFICATION_LEVEL_HIGH /**< High level notification */
483 } Utilx_Notification_Level;
486 * @brief Enumeration for the opaque state.
488 typedef enum _Utilx_Opaque_State
490 UTILX_OPAQUE_STATE_OFF = 0, /**< Transparent state */
491 UTILX_OPAQUE_STATE_ON = 1, /**< Opaque state */
492 } Utilx_Opaque_State;
495 * @brief Sets the priority level for the specified notification window, asynchronously.
497 * @details This function sets the priority level of notification windows.\n
498 * Every notification window has a base priority level by the notification window's priority value (default priority is #UTILX_NOTIFICATION_LEVEL_LOW).
500 * The priority is used for ordering of notification windows.\n
501 * The notification window with the priority set to #UTILX_NOTIFICATION_LEVEL_HIGH will be placed at the top of the notification windows.\n
502 * If there are notification windows which have same priorities, the last created notification window will be placed on the other window.
505 * @remarks This is used only for notification windows.
506 * @param[in] dpy The connection to the X server
507 * @param[in] win The window to set
508 * @param[in] level The level (#UTILX_NOTIFICATION_LEVEL_LOW, #UTILX_NOTIFICATION_LEVEL_NORMAL, #UTILX_NOTIFICATION_LEVEL_HIGH)
509 * @pre The window should be a notification type window.
510 * @see #Utilx_Notification_Level
511 * @see utilx_get_system_notification_level()
522 xwin = elm_win_xwindow_get(win);
524 // Set Notification type
525 ecore_x_netwm_window_type_set (xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
527 // Set Notification's priority
528 utilx_set_system_notification_level (ecore_x_display_get(), xwin, UTILX_NOTIFICATION_LEVEL_HIGH);
533 void utilx_set_system_notification_level (Display* dpy, Window win, Utilx_Notification_Level level);
536 * @brief Gets the priority level for the specified notification window.
538 * @details This function returns the priority level of notification windows.\n
539 * If a user didn't set the notification's priority level, this function returns the default value (#UTILX_NOTIFICATION_LEVEL_LOW).
541 * This function is a synchronous call.
544 * @remarks This is used only for notification windows.
545 * @param[in] dpy The connection to the X server
546 * @param[in] win The window to get
547 * @return The current notification level (#UTILX_NOTIFICATION_LEVEL_LOW, #UTILX_NOTIFICATION_LEVEL_NORMAL, #UTILX_NOTIFICATION_LEVEL_HIGH)
548 * @pre The window should be a notification type window.
549 * @see utilx_set_system_notification_level()
558 Utilx_Notification_Level level;
560 win = elm_win_add (NULL, "test", ELM_WIN_NOTIFICATION);
561 xwin = elm_win_xwindow_get(win);
563 level = utilx_get_system_notification_level (ecore_x_display_get(), xwin);
568 Utilx_Notification_Level utilx_get_system_notification_level (Display* dpy, Window win);
571 * @brief Gets the string list and count of available key-names to grab.
572 * @details This function returns the newly-allocated list and count of available key-names to grab for a target device.
573 * The key-name is unchangeable whatever you develope in different target.
574 * However, key-symbol got by utilx_get_key_symbol() is changeable in different target.
576 * @remarks You should free the pointer of name list by free() to avoid memory-leak
577 * @param[out] count The number of avaiable keys for a target device
578 * @return newly-allocated list of available key strings, otherwise NULL.
579 * @see utilx_get_key_symbol()
586 main (int argc, char* argv[])
592 names = utilx_get_available_key_names (&count);
596 for (i = 0; i < count; i++)
598 const char *symbol = utilx_get_key_symbol (names[i]);
599 printf ("name: %s, symbol: %s\n", names[i], symbol);
610 const char** utilx_get_available_key_names (int *count);
613 * @brief Gets a key-symbol string for a available key-name string to grab.
614 * @details This function returns a key-symbol string for a available key-name to grab for a target device.
615 * The key-name got by utilx_get_available_key_names() is unchangeable whatever you develope in different target.
616 * However, key-symbol is changeable in different target.
618 * @param[in] key_name The name of a key got by utilx_get_available_key_names()
619 * @return key-symbol string if success, otherwise NULL.
620 * @see utilx_get_available_key_names(), utilx_grab_key(), utilx_ungrab_key()
627 main (int argc, char* argv[])
633 names = utilx_get_available_key_names (&count);
637 for (i = 0; i < count; i++)
639 const char *symbol = utilx_get_key_symbol (names[i]);
640 printf ("name: %s, symbol: %s\n", names[i], symbol);
651 const char* utilx_get_key_symbol (const char *key_name);
654 * @brief Grabs the key specfied by @a key_symbol for a window in the @a grab_mode.
656 * @details This function establishes a grab of the specified key for the specified window.\n
657 * Once a key is grabbed, all events originating from the key will only be reported to the specfied window.\n
658 * The grab of the key can be released by calling utilx_ungrab_key().
660 * This function is synchronous.
663 * @remarks If utilx_grab_key() returns @c 0, the specified window will get the events of the specified key.\n
664 * However, delivery of a key can always be changed by other applications grabbing the key with higher priority.\n
665 * It can also be changed by the changes of window stacks.\n
666 * A trial for choosing a proper grab mode will be needed.
667 * @param[in] dpy The connection to the X server
668 * @param[in] win The window to grab a key
669 * @param[in] key_symbol The symbol of a key in the string
670 * @param[in] grab_mode The grab mode (such as #EXCLUSIVE_GRAB, #TOP_POSITION_GRAB, and #SHARED_GRAB)
671 * @return @c 0 on success,
673 * @pre This API must be called after the window 'win' has been mapped.
674 * @post This API adds/changes the window property related to the grabbed key.
675 * @see utilx_ungrab_key(), utilx_get_available_key_names(), utilx_get_key_symbol()
676 * @par Example (using X11 APIs)
678 #include <X11/Xlib.h>
681 static const char* key_symbol;
684 get_key_symbol (void)
689 names = utilx_get_available_key_names (&count);
693 for (i = 0; i < count; i++)
694 if (!strcmp (names[i], "KEY_UP"))
696 key_symbol = utilx_get_key_symbol ("KEY_UP");
697 printf ("found: key(%s,%s)\n", "KEY_UP", key_symbol);
698 free (names); // should free
702 free (names); // should free
708 Display *disp = XOpenDisplay(NULL);
711 Window w = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 5,5, 470, 780, 2, BlackPixel(disp,0), WhitePixel(disp,0));
712 XSelectInput(disp, w, StructureNotifyMask | KeyPressMask | KeyReleaseMask | ExposureMask);
715 if (!get_key_symbol ())
720 XNextEvent(disp, &e);
726 grab_result = utilx_grab_key(disp, w, key_symbol, EXCLUSIVE_GRAB);
727 if( EXCLUSIVE_GRABBED_ALREADY == grab_result )
730 //utilx_grab_key(disp, w, key_symbol, TOP_POSITION_GRAB);
731 //utilx_grab_key(disp, w, key_symbol, SHARED_GRAB);
740 utilx_ungrab_key(disp, w, key_symbol);
745 * @par Example (using EFL APIs)
748 #include <Ecore_Evas.h>
751 static const char* key_symbol;
754 get_key_symbol (void)
759 names = utilx_get_available_key_names (&count);
763 for (i = 0; i < count; i++)
764 if (!strcmp (names[i], "KEY_UP"))
766 key_symbol = utilx_get_key_symbol ("KEY_UP");
767 printf ("found: key(%s,%s)\n", "KEY_UP", key_symbol);
768 free (names); // should free
772 free (names); // should free
780 Ecore_X_Display* disp = ecore_x_display_get();
781 Ecore_X_Window w = ecore_evas_software_x11_window_get(ee);
787 grab_result = utilx_grab_key(disp, w, key_symbol, EXCLUSIVE_GRAB);
788 if( EXCLUSIVE_GRABBED_ALREADY == grab_result )
791 //utilx_grab_key(disp, w, key_symbol, TOP_POSITION_GRAB);
792 //utilx_grab_key(disp, w, key_symbol, SHARED_GRAB);
796 utilx_ungrab_key(disp, w, key_symbol); //Ungrab whenever a user wants to
802 int utilx_grab_key (Display* dpy, Window win, const char* key_symbol, int grab_mode);
805 * @brief Ungrabs the key specfied by @a key_symbol for a window.
807 * @details This function releases the already established grab of the specfied key for the specified window.\n
808 * Once the grab of the key is released, delivery of the key events for the specfied window is going to be stopped.
810 * This function is synchronous.
813 * @param[in] dpy The connection to the X server
814 * @param[in] win The window to grab a key
815 * @param[in] key_symbol The symbol of a key in the string got by utilx_get_key_symbol()
816 * @return @c 0 on success,
818 * @pre This API must be called after the window 'win' is mapped.
819 * @post This API changes/removes the window property related to the grabbed key.
820 * @see utilx_grab_key(), utilx_get_available_key_names(), utilx_get_key_symbol()
821 * @par Example (using X11 APIs)
823 #include <X11/Xlib.h>
826 static const char* key_symbol;
829 get_key_symbol (void)
834 names = utilx_get_available_key_names (&count);
838 for (i = 0; i < count; i++)
839 if (!strcmp (names[i], "KEY_UP"))
841 key_symbol = utilx_get_key_symbol ("KEY_UP");
842 printf ("found: key(%s,%s)\n", "KEY_UP", key_symbol);
843 free (names); // should free
847 free (names); // should free
853 Display *disp = XOpenDisplay(NULL);
856 Window w = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 5,5, 470, 780, 2, BlackPixel(disp,0), WhitePixel(disp,0));
857 XSelectInput(disp, w, StructureNotifyMask | KeyPressMask | KeyReleaseMask | ExposureMask);
860 if (!get_key_symbol ())
865 XNextEvent(disp, &e);
871 grab_result = utilx_grab_key(disp, w, key_symbol, EXCLUSIVE_GRAB);
872 if( EXCLUSIVE_GRABBED_ALREADY == grab_result )
875 //utilx_grab_key(disp, w, key_symbol, TOP_POSITION_GRAB);
876 //utilx_grab_key(disp, w, key_symbol, SHARED_GRAB);
885 utilx_ungrab_key(disp, w, key_symbol);
890 * @par Example (using EFL APIs)
893 #include <Ecore_Evas.h>
896 static const char* key_symbol;
899 get_key_symbol (void)
904 names = utilx_get_available_key_names (&count);
908 for (i = 0; i < count; i++)
909 if (!strcmp (names[i], "KEY_UP"))
911 key_symbol = utilx_get_key_symbol ("KEY_UP");
912 printf ("found: key(%s,%s)\n", "KEY_UP", key_symbol);
913 free (names); // should free
917 free (names); // should free
925 Ecore_X_Display* disp = ecore_x_display_get();
926 Ecore_X_Window w = ecore_evas_software_x11_window_get(ee);
932 grab_result = utilx_grab_key(disp, w, key_symbol, EXCLUSIVE_GRAB);
933 if( EXCLUSIVE_GRABBED_ALREADY == grab_result )
936 //utilx_grab_key(disp, w, key_symbol, TOP_POSITION_GRAB);
937 //utilx_grab_key(disp, w, key_symbol, SHARED_GRAB);
941 utilx_ungrab_key(disp, w, key_symbol); //Ungrab whenever a user wants to
947 int utilx_ungrab_key (Display* dpy, Window win, const char* key_symbol);
950 * @brief Sets the window's opaque state.
952 * @details This function sets the window's visibility to opaque even if the window is an alpha window.
953 * This function is available only for an alpha window.
954 * An alpha window's default opaque state is #UTILX_OPAQUE_STATE_OFF.
956 * This function is an asynchronous call.
959 * @remarks This is used only for alpha windows.
960 * @param[in] dpy The connection to the X server
961 * @param[in] win The window handle
962 * @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)
963 * @return @c 1 on success,
967 #include <X11/Xlib.h>
976 dpy = XOpenDisplay (NULL);
977 root = XDefaultRootWindow (dpy);
979 win = XCreateSimpleWindow (dpy, root, 0, 0, 480, 800, 2, BlackPixel (dpy,0), WhitePixel(dpy,0));
980 XMapWindow (dpy, win);
982 ret = utilx_set_window_opaque_state (dpy, win, UTILX_OPAQUE_STATE_ON);
985 printf ("Error! Failed to set opaque state.\n");
993 int utilx_set_window_opaque_state (Display* dpy, Window win, Utilx_Opaque_State state);
996 * @brief Creates a screenshot image.
998 * @details This function creates a screenshot image of the display.\n
999 * To use this function, you should get the permission first.\n
1000 * In addition, device LCD must be turned on; otherwise, this function fails.\n
1001 * Once this functions is called, utilx_release_screen_shot() should be called after it.
1004 * @privlevel platform
1005 * @privilege %http://tizen.org/privilege/screenshot
1006 * @remarks You should get the permission to use. Device LCD must be on.
1007 * @param[in] dpy The connection to the X server
1008 * @param[in] width The root window handle
1009 * @param[in] height The root window handle
1010 * @see utilx_release_screen_shot()
1017 dpy = XOpenDisplay (NULL);
1018 width = DisplayWidth (dpy, DefaultScreen (dpy));
1019 height = DisplayHeight (dpy, DefaultScreen (dpy));
1021 dump = utilx_create_screen_shot (dpy, width, height);
1024 // do_something (dump);
1028 // utilx_create_screen_shot can return NULL in some cases.
1029 // Even if it returns NULL, utilx_release_screen_shot should be called.
1032 utilx_release_screen_shot ();
1035 void* utilx_create_screen_shot (Display* dpy, int width, int height);
1038 * @brief Releases screenshot resources.
1040 * @details This function releases resources associated with screenshot
1041 * image of the display. utilx_release_screen_shot() should be called once
1042 * utilx_create_screen_shot() is called.
1045 * @privlevel platform
1046 * @privilege %http://tizen.org/privilege/screenshot
1047 * @see utilx_create_screen_shot()
1054 dpy = XOpenDisplay (NULL);
1055 width = DisplayWidth (dpy, DefaultScreen (dpy));
1056 height = DisplayHeight (dpy, DefaultScreen (dpy));
1058 dump = utilx_create_screen_shot (dpy, width, height);
1061 // do_something (dump);
1065 // utilx_create_screen_shot can return NULL in some cases.
1066 // Even if it returns NULL, utilx_release_screen_shot should be called.
1069 utilx_release_screen_shot ();
1072 void utilx_release_screen_shot (void);
1082 #endif /* __TIZEN_LINUX_UTIL_X11_H__ */