4 Copyright (c) 2011 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 __SAMSUNG_LINUX_UTIL_X11_H__
21 #define __SAMSUNG_LINUX_UTIL_X11_H__
24 #define DEPRECATED __attribute__((deprecated))
30 * @defgroup utilX X11 utilities
32 * @brief Samsung Linux platform X11 utilties
34 * Common X11 utilities
35 * You can use this API with #include <utilX.h>
43 #include <sys/types.h>
52 #define KEY_VOLUMEUP "XF86AudioRaiseVolume" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Volume Up' key */
53 #define KEY_VOLUMEDOWN "XF86AudioLowerVolume" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Volume Down' key */
55 #define KEY_CAMERA "XF86WebCam" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Half-Press of Camera' key */
56 #define KEY_CONFIG "XF86Pictures" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Full-Press of Camera' key */
58 #define KEY_POWER "XF86PowerOff" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Power' key */
59 #define KEY_PAUSE "XF86Standby" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Pause' key */
60 #define KEY_CANCEL "Cancel" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Cancel' key */
62 // Earjack/BT Headset/Multimedia keys
63 #define KEY_PLAYCD "XF86AudioPlay" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Play Audio' key */
64 #define KEY_STOPCD "XF86AudioStop" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Stop Audio' key */
65 #define KEY_PAUSECD "XF86AudioPause" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Pause Audio' key */
66 #define KEY_NEXTSONG "XF86AudioNext" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Next Song' key */
67 #define KEY_PREVIOUSSONG "XF86AudioPrev" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Previous Song' key */
68 #define KEY_REWIND "XF86AudioRewind" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Rewind Song' key */
69 #define KEY_FASTFORWARD "XF86AudioForward" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Forward Song' key */
72 #define KEY_SEND "XF86Send" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Send' key */
73 #define KEY_SELECT "XF86Phone" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Home' key */
74 #define KEY_END "XF86Stop" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'End' key */
76 // Renamed 3-Touch key
77 #define KEY_MENU "XF86Send" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Send' key */
78 #define KEY_HOME "XF86Phone" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Home' key */
79 #define KEY_BACK "XF86Stop" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'End' key */
81 #define LEN_KEY_VOLUMEUP 20 /**< this macro is the length of string corresponds to 'Volume Up' key */
82 #define LEN_KEY_VOLUMEDOWN 20 /**< this macro is the length of string corresponds to 'Volume Down' key */
84 #define LEN_KEY_CAMERA 10 /**< this macro is the length of string corresponds to 'Half-Press of Camera' key */
85 #define LEN_KEY_CONFIG 12 /**< this macro is the length of string corresponds to 'Full-Press of Camera' key */
87 #define LEN_KEY_POWER 12 /**< this macro is the length of string corresponds to 'Power' key */
88 #define LEN_KEY_PAUSE 11 /**< this macro is the length of string corresponds to 'Pause' key */
90 // Earjack/BT Headset/Multimedia keys
91 #define LEN_KEY_PLAYCD 13/**< this macro is the length of string corresponds to 'Play Audio' key */
92 #define LEN_KEY_STOPCD 13/**< this macro is the length of string corresponds to 'Stop Audio' key */
93 #define LEN_KEY_PAUSECD 14/**< this macro is the length of string corresponds to 'Pause Audio' key */
94 #define LEN_KEY_NEXTSONG 13/**< this macro is the length of string corresponds to 'Next Song' key */
95 #define LEN_KEY_PREVIOUSSONG 13/**< this macro is the length of string corresponds to 'Previous Song' key */
96 #define LEN_KEY_REWIND 15/**< this macro is the length of string corresponds to 'Rewind Song' key */
97 #define LEN_KEY_FASTFORWARD 16/**< this macro is the length of string corresponds to 'Forwand Song' key */
100 #define LEN_KEY_SEND 8 /**< this macro is the length of string corresponds to 'Send' key */
101 #define LEN_KEY_SELECT 9 /**< this macro is the length of string corresponds to 'Home' key */
102 #define LEN_KEY_END 8 /**< this macro is the length of string corresponds to 'End' key */
104 // Renamed 3-Touch key
105 #define LEN_KEY_MENU 8 /**< this macro is the length of string corresponds to 'Send' key */
106 #define LEN_KEY_HOME 9 /**< this macro is the length of string corresponds to 'Home' key */
107 #define LEN_KEY_BACK 8 /**< this macro is the length of string corresponds to 'End' key */
109 #define OR_EXCLUSIVE_GRAB 0xf00000 /**< this means that the client window will always get the grabbed-key exclusively regardless of the position on the window stack but the grab is overridable by the other client window */
110 #define EXCLUSIVE_GRAB 0x0f0000 /**< this means that the client window will always get the grabbed-key exclusively regardless of the position on the window stack */
111 #define TOP_POSITION_GRAB 0x00f000 /**< this means that the client window will get the grabbed-key only when on the top of the grabbing-window stack */
112 #define SHARED_GRAB 0x000f00 /**< this means that the client window will get the grabbed-key together with the other client window(s) */
113 #define GRAB_MODE_MASK 0xffff00 /**< this mask will be used for getting the key-grab mode of a client window */
115 #define EXCLUSIVE_GRABBED_ALREADY 1 /**< this means that the client window is grabbing the key already in EXCLUSIVE mode */
117 #define STR_ATOM_GRAB_KEY "_GRAB_KEY" /**< this is an XATOM for getting/setting the property for grabbing a key for a window */
118 #define STR_ATOM_GRAB_EXCL_WIN "_GRAB_EXCL_WIN_KEYCODE" /**< this means that the key was grabbed by a client window in EXCLUSIVE mod */
119 #define STR_ATOM_GRAB_OR_EXCL_WIN "_GRAB_OR_EXCL_WIN_KEYCODE" /**< this means that the key was grabbed by a client window in OR_EXCLUSIVE mod */
122 * @brief Enumeration of key status
124 typedef enum _Utilx_Key_Status
126 UTILX_KEY_STATUS_PRESSED, /**< key status is pressed */
127 UTILX_KEY_STATUS_RELEASED, /**< key status is released */
128 UTILX_KEY_STATUS_UNKNOWN /** < key status is unknown or error happened */
132 * @brief Enumeration of notification window's priority level
134 typedef enum _Utilx_Notification_Level
136 UTILX_NOTIFICATION_LEVEL_LOW, /**< low level notification */
137 UTILX_NOTIFICATION_LEVEL_NORMAL, /**< normal level notification*/
138 UTILX_NOTIFICATION_LEVEL_HIGH /**< high level notification */
139 } Utilx_Notification_Level;
142 * @brief Enumeration of Compositing Window Manager's Effect Type
144 typedef enum _Utilx_Effect_Type
146 UTILX_EFFECT_TYPE_MAP, /**< Effect for Window's Map Notify Event */
147 UTILX_EFFECT_TYPE_UNMAP, /**< Effect for Window's UnMap Notify Event */
148 UTILX_EFFECT_TYPE_RAISEABOVE, /**< Effect for Window's Configure Notify ( RaiseAbove case ) Event */
149 UTILX_EFFECT_TYPE_ROTATION, /**< Effect for Window's Rotation Property Change Notify Event ( X Property: ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE ) */
150 UTILX_EFFECT_TYPE_FOCUSIN, /**< Effect for Window's FocusIn Event ( E17's Event: E_EVENT_BORDER_FOCUS_IN ) */
151 UTILX_EFFECT_TYPE_FOCUSOUT /**< Effect for Window's FocusOut Event ( E17's Event : E_EVENT_BORDER_FOCUS_OUT ) */
155 * @brief Enumeration of Compositing Window Manager's Effect Style
157 typedef enum _Utilx_Effect_Style
159 UTILX_EFFECT_STYLE_DEFAULT, /**< Default Effect Style for Effect Type */
160 UTILX_EFFECT_STYLE_NONE, /**< None of Effect Style for Effect Type */
161 UTILX_EFFECT_STYLE_CUSTOM0, /**< Custom0 Effect Style for Effect Type */
162 UTILX_EFFECT_STYLE_CUSTOM1, /**< Custom1 Effect Style for Effect Type */
163 UTILX_EFFECT_STYLE_CUSTOM2, /**< Custom2 Effect Style for Effect Type */
164 UTILX_EFFECT_STYLE_CUSTOM3, /**< Custom3 Effect Style for Effect Type */
165 UTILX_EFFECT_STYLE_CUSTOM4, /**< Custom4 Effect Style for Effect Type */
166 UTILX_EFFECT_STYLE_CUSTOM5, /**< Custom5 Effect Style for Effect Type */
167 UTILX_EFFECT_STYLE_CUSTOM6, /**< Custom6 Effect Style for Effect Type */
168 UTILX_EFFECT_STYLE_CUSTOM7, /**< Custom7 Effect Style for Effect Type */
169 UTILX_EFFECT_STYLE_CUSTOM8, /**< Custom8 Effect Style for Effect Type */
170 UTILX_EFFECT_STYLE_CUSTOM9 /**< Custom9 Effect Style for Effect Type */
171 } Utilx_Effect_Style;
174 * @brief Enumeration of opaque state
176 typedef enum _Utilx_Opaque_State
178 UTILX_OPAQUE_STATE_OFF = 0, /**< Transparent state */
179 UTILX_OPAQUE_STATE_ON = 1, /**< Opaque state */
180 } Utilx_Opaque_State;
184 * @fn void utilx_set_system_notification_level (Display* dpy, Window win, Utilx_Notification_Level level)
185 * @brief Sets the priority level for the specified notification window
187 * This function sets the priority level of the notification windows.\n
188 * Every notification window has a base priority level by the notification window's priority value. (Default priority is UTILX_NOTIFICATION_LEVEL_LOW)
190 * The priority is used for ordering of notification windows.\n
191 * The notification window which is set UTILX_NOTIFICATION_LEVEL_HIGH priority will be placed to the top of notification windows.\n
192 * If there are notification windows that have same priorities, the latest created notification window is placed on the other window.
194 * This function is a asynchronous call.
196 * @param[in] dpy Specifies the connection to the X server
197 * @param[in] win Specifies the window to be set
198 * @param[in] level Specifies the level (UTILX_NOTIFICATION_LEVEL_LOW, UTILX_NOTIFICATION_LEVEL_NORMAL, UTILX_NOTIFICATION_LEVEL_HIGH)
199 * @remark This is used only notification window.
200 * @pre The win should be notification type window
202 * @see utilx_get_system_notification_level
213 xwin = elm_win_xwindow_get(win);
215 // Set Notification type
216 ecore_x_netwm_window_type_set (xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
218 // Set Notification's priority
219 utilx_set_system_notification_level (ecore_x_display_get(), xwin, UTILX_NOTIFICATION_LEVEL_HIGH);
224 void utilx_set_system_notification_level (Display* dpy, Window win, Utilx_Notification_Level level);
227 * @fn Utilx_Notification_Level utilx_get_system_notification_level (Display* dpy, Window win)
228 * @brief Gets the priority level for the specified notification window
230 * This function returns the priority level of the notification windows.\n
231 * If a user didn't set the notification's priority level, this function returns default value (UTILX_NOTIFICATION_LEVEL_LOW).
233 * This function is a synchronous call.
235 * @param[in] dpy Specifies the connection to the X server
236 * @param[in] win Specifies the window to be get
237 * @return current notication level (UTILX_NOTIFICATION_LEVEL_LOW, UTILX_NOTIFICATION_LEVEL_NORMAL, UTILX_NOTIFICATION_LEVEL_HIGH)
238 * @remark This is used only notification window.
239 * @pre The win should be notification type window
241 * @see utilx_set_system_notification_level
250 Utilx_Notification_Level level;
252 win = elm_win_add (NULL, "test", ELM_WIN_NOTIFICATION);
253 xwin = elm_win_xwindow_get(win);
255 level = utilx_get_system_notification_level (ecore_x_display_get(), xwin);
260 Utilx_Notification_Level utilx_get_system_notification_level (Display* dpy, Window win);
263 * @fn void utilx_enable_indicator (Display* dpy, Window win, int enable)
264 * @brief Sets the window to show/hide the indicator
266 * This function enables or disables the indicator.
268 * If an application wants to show the window with the indicator, the application must call this function with 1 as the enable parameter.\n
269 * Otherwise, the application must call this function with 0 as the enable parameter.
271 * This function is a asynchronous call.
273 * @param[in] dpy Specifies the connection to the X server
274 * @param[in] win Specifies the window to use indicator
275 * @param[in] enable Specifies whether the window use indicator or not
278 * @post If the enable is 1, then the indicator window should be shown on the screen. Otherwise, the indicator window should be hidden from the screen.
279 * @see elm_win_indicator_state_set, utilx_get_indicator_state
282 #include <X11/Xlib.h>
290 dpy = XOpenDisplay (NULL);
291 root = XDefaultRootWindow (dpy);
293 win = XCreateSimpleWindow (dpy, root, 0, 0, 480, 800, 2, BlackPixel (dpy,0), WhitePixel(dpy,0));
294 XMapWindow (dpy, win);
296 // If the win want to show indicator, enables indicator.
297 utilx_enable_indicator (dpy, win, 1);
300 // If the win want to hide indicator, disables indicator.
301 utilx_enable_indicator (dpy, win, 0);
307 void utilx_enable_indicator (Display* dpy, Window win, int enable);
310 * @fn int utilx_get_indicator_state (Display* dpy, Window win)
311 * @brief Gets the indicator's state of the specified window
313 * This function gets the indicator's state of the specified window.
315 * An application can set the indicator's state using utilx_enable_indicator or elm_win_indicator_state_set.
316 * If an application sets enables the indicator, this returns 1.\n
317 * If an application disables the indicator, this returns 0.\n
318 * If an application doesn't set the indicator's state, in other words,
319 * an application doesn't call utilx_enable_indicator or elm_win_indicator_state_set,
322 * This function is a asynchronous call.
324 * @param[in] dpy Specifies the connection to the X server
325 * @param[in] win Specifies the window to get the indicator's state
326 * @return 1 if the indicator is enabled, 0 if the indicator is disabled, otherwise -1
330 * @see elm_win_indicator_state_set, utilx_enable_indicator
333 #include <X11/Xlib.h>
342 dpy = XOpenDisplay (NULL);
343 root = XDefaultRootWindow (dpy);
345 win = XCreateSimpleWindow (dpy, root, 0, 0, 480, 800, 2, BlackPixel (dpy,0), WhitePixel(dpy,0));
346 XMapWindow (dpy, win);
348 state = utilx_get_indicator_state (dpy, win)
349 // state is -1 (unknown)
351 // If the win want to show indicator, enables indicator.
352 utilx_enable_indicator (dpy, win, 1);
355 state = utilx_get_indicator_state (dpy, win)
356 // state is 1 (enabled)
358 // If the win want to hide indicator, disables indicator.
359 utilx_enable_indicator (dpy, win, 0);
362 state = utilx_get_indicator_state (dpy, win)
363 // state is 0 (disabled)
368 int utilx_get_indicator_state (Display* dpy, Window win);
372 * @fn int utilx_grab_key (Display* dpy, Window win, const char* key_name, int grab_mode)
373 * @brief Grabs a key specfied by key_name for win in grab_mode
375 * This function establishs a grab of the specified key for the specified window.\n
376 * Once a key was grabbed, all events originated from the key will only be reported to the specfied window.\n
377 * The grab of the key will be released by calling utilx_ungrab_key.
379 * This function is synchronous.
381 * @param[in] dpy Specifies the connection to the X server
382 * @param[in] win Specifies the window to grab a key
383 * @param[in] key_name Name of a key in string (ex> KEY_VOLUMEUP, KEY_VOLUMEDOWN, KEY_SEND and so on)
384 * @param[in] grab_mode Grab mode (such as EXCLUSIVE_GRAB, TOP_POSITION_GRAB and SHARED_GRAB)
385 * @return 0 on Success, otherwise Fail
386 * @remark If utilx_grab_key() returns 0, the specified window will get the events of the specified key.\n
387 However, delivery of a key can always be changed by other applications grabbing the key with higher priority.\n
388 It can also be changed by the changes of window stacks.\n
389 Trial for choosing a proper grab mode will be needed.
390 * @pre This API must be called after the window 'win' has been mapped
391 * @post This API adds/changes the window property related to grabbed key
392 * @see utilx_ungrab_key
393 * @par Example (using X11 APIs)
398 #include <X11/Xlib.h>
403 Display *disp = XOpenDisplay(NULL);
406 Window w = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 5,5, 470, 780, 2, BlackPixel(d,0), WhitePixel(d,0));
407 XSelectInput(disp, w, StructureNotifyMask | KeyPressMask | KeyReleaseMask);
412 XNextEvent(disp, &e);
416 grab_result = utilx_grab_key(disp, w, KEY_POWER, EXCLUSIVE_GRAB);
417 if( EXCLUSIVE_GRABBED_ALREADY == grab_result )
425 utilx_ungrab_key(disp, win, KEY_POWER);
429 // TOP_POSITION_GRAB //
431 #include <X11/Xlib.h>
436 Display *disp = XOpenDisplay(NULL);
438 Window w = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 5,5, 470, 780, 2, BlackPixel(d,0), WhitePixel(d,0));
439 XSelectInput(disp, w, StructureNotifyMask | KeyPressMask | KeyReleaseMask);
444 XNextEvent(disp, &e);
448 utilx_grab_key(disp, w, KEY_POWER, TOP_POSITION_GRAB);
455 utilx_ungrab_key(disp, win, KEY_POWER);
461 #include <X11/Xlib.h>
466 Display *disp = XOpenDisplay(NULL);
468 Window w = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 5,5, 470, 780, 2, BlackPixel(d,0), WhitePixel(d,0));
469 XSelectInput(disp, w, StructureNotifyMask | KeyPressMask | KeyReleaseMask);
474 XNextEvent(disp, &e);
478 utilx_grab_key(disp, w, KEY_POWER, SHARED_GRAB);
485 utilx_ungrab_key(disp, win, KEY_POWER);
490 * @par Example (using EFL APIs)
496 #include <Ecore_Evas.h>
503 Ecore_X_Display* disp = ecore_x_display_get();
504 Ecore_X_Window win = ecore_evas_software_x11_window_get(ee);
506 int grab_result = utilx_grab_key(disp, win, KEY_POWER, EXCLUSIVE_GRAB);
507 if( EXCLUSIVE_GRABBED_ALREADY == grab_result )
512 utilx_ungrab_key(disp, win, KEY_POWER);//Ungrab whenever you want to ¡¦
516 // TOP_POSITION_GRAB //
519 #include <Ecore_Evas.h>
526 Ecore_X_Display* disp = ecore_x_display_get();
527 Ecore_X_Window win = ecore_evas_software_x11_window_get(ee);
529 utilx_grab_key(disp, win, KEY_POWER, TOP_POSITION_GRAB);
533 utilx_ungrab_key(disp, win, KEY_POWER);//Ungrab whenever you want to ¡¦
540 #include <Ecore_Evas.h>
547 Ecore_X_Display* disp = ecore_x_display_get();
548 Ecore_X_Window win = ecore_evas_software_x11_window_get(ee);
550 utilx_grab_key(disp, win, KEY_POWER, SHARED_GRAB);
554 utilx_ungrab_key(disp, win, KEY_POWER);//Ungrab whenever you want to ¡¦
559 int utilx_grab_key (Display* dpy, Window win, const char* key_name, int grab_mode);
562 * @fn int utilx_ungrab_key (Display* dpy, Window win, const char* key_name)
563 * @brief Ungrabs a key specfied by key_name for win
565 * This function releases the already established grab of the specfied key for the specified window.\n
566 * Once the grab of the key was released, delivery of the key events for the specfied window is going to be stopped.
568 * This function is synchronous.
570 * @param[in] dpy Specifies the connection to the X server
571 * @param[in] win Specifies the window to grab a key
572 * @param[in] key_name Name of a key in string (ex> KEY_VOLUMEUP, KEY_VOLUMEDOWN, KEY_SEND and so on)
573 * @return 0 on Success, otherwise Fail
574 * @remark No additional information
575 * @pre This API must be called after the window 'win' has been mapped
576 * @post This API changes/removes the window property related to grabbed key
577 * @see utilx_grab_key
578 * @par Example (using X11 APIs)
583 #include <X11/Xlib.h>
588 Display *disp = XOpenDisplay(NULL);
591 Window w = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 5,5, 470, 780, 2, BlackPixel(d,0), WhitePixel(d,0));
592 XSelectInput(disp, w, StructureNotifyMask | KeyPressMask | KeyReleaseMask);
597 XNextEvent(disp, &e);
601 grab_result = utilx_grab_key(disp, w, KEY_POWER, EXCLUSIVE_GRAB);
602 if( EXCLUSIVE_GRABBED_ALREADY == grab_result )
610 utilx_ungrab_key(disp, win, KEY_POWER);
614 // TOP_POSITION_GRAB //
616 #include <X11/Xlib.h>
621 Display *disp = XOpenDisplay(NULL);
623 Window w = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 5,5, 470, 780, 2, BlackPixel(d,0), WhitePixel(d,0));
624 XSelectInput(disp, w, StructureNotifyMask | KeyPressMask | KeyReleaseMask);
629 XNextEvent(disp, &e);
633 utilx_grab_key(disp, w, KEY_POWER, TOP_POSITION_GRAB);
640 utilx_ungrab_key(disp, win, KEY_POWER);
646 #include <X11/Xlib.h>
651 Display *disp = XOpenDisplay(NULL);
653 Window w = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 5,5, 470, 780, 2, BlackPixel(d,0), WhitePixel(d,0));
654 XSelectInput(disp, w, StructureNotifyMask | KeyPressMask | KeyReleaseMask);
659 XNextEvent(disp, &e);
663 utilx_grab_key(disp, w, KEY_POWER, SHARED_GRAB);
670 utilx_ungrab_key(disp, win, KEY_POWER);
675 * @par Example (using EFL APIs)
681 #include <Ecore_Evas.h>
688 Ecore_X_Display* disp = ecore_x_display_get();
689 Ecore_X_Window win = ecore_evas_software_x11_window_get(ee);
691 int grab_result = utilx_grab_key(disp, win, KEY_POWER, EXCLUSIVE_GRAB);
692 if( EXCLUSIVE_GRABBED_ALREADY == grab_result )
696 utilx_ungrab_key(disp, win, KEY_POWER);//Ungrab whenever you want to ¡¦
700 // TOP_POSITION_GRAB //
703 #include <Ecore_Evas.h>
710 Ecore_X_Display* disp = ecore_x_display_get();
711 Ecore_X_Window win = ecore_evas_software_x11_window_get(ee);
713 utilx_grab_key(disp, win, KEY_POWER, TOP_POSITION_GRAB);
717 utilx_ungrab_key(disp, win, KEY_POWER);//Ungrab whenever you want to ¡¦
725 #include <Ecore_Evas.h>
732 Ecore_X_Display* disp = ecore_x_display_get();
733 Ecore_X_Window win = ecore_evas_software_x11_window_get(ee);
735 utilx_grab_key(disp, win, KEY_POWER, SHARED_GRAB);
739 utilx_ungrab_key(disp, win, KEY_POWER);//Ungrab whenever you want to ¡¦
744 int utilx_ungrab_key (Display* dpy, Window win, const char* key_name);
747 * @fn int utilx_get_key_status(Display* dpy, char *key_name)
748 * @brief Gets a status of a key specified by key_name
750 * This function gets a status of a key.\n
751 * ex>UTILX_KEY_STATUS_PRESSED, UTILX_KEY_STATUS_RELEASED and UTILX_KEY_STATUS_UNKNOWN
753 * This function is synchronous.
755 * @param[in] dpy Specifies the connection to the X server
756 * @param[in] key_name Name of a key in string (ex> KEY_VOLUMEUP, KEY_VOLUMEDOWN, KEY_SEND and so on)
757 * @return 0 on Success, otherwise Fail
758 * @remark No additional information
759 * @pre This API must be called for H/W keys specified in this header file(utilX.h).
760 * @par Example (using X11 APIs)
763 #include <X11/Xlib.h>
768 Display *disp = XOpenDisplay(NULL);
769 Utilx_Key_Status status;
771 status = utilx_get_key_status(disp, KEY_PLAYCD);
775 case UTILX_KEY_STATUS_PRESSED:
776 //The key is pressed.
779 case UTILX_KEY_STATUS_RELEASED:
780 //The key is released.
783 case UTILX_KEY_STATUS_UNKNOWN:
785 //The key status is unknown;
793 * @par Example (using EFL APIs)
797 #include <Ecore_Evas.h>
804 Ecore_X_Display* disp = ecore_x_display_get();
805 Utilx_Key_Status status;
807 status = utilx_get_key_status(disp, KEY_PLAYCD);
811 case UTILX_KEY_STATUS_PRESSED:
812 //The key is pressed.
815 case UTILX_KEY_STATUS_RELEASED:
816 //The key is released.
819 case UTILX_KEY_STATUS_UNKNOWN:
821 //The key status is unknown;
828 Utilx_Key_Status utilx_get_key_status(Display* dpy, char *key_name);
830 /* Window Effect APIs */
832 * @fn void utilx_set_window_effect_state(Display* dpy, Window win, int state)
833 * @brief Sets a window's effect state ( enable or disable )
835 * This function sets window's effect state. if effect is not enabled by composite manager, \n
836 * window's effect could not be enabled.
838 * This function is a asynchronous call.
840 * @param[in] dpy Specifies the connection to the X server
841 * @param[in] win Specifies the window handle
842 * @param[in] state Enables/disables the window effect
843 * @remark This is used only client window. ( not root window )
844 * @pre This api must be called before fist show ( XMapWindow Event ).
845 * @post This changes Client Window's Effect related property.
846 * @see utilx_get_window_effect_state
849 #include <X11/Xlib.h>
856 dpy = XOpenDisplay (NULL);
857 root = XDefaultRootWindow (dpy);
859 win = XCreateSimpleWindow (dpy, root, 0, 0, 480, 800, 2, BlackPixel (dpy,0), WhitePixel(dpy,0));
861 // Sets a window's effect state to enable ( enable : 1, disable 0 )
862 utilx_set_window_effect_state(dpy, win, 1);
864 XMapWindow (dpy, win);
868 void utilx_set_window_effect_state(Display* dpy, Window win, int state);
871 * @fn int utilx_get_window_effect_state(Display* dpy, Window win)
872 * @brief Gets a window's effect state ( enable or disable )
874 * This function returns windows's effect state.\n
875 * If effect is not enabled by composite manager, then this return value is unusable or meanless.
877 * This function is a asynchronous call.
879 * @param[in] dpy Specifies the connection to the X server
880 * @param[in] win Specifies the window handle
881 * @return Current window effect state
882 * @remark This is used only client window. ( not root window )
883 * @pre This api does not require any pre-condition.
884 * @post This api does not change any condition.
885 * @see utilx_set_window_effect_state
888 #include <X11/Xlib.h>
895 dpy = XOpenDisplay (NULL);
896 root = XDefaultRootWindow (dpy);
898 win = XCreateSimpleWindow (dpy, root, 0, 0, 480, 800, 2, BlackPixel (dpy,0), WhitePixel(dpy,0));
900 XMapWindow (dpy, win);
902 // Gets a window's effect state ( enable : 1, disable 0 )
903 printf( "current window's effect state = %d\n", utilx_get_window_effect_state(dpy, win) ) ;
907 int utilx_get_window_effect_state(Display* dpy, Window win);
910 * @fn void utilx_show_fake_effect(Display* dpy, Window win, char *fake_image_file)
911 * @brief Shows a window's "fake show effect" animation
913 * This function show's application fake show image.\n
914 * This function is only used by application launching program.
916 * This function is a asynchronous call.
918 * @param[in] dpy Specifies the connection to the X server
919 * @param[in] win Specifies the root window handle
920 * @param[in] fake_image_file Specifies the fake window image and file format is png type.
921 * @remark This is used only menu-screen window.
922 * @pre This api must be called before client's fist show ( XMapWindow Event ). you must call this api then run application.
923 * @post This changes root window's fake effect related property.
924 * @see utilx_hide_fake_effect
927 #include <X11/Xlib.h>
934 dpy = XOpenDisplay (NULL);
935 root = XDefaultRootWindow (dpy);
937 // Shows a window's "fake show effect" animation, and if you want to see animation, /root/fake_window_image.png file must be exited.
938 utilx_show_fake_effect( dpy, root, "/root/fake_window_image.png");
942 void utilx_show_fake_effect(Display *dpy, Window win, char *fake_image_file);
945 * @fn void utilx_hide_fake_effect(Display* dpy, Window win)
946 * @brief Shows a window's "fake hide effect" animation, and this animation uses "fake show effect" 's window image.
948 * This function shoes a window's fake hide effect.\n
949 * This function is only used by application launching program.\n
950 * When application was not executed by any error.
952 * This function is a asynchronous call.
954 * @param[in] dpy Specifies the connection to the X server
955 * @param[in] win Specifies the root window handle
956 * @remark This is used only menu-screen window.
957 * @pre This api must be called after "utilx_show_fake_effect()".
958 * @post This changes root window's fake effect related property.
959 * @see utilx_show_fake_effect
962 #include <X11/Xlib.h>
969 dpy = XOpenDisplay (NULL);
970 root = XDefaultRootWindow (dpy);
972 // Shows a window's "fake hide effect" animation. and if you wnat to see animation, utilx_show_fake_effect() function must be excuted before utilx_show_fake_effect()
973 // and if real window is showed , then fake hide effect could not be showed.
974 utilx_hide_fake_effect( dpy, root );
978 void utilx_hide_fake_effect(Display *dpy, Window win);
981 * @fn void utilx_set_window_effect_style(Display* dpy, Window win, Utilx_Effect_Type type, Utilx_Effect_Style style)
982 * @brief Sets a window's effect style with effect type.
984 * This function sets a window's effect style with effect type.\n
985 * Default Window Effect is setted by Window Type and Window Class.\n
986 * And then, you could change custom effecct.\n
987 * Custom Effect is available max 10. ( CUSTOM0 ~ CUSTOM9 )\n
988 * If you didn't set custom effect, then compositing window manger provides Default Window Effect.\n
990 * This function is a asynchronous call.
992 * @param[in] dpy Specifies the connection to the X server
993 * @param[in] win Specifies the window handle
994 * @param[in] type Specifies the window's effect type ( ex. UTILX_EFFECT_TYPE_MAP, UTILX_EFFECT_TYPE_UNMAP, etc )
995 * @param[in] style Specifies the window's effect style ( ex. UTILX_EFFECT_STYLE_DEFAULT, UTILX_EFFECT_STYLE_NONE, UTILX_EFFECT_STYLE_CUSTOM0, etc )
996 * @remark This is used only client window. ( not root window )
997 * @pre This api does not require any pre-condition.
998 * @post This changes window's effect type related property ( _NET_CM_WINDOW_EFFECT_TYPE ).
999 * @see utilx_get_window_effect_style
1002 #include <X11/Xlib.h>
1003 #include <X11/Xutil.h>
1009 unsigned long black, white;
1011 dpy = XOpenDisplay(NULL) ;
1013 black = BlackPixel(dpy, 0);
1014 white = WhitePixel(dpy, 0);
1016 root = XDefaultRootWindow (dpy);
1017 win = XCreateSimpleWindow ( dpy, root, 0, 0, 100, 100, 2, BlackPixel (d,0), WhitePixel(d,0) );
1019 utilx_set_window_effect_style(dpy, win, UTILX_EFFECT_TYPE_MAP, UTILX_EFFECT_STYLE_CUSTOM0); // window's show effet type change to UTILX_EFFECT_STYLE_CUSTOM0
1021 XMapWindow(dpy, win);
1025 utilx_set_window_effect_style(dpy, win, UTILX_EFFECT_TYPE_UNMAP, UTILX_EFFECT_STYLE_CUSTOM0); // window's hide effet type change to UTILX_EFFECT_STYLE_CUSTOM0
1027 XUnmapWindow (dpy, win);
1029 utilx_set_window_effect_style(dpy, win, UTILX_EFFECT_TYPE_MAP, UTILX_EFFECT_STYLE_DEFAULT); // window's show effet type change to UTILX_EFFECT_STYLE_DEFAULT
1030 XMapWindow (dpy, win);
1034 utilx_set_window_effect_style(dpy, win, UTILX_EFFECT_TYPE_UNMAP, UTILX_EFFECT_STYLE_DEFAULT); // window's hide effet type change to UTILX_EFFECT_STYLE_DEFAULT
1035 XUnmapWindow (dpy, win);
1039 utilx_set_window_effect_style(dpy, win, UTILX_EFFECT_TYPE_MAP, UTILX_EFFECT_STYLE_NONE); // window's show effet type change to UTILX_EFFECT_STYLE_NONE
1040 XMapWindow (dpy, win);
1044 utilx_set_window_effect_style(dpy, win, UTILX_EFFECT_TYPE_UNMAP, UTILX_EFFECT_STYLE_NONE); // window's hide effet type change to UTILX_EFFECT_STYLE_NONE
1045 XUnmapWindow (dpy, win);
1050 void utilx_set_window_effect_style(Display* dpy, Window win, Utilx_Effect_Type type, Utilx_Effect_Style style);
1053 * @fn Utilx_Effect_Style utilx_get_window_effect_style(Display* dpy, Window win, Utilx_Effect_Type type)
1054 * @brief Gets a window's effect style with effect type.
1056 * This function gets a window's effect style with effect type.\n
1058 * This function is a asynchronous call.
1060 * @param[in] dpy Specifies the connection to the X server
1061 * @param[in] win Specifies the window handle
1062 * @param[in] type Specifies the window's effect type ( ex. UTILX_EFFECT_TYPE_MAP, UTILX_EFFECT_TYPE_UNMAP, etc )
1063 * @return Current window's effect style ( ex. UTILX_EFFECT_STYLE_DEFAULT, UTILX_EFFECT_STYLE_NONE, UTILX_EFFECT_STYLE_CUSTOM0, etc )
1064 * @remark This is used only client window. ( not root window )
1065 * @pre This api does not require any pre-condition.
1066 * @post This api does not change any condition.
1067 * @see utilx_set_window_effect_style
1070 #include <X11/Xlib.h>
1071 #include <X11/Xutil.h>
1077 unsigned long black, white;
1078 Utilx_Effect_Style style;
1080 dpy = XOpenDisplay(NULL) ;
1082 black = BlackPixel(dpy, 0);
1083 white = WhitePixel(dpy, 0);
1085 root = XDefaultRootWindow (dpy);
1086 win = XCreateSimpleWindow ( dpy, root, 0, 0, 100, 100, 2, BlackPixel (d,0), WhitePixel(d,0) );
1088 style = utilx_set_window_effect_style(dpy, win, UTILX_EFFECT_TYPE_MAP); // get effect style with window's show effet type
1092 style = utilx_set_window_effect_style(dpy, win, UTILX_EFFECT_TYPE_UNMAP); // get effect style with window's show effet type
1097 Utilx_Effect_Style utilx_get_window_effect_style(Display* dpy, Window win, Utilx_Effect_Type type);
1100 * @fn void utilx_set_window_opaque_state (Display* dpy, Window win, int opaque)
1101 * @brief Sets the window's opaque state
1103 * This function sets window's visibility to opaque even if the window is an alpha window.
1104 * This function is available only alpha window.
1105 * An alpha window's default opaque state is UTILX_OPAQUE_STATE_OFF.
1107 * This function is a asynchronous call.
1109 * @param[in] dpy Specifies the connection to the X server
1110 * @param[in] win Specifies the window handle
1111 * @param[in] state Specifies whether the window set a visible state to opaque(UTILX_OPAQUE_STATE_ON) or not(UTILX_OPAQUE_STATE_OFF)
1112 * @return 1 on Success, otherwise Fail
1113 * @remark This is used only alpha window.
1119 #include <X11/Xlib.h>
1128 dpy = XOpenDisplay (NULL);
1129 root = XDefaultRootWindow (dpy);
1131 win = XCreateSimpleWindow (dpy, root, 0, 0, 480, 800, 2, BlackPixel (dpy,0), WhitePixel(dpy,0));
1132 XMapWindow (dpy, win);
1134 ret = utilx_set_window_opaque_state (dpy, win, UTILX_OPAQUE_STATE_ON);
1137 printf ("Error! Failed to set opaque state.\n");
1145 int utilx_set_window_opaque_state (Display* dpy, Window win, Utilx_Opaque_State state);
1148 * @fn int utilx_set_screen_capture(Display* dpy, int enable)
1149 * @brief Specifies whether the screen capture functionality is enable or not.
1151 * This function makes the screen capture functionality of CBHM enable or disable.
1152 * CBHM = Clipboard History Manager.
1154 * This function is synchronous.
1156 * @param[in] dpy Specifies the connection to the X server
1157 * @param[in] enable Specifies the window handle. (1:Enable, 0:Disable)
1158 * @pre This api does not require any pre-condition.
1159 * @post This api does not change any condition.
1160 * @see utilx_get_screen_capture
1163 #include <X11/Xlib.h>
1164 #include <X11/Xutil.h>
1170 dpy = XOpenDisplay(NULL) ;
1172 utilx_set_screen_capture (dpy, 1);
1177 int utilx_set_screen_capture(Display* dpy, int enable);
1180 * @fn int utilx_get_screen_capture(Display* dpy, int enable)
1181 * @brief Gets whether the screen capture functionality is enable or not.
1183 * This function gets whether the screen capture functionality of CBHM is enable or not.
1184 * CBHM = Clipboard History Manager.
1186 * This function is synchronous.
1188 * @param[in] dpy Specifies the connection to the X server
1189 * @pre This api does not require any pre-condition.
1190 * @post This api does not change any condition.
1191 * @see utilx_set_screen_capture
1194 #include <X11/Xlib.h>
1195 #include <X11/Xutil.h>
1202 dpy = XOpenDisplay(NULL) ;
1204 enable = utilx_set_screen_capture (dpy);
1209 int utilx_get_screen_capture(Display* dpy);
1212 * @fn void utilx_set_window_cardinal_property(Display* dpy, Window win, Atom atom, unsigned int *value)
1213 * @brief Sets the cardinal property to Window
1215 * This function Sets the cardinal property to Window.
1217 * This function is synchronous.
1219 * @param[in] dpy Specifies the connection to the X server
1220 * @param[in] win Specifies the window handle
1221 * @param[in] atom Specifies the atom of cardinal property
1222 * @param[in] value the value of cardinal property to set.
1223 * @pre This api does not require any pre-condition.
1224 * @post This api does not change any condition.
1225 * @see utilx_get_window_cardinal_property
1228 #include <X11/Xlib.h>
1229 #include <X11/Xutil.h>
1238 dpy = XOpenDisplay (NULL);
1239 root = XDefaultRootWindow (dpy);
1241 atom = XInternAtom(dpy, "TEST_ATOM", False);
1243 utilx_set_window_cardinal_property (dpy, root, atom, (unsigned int*)&value);
1248 void utilx_set_window_cardinal_property(Display* dpy, Window win, Atom atom, unsigned int *value);
1251 * @fn int utilx_get_window_cardinal_property(Display* dpy, Window win, Atom atom, unsigned int *value)
1252 * @brief Gets the value of cardinal property.
1254 * This function gets the value of cardinal property.
1256 * This function is synchronous.
1258 * @param[in] dpy Specifies the connection to the X server
1259 * @param[in] win Specifies the window handle
1260 * @param[in] atom Specifies the atom of cardinal property
1261 * @param[out] value the value of cardinal property to get.
1262 * @pre This api does not require any pre-condition.
1263 * @post This api does not change any condition.
1264 * @see utilx_set_window_cardinal_property
1267 #include <X11/Xlib.h>
1268 #include <X11/Xutil.h>
1277 dpy = XOpenDisplay (NULL);
1278 root = XDefaultRootWindow (dpy);
1280 atom = XInternAtom(dpy, "TEST_ATOM", False);
1282 if (utilx_set_window_cardinal_property (dpy, root, atom, (unsigned int*)&value) > 0)
1290 int utilx_get_window_cardinal_property(Display* dpy, Window win, Atom atom, unsigned int *value);
1293 * @fn void utilx_show_capture_effect(Display *dpy, Window win )
1294 * @brief Shows a capture effect animation
1296 * This function show capture effect animation.\n
1297 * This function is only used by Screen Capture Application.
1299 * This function is a asynchronous call.
1301 * @param[in] dpy Specifies the connection to the X server
1302 * @param[in] win Specifies the root window handle
1303 * @remark This is used only screen capture application.
1304 * @pre This api does not require any pre-condition.
1305 * @post This api does not change any condition.
1306 * @see utilx_set_screen_capture
1309 #include <X11/Xlib.h>
1316 dpy = XOpenDisplay (NULL);
1317 root = XDefaultRootWindow (dpy);
1319 // Shows a Shows a capture effect animation
1320 utilx_show_capture_effect( dpy, root);
1324 void utilx_show_capture_effect(Display *dpy, Window win );
1335 #endif /* __SAMSUNG_LINUX_UTIL_X11_H__ */