/**
* @internal
+ * @deprecated Deprecated since 2.4. Use "XF86AudioRaiseVolume" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Volume Up' key.
*/
#define KEY_VOLUMEUP "XF86AudioRaiseVolume"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86AudioLowerVolume" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Volume Down' key.
*/
#define KEY_VOLUMEDOWN "XF86AudioLowerVolume"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86Camera" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Half-Press of Camera' key.
*/
-#define KEY_CAMERA "XF86WebCam"
+#define KEY_CAMERA "XF86Camera"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86Camera_Full" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Full-Press of Camera' key.
*/
-#define KEY_CONFIG "XF86Pictures"
+#define KEY_CONFIG "XF86Camera_Full"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86PowerOff" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Power' key.
*/
#define KEY_POWER "XF86PowerOff"
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Pause' key.
*/
#define KEY_PAUSE "XF86Standby"
/**
+ * @deprecated Deprecated since 2.4. Use "Cancel" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Cancel' key.
*/
#define KEY_CANCEL "Cancel"
-// Earjack/BT Headset/Multimedia keys
+/* Earjack/BT Headset/Multimedia keys */
/**
+ * @deprecated Deprecated since 2.4. Use "XF86AudioPlay" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Play Audio' key.
*/
#define KEY_PLAYCD "XF86AudioPlay"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86AudioStop" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Stop Audio' key.
*/
#define KEY_STOPCD "XF86AudioStop"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86AudioPause" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Pause Audio' key.
*/
#define KEY_PAUSECD "XF86AudioPause"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86AudioNext" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Next Song' key.
*/
#define KEY_NEXTSONG "XF86AudioNext"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86AudioPrev" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Previous Song' key.
*/
#define KEY_PREVIOUSSONG "XF86AudioPrev"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86AudioRewind" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Rewind Song' key.
*/
#define KEY_REWIND "XF86AudioRewind"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86AudioForward" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Forward Song' key.
*/
#define KEY_FASTFORWARD "XF86AudioForward"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86AudioMedia" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Media' key.
*/
#define KEY_MEDIA "XF86AudioMedia"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86AudioPlayPause" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'PlayPause' key.
*/
#define KEY_PLAYPAUSE "XF86AudioPlayPause"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86AudioMute" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Mute' key.
*/
#define KEY_MUTE "XF86AudioMute"
-// 3-Touch key
+/* 3-Touch key */
/**
+ * @deprecated Deprecated since 2.4. Use "XF86Menu" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Send' key.
*/
-#define KEY_SEND "XF86Send"
+#define KEY_SEND "XF86Menu"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86Home" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Home' key.
*/
-#define KEY_SELECT "XF86Phone"
+#define KEY_SELECT "XF86Home"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86Back" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'End' key.
*/
-#define KEY_END "XF86Stop"
+#define KEY_END "XF86Back"
-// Renamed 3-Touch key
+/* Renamed 3-Touch key */
/**
+ * @deprecated Deprecated since 2.4. Use "XF86Menu" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Send' key.
*/
-#define KEY_MENU "XF86Send"
+#define KEY_MENU "XF86Menu"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86Home" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Home' key.
*/
-#define KEY_HOME "XF86Phone"
+#define KEY_HOME "XF86Home"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86Back" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'End' key.
*/
-#define KEY_BACK "XF86Stop"
+#define KEY_BACK "XF86Back"
-//Other functions keys
+/* Other functions keys */
/**
+ * @deprecated Deprecated since 2.4. Use "XF86HomePage" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'HomePage' key.
*/
#define KEY_HOMEPAGE "XF86HomePage"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86WWW" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'WWW' key.
*/
#define KEY_WEBPAGE "XF86WWW"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86Mail" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Mail' key.
*/
#define KEY_MAIL "XF86Mail"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86ScreenSaver" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'ScreenSaver' key.
*/
#define KEY_SCREENSAVER "XF86ScreenSaver"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86MonBrightnessUp" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'BrightnessUp' key.
*/
#define KEY_BRIGHTNESSUP "XF86MonBrightnessUp"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86MonBrightnessDown" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'BrightnessDown' key.
*/
#define KEY_BRIGHTNESSDOWN "XF86MonBrightnessDown"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86SoftKBD" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Soft keyboard(toggle)' key.
*/
-#define KEY_SOFTKBD "XF86MenuKB"
+#define KEY_SOFTKBD "XF86SoftKBD"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86QuickPanel" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Quick panel(toggle)' key.
*/
-#define KEY_QUICKPANEL "XF86Tools"
+#define KEY_QUICKPANEL "XF86QuickPanel"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86TaskPane" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Task switcher(toggle)' key.
*/
#define KEY_TASKSWITCH "XF86TaskPane"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86Apps" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Apptray(toggle)' key.
*/
-#define KEY_APPS "XF86Launch0"
+#define KEY_APPS "XF86Apps"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86Search" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Search(toggle)' key.
*/
#define KEY_SEARCH "XF86Search"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86Voice" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Voice(toggle)' key.
*/
-#define KEY_VOICE "XF86Launch2"
+#define KEY_VOICE "XF86Voice"
/**
+ * @deprecated Deprecated since 2.4. Use "Hangul" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Language(toggle)' key.
*/
#define KEY_LANGUAGE "Hangul"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86Call" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Call(toggle)' key.
*/
-#define KEY_CONNECT "XF86Go"
+#define KEY_CONNECT "XF86Call"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86Game" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Play(toggle)' key.
*/
#define KEY_GAMEPLAY "XF86Game"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86VoiceWakeUp_LPSD" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Voice Wakeup LPSD' key.
*/
-#define KEY_VOICEWAKEUP_LPSD "XF86Launch3"
+#define KEY_VOICEWAKEUP_LPSD "XF86VoiceWakeUp_LPSD"
/**
+ * @deprecated Deprecated since 2.4. Use "XF86VoiceWakeUp" string instead.
* @brief Definition for XKeySym (XServer Key Symbol) corresponding to the 'Voice Wakeup' key.
*/
-#define KEY_VOICEWAKEUP "XF86Launch4"
+#define KEY_VOICEWAKEUP "XF86VoiceWakeUp"
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Volume Up' key.
*/
#define LEN_KEY_VOLUMEUP 20
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Volume Down' key.
*/
#define LEN_KEY_VOLUMEDOWN 20
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Half-Press of Camera' key.
*/
#define LEN_KEY_CAMERA 10
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Full-Press of Camera' key.
*/
-#define LEN_KEY_CONFIG 12
+#define LEN_KEY_CONFIG 15
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Power' key.
*/
#define LEN_KEY_POWER 12
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Pause' key.
*/
#define LEN_KEY_PAUSE 11
-// Earjack/BT Headset/Multimedia keys
+/* Earjack/BT Headset/Multimedia keys */
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Play Audio' key.
*/
#define LEN_KEY_PLAYCD 13
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Stop Audio' key.
*/
#define LEN_KEY_STOPCD 13
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Pause Audio' key.
*/
#define LEN_KEY_PAUSECD 14
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Next Song' key.
*/
#define LEN_KEY_NEXTSONG 13
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Previous Song' key.
*/
#define LEN_KEY_PREVIOUSSONG 13
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Rewind Song' key.
*/
#define LEN_KEY_REWIND 15
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Forwand Song' key.
*/
#define LEN_KEY_FASTFORWARD 16
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Media' key.
*/
#define LEN_KEY_MEDIA 14
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'PlayPause' key.
*/
#define LEN_KEY_PLAYPAUSE 13
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Mute' key.
*/
#define LEN_KEY_MUTE 13
-// 3-Touch key
+/* 3-Touch key */
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Send' key.
*/
#define LEN_KEY_SEND 8
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Home' key.
*/
#define LEN_KEY_SELECT 9
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'End' key.
*/
#define LEN_KEY_END 8
-// Renamed 3-Touch key
+/* Renamed 3-Touch key */
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Send' key.
*/
#define LEN_KEY_MENU 8
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Home' key.
*/
-#define LEN_KEY_HOME 9
+#define LEN_KEY_HOME 8
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'End' key.
*/
#define LEN_KEY_BACK 8
-//Other functions keys
+/* Other functions keys */
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'HomePage' key.
*/
#define LEN_KEY_HOMEPAGE 12
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'WWW' key.
*/
#define LEN_KEY_WEBPAGE 7
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Mail' key.
*/
#define LEN_KEY_MAIL 8
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'ScreenSaver' key.
*/
#define LEN_KEY_SCREENSAVER 15
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'BrightnessUp' key.
*/
#define LEN_KEY_BRIGHTNESSUP 19
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'BrightnessDown' key.
*/
#define LEN_KEY_BRIGHTNESSDOWN 21
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Soft keyboard(toggle)' key.
*/
#define LEN_KEY_SOFTKBD 10
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Quick panel(toggle)' key.
*/
-#define LEN_KEY_QUICKPANEL 9
+#define LEN_KEY_QUICKPANEL 13
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Task switcher(toggle)' key.
*/
#define LEN_KEY_TASKSWITCH 12
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Apptray(toggle)' key.
*/
-#define LEN_KEY_APPS 11
+#define LEN_KEY_APPS 8
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Search(toggle)' key.
*/
#define LEN_KEY_SEARCH 10
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Voice(toggle)' key.
*/
-#define LEN_KEY_VOICE 11
+#define LEN_KEY_VOICE 9
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Language(toggle)' key.
*/
#define LEN_KEY_LANGUAGE 6
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Call(toggle)' key.
*/
-#define LEN_KEY_CONNECT 6
+#define LEN_KEY_CONNECT 8
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Play(toggle)' key.
*/
#define LEN_KEY_GAMEPLAY 8
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Voice Wakeup LPSD' key.
*/
-#define LEN_KEY_VOICEWAKEUP_LPSD 11
+#define LEN_KEY_VOICEWAKEUP_LPSD 20
/**
+ * @deprecated Deprecated since 2.4.
* @brief Definition for the length of a string corresponding to the 'Voice Wakeup' key.
*/
-#define LEN_KEY_VOICEWAKEUP 11
+#define LEN_KEY_VOICEWAKEUP 15
/**
* @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.
/**
* @brief Definition for getting/setting the property while grabbing a key for a window.
*/
-#define STR_ATOM_GRAB_KEY "_GRAB_KEY"
+#define STR_ATOM_GRAB_KEY "_E_KEYROUTER_WINDOW_KEYTABLE"
/**
* @brief Definition for the key grabbed by a client window in the EXCLUSIVE mode.
*/
} Utilx_Notification_Level;
/**
+ * @brief Enumeration for notification window's priority level.
+ */
+typedef enum _Utilx_Notification_Priority
+{
+ UTILX_NOTIFICATION_PRIORITY_UNKNOWN = -1,
+ UTILX_NOTIFICATION_PRIORITY_NONE = 0, /**< No priority. This value makes the window place in normal layer. */
+ UTILX_NOTIFICATION_PRIORITY_DEFAULT = 10, /**< Default priority notification */
+ UTILX_NOTIFICATION_PRIORITY_MEDIUM = 20, /**< Medium priority notification */
+ UTILX_NOTIFICATION_PRIORITY_HIGH = 30, /**< High priority notification */
+ UTILX_NOTIFICATION_PRIORITY_TOP = 40, /**< Top priority notification */
+} Utilx_Notification_Priority;
+
+/**
* @brief Enumeration for the opaque state.
*/
typedef enum _Utilx_Opaque_State
* @brief Sets the priority level for the specified notification window, asynchronously.
*
* @details This function sets the priority level of notification windows.\n
- * Every notification window has a base priority level by the notification window's priority value (default priority is #UTILX_NOTIFICATION_LEVEL_LOW).
+ * Every notification window needs to set its priority level to be placed in the notification layers.
*
* The priority is used for ordering of notification windows.\n
* The notification window with the priority set to #UTILX_NOTIFICATION_LEVEL_HIGH will be placed at the top of the notification windows.\n
Utilx_Notification_Level utilx_get_system_notification_level (Display* dpy, Window win);
/**
+ * @brief Sets the priority level for the specified notification window, asynchronously.
+ *
+ * @details This function sets the priority level of notification windows.\n
+ * Every notification window needs to set its priority level to be placed in the notification layers
+ *
+ * The priority is used for ordering of notification windows.\n
+ * The notification window with the priority set to #UTILX_NOTIFICATION_PRIORITY_TOP will be placed at the top of the notification windows.\n
+ * If there are notification windows which have same priorities, the last created notification window will be placed on the other window.\n
+ * If you want to make notification window place in normal layer like normal type window, then you can use #UTILX_NOTIFICATION_PRIORITY_NONE.
+ *
+ * @since_tizen 2.4
+ * @remarks This is used only for notification windows.
+ * @param[in] dpy The connection to the X server
+ * @param[in] win The window to set
+ * @param[in] priority The priority (#UTILX_NOTIFICATION_PRIORITY_NONE, #UTILX_NOTIFICATION_PRIORITY_DEFAULT, #UTILX_NOTIFICATION_PRIORITY_MEDIUM, #UTILX_NOTIFICATION_PRIORITY_HIGH, UTILX_NOTIFICATION_PRIORITY_TOP)
+ * @pre The window should be a notification type window.
+ * @see #Utilx_Notification_Level
+ * @see utilx_get_system_notification_priority()
+ * @par Example
+ @code
+ #include <utilX.h>
+
+ ...
+
+ Evas_Object *win;
+ Ecore_X_Window xwin;
+
+ win = create_mwnd();
+ xwin = elm_win_xwindow_get(win);
+
+ // Set Notification type
+ ecore_x_netwm_window_type_set (xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
+
+ // Set Notification's priority
+ utilx_set_system_notification_priority (ecore_x_display_get(), xwin, UTILX_NOTIFICATION_PRIORITY_HIGH);
+
+ ...
+ @endcode
+ */
+int utilx_set_system_notification_priority (Display* dpy, Window win, Utilx_Notification_Priority priority);
+
+/**
+ * @brief Gets the priority level for the specified notification window.
+ *
+ * @details This function returns the priority level of notification windows.\n
+ * If a user didn't set the notification's priority level, this function returns the default value (#UTILX_NOTIFICATION_PRIORITY_UNKNOWN).
+ *
+ * This function is a synchronous call.
+ *
+ * @since_tizen 2.4
+ * @remarks This is used only for notification windows.
+ * @param[in] dpy The connection to the X server
+ * @param[in] win The window to get
+ * @return The current notification priority (#UTILX_NOTIFICATION_PRIORITY_NONE, #UTILX_NOTIFICATION_PRIORITY_DEFAULT, #UTILX_NOTIFICATION_PRIORITY_MEDIUM, #UTILX_NOTIFICATION_PRIORITY_HIGH, UTILX_NOTIFICATION_PRIORITY_TOP)
+ * @pre The window should be a notification type window.
+ * @see utilx_set_system_notification_priority()
+ * @par Example
+ @code
+ #include <utilX.h>
+
+ ...
+
+ Evas_Object *win;
+ Ecore_X_Window xwin;
+ Utilx_Notification_Priority priority;
+
+ win = elm_win_add (NULL, "test", ELM_WIN_NOTIFICATION);
+ xwin = elm_win_xwindow_get(win);
+
+ priority = utilx_get_system_notification_priority (ecore_x_display_get(), xwin);
+
+ ...
+ @endcode
+ */
+Utilx_Notification_Priority utilx_get_system_notification_priority(Display* dpy, Window win);
+
+/**
* @brief Grabs the key specfied by @a key_name for a window in the @a grab_mode.
*
* @details This function establishes a grab of the specified key for the specified window.\n
* A trial for choosing a proper grab mode will be needed.
* @param[in] dpy The connection to the X server
* @param[in] win The window to grab a key
- * @param[in] key_name The name of a key in the string (ex> #KEY_VOLUMEUP, #KEY_VOLUMEDOWN, #KEY_SEND, and so on)
+ * @param[in] key_name The name of a key in the string (ex> "KEY_VOLUME_UP", "KEY_VOLUME_DOWN", "KEY_MENU", and so on)
* @param[in] grab_mode The grab mode (such as #EXCLUSIVE_GRAB, #TOP_POSITION_GRAB, and #SHARED_GRAB)
* @return @c 0 on success,
* otherwise failure
switch(e.type)
{
case MapNotify:
- grab_result = utilx_grab_key(disp, w, KEY_POWER, EXCLUSIVE_GRAB);
+ grab_result = utilx_grab_key(disp, w, "KEY_POWER", EXCLUSIVE_GRAB);
if( EXCLUSIVE_GRABBED_ALREADY == grab_result )
return -1;
break;
}
...
- utilx_ungrab_key(disp, win, KEY_POWER);
+ utilx_ungrab_key(disp, win, "KEY_POWER");
return 0;
}
switch(e.type)
{
case MapNotify:
- utilx_grab_key(disp, w, KEY_POWER, TOP_POSITION_GRAB);
+ utilx_grab_key(disp, w, "KEY_POWER", TOP_POSITION_GRAB);
break;
}
...
}
...
- utilx_ungrab_key(disp, win, KEY_POWER);
+ utilx_ungrab_key(disp, win, "KEY_POWER");
return 0;
}
switch(e.type)
{
case MapNotify:
- utilx_grab_key(disp, w, KEY_POWER, SHARED_GRAB);
+ utilx_grab_key(disp, w, "KEY_POWER", SHARED_GRAB);
break;
}
...
}
...
- utilx_ungrab_key(disp, win, KEY_POWER);
+ utilx_ungrab_key(disp, win, "KEY_POWER");
return 0;
}
Ecore_X_Display* disp = ecore_x_display_get();
Ecore_X_Window win = ecore_evas_software_x11_window_get(ee);
- int grab_result = utilx_grab_key(disp, win, KEY_POWER, EXCLUSIVE_GRAB);
+ int grab_result = utilx_grab_key(disp, win, "KEY_POWER", EXCLUSIVE_GRAB);
if( EXCLUSIVE_GRABBED_ALREADY == grab_result )
return -1;
...
- utilx_ungrab_key(disp, win, KEY_POWER);//Ungrab whenever a user wants to
+ utilx_ungrab_key(disp, win, "KEY_POWER");//Ungrab whenever a user wants to
return 0;
}
Ecore_X_Display* disp = ecore_x_display_get();
Ecore_X_Window win = ecore_evas_software_x11_window_get(ee);
- utilx_grab_key(disp, win, KEY_POWER, TOP_POSITION_GRAB);
+ utilx_grab_key(disp, win, "KEY_POWER", TOP_POSITION_GRAB);
...
- utilx_ungrab_key(disp, win, KEY_POWER);//Ungrab whenever a user wants to
+ utilx_ungrab_key(disp, win, "KEY_POWER");//Ungrab whenever a user wants to
return 0;
}
Ecore_X_Display* disp = ecore_x_display_get();
Ecore_X_Window win = ecore_evas_software_x11_window_get(ee);
- utilx_grab_key(disp, win, KEY_POWER, SHARED_GRAB);
+ utilx_grab_key(disp, win, "KEY_POWER", SHARED_GRAB);
...
- utilx_ungrab_key(disp, win, KEY_POWER);//Ungrab whenever a user wants to
+ utilx_ungrab_key(disp, win, "KEY_POWER");//Ungrab whenever a user wants to
return 0;
}
@endcode
* @since_tizen 2.3
* @param[in] dpy The connection to the X server
* @param[in] win The window to grab a key
- * @param[in] key_name The name of a key in the string (ex> #KEY_VOLUMEUP, #KEY_VOLUMEDOWN, #KEY_SEND, and so on)
+ * @param[in] key_name The name of a key in the string (ex> "KEY_VOLUME_UP", "KEY_VOLUME_DOWN", "KEY_MENU", and so on)
* @return @c 0 on success,
* otherwise failure
* @pre This API must be called after the window 'win' is mapped.
switch(e.type)
{
case MapNotify:
- grab_result = utilx_grab_key(disp, w, KEY_POWER, EXCLUSIVE_GRAB);
+ grab_result = utilx_grab_key(disp, w, "KEY_POWER", EXCLUSIVE_GRAB);
if( EXCLUSIVE_GRABBED_ALREADY == grab_result )
return -1;
break;
}
...
- utilx_ungrab_key(disp, win, KEY_POWER);
+ utilx_ungrab_key(disp, win, "KEY_POWER");
return 0;
}
switch(e.type)
{
case MapNotify:
- utilx_grab_key(disp, w, KEY_POWER, TOP_POSITION_GRAB);
+ utilx_grab_key(disp, w, "KEY_POWER", TOP_POSITION_GRAB);
break;
}
...
}
...
- utilx_ungrab_key(disp, win, KEY_POWER);
+ utilx_ungrab_key(disp, win, "KEY_POWER");
return 0;
}
switch(e.type)
{
case MapNotify:
- utilx_grab_key(disp, w, KEY_POWER, SHARED_GRAB);
+ utilx_grab_key(disp, w, "KEY_POWER", SHARED_GRAB);
break;
}
...
}
...
- utilx_ungrab_key(disp, win, KEY_POWER);
+ utilx_ungrab_key(disp, win, "KEY_POWER");
return 0;
}
Ecore_X_Display* disp = ecore_x_display_get();
Ecore_X_Window win = ecore_evas_software_x11_window_get(ee);
- int grab_result = utilx_grab_key(disp, win, KEY_POWER, EXCLUSIVE_GRAB);
+ int grab_result = utilx_grab_key(disp, win, "KEY_POWER", EXCLUSIVE_GRAB);
if( EXCLUSIVE_GRABBED_ALREADY == grab_result )
return -1;
...
- utilx_ungrab_key(disp, win, KEY_POWER);//Ungrab whenever a user wants to
+ utilx_ungrab_key(disp, win, "KEY_POWER");//Ungrab whenever a user wants to
return 0;
}
Ecore_X_Display* disp = ecore_x_display_get();
Ecore_X_Window win = ecore_evas_software_x11_window_get(ee);
- utilx_grab_key(disp, win, KEY_POWER, TOP_POSITION_GRAB);
+ utilx_grab_key(disp, win, "KEY_POWER", TOP_POSITION_GRAB);
...
- utilx_ungrab_key(disp, win, KEY_POWER);//Ungrab whenever a user wants to
+ utilx_ungrab_key(disp, win, "KEY_POWER");//Ungrab whenever a user wants to
return 0;
}
Ecore_X_Display* disp = ecore_x_display_get();
Ecore_X_Window win = ecore_evas_software_x11_window_get(ee);
- utilx_grab_key(disp, win, KEY_POWER, SHARED_GRAB);
+ utilx_grab_key(disp, win, "KEY_POWER", SHARED_GRAB);
...
- utilx_ungrab_key(disp, win, KEY_POWER);//Ungrab whenever a user wants to
+ utilx_ungrab_key(disp, win, "KEY_POWER");//Ungrab whenever a user wants to
return 0;
}
@endcode
#include <tbm_bufmgr.h>
#include <dri2.h>
+#ifdef ENABLE_TTRACE
+#include <ttrace.h>
+
+#define TTRACE_INPUT_BEGIN(NAME) traceBegin(TTRACE_TAG_INPUT, NAME)
+#define TTRACE_INPUT_END() traceEnd(TTRACE_TAG_INPUT)
+#define TTRACE_VIDEO_BEGIN(NAME) traceBegin(TTRACE_TAG_VIDEO, NAME)
+#define TTRACE_VIDEO_END() traceEnd(TTRACE_TAG_VIDEO)
+#else /* ENABLE_TTRACE */
+#define TTRACE_INPUT_BEGIN(NAME)
+#define TTRACE_INPUT_END()
+#define TTRACE_VIDEO_BEGIN(NAME)
+#define TTRACE_VIDEO_END()
+#endif /* ENABLE_TTRACE */
#define UTILX_DEBUG 0
#if UTILX_DEBUG
const unsigned long maxlen = 1024l;
-static void _utilx_set_window_property (Display* dpy, Window win, Atom atom, Atom type, unsigned int *val, unsigned int num);
-static int _utilx_get_window_property (Display* dpy, Window win, Atom atom, Atom type, unsigned int *val, unsigned int len);
+static void _utilx_set_window_property(Display *dpy, Window win, Atom atom, Atom type, unsigned int *val, unsigned int num);
+static int _utilx_get_window_property(Display *dpy, Window win, Atom atom, Atom type, unsigned int *val, unsigned int len);
-API void utilx_set_system_notification_level (Display* dpy, Window win, Utilx_Notification_Level level)
+API void utilx_set_system_notification_level(Display *dpy, Window win, Utilx_Notification_Level level)
{
- UTILX_TRACE ("[UTILX] utilx_set_system_notification_level... win = %x, level = %d\n", win, level);
+ traceBegin(TTRACE_TAG_INPUT, "XORG:UTILX:SET_SYSTEM_NOTIFICATION_LEVEL(%d)", level);
+ UTILX_TRACE("[UTILX] utilx_set_system_notification_level... win = %x, level = %d\n", win, level);
int noti_level;
- if (dpy == NULL)
- {
- fprintf (stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__);
- return;
+ if (dpy == NULL) {
+ fprintf(stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__);
+ goto out;
}
- switch (level)
- {
- case UTILX_NOTIFICATION_LEVEL_LOW:
- noti_level = 50;
- break;
+ switch (level) {
+ case UTILX_NOTIFICATION_LEVEL_LOW:
+ noti_level = 50;
+ break;
- case UTILX_NOTIFICATION_LEVEL_NORMAL:
- noti_level = 100;
- break;
+ case UTILX_NOTIFICATION_LEVEL_NORMAL:
+ noti_level = 100;
+ break;
- case UTILX_NOTIFICATION_LEVEL_HIGH:
- noti_level = 150;
- break;
+ case UTILX_NOTIFICATION_LEVEL_HIGH:
+ noti_level = 150;
+ break;
- default:
- noti_level = 50;
- break;
+ default:
+ noti_level = 50;
+ break;
}
- if (!_atom_notification_level)
- {
- _atom_notification_level = XInternAtom (dpy, "_E_ILLUME_NOTIFICATION_LEVEL", False);
- if (!_atom_notification_level)
- {
- fprintf (stderr, "[UTILX] Error.. Cannot create _E_ILLUME_NOTIFICATION_LEVEL atom.. %s (%d)\n", __func__, __LINE__);
- return;
+ if (!_atom_notification_level) {
+ _atom_notification_level = XInternAtom(dpy, "_E_ILLUME_NOTIFICATION_LEVEL", False);
+ if (!_atom_notification_level) {
+ fprintf(stderr, "[UTILX] Error.. Cannot create _E_ILLUME_NOTIFICATION_LEVEL atom.. %s (%d)\n", __func__, __LINE__);
+ goto out;
}
}
- _utilx_set_window_property (dpy, win, _atom_notification_level, XA_CARDINAL,
+ _utilx_set_window_property(dpy, win, _atom_notification_level, XA_CARDINAL,
(unsigned int *)¬i_level, 1);
+out:
+ TTRACE_INPUT_END();
+ return;
}
-API Utilx_Notification_Level utilx_get_system_notification_level (Display* dpy, Window win)
+API Utilx_Notification_Level utilx_get_system_notification_level(Display *dpy, Window win)
{
- UTILX_TRACE ("[UTILX] utilx_get_system_notification_level... win = %x\n", win);
+ TTRACE_INPUT_BEGIN("XORG:UTILX:GET_SYSTEM_NOTIFICATION_LEVEL");
+
+ UTILX_TRACE("[UTILX] utilx_get_system_notification_level... win = %x\n", win);
Utilx_Notification_Level noti_level;
unsigned int level;
noti_level = UTILX_NOTIFICATION_LEVEL_LOW;
- if (dpy == NULL)
- {
- fprintf (stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__);
+ if (dpy == NULL) {
+ fprintf(stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__);
goto error;
}
- if (!_atom_notification_level)
- {
- _atom_notification_level = XInternAtom (dpy, "_E_ILLUME_NOTIFICATION_LEVEL", False);
- if (!_atom_notification_level)
- {
- fprintf (stderr, "[UTILX] Error.. Cannot create _E_ILLUME_NOTIFICATION_LEVEL atom.. %s (%d)\n", __func__, __LINE__);
+ if (!_atom_notification_level) {
+ _atom_notification_level = XInternAtom(dpy, "_E_ILLUME_NOTIFICATION_LEVEL", False);
+ if (!_atom_notification_level) {
+ fprintf(stderr, "[UTILX] Error.. Cannot create _E_ILLUME_NOTIFICATION_LEVEL atom.. %s (%d)\n", __func__, __LINE__);
goto error;
}
}
- ret = _utilx_get_window_property (dpy, win, _atom_notification_level, XA_CARDINAL,
+ ret = _utilx_get_window_property(dpy, win, _atom_notification_level, XA_CARDINAL,
(unsigned int *)&level, 1);
- if (ret > 0)
- {
- switch (level)
- {
- case 50:
- noti_level = UTILX_NOTIFICATION_LEVEL_LOW;
- break;
+ if (ret > 0) {
+ switch (level) {
+ case 50:
+ noti_level = UTILX_NOTIFICATION_LEVEL_LOW;
+ break;
- case 100:
- noti_level = UTILX_NOTIFICATION_LEVEL_NORMAL;
- break;
+ case 100:
+ noti_level = UTILX_NOTIFICATION_LEVEL_NORMAL;
+ break;
- case 150:
- noti_level = UTILX_NOTIFICATION_LEVEL_HIGH;
- break;
+ case 150:
+ noti_level = UTILX_NOTIFICATION_LEVEL_HIGH;
+ break;
- default:
- noti_level = UTILX_NOTIFICATION_LEVEL_LOW;
- break;
+ default:
+ noti_level = UTILX_NOTIFICATION_LEVEL_LOW;
+ break;
}
- }
- else
- {
+ } else {
noti_level = UTILX_NOTIFICATION_LEVEL_LOW;
}
error:
+ TTRACE_INPUT_END();
return noti_level;
}
+
+API int utilx_set_system_notification_priority(Display *dpy, Window win, Utilx_Notification_Priority priority)
+{
+ traceBegin(TTRACE_TAG_INPUT, "XORG:UTILX:SET_NOTIFICATION_PRIORITY(%d)", priority);
+ UTILX_TRACE("[UTILX] utilx_set_system_notification_priority... win = %x, priority = %d\n", win, priority);
+
+ int noti_priority;
+
+ if (dpy == NULL) {
+ fprintf(stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__);
+ goto err;
+ }
+
+ switch (priority) {
+ case UTILX_NOTIFICATION_PRIORITY_NONE:
+ noti_priority = 0;
+ break;
+
+ case UTILX_NOTIFICATION_PRIORITY_DEFAULT:
+ noti_priority = 51;
+ break;
+
+ case UTILX_NOTIFICATION_PRIORITY_MEDIUM:
+ noti_priority = 101;
+ break;
+
+ case UTILX_NOTIFICATION_PRIORITY_HIGH:
+ noti_priority = 131;
+ break;
+
+ case UTILX_NOTIFICATION_PRIORITY_TOP:
+ noti_priority = 151;
+ break;
+
+ default: goto err;
+ }
+
+ if (!_atom_notification_level) {
+ _atom_notification_level = XInternAtom(dpy, "_E_ILLUME_NOTIFICATION_LEVEL", False);
+ if (!_atom_notification_level) {
+ fprintf(stderr, "[UTILX] Error.. Cannot create _E_ILLUME_NOTIFICATION_LEVEL atom.. %s (%d)\n", __func__, __LINE__);
+ goto err;
+ }
+ }
+
+ _utilx_set_window_property(dpy, win, _atom_notification_level, XA_CARDINAL,
+ (unsigned int *)¬i_priority, 1);
+
+ TTRACE_INPUT_END();
+ return 1;
+
+err:
+ TTRACE_INPUT_END();
+ return 0;
+}
+
+
+API Utilx_Notification_Priority utilx_get_system_notification_priority(Display *dpy, Window win)
+{
+ TTRACE_INPUT_BEGIN("XORG:UTILX:GET_SYSTEM_NOTIFICATION_PRIORITY");
+
+ UTILX_TRACE("[UTILX] utilx_get_system_notification_priority... win = %x\n", win);
+
+ Utilx_Notification_Level noti_priority;
+ unsigned int priority;
+ int ret;
+
+ noti_priority = UTILX_NOTIFICATION_PRIORITY_UNKNOWN;
+
+ if (dpy == NULL) {
+ fprintf(stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__);
+ goto error;
+ }
+
+ if (!_atom_notification_level) {
+ _atom_notification_level = XInternAtom(dpy, "_E_ILLUME_NOTIFICATION_LEVEL", False);
+ if (!_atom_notification_level) {
+ fprintf(stderr, "[UTILX] Error.. Cannot create _E_ILLUME_NOTIFICATION_LEVEL atom.. %s (%d)\n", __func__, __LINE__);
+ goto error;
+ }
+ }
+
+ ret = _utilx_get_window_property(dpy, win, _atom_notification_level, XA_CARDINAL,
+ (unsigned int *)&priority, 1);
+
+ if (ret > 0) {
+ switch (priority) {
+ case 0:
+ noti_priority = UTILX_NOTIFICATION_PRIORITY_NONE;
+ break;
+
+ case 51:
+ noti_priority = UTILX_NOTIFICATION_PRIORITY_DEFAULT;
+ break;
+
+ case 101:
+ noti_priority = UTILX_NOTIFICATION_PRIORITY_MEDIUM;
+ break;
+
+ case 131:
+ noti_priority = UTILX_NOTIFICATION_PRIORITY_HIGH;
+ break;
+
+ case 151:
+ noti_priority = UTILX_NOTIFICATION_PRIORITY_TOP;
+ break;
+
+ default:
+ noti_priority = UTILX_NOTIFICATION_PRIORITY_UNKNOWN;
+ break;
+ }
+ } else {
+ noti_priority = UTILX_NOTIFICATION_PRIORITY_UNKNOWN;
+ }
+
+error:
+ TTRACE_INPUT_END();
+ return noti_priority;
+}
+
static void
-_utilx_set_window_property (Display* dpy, Window win, Atom atom, Atom type, unsigned int *val, unsigned int num)
+_utilx_set_window_property(Display *dpy, Window win, Atom atom, Atom type, unsigned int *val, unsigned int num)
{
- XChangeProperty (dpy, win, atom, type, 32, PropModeReplace, (unsigned char *)val, num);
- XSync(dpy, 0 );
+ XChangeProperty(dpy, win, atom, type, 32, PropModeReplace, (unsigned char *)val, num);
+ XSync(dpy, 0);
}
static int
-_utilx_get_window_property (Display* dpy, Window win, Atom atom, Atom type, unsigned int *val, unsigned int len)
+_utilx_get_window_property(Display *dpy, Window win, Atom atom, Atom type, unsigned int *val, unsigned int len)
{
- unsigned char* prop_ret;
+ unsigned char *prop_ret;
Atom type_ret;
unsigned long bytes_after, num_ret;
int format_ret;
prop_ret = NULL;
if (XGetWindowProperty(dpy, win, atom, 0, 0x7fffffff, False,
type, &type_ret, &format_ret, &num_ret,
- &bytes_after, &prop_ret) != Success)
- {
+ &bytes_after, &prop_ret) != Success) {
return -1;
}
- if (type_ret != type || format_ret != 32)
- {
+ if (type_ret != type || format_ret != 32) {
num = -1;
- }
- else if (num_ret == 0 || !prop_ret)
- {
+ } else if (num_ret == 0 || !prop_ret) {
num = 0;
- }
- else
- {
+ } else {
if (num_ret < len)
- len = num_ret;
+ len = num_ret;
for (i = 0; i < len; i++)
- {
val[i] = ((unsigned long *)prop_ret)[i];
- }
num = len;
}
}
-static unsigned long _get_list_of_grabbed_key (Display *disp, Window win, int **key_list)
+static unsigned long _get_list_of_grabbed_key(Display *disp, Window win, int **key_list)
{
Atom ret_type;
int ret_format;
unsigned long sz_remains_data;
if (XGetWindowProperty(disp, win,
- _atom_grab_key, 0, 0x7fffffff, False, XA_CARDINAL,
- &ret_type, &ret_format, &nr_item,
- &sz_remains_data, (unsigned char**)key_list) != Success)
- {
+ _atom_grab_key, 0, 0x7fffffff, False, XA_CARDINAL,
+ &ret_type, &ret_format, &nr_item,
+ &sz_remains_data, (unsigned char **)key_list) != Success) {
nr_item = 0;
}
-// fprintf(stderr, "\e[31m%d - %lu\e[0m\n", ret_format, nr_item);
+ /* fprintf(stderr, "\e[31m%d - %lu\e[0m\n", ret_format, nr_item); */
return nr_item;
}
-static void _free_list_of_grabbed_key (int *key_list)
+static void _free_list_of_grabbed_key(int *key_list)
{
- if (key_list) {
+ if (key_list)
XFree(key_list);
- }
}
-static void _free_new_list_of_grabbed_key (int *new_key_list)
+static void _free_new_list_of_grabbed_key(int *new_key_list)
{
- if (new_key_list) {
+ if (new_key_list)
free(new_key_list);
- }
}
-static int _search_grabbed_key (int *key_list, int key, unsigned long cnt)
+static int _search_grabbed_key(int *key_list, int key, unsigned long cnt)
{
register int i;
- for (i = cnt - 1; i >= 0; i --) {
+ for (i = cnt - 1; i >= 0; i--) {
if (key_list[i] == key) break;
}
}
-static int *_del_grabbed_key (int *key_list, int i, unsigned long *cnt)
+static int *_del_grabbed_key(int *key_list, int i, unsigned long *cnt)
{
int *new_key_list = NULL;
- // Only one element is exists in the list of grabbed key
- (*cnt) --;
+ /* Only one element is exists in the list of grabbed key */
+ (*cnt)--;
if (*cnt == 0) return NULL;
- // Shrink the buffer
+ /* Shrink the buffer */
new_key_list = malloc((*cnt) * sizeof(int));
if (new_key_list == NULL) {
perror(__func__);
return NULL;
}
- // copy head
- if (i > 0) {
- memcpy(new_key_list, key_list, sizeof(int) * i);
- }
+ /* copy head */
+ if (i > 0)
+ memcpy(new_key_list, key_list, i * sizeof(int));
- // copy tail
+ /* copy tail */
if ((*cnt) - i > 0) {
memcpy(new_key_list + i,
- key_list + i + 1,
- sizeof(int) * ((*cnt) - i)
- );
+ key_list + i + 1,
+ ((*cnt) - i) * sizeof(int)
+ );
}
return new_key_list;
}
-static void _set_exclusive_grab_info_to_root (Display *disp, int keycode, Window win, int grab_mode)
+static void _set_exclusive_grab_info_to_root(Display *disp, int keycode, Window win, int grab_mode)
{
int i;
int *key_list = NULL;
unsigned long sz_remains_data;
Window ex_grabwin;
- if( grab_mode == EXCLUSIVE_GRAB )
- {
- if( _atom_grab_excl_win == None )
+ if (grab_mode == EXCLUSIVE_GRAB) {
+ if (_atom_grab_excl_win == None)
_atom_grab_excl_win = XInternAtom(disp, STR_ATOM_GRAB_EXCL_WIN, False);
ex_grabwin = _atom_grab_excl_win;
- }
- else if( grab_mode == OR_EXCLUSIVE_GRAB )
- {
- if( _atom_grab_or_excl_win == None )
+ } else if (grab_mode == OR_EXCLUSIVE_GRAB) {
+ if (_atom_grab_or_excl_win == None)
_atom_grab_or_excl_win = XInternAtom(disp, STR_ATOM_GRAB_OR_EXCL_WIN, False);
ex_grabwin = _atom_grab_or_excl_win;
- }
- else
+ } else
return;
if (XGetWindowProperty(disp, DefaultRootWindow(disp),
- ex_grabwin, 0, 0x7fffffff, False, XA_CARDINAL,
- &ret_type, &ret_format, &nr_item,
- &sz_remains_data, (unsigned char**)&key_list) != Success)
- {
+ ex_grabwin, 0, 0x7fffffff, False, XA_CARDINAL,
+ &ret_type, &ret_format, &nr_item,
+ &sz_remains_data, (unsigned char **)&key_list) != Success) {
fprintf(stderr, "[utilX][%s] Fail to get root window property !\n", __FUNCTION__);
goto out;
}
- for( i=0 ; i < nr_item ; i++ )
- {
- if( key_list && (key_list[i] == keycode) )
+ for (i = 0 ; i < nr_item ; i++) {
+ if (key_list && (key_list[i] == keycode))
return;
}
XChangeProperty(disp, DefaultRootWindow(disp), ex_grabwin, XA_CARDINAL, 32,
- nr_item ? PropModeAppend : PropModeReplace, (unsigned char *)&keycode, 1);
+ nr_item ? PropModeAppend : PropModeReplace, (unsigned char *)&keycode, 1);
XSync(disp, False);
out:
}
-static void _unset_exclusive_grab_info_to_root (Display *disp, int keycode, int grab_mode)
+static void _unset_exclusive_grab_info_to_root(Display *disp, int keycode, int grab_mode)
{
int i;
unsigned long cnt = 0;
unsigned long sz_remains_data;
Window ex_grabwin;
- if( grab_mode == EXCLUSIVE_GRAB )
- {
- if( _atom_grab_excl_win == None )
+ if (grab_mode == EXCLUSIVE_GRAB) {
+ if (_atom_grab_excl_win == None)
_atom_grab_excl_win = XInternAtom(disp, STR_ATOM_GRAB_EXCL_WIN, False);
ex_grabwin = _atom_grab_excl_win;
- }
- else if( grab_mode == OR_EXCLUSIVE_GRAB )
- {
- if( _atom_grab_or_excl_win == None )
+ } else if (grab_mode == OR_EXCLUSIVE_GRAB) {
+ if (_atom_grab_or_excl_win == None)
_atom_grab_or_excl_win = XInternAtom(disp, STR_ATOM_GRAB_OR_EXCL_WIN, False);
ex_grabwin = _atom_grab_or_excl_win;
- }
- else
+ } else
return;
if (XGetWindowProperty(disp, DefaultRootWindow(disp),
- ex_grabwin, 0, 0x7fffffff, False, XA_CARDINAL,
- &ret_type, &ret_format, &nr_item,
- &sz_remains_data, (unsigned char**)&key_list) != Success)
- {
+ ex_grabwin, 0, 0x7fffffff, False, XA_CARDINAL,
+ &ret_type, &ret_format, &nr_item,
+ &sz_remains_data, (unsigned char **)&key_list) != Success) {
nr_item = 0;
}
if (nr_item == 0)
- {
goto out;
- }
- for( i=0 ; i < nr_item ; i++ )
- {
- if( key_list[i] == keycode )//&& grab_mode == EXCLUSIVE_GRAB )
- {
+ for (i = 0; i < nr_item; i++) {
+ if (key_list[i] == keycode)/* && grab_mode == EXCLUSIVE_GRAB ) */ {
continue;
}
cnt++;
}
- if( 0 < cnt )
- {
+ if (0 < cnt) {
new_key_list = malloc(sizeof(int)*cnt);
cnt = 0;
- }
- else
+ } else
new_key_list = NULL;
- if( !new_key_list )
- {
- //fprintf(stderr, "\e[32m[utilX][%s] Fail to allocation memory for new_key_list ! \e[0m\n", __FUNCTION__);
+ if (!new_key_list) {
+ /* fprintf(stderr, "\e[32m[utilX][%s] Fail to allocation memory for new_key_list ! \e[0m\n", __FUNCTION__); */
XDeleteProperty(disp, DefaultRootWindow(disp), ex_grabwin);
XSync(disp, False);
goto out;
}
- for( i=0 ; i < nr_item ; i++ )
- {
- if( key_list[i] == keycode )//&& grab_mode == EXCLUSIVE_GRAB )
- {
+ for (i = 0; i < nr_item; i++) {
+ if (key_list[i] == keycode)/* && grab_mode == EXCLUSIVE_GRAB ) */ {
continue;
- }
- else
+ } else
new_key_list[cnt++] = key_list[i];
}
XChangeProperty(disp, DefaultRootWindow(disp), ex_grabwin, XA_CARDINAL, 32,
- PropModeReplace, (unsigned char *)new_key_list, cnt);
+ PropModeReplace, (unsigned char *)new_key_list, cnt);
XSync(disp, False);
}
-static int _is_grabbed_key_exclusively (Display* disp, int keycode, int grab_mode)
+static int _is_grabbed_key_exclusively(Display *disp, int keycode, int grab_mode)
{
int i, result = 0;
int *key_list = NULL;
unsigned long sz_remains_data;
Window ex_grabwin;
- if( grab_mode == EXCLUSIVE_GRAB )
- {
- if( _atom_grab_excl_win == None )
+ if (grab_mode == EXCLUSIVE_GRAB) {
+ if (_atom_grab_excl_win == None)
_atom_grab_excl_win = XInternAtom(disp, STR_ATOM_GRAB_EXCL_WIN, False);
ex_grabwin = _atom_grab_excl_win;
- }
- else if( grab_mode == OR_EXCLUSIVE_GRAB )
- {
- if( _atom_grab_or_excl_win == None )
+ } else if (grab_mode == OR_EXCLUSIVE_GRAB) {
+ if (_atom_grab_or_excl_win == None)
_atom_grab_or_excl_win = XInternAtom(disp, STR_ATOM_GRAB_OR_EXCL_WIN, False);
ex_grabwin = _atom_grab_or_excl_win;
- }
- else
+ } else
return result;
if (XGetWindowProperty(disp, DefaultRootWindow(disp),
- ex_grabwin, 0, 0x7fffffff, False, XA_CARDINAL,
- &ret_type, &ret_format, &nr_item,
- &sz_remains_data, (unsigned char**)&key_list) != Success)
- {
+ ex_grabwin, 0, 0x7fffffff, False, XA_CARDINAL,
+ &ret_type, &ret_format, &nr_item,
+ &sz_remains_data, (unsigned char **)&key_list) != Success) {
fprintf(stderr, "[%s] Fail to get root window property !\n", __FUNCTION__);
goto out;
}
- for( i=0 ; i < nr_item ; i++ )
- {
- if( key_list[i] == keycode )
- {
- _free_list_of_grabbed_key(key_list);
+ for (i = 0; i < nr_item; i++) {
+ if (key_list[i] == keycode) {
+ _free_list_of_grabbed_key(key_list);
return EXCLUSIVE_GRABBED_ALREADY;
- }
+ }
}
out:
return result;
}
-API int utilx_grab_key (Display* disp, Window win, const char* key, int grab_mode)
+API int utilx_grab_key(Display *disp, Window win, const char* key, int grab_mode)
{
unsigned long cnt;
int *key_list = NULL;
- int i, result=0, ret = 0;
+ int i, result = 0, ret = 0;
int keycode = 0;
KeySym keysym;
errno = EINVAL;
- if( NULL == disp )
- {
+ TTRACE_INPUT_BEGIN("XORG:UTILX:GRAB_KEY");
+
+ if (NULL == disp) {
fprintf(stderr, "[%s] Display is NULL\n", __FUNCTION__);
+
+ TTRACE_INPUT_END();
return -1;
}
- if (_atom_grab_key == None) {
+ if (_atom_grab_key == None)
_atom_grab_key = XInternAtom(disp, STR_ATOM_GRAB_KEY, False);
- }
if (!strncmp(key, "Keycode-", 8)) {
keycode = atoi(key + 8);
}
if (keycode == 0) goto out;
- if( grab_mode == EXCLUSIVE_GRAB )
- {
- //Window grabWin;
+ if (grab_mode == EXCLUSIVE_GRAB) {
+ /* Window grabWin; */
result = _is_grabbed_key_exclusively(disp, keycode, grab_mode);
- if( result )
- {
+ if (result)
goto out;
- }
}
keycode |= grab_mode;
if (cnt > 0) {
i = _search_grabbed_key(key_list, keycode, cnt);
_free_list_of_grabbed_key(key_list);
- if ( i != -1 ) {
+ if (i != -1) {
fprintf(stderr, "Key is already grabbed\n");
goto out;
}
XSync(disp, False);
keycode = keycode & (~GRAB_MODE_MASK);
- if( EXCLUSIVE_GRAB == grab_mode )
+ if (EXCLUSIVE_GRAB == grab_mode)
_set_exclusive_grab_info_to_root(disp, keycode, win, grab_mode);
- if( OR_EXCLUSIVE_GRAB == grab_mode )
- {
+ if (OR_EXCLUSIVE_GRAB == grab_mode) {
ret = _is_grabbed_key_exclusively(disp, keycode, grab_mode);
- if( !ret )
- {
+ if (!ret)
_set_exclusive_grab_info_to_root(disp, keycode, win, grab_mode);
- }
}
errno = 0;
out:
-
+ TTRACE_INPUT_END();
return result;
}
-API int utilx_ungrab_key (Display* disp, Window win, const char* key)
+API int utilx_ungrab_key(Display *disp, Window win, const char* key)
{
int i;
unsigned long cnt;
int ret = -1;
errno = EINVAL;
- if( NULL == disp )
- {
+ TTRACE_INPUT_BEGIN("XORG:UTILX:UNGRAB_KEY");
+
+ if (NULL == disp) {
fprintf(stderr, "[%s] Display is NULL\n", __FUNCTION__);
+
+ TTRACE_INPUT_END();
return -1;
}
- if (_atom_grab_key == None) {
+ if (_atom_grab_key == None)
_atom_grab_key = XInternAtom(disp, STR_ATOM_GRAB_KEY, False);
- }
if (!strncmp(key, "Keycode-", 8)) {
keycode = atoi(key + 8);
cnt = _get_list_of_grabbed_key(disp, win, &key_list);
if (cnt == 0) goto out;
- //EXCLUSIVE mode
+ /* EXCLUSIVE mode */
i = _search_grabbed_key(key_list, keycode | EXCLUSIVE_GRAB, cnt);
- if ( i == -1)
- {
- //OR_EXCLUSIVE mode
+ if (i == -1) {
+ /* OR_EXCLUSIVE mode */
i = _search_grabbed_key(key_list, keycode | OR_EXCLUSIVE_GRAB, cnt);
- if ( i == -1)
- {
- //TOP_POSITION mode
+ if (i == -1) {
+ /* TOP_POSITION mode */
i = _search_grabbed_key(key_list, keycode | TOP_POSITION_GRAB, cnt);
- if (i == -1)
- {
- //SHARED mode
+ if (i == -1) {
+ /* SHARED mode */
i = _search_grabbed_key(key_list, keycode | SHARED_GRAB, cnt);
- if (i == -1)
- {
+ if (i == -1) {
_free_list_of_grabbed_key(key_list);
goto out;
}
}
}
- }
- else
- {
+ } else {
_unset_exclusive_grab_info_to_root(disp, keycode, EXCLUSIVE_GRAB);
}
if (new_key_list) {
XChangeProperty(disp, win, _atom_grab_key, XA_CARDINAL, 32,
- PropModeReplace, (unsigned char *)new_key_list, cnt);
- }
- else {
+ PropModeReplace, (unsigned char *)new_key_list, cnt);
+ } else {
XDeleteProperty(disp, win, _atom_grab_key);
}
XSync(disp, False);
errno = 0;
out:
-
+ TTRACE_INPUT_END();
return ret;
}
static void
-_utilx_string_set_window_property( Display *dpy, Window win, Atom atom, char *val, unsigned int num)
+_utilx_string_set_window_property(Display *dpy, Window win, Atom atom, char *val, unsigned int num)
{
- XChangeProperty( dpy, win, atom, XA_STRING, 8, PropModeReplace, (unsigned char*)val, val ? strlen(val):0 );
+ XChangeProperty(dpy, win, atom, XA_STRING, 8, PropModeReplace, (unsigned char *)val, val ? strlen(val) : 0);
}
-API void utilx_set_fake_launch_img(Display* dpy, Window win, char *file_name)
+API void utilx_set_fake_launch_img(Display *dpy, Window win, char *file_name)
{
- //UTILX_TRACE ("[UTILX] utilx_set_effect_state... win = %x, show_state = %d\n", win, enable);
+ TTRACE_VIDEO_BEGIN("XORG:UTILX:SET_FAKE_LAUNCH_IMG");
+ /* UTILX_TRACE("[UTILX] utilx_set_effect_state... win = %x, show_state = %d\n", win, enable); */
- if ( dpy == NULL )
- {
- fprintf (stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__);
+ if (dpy == NULL) {
+ fprintf(stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__);
+
+ TTRACE_VIDEO_END();
return;
}
- if( !_atom_comp_fake_launch_image)
- _atom_comp_fake_launch_image = XInternAtom(dpy, "_E_COMP_FAKE_LAUNCH_IMAGE",False);
+ if (!_atom_comp_fake_launch_image)
+ _atom_comp_fake_launch_image = XInternAtom(dpy, "_E_COMP_FAKE_LAUNCH_IMAGE", False);
_utilx_string_set_window_property(dpy, win, _atom_comp_fake_launch_image, file_name, 1);
+ TTRACE_VIDEO_END();
}
-API int utilx_set_window_opaque_state (Display* dpy, Window win, Utilx_Opaque_State state)
+API int utilx_set_window_opaque_state(Display *dpy, Window win, Utilx_Opaque_State state)
{
- UTILX_TRACE ("[UTILX] utilx_set_window_opaque_state... win = %x, show_state = %d\n", win, state);
+ TTRACE_VIDEO_BEGIN("XORG:UTILX:SET_WINDOW_OPAQUE_STATE");
+
+ UTILX_TRACE("[UTILX] utilx_set_window_opaque_state... win = %x, show_state = %d\n", win, state);
unsigned int is_opaque;
- if (dpy == NULL)
- {
- fprintf (stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__);
+ if (dpy == NULL) {
+ fprintf(stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__);
+
+ TTRACE_VIDEO_END();
return 0;
}
- switch (state)
- {
- case UTILX_OPAQUE_STATE_OFF:
- is_opaque = 0;
- break;
+ switch (state) {
+ case UTILX_OPAQUE_STATE_OFF:
+ is_opaque = 0;
+ break;
- case UTILX_OPAQUE_STATE_ON:
- is_opaque = 1;
- break;
+ case UTILX_OPAQUE_STATE_ON:
+ is_opaque = 1;
+ break;
- default:
- fprintf (stderr, "[UTILX] Error.. Invald State.. %s (%d)\n", __func__, __LINE__);
- return 0;
+ default:
+ fprintf(stderr, "[UTILX] Error.. Invald State.. %s (%d)\n", __func__, __LINE__);
+ TTRACE_VIDEO_END();
+ return 0;
}
- if (!_atom_window_opaque)
- {
- _atom_window_opaque = XInternAtom (dpy, "_E_ILLUME_WINDOW_REGION_OPAQUE", False);
- if (!_atom_window_opaque)
- {
- fprintf (stderr, "[UTILX] Error.. Cannot create _E_ILLUME_WINDOW_REGION_OPAQUE atom.. %s (%d)\n", __func__, __LINE__);
+ if (!_atom_window_opaque) {
+ _atom_window_opaque = XInternAtom(dpy, "_E_ILLUME_WINDOW_REGION_OPAQUE", False);
+ if (!_atom_window_opaque) {
+ fprintf(stderr, "[UTILX] Error.. Cannot create _E_ILLUME_WINDOW_REGION_OPAQUE atom.. %s (%d)\n", __func__, __LINE__);
+ TTRACE_VIDEO_END();
return 0;
}
}
- _utilx_set_window_property (dpy, win, _atom_window_opaque, XA_CARDINAL,
+ _utilx_set_window_property(dpy, win, _atom_window_opaque, XA_CARDINAL,
(unsigned int *)&is_opaque, 1);
+ TTRACE_VIDEO_END();
return 1;
}
-API UtilxScrnConf *utilx_scrnconf_allocate (void)
+API UtilxScrnConf *utilx_scrnconf_allocate(void)
{
- UtilxScrnConf *scrnconf = calloc (1, sizeof(UtilxScrnConf));
- if (!scrnconf)
- {
- fprintf (stderr, "fail to allocate UtilxScrnConf\n");
- return NULL;
- }
-
- return scrnconf;
+ TTRACE_VIDEO_BEGIN("XORG:UTILX:SCRNCONF_ALLOCATE");
+
+ UtilxScrnConf *scrnconf = calloc(1, sizeof(UtilxScrnConf));
+ if (!scrnconf) {
+ fprintf(stderr, "fail to allocate UtilxScrnConf\n");
+
+ TTRACE_VIDEO_END();
+ return NULL;
+ }
+
+ TTRACE_VIDEO_END();
+ return scrnconf;
}
-API void utilx_scrnconf_free (UtilxScrnConf *scrnconf)
+API void utilx_scrnconf_free(UtilxScrnConf *scrnconf)
{
- if (!scrnconf)
- return;
+ TTRACE_VIDEO_BEGIN("XORG:UTILX:SCRNCONF_FREE");
- if (scrnconf->str_output)
- free (scrnconf->str_output);
+ if (!scrnconf) {
+ TTRACE_VIDEO_END();
+ return;
+ }
- if (scrnconf->str_resolution)
- free (scrnconf->str_resolution);
+ if (scrnconf->str_output)
+ free(scrnconf->str_output);
- free(scrnconf);
- scrnconf = NULL;
+ if (scrnconf->str_resolution)
+ free(scrnconf->str_resolution);
+
+ free(scrnconf);
+ scrnconf = NULL;
+
+ TTRACE_VIDEO_END();
}
-API int utilx_scrnconf_get_info (Display *dpy, UtilxScrnConf *scrnconf)
+API int utilx_scrnconf_get_info(Display *dpy, UtilxScrnConf *scrnconf)
{
- Window win;
- Atom scrnconf_atom = None;
- XTextProperty xtp;
- char *str = NULL;
- char *ptr = NULL;
- int items;
- char **list = NULL;
- int i = 0;
- int s;
-
- if (!dpy)
- goto fail;
-
- if (!scrnconf)
- goto fail;
-
- win = DefaultRootWindow(dpy);
-
- scrnconf_atom = XInternAtom (dpy, "_SCRNCONF_INFO", False);
-
- /* get property */
- if (XGetTextProperty (dpy, win, &xtp, scrnconf_atom))
- {
- s = XmbTextPropertyToTextList (dpy, &xtp, &list, &items);
- if ((s == XLocaleNotSupported) ||
- (s == XNoMemory) || (s == XConverterNotFound))
- str = strdup((char *)xtp.value);
- else if ((s >= Success) && (items > 0))
- str = strdup(list[0]);
-
- if (list)
- XFreeStringList (list);
-
- XFree(xtp.value);
- }
-
- ptr = strtok (str, ",");
- while (ptr != NULL)
- {
- if (i == 0)
- {
- scrnconf->str_output = calloc (1, strlen(ptr)+1);
- if (!scrnconf->str_output)
- goto fail;
-
- strcpy (scrnconf->str_output, ptr);
- }
- else if (i == 1)
- {
- if (!strcmp(ptr, "CONNECT"))
- scrnconf->status = UTILX_SCRNCONF_STATUS_CONNECT;
- else if (!strcmp(ptr, "ACTIVE"))
- scrnconf->status = UTILX_SCRNCONF_STATUS_ACTIVE;
- else
- scrnconf->status = UTILX_SCRNCONF_STATUS_NULL;
- }
- else if (i == 2)
- {
- if (scrnconf->str_resolution) free(scrnconf->str_resolution);
- scrnconf->str_resolution = calloc (1, strlen(ptr)+1);
- if (!scrnconf->str_resolution)
- goto fail;
-
- strcpy (scrnconf->str_resolution, ptr);
- }
- else if (i == 3)
- {
- if (!strcmp(ptr, "CLONE"))
- scrnconf->dispmode = UTILX_SCRNCONF_DISPMODE_CLONE;
- else if (!strcmp(ptr, "EXTENDED"))
- scrnconf->dispmode = UTILX_SCRNCONF_DISPMODE_EXTENDED;
- else
- scrnconf->dispmode = UTILX_SCRNCONF_DISPMODE_NULL;
- }
- else
- break;
-
- ptr = strtok (NULL, ",");
- i++;
- }
-
- free (str);
-
- return 1;
+ Window win;
+ Atom scrnconf_atom = None;
+ XTextProperty xtp;
+ char *str = NULL;
+ char *ptr = NULL;
+ int items;
+ char **list = NULL;
+ int i = 0;
+ int s;
+ char *saveptr = NULL;
+
+ TTRACE_VIDEO_BEGIN("XORG:UTILX:SCRNCONF_GET_INFO");
+
+ if (!dpy)
+ goto fail;
+
+ if (!scrnconf)
+ goto fail;
+
+ win = DefaultRootWindow(dpy);
+
+ scrnconf_atom = XInternAtom(dpy, "_SCRNCONF_INFO", False);
+
+ /* get property */
+ if (XGetTextProperty(dpy, win, &xtp, scrnconf_atom)) {
+ s = XmbTextPropertyToTextList(dpy, &xtp, &list, &items);
+ if ((s == XLocaleNotSupported) || (s == XNoMemory) || (s == XConverterNotFound))
+ str = strdup((char *)xtp.value);
+ else if ((s >= Success) && (items > 0))
+ str = strdup(list[0]);
+
+ if (list)
+ XFreeStringList(list);
+
+ XFree(xtp.value);
+ }
+
+ ptr = strtok_r(str, ",", &saveptr);
+ while (ptr != NULL) {
+ if (i == 0) {
+ scrnconf->str_output = calloc(1, strlen(ptr)+1);
+ if (!scrnconf->str_output)
+ goto fail;
+
+ strncpy(scrnconf->str_output, ptr, strlen(ptr));
+ } else if (i == 1) {
+ if (!strncmp(ptr, "CONNECT", sizeof("CONNECT")))
+ scrnconf->status = UTILX_SCRNCONF_STATUS_CONNECT;
+ else if (!strncmp(ptr, "ACTIVE", sizeof("ACTIVE")))
+ scrnconf->status = UTILX_SCRNCONF_STATUS_ACTIVE;
+ else
+ scrnconf->status = UTILX_SCRNCONF_STATUS_NULL;
+ } else if (i == 2) {
+ if (scrnconf->str_resolution) {
+ free(scrnconf->str_resolution);
+ scrnconf->str_resolution = NULL;
+ }
+ scrnconf->str_resolution = calloc(1, strlen(ptr)+1);
+ if (!scrnconf->str_resolution)
+ goto fail;
+
+ strncpy(scrnconf->str_resolution, ptr, strlen(ptr));
+ } else if (i == 3) {
+ if (!strncmp(ptr, "CLONE", sizeof("CLONE")))
+ scrnconf->dispmode = UTILX_SCRNCONF_DISPMODE_CLONE;
+ else if (!strncmp(ptr, "EXTENDED", sizeof("EXTENDED")))
+ scrnconf->dispmode = UTILX_SCRNCONF_DISPMODE_EXTENDED;
+ else
+ scrnconf->dispmode = UTILX_SCRNCONF_DISPMODE_NULL;
+ } else
+ break;
+
+ ptr = strtok_r(NULL, ",", &saveptr);
+ i++;
+ }
+
+ free(str);
+
+ TTRACE_VIDEO_END();
+ return 1;
fail:
- if (str)
- free (str);
+ if (str)
+ free(str);
- return 0;
+ TTRACE_VIDEO_END();
+ return 0;
}
-API int utilx_scrnconf_set_dispmode (Display *dpy, Utilx_Scrnconf_Dispmode dispmode)
+API int utilx_scrnconf_set_dispmode(Display *dpy, Utilx_Scrnconf_Dispmode dispmode)
{
- Window win = DefaultRootWindow(dpy);
+ Window win = DefaultRootWindow(dpy);
XEvent xev;
Atom scrnconf_atom = None;
- UtilxScrnConf *scrnconf = NULL;
+ UtilxScrnConf *scrnconf = NULL;
- scrnconf = utilx_scrnconf_allocate ();
- if (!scrnconf)
- return 0;
+ TTRACE_VIDEO_BEGIN("XORG:UTILX:SCRNCONF_SET_DISPMODE");
+
+ scrnconf = utilx_scrnconf_allocate();
+ if (!scrnconf)
+ goto fail;
+
+ if (!utilx_scrnconf_get_info(dpy, scrnconf)) {
+ utilx_scrnconf_free(scrnconf);
+ goto fail;
+ }
- if (!utilx_scrnconf_get_info (dpy, scrnconf))
- {
- utilx_scrnconf_free (scrnconf);
- return 0;
- }
+ if (scrnconf->status == UTILX_SCRNCONF_STATUS_NULL) {
+ fprintf(stderr, "[utilx_scrnconf]: the status of screen configuration is null\n");
+ utilx_scrnconf_free(scrnconf);
+ goto fail;
+ }
- if (scrnconf->status == UTILX_SCRNCONF_STATUS_NULL)
- {
- fprintf (stderr, "[utilx_scrnconf]: the status of screen configuration is null\n");
- utilx_scrnconf_free (scrnconf);
- return 0;
- }
+ if (scrnconf->dispmode == dispmode) {
+ fprintf(stderr, "[utilx_scrnconf]: dispmode (%d) already set\n", dispmode);
+ utilx_scrnconf_free(scrnconf);
- if (scrnconf->dispmode == dispmode)
- {
- fprintf (stderr, "[utilx_scrnconf]: dispmode (%d) already set\n", dispmode);
- utilx_scrnconf_free (scrnconf);
- return 1;
- }
+ TTRACE_VIDEO_END();
+ return 1;
+ }
- utilx_scrnconf_free (scrnconf);
+ utilx_scrnconf_free(scrnconf);
- scrnconf_atom = XInternAtom (dpy, "_SCRNCONF_DISPMODE_SET", False);
+ scrnconf_atom = XInternAtom(dpy, "_SCRNCONF_DISPMODE_SET", False);
xev.xclient.window = win;
xev.xclient.type = ClientMessage;
XSendEvent(dpy, win, False, StructureNotifyMask, &xev);
XSync(dpy, False);
- return 1;
+ TTRACE_VIDEO_END();
+ return 1;
+fail:
+ TTRACE_VIDEO_END();
+ return 0;
}
-typedef struct _ShotInfo
-{
- Display *dpy;
+typedef struct _ShotInfo {
+ Display *dpy;
- /* PutImage */
- int port;
- unsigned int width;
- unsigned int height;
- Pixmap pixmap;
- GC gc;
+ /* PutImage */
+ int port;
+ unsigned int width;
+ unsigned int height;
+ Pixmap pixmap;
+ GC gc;
- /* Damage */
- Damage damage;
- int damage_base;
+ /* Damage */
+ Damage damage;
+ int damage_base;
- void *virtual;
+ void *virtual;
- /* XShm */
- XImage *image;
- XShmSegmentInfo shminfo;
+ /* XShm */
+ XImage *image;
+ XShmSegmentInfo shminfo;
} ShotInfo;
-#define FOURCC(a,b,c,d) (((unsigned)d&0xff)<<24 | ((unsigned)c&0xff)<<16 | ((unsigned)b&0xff)<<8 | ((unsigned)a&0xff))
+#define FOURCC(a, b, c, d) (((unsigned)d&0xff)<<24 | ((unsigned)c&0xff)<<16 | ((unsigned)b&0xff)<<8 | ((unsigned)a&0xff))
-#define FOURCC_RGB32 FOURCC('R','G','B','4')
+#define FOURCC_RGB32 FOURCC('R', 'G', 'B', '4')
#define TIMEOUT_CAPTURE 3
- /* x error handling */
+/* x error handling */
static Bool x_error_caught;
static ShotInfo *shot_info;
static int
-_get_port (Display *dpy, unsigned int id, Window win)
+_get_port(Display *dpy, unsigned int id, Window win)
{
- unsigned int ver, rev, req_base, evt_base, err_base;
- unsigned int adaptors;
- XvAdaptorInfo *ai = NULL;
- XvImageFormatValues *fo = NULL;
- int formats;
- int i, j, p;
-
- if (XvQueryExtension (dpy, &ver, &rev, &req_base, &evt_base, &err_base) != Success)
- {
- fprintf (stderr, "[UTILX] no XV extension. \n");
- return -1;
- }
-
- if (XvQueryAdaptors (dpy, win, &adaptors, &ai) != Success)
- {
- fprintf (stderr, "[UTILX] fail : query adaptors. \n");
- return -1;
- }
-
- if (!ai)
- {
- fprintf (stderr, "[UTILX] fail : get adaptor info. \n");
- return -1;
- }
-
- for (i = 0; i < adaptors; i++)
- {
- int support_format = False;
-
- if (!(ai[i].type & XvInputMask) ||
- !(ai[i].type & XvStillMask))
- continue;
-
- p = ai[i].base_id;
-
- fo = XvListImageFormats (dpy, p, &formats);
- for (j = 0; j < formats; j++)
- if (fo[j].id == (int)id)
- support_format = True;
-
- if (fo)
- XFree (fo);
-
- if (!support_format)
- continue;
-
- for (; p < ai[i].base_id + ai[i].num_ports; p++)
- {
- if (XvGrabPort (dpy, p, 0) == Success)
- {
- XvFreeAdaptorInfo (ai);
- return p;
- }
- }
-
- fprintf (stderr, "[UTILX] fail : grab port. \n");
- }
-
- XvFreeAdaptorInfo (ai);
-
- return -1;
+ unsigned int ver, rev, req_base, evt_base, err_base;
+ unsigned int adaptors;
+ XvAdaptorInfo *ai = NULL;
+ XvImageFormatValues *fo = NULL;
+ int formats;
+ int i, j, p;
+
+ if (XvQueryExtension(dpy, &ver, &rev, &req_base, &evt_base, &err_base) != Success) {
+ fprintf(stderr, "[UTILX] no XV extension. \n");
+ return -1;
+ }
+
+ if (XvQueryAdaptors(dpy, win, &adaptors, &ai) != Success) {
+ fprintf(stderr, "[UTILX] fail : query adaptors. \n");
+ return -1;
+ }
+
+ if (!ai) {
+ fprintf(stderr, "[UTILX] fail : get adaptor info. \n");
+ return -1;
+ }
+
+ for (i = 0; i < adaptors; i++) {
+ int support_format = False;
+
+ if (!(ai[i].type & XvInputMask) ||
+ !(ai[i].type & XvStillMask))
+ continue;
+
+ p = ai[i].base_id;
+
+ fo = XvListImageFormats(dpy, p, &formats);
+ for (j = 0; j < formats; j++)
+ if (fo[j].id == (int)id)
+ support_format = True;
+
+ if (fo)
+ XFree(fo);
+
+ if (!support_format)
+ continue;
+
+ for (; p < ai[i].base_id + ai[i].num_ports; p++) {
+ if (XvGrabPort(dpy, p, 0) == Success) {
+ XvFreeAdaptorInfo(ai);
+ return p;
+ }
+ }
+
+ fprintf(stderr, "[UTILX] fail : grab port. \n");
+ }
+
+ XvFreeAdaptorInfo(ai);
+
+ return -1;
}
static void
-_deinit_screen_shot (ShotInfo *info)
+_deinit_screen_shot(ShotInfo *info)
{
- if (!info)
- return;
-
- if (info->port > 0 && info->pixmap > 0)
- XvStopVideo (info->dpy, info->port, info->pixmap);
-
- if (info->image)
- XDestroyImage (info->image);
- if (info->shminfo.shmid != -1)
- {
- XShmDetach (info->dpy, &info->shminfo);
- shmdt (info->shminfo.shmaddr);
- shmctl (info->shminfo.shmid, IPC_RMID, 0);
- }
-
- if (info->damage)
- XDamageDestroy (info->dpy, info->damage);
-
- if (info->gc)
- XFreeGC (info->dpy, info->gc);
- if (info->pixmap > 0)
- XFreePixmap (info->dpy, info->pixmap);
- if (info->port > 0)
- XvUngrabPort (info->dpy, info->port, 0);
-
- XSync (info->dpy, False);
-
- free (info);
- shot_info = NULL;
+ if (!info)
+ return;
+
+ if (info->port > 0 && info->pixmap > 0)
+ XvStopVideo(info->dpy, info->port, info->pixmap);
+
+ if (info->image)
+ XDestroyImage(info->image);
+ if (info->shminfo.shmid != -1) {
+ XShmDetach(info->dpy, &info->shminfo);
+ shmdt(info->shminfo.shmaddr);
+ shmctl(info->shminfo.shmid, IPC_RMID, 0);
+ }
+
+ if (info->damage)
+ XDamageDestroy(info->dpy, info->damage);
+
+ if (info->gc)
+ XFreeGC(info->dpy, info->gc);
+ if (info->pixmap > 0)
+ XFreePixmap(info->dpy, info->pixmap);
+ if (info->port > 0)
+ XvUngrabPort(info->dpy, info->port, 0);
+
+ XSync(info->dpy, False);
+
+ free(info);
+ shot_info = NULL;
}
static int
-_screen_shot_x_error_handle (Display *dpy, XErrorEvent *ev)
+_screen_shot_x_error_handle(Display *dpy, XErrorEvent *ev)
{
- if (!shot_info || (dpy != shot_info->dpy))
- return 0;
+ if (!shot_info || (dpy != shot_info->dpy))
+ return 0;
- x_error_caught = True;
+ x_error_caught = True;
- return 0;
+ return 0;
}
static Bool
-_init_screen_shot_damage (ShotInfo *info)
+_init_screen_shot_damage(ShotInfo *info)
{
- int damage_err_base = 0;
-
- if (!XDamageQueryExtension(info->dpy, &info->damage_base, &damage_err_base))
- {
- fprintf (stderr, "[UTILX] no X Damage extension. \n");
- return False;
- }
-
- info->damage = XDamageCreate (info->dpy, info->pixmap, XDamageReportNonEmpty);
- if (info->damage <= 0)
- {
- fprintf (stderr, "[UTILX] fail : create damage \n");
- return False;
- }
-
- return True;
+ int damage_err_base = 0;
+
+ if (!XDamageQueryExtension(info->dpy, &info->damage_base, &damage_err_base)) {
+ fprintf(stderr, "[UTILX] no X Damage extension. \n");
+ return False;
+ }
+
+ info->damage = XDamageCreate(info->dpy, info->pixmap, XDamageReportNonEmpty);
+ if (info->damage <= 0) {
+ fprintf(stderr, "[UTILX] fail : create damage \n");
+ return False;
+ }
+
+ return True;
}
static Bool
-_init_screen_shot_shm (ShotInfo *info)
+_init_screen_shot_shm(ShotInfo *info)
{
- if (!XShmQueryExtension (info->dpy))
- {
- fprintf (stderr, "[UTILX] no XShm extension. !!\n");
- return False;
- }
-
- info->image = XShmCreateImage (info->dpy,
- DefaultVisual (info->dpy, DefaultScreen (info->dpy)),
- DefaultDepth (info->dpy, DefaultScreen (info->dpy)),
- ZPixmap,
- NULL,
- &info->shminfo,
- info->width,
- info->height);
- if (!info->image)
- {
- fprintf (stderr, "[UTILX] fail : XShmCreateImage \n");
- return False;
- }
-
- info->shminfo.shmid = shmget (IPC_PRIVATE, info->image->bytes_per_line * info->height, IPC_CREAT | 0777);
- if (info->shminfo.shmid == -1)
- {
- XDestroyImage (info->image);
- fprintf (stderr, "[UTILX] fail : shmget\n");
- return False;
- }
-
- info->shminfo.shmaddr = shmat (info->shminfo.shmid, 0, 0);
- if (info->shminfo.shmaddr == (void *) -1)
- {
- XDestroyImage (info->image);
- shmctl (info->shminfo.shmid, IPC_RMID, 0);
- info->shminfo.shmid = -1;
- fprintf (stderr, "[UTILX] fail : shmat\n");
- return False;
- }
-
- info->shminfo.readOnly = False;
-
- if (!XShmAttach (info->dpy, &info->shminfo))
- {
- XDestroyImage (info->image);
- shmdt (info->shminfo.shmaddr);
- shmctl (info->shminfo.shmid, IPC_RMID, 0);
- info->shminfo.shmid = -1;
- fprintf (stderr, "[UTILX] fail : XShmAttach\n");
- return False;
- }
-
- info->image->data = info->shminfo.shmaddr;
- info->virtual = info->shminfo.shmaddr;
-
- return True;
+ if (!XShmQueryExtension(info->dpy)) {
+ fprintf(stderr, "[UTILX] no XShm extension. !!\n");
+ return False;
+ }
+
+ info->image = XShmCreateImage(info->dpy,
+ DefaultVisual(info->dpy, DefaultScreen(info->dpy)),
+ DefaultDepth(info->dpy, DefaultScreen(info->dpy)),
+ ZPixmap,
+ NULL,
+ &info->shminfo,
+ info->width,
+ info->height);
+ if (!info->image) {
+ fprintf(stderr, "[UTILX] fail : XShmCreateImage \n");
+ return False;
+ }
+
+ info->shminfo.shmid = shmget(IPC_PRIVATE, info->image->bytes_per_line * info->height, IPC_CREAT | 0777);
+ if (info->shminfo.shmid == -1) {
+ XDestroyImage(info->image);
+ fprintf(stderr, "[UTILX] fail : shmget\n");
+ return False;
+ }
+
+ info->shminfo.shmaddr = shmat(info->shminfo.shmid, 0, 0);
+ if (info->shminfo.shmaddr == (void *) -1) {
+ XDestroyImage(info->image);
+ shmctl(info->shminfo.shmid, IPC_RMID, 0);
+ info->shminfo.shmid = -1;
+ fprintf(stderr, "[UTILX] fail : shmat\n");
+ return False;
+ }
+
+ info->shminfo.readOnly = False;
+
+ if (!XShmAttach(info->dpy, &info->shminfo)) {
+ XDestroyImage(info->image);
+ shmdt(info->shminfo.shmaddr);
+ shmctl(info->shminfo.shmid, IPC_RMID, 0);
+ info->shminfo.shmid = -1;
+ fprintf(stderr, "[UTILX] fail : XShmAttach\n");
+ return False;
+ }
+
+ info->image->data = info->shminfo.shmaddr;
+ info->virtual = info->shminfo.shmaddr;
+
+ return True;
}
-static ShotInfo*
-_init_screen_shot (Display* dpy, unsigned int width, unsigned int height)
+static ShotInfo *
+_init_screen_shot(Display *dpy, unsigned int width, unsigned int height)
{
- ShotInfo *info = NULL;
- static Atom atom_capture = None;
- XErrorHandler old_handler = NULL;
-
- if (shot_info)
- {
- if (shot_info->width == width && shot_info->height == height)
- return shot_info;
-
- _deinit_screen_shot (shot_info);
- }
-
- info = calloc (1, sizeof (ShotInfo));
- if (!info)
- goto fail_init;
-
- shot_info = info;
-
- /* dpy */
- info->dpy = dpy;
- info->shminfo.shmid = -1;
- info->shminfo.shmaddr = (void*)-1;
-
- /* port */
- info->port = _get_port (info->dpy, FOURCC_RGB32, DefaultRootWindow (dpy));
- if (info->port <= 0)
- goto fail_init;
-
- /* width, height */
- if (atom_capture == None)
- atom_capture = XInternAtom (info->dpy, "_USER_WM_PORT_ATTRIBUTE_CAPTURE", False);
-
- XSync (info->dpy, 0);
- x_error_caught = False;
- old_handler = XSetErrorHandler (_screen_shot_x_error_handle);
-
- XvSetPortAttribute (info->dpy, info->port, atom_capture, 1);
-
- XSync (info->dpy, 0);
-
- x_error_caught = False;
- XSetErrorHandler (old_handler);
-
- XvQueryBestSize (info->dpy, info->port, 0, 0, 0, width, height, &width, &height);
- if (width <= 0 || height <= 0)
- goto fail_init;
- info->width = width;
- info->height = height;
-
- /* pixmap */
- info->pixmap = XCreatePixmap (info->dpy,
- DefaultRootWindow (info->dpy),
- width, height,
- DefaultDepth (info->dpy, DefaultScreen (info->dpy)));
- if (info->pixmap <= 0)
- {
- fprintf (stderr, "[UTILX] fail : create pixmap. \n");
- goto fail_init;
- }
-
- /* gc */
- info->gc = XCreateGC (info->dpy, info->pixmap, 0, 0);
- if (info->gc == NULL)
- {
- fprintf (stderr, "[UTILX] fail : create gc. \n");
- goto fail_init;
- }
-
- XSetForeground (info->dpy, info->gc, 0xFF000000);
- XFillRectangle (info->dpy, info->pixmap, info->gc, 0, 0, width, height);
-
- if (!_init_screen_shot_damage (info))
- goto fail_init;
-
- if (!_init_screen_shot_shm (info))
- goto fail_init;
- else
- fprintf (stderr, "[UTILX] XShm success. !!\n");
-
- if (!info->virtual)
- {
- fprintf (stderr, "[UTILX] fail : get virtual \n");
- goto fail_init;
- }
-
- XFlush (info->dpy);
-
- return info;
+ ShotInfo *info = NULL;
+ static Atom atom_capture = None;
+ XErrorHandler old_handler = NULL;
+
+ if (shot_info) {
+ if (shot_info->width == width && shot_info->height == height)
+ return shot_info;
+
+ _deinit_screen_shot(shot_info);
+ }
+
+ info = calloc(1, sizeof(ShotInfo));
+ if (!info)
+ goto fail_init;
+
+ shot_info = info;
+
+ /* dpy */
+ info->dpy = dpy;
+ info->shminfo.shmid = -1;
+ info->shminfo.shmaddr = (void *)-1;
+
+ /* port */
+ info->port = _get_port(info->dpy, FOURCC_RGB32, DefaultRootWindow(dpy));
+ if (info->port <= 0)
+ goto fail_init;
+
+ /* width, height */
+ if (atom_capture == None)
+ atom_capture = XInternAtom(info->dpy, "_USER_WM_PORT_ATTRIBUTE_CAPTURE", False);
+
+ XSync(info->dpy, 0);
+ x_error_caught = False;
+ old_handler = XSetErrorHandler(_screen_shot_x_error_handle);
+
+ XvSetPortAttribute(info->dpy, info->port, atom_capture, 1);
+
+ XSync(info->dpy, 0);
+
+ x_error_caught = False;
+ XSetErrorHandler(old_handler);
+
+ XvQueryBestSize(info->dpy, info->port, 0, 0, 0, width, height, &width, &height);
+ if (width <= 0 || height <= 0)
+ goto fail_init;
+ info->width = width;
+ info->height = height;
+
+ /* pixmap */
+ info->pixmap = XCreatePixmap(info->dpy,
+ DefaultRootWindow(info->dpy),
+ width, height,
+ DefaultDepth(info->dpy, DefaultScreen(info->dpy)));
+ if (info->pixmap <= 0) {
+ fprintf(stderr, "[UTILX] fail : create pixmap. \n");
+ goto fail_init;
+ }
+
+ /* gc */
+ info->gc = XCreateGC(info->dpy, info->pixmap, 0, 0);
+ if (info->gc == NULL) {
+ fprintf(stderr, "[UTILX] fail : create gc. \n");
+ goto fail_init;
+ }
+
+ XSetForeground(info->dpy, info->gc, 0xFF000000);
+ XFillRectangle(info->dpy, info->pixmap, info->gc, 0, 0, width, height);
+
+ if (!_init_screen_shot_damage(info))
+ goto fail_init;
+
+ if (!_init_screen_shot_shm(info))
+ goto fail_init;
+ else
+ fprintf(stderr, "[UTILX] XShm success. !!\n");
+
+ if (!info->virtual) {
+ fprintf(stderr, "[UTILX] fail : get virtual \n");
+ goto fail_init;
+ }
+
+ XFlush(info->dpy);
+
+ return info;
fail_init:
- _deinit_screen_shot (info);
- return NULL;
+ _deinit_screen_shot(info);
+ return NULL;
}
API void*
-utilx_create_screen_shot (Display* dpy, int width, int height)
+utilx_create_screen_shot(Display *dpy, int width, int height)
{
- ShotInfo *info;
- XEvent ev = {0,};
- XErrorHandler old_handler = NULL;
-
- if (dpy == NULL)
- {
- fprintf (stderr, "[UTILX] invalid display(%p) \n", dpy);
- return NULL;
- }
-
- if (width <= 0 || height <= 0)
- {
- fprintf (stderr, "[UTILX] invalid size(%dx%d) \n", width, height);
- return NULL;
- }
-
- XSync (dpy, 0);
-
- info = _init_screen_shot (dpy, width, height);
-
- if (!info)
- {
- fprintf (stderr, "[UTILX] fail : initialize screenshot. \n");
- return NULL;
- }
-
- XSync (dpy, 0);
-
- x_error_caught = False;
- old_handler = XSetErrorHandler (_screen_shot_x_error_handle);
-
- XvPutStill (info->dpy, info->port, info->pixmap, info->gc,
- 0, 0, info->width, info->height,
- 0, 0, info->width, info->height);
-
- XSync (dpy, 0);
-
- if (x_error_caught)
- {
- x_error_caught = False;
- XSetErrorHandler (old_handler);
- return NULL;
- }
-
- x_error_caught = False;
- XSetErrorHandler (old_handler);
-
- if (XPending (info->dpy))
- XNextEvent (info->dpy, &ev);
- else
- {
- int fd = ConnectionNumber (info->dpy);
- fd_set mask;
- struct timeval tv;
- int ret;
-
- FD_ZERO (&mask);
- FD_SET (fd, &mask);
-
- tv.tv_usec = 0;
- tv.tv_sec = TIMEOUT_CAPTURE;
-
- ret = select (fd + 1, &mask, 0, 0, &tv);
- if (ret < 0)
- fprintf (stderr, "[UTILX] fail: select.\n");
- else if (ret == 0)
- fprintf (stderr, "[UTILX] timeout(%d sec)!\n", TIMEOUT_CAPTURE);
- else if (XPending (info->dpy))
- XNextEvent (info->dpy, &ev);
- else
- fprintf (stderr, "[UTILX] fail: not passed a event!\n");
- }
-
- if (ev.type == (info->damage_base + XDamageNotify))
- {
- XDamageNotifyEvent *damage_ev = (XDamageNotifyEvent *)&ev;
- if (damage_ev->drawable == info->pixmap)
- {
- XShmGetImage (info->dpy, info->pixmap, info->image, 0, 0, AllPlanes);
- XDamageSubtract (info->dpy, info->damage, None, None );
- return info->virtual;
- }
-
- XDamageSubtract (info->dpy, info->damage, None, None );
- }
-
- utilx_release_screen_shot ();
-
- return NULL;
+ ShotInfo *info;
+ XEvent ev = {0,};
+ XErrorHandler old_handler = NULL;
+
+ TTRACE_VIDEO_BEGIN("XORG:UTILX:CREATE_SCREEN_SHOT");
+
+ if (dpy == NULL) {
+ fprintf(stderr, "[UTILX] invalid display(%p) \n", dpy);
+ goto fail;
+ }
+
+ if (width <= 0 || height <= 0) {
+ fprintf(stderr, "[UTILX] invalid size(%dx%d) \n", width, height);
+ goto fail;
+ }
+
+ XSync(dpy, 0);
+
+ info = _init_screen_shot(dpy, width, height);
+
+ if (!info) {
+ fprintf(stderr, "[UTILX] fail : initialize screenshot. \n");
+ goto fail;
+ }
+
+ XSync(dpy, 0);
+
+ x_error_caught = False;
+ old_handler = XSetErrorHandler(_screen_shot_x_error_handle);
+
+ XvPutStill(info->dpy, info->port, info->pixmap, info->gc,
+ 0, 0, info->width, info->height,
+ 0, 0, info->width, info->height);
+
+ XSync(dpy, 0);
+
+ if (x_error_caught) {
+ x_error_caught = False;
+ XSetErrorHandler(old_handler);
+ goto fail;
+ }
+
+ x_error_caught = False;
+ XSetErrorHandler(old_handler);
+
+ if (XPending(info->dpy))
+ XNextEvent(info->dpy, &ev);
+ else {
+ int fd = ConnectionNumber(info->dpy);
+ fd_set mask;
+ struct timeval tv;
+ int ret;
+
+ FD_ZERO(&mask);
+ FD_SET(fd, &mask);
+
+ tv.tv_usec = 0;
+ tv.tv_sec = TIMEOUT_CAPTURE;
+
+ ret = select(fd + 1, &mask, 0, 0, &tv);
+ if (ret < 0)
+ fprintf(stderr, "[UTILX] fail: select.\n");
+ else if (ret == 0)
+ fprintf(stderr, "[UTILX] timeout(%d sec)!\n", TIMEOUT_CAPTURE);
+ else if (XPending(info->dpy))
+ XNextEvent(info->dpy, &ev);
+ else
+ fprintf(stderr, "[UTILX] fail: not passed a event!\n");
+ }
+
+ if (ev.type == (info->damage_base + XDamageNotify)) {
+ XDamageNotifyEvent *damage_ev = (XDamageNotifyEvent *)&ev;
+ if (damage_ev->drawable == info->pixmap) {
+ XShmGetImage(info->dpy, info->pixmap, info->image, 0, 0, AllPlanes);
+ XDamageSubtract(info->dpy, info->damage, None, None);
+
+ TTRACE_VIDEO_END();
+ return info->virtual;
+ }
+
+ XDamageSubtract(info->dpy, info->damage, None, None);
+ }
+
+ utilx_release_screen_shot();
+fail:
+ TTRACE_VIDEO_END();
+ return NULL;
}
static ShotInfo*
-_init_video_screen_shot (Display* dpy, unsigned int width, unsigned int height, Window win)
+_init_video_screen_shot(Display *dpy, unsigned int width, unsigned int height, Window win)
{
- ShotInfo *info = NULL;
- static Atom atom_capture = None;
- static Atom atom_capture_on_win = None;
- XErrorHandler old_handler = NULL;
-
- if (shot_info)
- {
- if (shot_info->width == width && shot_info->height == height)
- return shot_info;
-
- _deinit_screen_shot (shot_info);
- }
-
- info = calloc (1, sizeof (ShotInfo));
- if (!info)
- goto fail_init;
-
- shot_info = info;
-
- /* dpy */
- info->dpy = dpy;
- info->shminfo.shmid = -1;
- info->shminfo.shmaddr = (void*)-1;
-
- /* port */
- info->port = _get_port (info->dpy, FOURCC_RGB32, win);
- if (info->port <= 0)
- goto fail_init;
-
- /* width, height */
- if (atom_capture == None)
- atom_capture = XInternAtom (info->dpy, "_USER_WM_PORT_ATTRIBUTE_CAPTURE", False);
-
- if (atom_capture_on_win == None)
- atom_capture_on_win = XInternAtom (info->dpy, "_USER_WM_PORT_ATTRIBUTE_CAPTURE_ON_WINDOW", False);
-
- XSync (info->dpy, 0);
- x_error_caught = False;
- old_handler = XSetErrorHandler (_screen_shot_x_error_handle);
-
- XvSetPortAttribute (info->dpy, info->port, atom_capture, 3);
- XvSetPortAttribute (info->dpy, info->port, atom_capture_on_win, 1);
-
- XSync (info->dpy, 0);
-
- x_error_caught = False;
- XSetErrorHandler (old_handler);
-
- XvQueryBestSize (info->dpy, info->port, 0, 0, 0, width, height, &width, &height);
- if (width <= 0 || height <= 0)
- goto fail_init;
- info->width = width;
- info->height = height;
-
- /* pixmap */
- info->pixmap = XCreatePixmap (info->dpy,
- win,
- width, height,
- DefaultDepth (info->dpy, DefaultScreen (info->dpy)));
- if (info->pixmap <= 0)
- {
- fprintf (stderr, "[UTILX] fail : create pixmap. \n");
- goto fail_init;
- }
-
- /* gc */
- info->gc = XCreateGC (info->dpy, info->pixmap, 0, 0);
- if (info->gc == NULL)
- {
- fprintf (stderr, "[UTILX] fail : create gc. \n");
- goto fail_init;
- }
-
- XSetForeground (info->dpy, info->gc, 0xFF000000);
- XFillRectangle (info->dpy, info->pixmap, info->gc, 0, 0, width, height);
-
- if (!_init_screen_shot_damage (info))
- goto fail_init;
-
- if (!_init_screen_shot_shm (info))
- goto fail_init;
- else
- fprintf (stderr, "[UTILX] XShm success. !!\n");
-
- if (!info->virtual)
- {
- fprintf (stderr, "[UTILX] fail : get virtual \n");
- goto fail_init;
- }
-
- XFlush (info->dpy);
-
- return info;
+ ShotInfo *info = NULL;
+ static Atom atom_capture = None;
+ static Atom atom_capture_on_win = None;
+ XErrorHandler old_handler = NULL;
+
+ if (shot_info) {
+ if (shot_info->width == width && shot_info->height == height)
+ return shot_info;
+
+ _deinit_screen_shot(shot_info);
+ }
+
+ info = calloc(1, sizeof(ShotInfo));
+ if (!info)
+ goto fail_init;
+
+ shot_info = info;
+
+ /* dpy */
+ info->dpy = dpy;
+ info->shminfo.shmid = -1;
+ info->shminfo.shmaddr = (void *)-1;
+
+ /* port */
+ info->port = _get_port(info->dpy, FOURCC_RGB32, win);
+ if (info->port <= 0)
+ goto fail_init;
+
+ /* width, height */
+ if (atom_capture == None)
+ atom_capture = XInternAtom(info->dpy, "_USER_WM_PORT_ATTRIBUTE_CAPTURE", False);
+
+ if (atom_capture_on_win == None)
+ atom_capture_on_win = XInternAtom(info->dpy, "_USER_WM_PORT_ATTRIBUTE_CAPTURE_ON_WINDOW", False);
+
+ XSync(info->dpy, 0);
+ x_error_caught = False;
+ old_handler = XSetErrorHandler(_screen_shot_x_error_handle);
+
+ XvSetPortAttribute(info->dpy, info->port, atom_capture, 3);
+ XvSetPortAttribute(info->dpy, info->port, atom_capture_on_win, 1);
+
+ XSync(info->dpy, 0);
+
+ x_error_caught = False;
+ XSetErrorHandler(old_handler);
+
+ XvQueryBestSize(info->dpy, info->port, 0, 0, 0, width, height, &width, &height);
+ if (width <= 0 || height <= 0)
+ goto fail_init;
+ info->width = width;
+ info->height = height;
+
+ /* pixmap */
+ info->pixmap = XCreatePixmap(info->dpy,
+ win,
+ width, height,
+ DefaultDepth(info->dpy, DefaultScreen(info->dpy)));
+ if (info->pixmap <= 0) {
+ fprintf(stderr, "[UTILX] fail : create pixmap. \n");
+ goto fail_init;
+ }
+
+ /* gc */
+ info->gc = XCreateGC(info->dpy, info->pixmap, 0, 0);
+ if (info->gc == NULL) {
+ fprintf(stderr, "[UTILX] fail : create gc. \n");
+ goto fail_init;
+ }
+
+ XSetForeground(info->dpy, info->gc, 0xFF000000);
+ XFillRectangle(info->dpy, info->pixmap, info->gc, 0, 0, width, height);
+
+ if (!_init_screen_shot_damage(info))
+ goto fail_init;
+
+ if (!_init_screen_shot_shm(info))
+ goto fail_init;
+ else
+ fprintf(stderr, "[UTILX] XShm success. !!\n");
+
+ if (!info->virtual) {
+ fprintf(stderr, "[UTILX] fail : get virtual \n");
+ goto fail_init;
+ }
+
+ XFlush(info->dpy);
+
+ return info;
fail_init:
- _deinit_screen_shot (info);
- return NULL;
+ _deinit_screen_shot(info);
+ return NULL;
}
Bool
predicate_proc(Display *dpy, XEvent *event, char *arg)
{
- ShotInfo *info = (ShotInfo *)arg;
+ ShotInfo *info = (ShotInfo *)arg;
- if(event->type == (info->damage_base + XDamageNotify))
- return True;
- else
- return False;
+ if (event->type == (info->damage_base + XDamageNotify))
+ return True;
+ else
+ return False;
}
+
API void*
-utilx_create_video_screen_shot (Display* dpy, Window win, int width, int height)
+utilx_create_video_screen_shot(Display *dpy, Window win, int width, int height)
{
- ShotInfo *info;
- XEvent ev = {0,};
- XErrorHandler old_handler = NULL;
- unsigned int pixmap = 0;
-
- if (dpy == NULL)
- {
- fprintf (stderr, "[UTILX] invalid display(%p) \n", dpy);
- return NULL;
- }
-
- if (width <= 0 || height <= 0)
- {
- fprintf (stderr, "[UTILX] invalid size(%dx%d) \n", width, height);
- return NULL;
- }
-
- XSync (dpy, 0);
-
- info = _init_video_screen_shot (dpy, width, height, win);
-
- if (!info)
- {
- fprintf (stderr, "[UTILX] fail : initialize screenshot. \n");
- return NULL;
- }
-
- if (!_atom_window_pixman)
- {
- _atom_window_pixman = XInternAtom (dpy, "_UTIL_WINDOW_PIXMAP_HANDLE", False);
- if (!_atom_window_pixman)
- {
- fprintf (stderr, "[UTILX] Error.. Cannot create _UTIL_WINDOW_PIXMAP_HANDLE atom.. %s (%d)\n", __func__, __LINE__);
- return 0;
- }
- }
-
- x_error_caught = False;
- old_handler = XSetErrorHandler (_screen_shot_x_error_handle);
-
- pixmap = (unsigned int)info->pixmap;
- XChangeProperty (dpy, win, _atom_window_pixman, XA_PIXMAP, 32, PropModeReplace, (unsigned char *)((unsigned int *)&pixmap), 1);
- XSync (dpy, 0);
-
- if (x_error_caught)
- {
- x_error_caught = False;
- XSetErrorHandler (old_handler);
- return NULL;
- }
-
- XvPutStill (info->dpy, info->port, info->pixmap, info->gc,
- 0, 0, info->width, info->height,
- 0, 0, info->width, info->height);
- XSync (dpy, 0);
-
- if (x_error_caught)
- {
- x_error_caught = False;
- XSetErrorHandler (old_handler);
- return NULL;
- }
-
- XDeleteProperty(info->dpy, win, _atom_window_pixman);
- _atom_window_pixman = None;
- XSync (dpy, 0);
-
- x_error_caught = False;
- XSetErrorHandler (old_handler);
-
- XIfEvent(info->dpy, &ev, predicate_proc, info);
- if (ev.type == (info->damage_base + XDamageNotify))
- {
- XDamageNotifyEvent *damage_ev = (XDamageNotifyEvent *)&ev;
- if (damage_ev->drawable == info->pixmap)
- {
- XShmGetImage (info->dpy, info->pixmap, info->image, 0, 0, AllPlanes);
- XDamageSubtract (info->dpy, info->damage, None, None );
- return info->virtual;
- }
-
- XDamageSubtract (info->dpy, info->damage, None, None );
- }
-
- utilx_release_screen_shot ();
-
- return NULL;
+ ShotInfo *info;
+ XEvent ev = {0,};
+ XErrorHandler old_handler = NULL;
+ unsigned int pixmap = 0;
+
+ TTRACE_VIDEO_BEGIN("XORG:UTILX:CREATE_VIDEO_SCREEN_SHOT");
+
+
+ if (dpy == NULL) {
+ fprintf(stderr, "[UTILX] invalid display(%p) \n", dpy);
+ goto fail;
+ }
+
+ if (width <= 0 || height <= 0) {
+ fprintf(stderr, "[UTILX] invalid size(%dx%d) \n", width, height);
+ goto fail;
+ }
+
+ XSync(dpy, 0);
+
+ info = _init_video_screen_shot(dpy, width, height, win);
+
+ if (!info) {
+ fprintf(stderr, "[UTILX] fail : initialize screenshot. \n");
+ goto fail;
+ }
+
+ if (!_atom_window_pixman) {
+ _atom_window_pixman = XInternAtom(dpy, "_UTIL_WINDOW_PIXMAP_HANDLE", False);
+ if (!_atom_window_pixman) {
+ fprintf(stderr, "[UTILX] Error.. Cannot create _UTIL_WINDOW_PIXMAP_HANDLE atom.. %s (%d)\n", __func__, __LINE__);
+ TTRACE_VIDEO_END();
+ return 0;
+ }
+ }
+
+ x_error_caught = False;
+ old_handler = XSetErrorHandler(_screen_shot_x_error_handle);
+
+ pixmap = (unsigned int)info->pixmap;
+ XChangeProperty(dpy, win, _atom_window_pixman, XA_PIXMAP, 32, PropModeReplace, (unsigned char *)((unsigned int *)&pixmap), 1);
+ XSync(dpy, 0);
+
+ if (x_error_caught) {
+ x_error_caught = False;
+ XSetErrorHandler(old_handler);
+ goto fail;
+ }
+
+ XvPutStill(info->dpy, info->port, info->pixmap, info->gc,
+ 0, 0, info->width, info->height,
+ 0, 0, info->width, info->height);
+ XSync(dpy, 0);
+
+ if (x_error_caught) {
+ x_error_caught = False;
+ XSetErrorHandler(old_handler);
+ goto fail;
+ }
+
+ XDeleteProperty(info->dpy, win, _atom_window_pixman);
+ _atom_window_pixman = None;
+ XSync(dpy, 0);
+
+ x_error_caught = False;
+ XSetErrorHandler(old_handler);
+
+ XIfEvent(info->dpy, &ev, predicate_proc, info);
+ if (ev.type == (info->damage_base + XDamageNotify)) {
+ XDamageNotifyEvent *damage_ev = (XDamageNotifyEvent *)&ev;
+ if (damage_ev->drawable == info->pixmap) {
+ XShmGetImage(info->dpy, info->pixmap, info->image, 0, 0, AllPlanes);
+ XDamageSubtract(info->dpy, info->damage, None, None);
+
+ TTRACE_VIDEO_END();
+ return info->virtual;
+ }
+
+ XDamageSubtract(info->dpy, info->damage, None, None);
+ }
+
+ utilx_release_screen_shot();
+fail:
+ TTRACE_VIDEO_END();
+ return NULL;
}
API void
-utilx_release_screen_shot (void)
+utilx_release_screen_shot(void)
{
- _deinit_screen_shot (shot_info);
+ TTRACE_VIDEO_BEGIN("XORG:UTILX:RELEASE_SCREEN_SHOT");
+ _deinit_screen_shot(shot_info);
+ TTRACE_VIDEO_END();
}
#define XRR_PROPERTY_FB_VISIBLE "XRR_PROPERTY_FB_VISIBLE"
#define XRR_PROPERTY_VIDEO_OFFSET "XRR_PROPERTY_VIDEO_OFFSET"
static Bool
-_utilx_xrr_set_property (Display* dpy, Atom atom, unsigned char *buf, int buf_len, unsigned char **get)
+_utilx_xrr_set_property(Display *dpy, Atom atom, unsigned char *buf, int buf_len, unsigned char **get)
{
- Window root = None;
- XRRScreenResources *res = NULL;
- RROutput rr_output = None;
- int i;
-
- root = XRootWindow (dpy, 0);
- if (root == None)
- {
- fprintf (stderr, "[UTILX] Warning : Root window is None.. %s (%d)\n", __func__, __LINE__);
- return False;
- }
-
- res = XRRGetScreenResources (dpy, root);
- if (res == NULL || res->noutput == 0)
- {
- fprintf (stderr, "[UTILX] Warning : ScreenResources is None.. %s (%d)\n", __func__, __LINE__);
- return False;
- }
-
- for (i = 0; i < res->noutput; i++)
- {
- XRROutputInfo *output_info = XRRGetOutputInfo (dpy, res, res->outputs[i]);
- if (output_info)
- {
- if (!strcmp (output_info->name, "LVDS1"))
- {
- rr_output = res->outputs[i];
- XRRFreeOutputInfo(output_info);
- break;
- }
- XRRFreeOutputInfo(output_info);
- }
- }
-
- if (rr_output == None)
- {
- fprintf (stderr, "[UTILX] Warning : output is None.. %s (%d)\n", __func__, __LINE__);
- XRRFreeScreenResources (res);
- return False;
- }
-
- XRRChangeOutputProperty (dpy, rr_output, atom,
- XA_CARDINAL, 8, PropModeReplace, buf, buf_len);
-
- if (get)
- {
- Atom actual_type;
- int actual_format;
- unsigned long nitems, bytes_after;
-
- XRRGetOutputProperty (dpy, rr_output, atom,
- 0, 1024L,
- True, False, XA_CARDINAL,
- &actual_type, &actual_format,
- &nitems, &bytes_after,
- get);
- }
-
- XSync (dpy, 0);
-
- XRRFreeScreenResources (res);
-
- return True;
+ Window root = None;
+ XRRScreenResources *res = NULL;
+ RROutput rr_output = None;
+ int i;
+
+ root = XRootWindow(dpy, 0);
+ if (root == None) {
+ fprintf(stderr, "[UTILX] Warning : Root window is None.. %s (%d)\n", __func__, __LINE__);
+ return False;
+ }
+
+ res = XRRGetScreenResources(dpy, root);
+ if (res == NULL || res->noutput == 0) {
+ fprintf(stderr, "[UTILX] Warning : ScreenResources is None.. %s (%d)\n", __func__, __LINE__);
+ return False;
+ }
+
+ for (i = 0; i < res->noutput; i++) {
+ XRROutputInfo *output_info = XRRGetOutputInfo(dpy, res, res->outputs[i]);
+ if (output_info) {
+ if (!strncmp(output_info->name, "LVDS1", sizeof("LVDS1"))) {
+ rr_output = res->outputs[i];
+ XRRFreeOutputInfo(output_info);
+ break;
+ }
+ XRRFreeOutputInfo(output_info);
+ }
+ }
+
+ if (rr_output == None) {
+ fprintf(stderr, "[UTILX] Warning : output is None.. %s (%d)\n", __func__, __LINE__);
+ XRRFreeScreenResources(res);
+ return False;
+ }
+
+ XRRChangeOutputProperty(dpy, rr_output, atom,
+ XA_CARDINAL, 8, PropModeReplace, buf, buf_len);
+
+ if (get) {
+ Atom actual_type;
+ int actual_format;
+ unsigned long nitems, bytes_after;
+
+ XRRGetOutputProperty(dpy, rr_output, atom,
+ 0, 1024L,
+ True, False, XA_CARDINAL,
+ &actual_type, &actual_format,
+ &nitems, &bytes_after,
+ get);
+ }
+
+ XSync(dpy, 0);
+
+ XRRFreeScreenResources(res);
+
+ return True;
}
API void
-utilx_set_fb_visible (Display* dpy, Utilx_Fb_Type fb, Bool visible)
+utilx_set_fb_visible(Display *dpy, Utilx_Fb_Type fb, Bool visible)
{
- static Atom property = None;
- char buf[8192] = {0,};
- char *p = buf;
- int buf_len = 0;
-
- if (!dpy)
- {
- fprintf (stderr, "[UTILX] invalid display(%p).. %s (%d)\n", dpy, __func__, __LINE__);
- return;
- }
-
- if (fb <= UTILX_FB_TYPE_NONE || fb > UTILX_FB_TYPE_OVERLAY)
- {
- fprintf (stderr, "[UTILX] Error.. Invald fb(%d).. %s (%d)\n", fb, __func__, __LINE__);
- return;
- }
-
- p += sprintf (p, "%d:", 0);
- p += sprintf (p, "%d", fb + 2);
- p += sprintf (p, ":%d", (visible > 0)? 1 : 0);
-
- *p = '\0';
- p++;
-
- buf_len = p - buf;
-
- if (property == None)
- property = XInternAtom (dpy, XRR_PROPERTY_FB_VISIBLE, False);
-
- if (property == None)
- {
- fprintf (stderr, "[UTILX] Warning : FB_VISIBLE property is None.. %s (%d)\n", __func__, __LINE__);
- return;
- }
-
- if (!_utilx_xrr_set_property (dpy, property, (unsigned char*)buf, buf_len, NULL))
- {
- fprintf (stderr, "[UTILX] Warning : set_property failed.. %s (%d)\n", __func__, __LINE__);
- return;
- }
+ static Atom property = None;
+ char buf[8192] = {0,};
+ char *p = buf;
+ int buf_len = 0;
+
+ TTRACE_VIDEO_BEGIN("XORG:UTILX:SET_FB_VISIBLE");
+
+ if (!dpy) {
+ fprintf(stderr, "[UTILX] invalid display(%p).. %s (%d)\n", dpy, __func__, __LINE__);
+ goto out;
+ }
+
+ if (fb <= UTILX_FB_TYPE_NONE || fb > UTILX_FB_TYPE_OVERLAY) {
+ fprintf(stderr, "[UTILX] Error.. Invald fb(%d).. %s (%d)\n", fb, __func__, __LINE__);
+ goto out;
+ }
+
+ p += snprintf(p, strlen("0") + 1, "%d:", 0);
+ p += snprintf(p, strlen("0") + 1, "%d", fb + 2);
+ p += snprintf(p, strlen("0") + 2, ":%d", (visible > 0) ? 1 : 0);
+
+ *p = '\0';
+ p++;
+
+ buf_len = p - buf;
+
+ if (property == None)
+ property = XInternAtom(dpy, XRR_PROPERTY_FB_VISIBLE, False);
+
+ if (property == None) {
+ fprintf(stderr, "[UTILX] Warning : FB_VISIBLE property is None.. %s (%d)\n", __func__, __LINE__);
+ goto out;
+ }
+
+ if (!_utilx_xrr_set_property(dpy, property, (unsigned char *)buf, buf_len, NULL)) {
+ fprintf(stderr, "[UTILX] Warning : set_property failed.. %s (%d)\n", __func__, __LINE__);
+ goto out;
+ }
+out:
+ TTRACE_VIDEO_END();
+ return;
}
API Bool
-utilx_get_fb_visible (Display* dpy, Utilx_Fb_Type fb)
+utilx_get_fb_visible(Display *dpy, Utilx_Fb_Type fb)
{
- static Atom property = None;
- char buf[32] = {0,};
- char *p = buf;
- int buf_len = 0;
- unsigned char *prop = NULL;
- Bool visible = False;
-
- if (!dpy)
- {
- fprintf (stderr, "[UTILX] invalid display(%p).. %s (%d)\n", dpy, __func__, __LINE__);
- return False;
- }
-
- if (fb <= UTILX_FB_TYPE_NONE || fb > UTILX_FB_TYPE_OVERLAY)
- {
- fprintf (stderr, "[UTILX] Error.. Invald fb(%d).. %s (%d)\n", fb, __func__, __LINE__);
- return False;
- }
-
- p += sprintf (p, "%d:", 0);
- p += sprintf (p, "%d", fb + 2);
-
- *p = '\0';
- p++;
-
- buf_len = p - buf;
-
- if (property == None)
- property = XInternAtom (dpy, XRR_PROPERTY_FB_VISIBLE, False);
-
- if (property == None)
- {
- fprintf (stderr, "[UTILX] Warning : FB_VISIBLE property is None.. %s (%d)\n", __func__, __LINE__);
- return False;
- }
-
- if (!_utilx_xrr_set_property (dpy, property, (unsigned char*)buf, buf_len, &prop))
- {
- fprintf (stderr, "[UTILX] Warning : set_property failed.. %s (%d)\n", __func__, __LINE__);
- return False;
- }
-
- if (prop)
- visible = atoi((char*)prop);
-
- return visible;
+ static Atom property = None;
+ char buf[32] = {0,};
+ char *p = buf;
+ int buf_len = 0;
+ unsigned char *prop = NULL;
+ Bool visible = False;
+
+ TTRACE_VIDEO_BEGIN("XORG:UTILX:GET_FB_VISIBLE");
+
+ if (!dpy) {
+ fprintf(stderr, "[UTILX] invalid display(%p).. %s (%d)\n", dpy, __func__, __LINE__);
+ goto fail;
+ }
+
+ if (fb <= UTILX_FB_TYPE_NONE || fb > UTILX_FB_TYPE_OVERLAY) {
+ fprintf(stderr, "[UTILX] Error.. Invald fb(%d).. %s (%d)\n", fb, __func__, __LINE__);
+ goto fail;
+ }
+
+ p += snprintf(p, strlen("0") + 1, "%d:", 0);
+ p += snprintf(p, strlen("0") + 1, "%d", fb + 2);
+
+ *p = '\0';
+ p++;
+
+ buf_len = p - buf;
+
+ if (property == None)
+ property = XInternAtom(dpy, XRR_PROPERTY_FB_VISIBLE, False);
+
+ if (property == None) {
+ fprintf(stderr, "[UTILX] Warning : FB_VISIBLE property is None.. %s (%d)\n", __func__, __LINE__);
+ goto fail;
+ }
+
+ if (!_utilx_xrr_set_property(dpy, property, (unsigned char *)buf, buf_len, &prop)) {
+ fprintf(stderr, "[UTILX] Warning : set_property failed.. %s (%d)\n", __func__, __LINE__);
+ goto fail;
+ }
+
+ if (prop)
+ visible = atoi((char *)prop);
+
+ TTRACE_VIDEO_END();
+ return visible;
+fail:
+ TTRACE_VIDEO_END();
+ return False;
}