Stubbing the functions to work with wayland 93/2693/1
authorJimmy Huang <jimmy.huang@intel.com>
Thu, 17 Jan 2013 20:48:26 +0000 (12:48 -0800)
committerJimmy Huang <jimmy.huang@intel.com>
Thu, 17 Jan 2013 20:48:26 +0000 (12:48 -0800)
Signed-off-by: Jimmy Huang <jimmy.huang@intel.com>
x11.c

diff --git a/x11.c b/x11.c
index 7367473..75d682e 100644 (file)
--- a/x11.c
+++ b/x11.c
@@ -93,7 +93,19 @@ API void utilx_set_system_notification_level (Display* dpy, Window win, Utilx_No
        UTILX_TRACE ("[UTILX] utilx_set_system_notification_level... win = %x, level = %d\n", win, level);
 
        int noti_level;
+       char *display = NULL;
 
+       display = getenv("DISPLAY");
+
+       if (!display)
+       {
+               /* WAYLAND specific */
+               //fprintf(stdout, "[UTILX] %s\n", __func__);
+               //fprintf(stdout, "[UTILX] Running in wayland.. NoOp\n");
+               return;
+       }
+
+       /* X11 specific */
        if (dpy == NULL)
        {
                fprintf (stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__);
@@ -141,9 +153,21 @@ API Utilx_Notification_Level utilx_get_system_notification_level (Display* dpy,
        Utilx_Notification_Level noti_level;
        unsigned int level;
        int ret;
+       char *display = NULL;
 
        noti_level = UTILX_NOTIFICATION_LEVEL_LOW;
+       display = getenv("DISPLAY");
+
+       /* check if backend is WAYLAND or X11 */
+       if (!display)
+       {
+               /* WAYLAND specific */
+               //fprintf(stdout, "[UTILX] %s\n", __func__);
+               //fprintf(stdout, "[UTILX] Running in wayland.. return UTILX_NOTIFICATION_LEVEL_LOW\n");
+               return noti_level;
+       }
 
+       /* X11 specific */
        if (dpy == NULL)
        {
                fprintf (stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__);
@@ -232,6 +256,19 @@ API void utilx_enable_indicator (Display* dpy, Window win, int enable)
 {
        UTILX_TRACE ("[UTILX] utilx_indicator_set_visible_state... win = %x, show_state = %d\n", win, enable);
 
+       char *display = NULL;
+
+       display = getenv("DISPLAY");
+
+       if (!display)
+       {
+               /* WAYLAND specific */
+               //fprintf(stdout, "[UTILX] %s\n", __func__);
+               //fprintf(stdout, "[UTILX] Running in wayland.. NoOp\n");
+               return;
+       }
+
+       /* X11 specific */
        if (dpy == NULL)
        {
                fprintf (stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__);
@@ -263,7 +300,19 @@ API int utilx_get_indicator_state (Display* dpy, Window win)
 
        int ret;
        Atom state;
+       char *display = NULL;
+
+       display = getenv("DISPLAY");
+
+       if (!display)
+       {
+               /* WAYLAND specific */
+               //fprintf(stdout, "[UTILX] %s\n", __func__);
+               //fprintf(stdout, "[UTILX] Running in wayland.. return 0\n");
+               return 0;
+       }
 
+       /* X11 specific */
        if (dpy == NULL)
        {
                fprintf (stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__);
@@ -631,7 +680,19 @@ API int utilx_grab_key (Display* disp, Window win, const char* key, int grab_mod
        int keycode = 0;
        KeySym keysym;
        errno = EINVAL;
+       char *display = NULL;
+
+       display = getenv("DISPLAY");
+
+       if (!display)
+       {
+               /* WAYLAND specific */
+               //fprintf(stdout, "[UTILX] %s\n", __func__);
+               //fprintf(stdout, "[UTILX] Running in wayland.. return 0\n");
+               return 0;
+       }
 
+       /* X11 specific */
        if( NULL == disp )
        {
                fprintf(stderr, "[%s] Display is NULL\n", __FUNCTION__);
@@ -726,7 +787,19 @@ API int utilx_ungrab_key (Display* disp, Window win, const char* key)
        KeySym keysym;
        int ret = -1;
        errno = EINVAL;
+       char *display = NULL;
 
+       display = getenv("DISPLAY");
+
+       if (!display)
+       {
+               /* WAYLAND specific */
+               //fprintf(stdout, "[UTILX] %s\n", __func__);
+               //fprintf(stdout, "[UTILX] Running in wayland.. return 0\n");
+               return 0;
+       }
+
+       /* X11 specific */
        if( NULL == disp )
        {
                fprintf(stderr, "[%s] Display is NULL\n", __FUNCTION__);
@@ -810,7 +883,19 @@ API Utilx_Key_Status utilx_get_key_status(Display* dpy, char *key_name)
        unsigned char keymap[32];
        static unsigned int masktable[8] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
        Utilx_Key_Status status = UTILX_KEY_STATUS_UNKNOWN;
+       char *display = NULL;
+
+       display = getenv("DISPLAY");
+
+       if (!display)
+       {
+               /* WAYLAND specific */
+               //fprintf(stdout, "[UTILX] %s\n", __func__);
+               //fprintf(stdout, "[UTILX] Running in wayland.. return UTILX_KEY_STATUS_UNKNOWN\n");
+               return status;
+       }
 
+       /* X11 specific */
        if( !strncmp(key_name, KEY_VOLUMEDOWN, LEN_KEY_VOLUMEDOWN) ||
                !strncmp(key_name, KEY_VOLUMEUP, LEN_KEY_VOLUMEUP) ||
                !strncmp(key_name, KEY_PAUSE, LEN_KEY_PAUSE) ||
@@ -847,6 +932,19 @@ API Utilx_Key_Status utilx_get_key_status(Display* dpy, char *key_name)
 
 API void utilx_set_window_effect_state(Display* dpy, Window win, int state)
 {
+       char *display = NULL;
+
+       display = getenv("DISPLAY");
+
+       if (!display)
+       {
+               /* WAYLAND specific */
+               //fprintf(stdout, "[UTILX] %s\n", __func__);
+               //fprintf(stdout, "[UTILX] Running in wayland.. NoOp\n");
+               return;
+       }
+
+       /* X11 specific */
        if ( dpy == NULL )
        {
                fprintf (stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__);
@@ -863,6 +961,19 @@ API void utilx_set_window_effect_state(Display* dpy, Window win, int state)
 API int utilx_get_window_effect_state(Display* dpy, Window win)
 {
        int state = 0;
+       char *display = NULL;
+
+       display = getenv("DISPLAY");
+
+       if (!display)
+       {
+               /* WAYLAND specific */
+               //fprintf(stdout, "[UTILX] %s\n", __func__);
+               //fprintf(stdout, "[UTILX] Running in wayland.. return 0\n");
+               return 0;
+       }
+
+       /* X11 specific */
        if( !_atom_comp_effect_state)
                _atom_comp_effect_state = XInternAtom(dpy, "_NET_CM_WINDOW_EFFECT_ENABLE",False);
        _utilx_get_window_property(dpy, win, _atom_comp_effect_state, XA_CARDINAL, (unsigned int *)&state, 1);
@@ -878,7 +989,19 @@ _utilx_string_set_window_property( Display *dpy, Window win, Atom atom, char *va
 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);
+       char *display = NULL;
+
+       display = getenv("DISPLAY");
+
+       if (!display)
+       {
+               /* WAYLAND specific */
+               //fprintf(stdout, "[UTILX] %s\n", __func__);
+               //fprintf(stdout, "[UTILX] Running in wayland.. NoOp\n");
+               return;
+       }
 
+       /* X11 specific */
        if ( dpy == NULL )
        {
                fprintf (stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__);
@@ -893,7 +1016,19 @@ API void utilx_set_fake_launch_img(Display* dpy, Window win, char *file_name)
 API void utilx_show_fake_effect( Display *dpy, Window win, char *fake_image_file )
 {
        XEvent xev;
+       char *display = NULL;
+
+       display = getenv("DISPLAY");
+
+       if (!display)
+       {
+               /* WAYLAND specific */
+               //fprintf(stdout, "[UTILX] %s\n", __func__);
+               //fprintf(stdout, "[UTILX] Running in wayland.. NoOp\n");
+               return;
+       }
 
+       /* X11 specific */
        _atom_comp_fake_launch = XInternAtom( dpy, "_E_COMP_FAKE_LAUNCH", False );
 
        if(  !_atom_comp_fake_launch )
@@ -922,14 +1057,25 @@ API void utilx_show_fake_effect( Display *dpy, Window win, char *fake_image_file
                                SubstructureRedirectMask | SubstructureNotifyMask,
                                &xev );
        XSync(dpy, 0 );
-
 }
 
 
 API void utilx_hide_fake_effect( Display *dpy, Window win)
 {
        XEvent xev;
+       char *display = NULL;
 
+       display = getenv("DISPLAY");
+
+       if (!display)
+       {
+               /* WAYLAND specific */
+               //fprintf(stdout, "[UTILX] %s\n", __func__);
+               //fprintf(stdout, "[UTILX] Running in wayland.. NoOp\n");
+               return;
+       }
+
+       /* X11 specific */
        _atom_comp_fake_launch = XInternAtom( dpy, "_E_COMP_FAKE_LAUNCH", False );
        if(  !_atom_comp_fake_launch )
        {
@@ -1043,6 +1189,19 @@ static Utilx_Effect_Style _utilx_convert_atom_to_style( Display* dpy, Atom style
 API void utilx_set_window_effect_style(Display* dpy, Window win, Utilx_Effect_Type type, Utilx_Effect_Style style)
 {
        Atom *window_effect_type_list = NULL;
+       char *display = NULL;
+
+       display = getenv("DISPLAY");
+
+       if (!display)
+       {
+               /* WAYLAND specific */
+               //fprintf(stdout, "[UTILX] %s\n", __func__);
+               //fprintf(stdout, "[UTILX] Running in wayland.. NoOp\n");
+               return;
+       }
+
+       /* X11 specific */
        if ( dpy == NULL )
        {
                fprintf (stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__);
@@ -1084,7 +1243,19 @@ API Utilx_Effect_Style utilx_get_window_effect_style(Display* dpy, Window win, U
 {
        Atom *window_effect_type_list = NULL;
        Utilx_Effect_Style style = UTILX_EFFECT_STYLE_DEFAULT;
+       char *display = NULL;
+
+       display = getenv("DISPLAY");
 
+       if (!display)
+       {
+               /* WAYLAND specific */
+               //fprintf(stdout, "[UTILX] %s\n", __func__);
+               //fprintf(stdout, "[UTILX] Running in wayland.. return UTILX_EFFECT_STYLE_DEFAULT\n");
+               return style;
+       }
+
+       /* X11 specific */
        if ( dpy == NULL )
        {
                fprintf (stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__);
@@ -1124,7 +1295,19 @@ API int utilx_set_window_opaque_state (Display* dpy, Window win, Utilx_Opaque_St
        UTILX_TRACE ("[UTILX] utilx_set_window_opaque_state... win = %x, show_state = %d\n", win, state);
 
        unsigned int is_opaque;
+       char *display = NULL;
+
+       display = getenv("DISPLAY");
 
+       if (!display)
+       {
+               /* WAYLAND specific */
+               //fprintf(stdout, "[UTILX] %s\n", __func__);
+               //fprintf(stdout, "[UTILX] Running in wayland.. return 1\n");
+               return 1;
+       }
+
+       /* X11 specific */
        if (dpy == NULL)
        {
                fprintf (stderr, "[UTILX] Error.. Invald Display.. %s (%d)\n", __func__, __LINE__);
@@ -1180,7 +1363,19 @@ utilx_set_screen_capture(Display* dpy, int enable)
 {
        Window root;
        int disable;
+       char *display = NULL;
+
+       display = getenv("DISPLAY");
 
+       if (!display)
+       {
+               /* WAYLAND specific */
+               //fprintf(stdout, "[UTILX] %s\n", __func__);
+               //fprintf(stdout, "[UTILX] Running in wayland.. return 1\n");
+               return 1;
+       }
+
+       /* X11 specific */
        if (!dpy)
        {
                fprintf (stderr, "[UTILX] Error.. dpy is NULL %s (%d)\n", __func__, __LINE__);
@@ -1202,7 +1397,19 @@ utilx_get_screen_capture(Display* dpy)
 {
        Window root;
        int disable = 0;
+       char *display = NULL;
+
+       display = getenv("DISPLAY");
 
+       if (!display)
+       {
+               /* WAYLAND specific */
+               //fprintf(stdout, "[UTILX] %s\n", __func__);
+               //fprintf(stdout, "[UTILX] Running in wayland.. return 0\n");
+               return 0;
+       }
+
+       /* X11 specific */
        if (!dpy)
        {
                fprintf (stderr, "[UTILX] Error.. dpy is NULL %s (%d)\n", __func__, __LINE__);
@@ -1221,18 +1428,56 @@ utilx_get_screen_capture(Display* dpy)
 
 API void utilx_set_window_cardinal_property(Display* dpy, Window win, Atom atom, unsigned int *value)
 {
+       char *display = NULL;
+
+       display = getenv("DISPLAY");
+
+       if (!display)
+       {
+               /* WAYLAND specific */
+               //fprintf(stdout, "[UTILX] %s\n", __func__);
+               //fprintf(stdout, "[UTILX] Running in wayland.. NoOp\n");
+               return;
+       }
+
+       /* X11 specific */
        _utilx_set_window_property(dpy, win, atom, XA_CARDINAL, value, 1);
 }
 
 API int utilx_get_window_cardinal_property (Display* dpy, Window win, Atom atom, unsigned int *value)
 {
+       char *display = NULL;
+
+       display = getenv("DISPLAY");
+
+       if (!display)
+       {
+               /* WAYLAND specific */
+               //fprintf(stdout, "[UTILX] %s\n", __func__);
+               //fprintf(stdout, "[UTILX] Running in wayland.. return -1\n");
+               return -1;
+       }
+
+       /* X11 specific */
        return _utilx_get_window_property(dpy, win, atom, XA_CARDINAL, value, 1);
 }
 
 API void utilx_show_capture_effect( Display *dpy, Window win)
 {
     XEvent xev;
+       char *display = NULL;
 
+       display = getenv("DISPLAY");
+
+       if (!display)
+       {
+               /* WAYLAND specific */
+               //fprintf(stdout, "[UTILX] %s\n", __func__);
+               //fprintf(stdout, "[UTILX] Running in wayland.. NoOp\n");
+               return;
+       }
+
+       /* X11 specific */
     _atom_comp_capture_effect = XInternAtom( dpy, "_E_COMP_CAPTURE_EFFECT", False );
     if(  !_atom_comp_capture_effect )
     {
@@ -1260,6 +1505,19 @@ API void utilx_show_capture_effect( Display *dpy, Window win)
 
 API UtilxScrnConf *utilx_scrnconf_allocate (void)
 {
+       char *display = NULL;
+
+       display = getenv("DISPLAY");
+
+       if (!display)
+       {
+               /* WAYLAND specific */
+               //fprintf(stdout, "[UTILX] %s\n", __func__);
+               //fprintf(stdout, "[UTILX] Running in wayland.. return NULL\n");
+               return NULL;
+       }
+
+       /* X11 specific */
     UtilxScrnConf *scrnconf = calloc (1, sizeof(UtilxScrnConf));
     if (!scrnconf)
     {
@@ -1296,7 +1554,19 @@ API void utilx_scrnconf_get_info (Display *dpy, UtilxScrnConf *scrnconf)
     char **list = NULL;
     int i = 0;
     int s;
+       char *display = NULL;
+
+       display = getenv("DISPLAY");
+
+       if (!display)
+       {
+               /* WAYLAND specific */
+               //fprintf(stdout, "[UTILX] %s\n", __func__);
+               //fprintf(stdout, "[UTILX] Running in wayland.. NoOp\n");
+               return NULL;
+       }
 
+       /* X11 specific */
     scrnconf_atom = XInternAtom (dpy, "_SCRNCONF_INFO", False);
 
     /* get property */
@@ -1384,7 +1654,19 @@ API int utilx_scrnconf_set_dispmode (Display *dpy, Utilx_Scrnconf_Dispmode dispm
        XEvent xev;
        Atom scrnconf_atom = None;
     UtilxScrnConf *scrnconf = NULL;
+       char *display = NULL;
 
+       display = getenv("DISPLAY");
+
+       if (!display)
+       {
+               /* WAYLAND specific */
+               //fprintf(stdout, "[UTILX] %s\n", __func__);
+               //fprintf(stdout, "[UTILX] Running in wayland.. return 0\n");
+               return 0;
+       }
+
+       /* X11 specific */
     scrnconf = utilx_scrnconf_allocate ();
     if (!scrnconf)
         return 0;
@@ -1700,7 +1982,19 @@ utilx_create_screen_shot (Display* dpy, int width, int height)
 {
     ShotInfo *info;
     XEvent ev;
+       char *display = NULL;
+
+       display = getenv("DISPLAY");
+
+       if (!display)
+       {
+               /* WAYLAND specific */
+               //fprintf(stdout, "[UTILX] %s\n", __func__);
+               //fprintf(stdout, "[UTILX] Running in wayland.. return NULL\n");
+               return NULL;
+       }
 
+       /* X11 specific */
     if (dpy <= 0)
     {
         fprintf (stderr, "[UTILX] invalid display(%p) \n", dpy);
@@ -1750,5 +2044,18 @@ utilx_create_screen_shot (Display* dpy, int width, int height)
 API void
 utilx_release_screen_shot (void)
 {
+       char *display = NULL;
+
+       display = getenv("DISPLAY");
+
+       if (!display)
+       {
+               /* WAYLAND specific */
+               //fprintf(stdout, "[UTILX] %s\n", __func__);
+               //fprintf(stdout, "[UTILX] Running in wayland.. NoOp\n");
+               return;
+       }
+
+       /* X11 specific */
     _deinit_screen_shot (shot_info);
 }