/**
 * Get the frame buffer sizes.
 * @param root The window (Unused).
 * @param num  The number of sizes.
 * @return     The sizes.
 *
 * Get the list of possible frame buffer sizes (at the normal
 * orientation supported by the screen associated to @p window (passed
 * to ecore_x_randr_get_screen_info_prefetch()). Each size indicates
 * both the linear physical size of the screen and the pixel size.
 *
 * To use this function, you must call before, and in order,
 * ecore_x_randr_get_screen_info_prefetch(), which sends the GetScreenInfo request,
 * then ecore_x_randr_get_screen_info_fetch(), which gets the reply.
 * @ingroup Ecore_X_RandR_Group
 */
EAPI Ecore_X_Screen_Size *
ecore_x_randr_screen_sizes_get(Ecore_X_Window root __UNUSED__,
                               int           *num)
{
#ifdef ECORE_XCB_RANDR
   xcb_randr_get_screen_info_reply_t *reply;
   xcb_randr_screen_size_t           *sizes;
   Ecore_X_Screen_Size               *ret;
   int                                n;
   int                                i;

   if (num) *num = 0;

   reply = _ecore_xcb_reply_get();
   if (!reply)
     return NULL;

   n = xcb_randr_get_screen_info_sizes_length(reply);
   ret = calloc(n, sizeof(Ecore_X_Screen_Size));
   if (!ret) return NULL;

   if (num) *num = n;
   sizes = xcb_randr_get_screen_info_sizes(reply);
   for (i = 0; i < n; i++)
     {
        ret[i].width = sizes[i].width;
        ret[i].height = sizes[i].height;
     }

   return ret;
#else
   if (num) *num = 0;
   return NULL;
#endif /* ECORE_XCB_RANDR */
}
示例#2
0
/*
 * Get X ID (array) property
 *
 * At most len items are returned in val.
 * If the property was successfully fetched the number of items stored in
 * val is returned, otherwise -1 is returned.
 * Note: Return value 0 means that the property exists but has no elements.
 */
EAPI int
ecore_x_window_prop_xid_get(Ecore_X_Window win __UNUSED__,
                            Ecore_X_Atom atom  __UNUSED__,
                            Ecore_X_Atom type  __UNUSED__,
                            Ecore_X_ID        *xids,
                            unsigned int       len)
{
   xcb_get_property_reply_t *reply;
   int num = len;

   reply = _ecore_xcb_reply_get();
   if (!reply)
      return -1;

   if (reply->type == XCB_NONE)
      num = 0;
   else if (reply->format == 32)
     {
        if (reply->value_len < len)
           num = xcb_get_property_value_length(reply);

        if (xids)
           memcpy(xids, xcb_get_property_value(reply), num);
     }

   return num;
} /* ecore_x_window_prop_xid_get */
示例#3
0
/**
 * To document.
 * @param  window  Unused.
 * @param  num_ret To document.
 * @return         To document.
 *
 * To use this function, you must call before, and in order,
 * ecore_x_window_shape_rectangles_get_prefetch(), which sends the ShapeGetRectangles request,
 * then ecore_x_window_shape_rectangles_get_fetch(), which gets the reply.
 * @ingroup Ecore_X_Shape_Group
 */
EAPI Ecore_X_Rectangle *
ecore_x_window_shape_rectangles_get(Ecore_X_Window window __UNUSED__,
                                    int                  *num_ret)
{
   Ecore_X_Rectangle *rects = NULL;
   uint32_t num = 0;
#ifdef ECORE_XCB_SHAPE
   xcb_shape_get_rectangles_reply_t *reply;

   reply = _ecore_xcb_reply_get();
   if (!reply)
     {
        if (num_ret)
           *num_ret = 0;

        return NULL;
     }

   num = reply->rectangles_len;
   rects = malloc(sizeof(Ecore_X_Rectangle) * num);
   if (rects)
      memcpy (rects,
              xcb_shape_get_rectangles_rectangles(reply),
              num * sizeof (Ecore_X_Rectangle));
   else
      num = 0;

#endif /* ECORE_XCB_SHAPE */

   if (num_ret)
      *num_ret = num;

   return rects;
} /* ecore_x_window_shape_rectangles_get */
示例#4
0
/**
 * To be documented.
 * @param window  The window (Unused).
 * @param num_ret The number of atoms.
 * @return        The returned atoms.
 *
 * FIXME: To be fixed.
 */
EAPI Ecore_X_Atom *
ecore_x_window_prop_list(Ecore_X_Window window __UNUSED__,
                         int                  *num_ret)
{
   xcb_list_properties_reply_t *reply;
   Ecore_X_Atom *atoms;

   if (num_ret)
      *num_ret = 0;

   reply = _ecore_xcb_reply_get();
   if (!reply)
      return NULL;

   atoms = (Ecore_X_Atom *)malloc(reply->atoms_len * sizeof(Ecore_X_Atom));
   if (!atoms)
      return NULL;

   memcpy(atoms,
          xcb_list_properties_atoms(reply),
          reply->atoms_len * sizeof(Ecore_X_Atom));
   if(num_ret)
      *num_ret = reply->atoms_len;

   return atoms;
} /* ecore_x_window_prop_list */
/**
 * Retrieves the width of the border of the given drawable.
 * @param  drawable Unused.
 * @return          The border width of the given drawable.
 *
 * To use this function, you must call before, and in order,
 * ecore_x_drawable_geometry_get_prefetch(), which sends the GetGeometry request,
 * then ecore_x_drawable_geometry_get_fetch(), which gets the reply.
 * @ingroup Ecore_X_Drawable_Group
 */
EAPI int
ecore_x_drawable_border_width_get(Ecore_X_Drawable drawable __UNUSED__)
{
   xcb_get_geometry_reply_t *reply;

   reply = _ecore_xcb_reply_get();
   if (!reply)
     return 0;

   return reply->border_width;
}
/**
 * Get the rotation.
 * @param root The window (Unused).
 * @return     The rotation.
 *
 * Get the rotation supported by the screen
 * associated to @p window (passed to
 * ecore_x_randr_get_screen_info_prefetch()).
 *
 * To use this function, you must call before, and in order,
 * ecore_x_randr_get_screen_info_prefetch(), which sends the GetScreenInfo request,
 * then ecore_x_randr_get_screen_info_fetch(), which gets the reply.
 * @ingroup Ecore_X_RandR_Group
 */
EAPI Ecore_X_Randr_Rotation
ecore_x_randr_screen_rotation_get(Ecore_X_Window root __UNUSED__)
{
#ifdef ECORE_XCB_RANDR
   xcb_randr_get_screen_info_reply_t *reply;

   reply = _ecore_xcb_reply_get();
   if (!reply)
     return 0;

   return reply->rotation;
#else
   return 0;
#endif /* ECORE_XCB_RANDR */
}
示例#7
0
/**
 * Get a window string property.
 * @param window The window
 * @param type The property
 *
 * Return window string property of a window. String must be free'd when done.
 *
 * To use this function, you must call before, and in order,
 * ecore_x_window_prop_string_get_prefetch(), which sends the GetProperty request,
 * then ecore_x_window_prop_string_get_fetch(), which gets the reply.
 */
EAPI char *
ecore_x_window_prop_string_get(Ecore_X_Window window __UNUSED__,
                               Ecore_X_Atom type     __UNUSED__)
{
   xcb_get_property_reply_t *reply;
   char *str = NULL;

   reply = _ecore_xcb_reply_get();
   if (!reply)
      return NULL;

   if (reply->type == ECORE_X_ATOM_UTF8_STRING)
     {
        int length;

        length = reply->value_len;
        str = (char *)malloc(length + 1);
        memcpy(str,
               xcb_get_property_value(reply),
               length);
        str[length] = '\0';
     }
   else
     {
        /* FIXME: to be done... */

/* #ifdef X_HAVE_UTF8_STRING */
/*         s = Xutf8TextPropertyToTextList(_ecore_xcb_conn, &xtp, */
/*                                         &list, &items); */
/* #else */
/*         s = XmbTextPropertyToTextList(_ecore_xcb_conn, &xtp, */
/*                                       &list, &items); */
/* #endif */
/*         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); */
     }

   return str;
} /* ecore_x_window_prop_string_get */
/**
 * Set the screen refresh rate.
 * @param root The root window.
 * @param size The size.
 * @param rate The refresh rate.
 *
 * Set the size and the refresh rate of the screen associated to
 * @p root.
 *
 * Note that that function is blocking.
 * @ingroup Ecore_X_RandR_Group
 */
EAPI int
ecore_x_randr_screen_refresh_rate_set(Ecore_X_Window              root,
                                      Ecore_X_Screen_Size         size,
                                      Ecore_X_Screen_Refresh_Rate rate)
{
#ifdef ECORE_XCB_RANDR
   xcb_randr_set_screen_config_cookie_t cookie;
   xcb_randr_set_screen_config_reply_t *reply_config;
   xcb_randr_get_screen_info_reply_t   *reply;
   xcb_randr_screen_size_iterator_t     iter;
   int                                  size_index = -1;
   int                                  i;

   reply = _ecore_xcb_reply_get();
   if (!reply)
     return 0;

   iter = xcb_randr_get_screen_info_sizes_iterator(reply);
   for (i = 0; iter.rem; xcb_randr_screen_size_next(&iter), i++)
     {
        if ((iter.data->width = size.width) &&
            (iter.data->height = size.height) &&
            (iter.data->mwidth = size.width) &&
            (iter.data->mheight = size.height))
          {
            size_index = i;
            break;
          }
     }
   if (size_index == -1) return 0;

   cookie = xcb_randr_set_screen_config_unchecked(_ecore_xcb_conn, root,
                                                  XCB_CURRENT_TIME,
                                                  reply->config_timestamp,
                                                  size_index,
                                                  XCB_RANDR_ROTATION_ROTATE_0,
                                                  rate.rate);
   reply_config = xcb_randr_set_screen_config_reply(_ecore_xcb_conn, cookie, NULL);
   if (!reply_config)
     return 0;

   free(reply_config);

   return 1;
#else
   return 0;
#endif /* ECORE_XCB_RANDR */
}
/**
 * Get the current refresh rate.
 * @param root The window (Unused).
 * @return     The current refresh rate.
 *
 * Get the current refresh rate supported by the screen associated
 * to @p window (passed to
 * ecore_x_randr_get_screen_info_prefetch()).
 *
 * To use this function, you must call before, and in order,
 * ecore_x_randr_get_screen_info_prefetch(), which sends the GetScreenInfo request,
 * then ecore_x_randr_get_screen_info_fetch(), which gets the reply.
 * @ingroup Ecore_X_RandR_Group
 */
EAPI Ecore_X_Screen_Refresh_Rate
ecore_x_randr_current_screen_refresh_rate_get(Ecore_X_Window root __UNUSED__)
{
   Ecore_X_Screen_Refresh_Rate        ret = { -1 };
#ifdef ECORE_XCB_RANDR
   xcb_randr_get_screen_info_reply_t *reply;

   reply = _ecore_xcb_reply_get();
   if (!reply)
     return ret;

   ret.rate = reply->rate;
#endif /* ECORE_XCB_RANDR */

   return ret;
}
/**
 * Return the number of screens.
 * @return The screen count.
 *
 * Return the number of screens.
 *
 * To use this function, you must call before, and in order,
 * ecore_x_xinerama_query_screens_prefetch(), which sends the XineramaQueryScreens request,
 * then ecore_x_xinerama_query_screens_fetch(), which gets the reply.
 * @ingroup Ecore_X_Xinerama_Group
 */
EAPI int
ecore_x_xinerama_screen_count_get(void)
{
   int                                 screen_count = 0;
#ifdef ECORE_XCB_XINERAMA
   xcb_xinerama_screen_info_iterator_t iter;
   xcb_xinerama_query_screens_reply_t *reply;

   reply = _ecore_xcb_reply_get();
   if (!reply) return 0;

   iter = xcb_xinerama_query_screens_screen_info_iterator(reply);
   screen_count = iter.rem;
#endif /* ECORE_XCB_XINERAMA */

   return screen_count;
}
/**
 * Get the geometry of the screen.
 * @param screen The screen (Unused).
 * @param x      The X coordinate of the screen.
 * @param y      The Y coordinate of the screen
 * @param width  The width of the screen
 * @param height The height of the screen
 * @return       1 on success, 0 otherwise.
 *
 * Get the geometry of the screen whose number is @p screen. The
 * returned values are stored in @p x, @p y, @p width and @p height.
 *
 * To use this function, you must call before, and in order,
 * ecore_x_xinerama_query_screens_prefetch(), which sends the XineramaQueryScreens request,
 * then ecore_x_xinerama_query_screens_fetch(), which gets the reply.
 * @ingroup Ecore_X_Xinerama_Group
 */
EAPI int
ecore_x_xinerama_screen_geometry_get(int  screen,
                                     int *x,
                                     int *y,
                                     int *width,
                                     int *height)
{
#ifdef ECORE_XCB_XINERAMA
   xcb_xinerama_screen_info_iterator_t iter;
   xcb_xinerama_query_screens_reply_t *reply;

   reply = _ecore_xcb_reply_get();
   if (!reply)
     {
        if (x) *x = 0;
        if (y) *y = 0;
        if (width) *width = ((xcb_screen_t *)_ecore_xcb_screen)->width_in_pixels;
        if (height) *height = ((xcb_screen_t *)_ecore_xcb_screen)->height_in_pixels;

        return 0;
     }

   iter = xcb_xinerama_query_screens_screen_info_iterator(reply);
   for (; iter.rem; screen--, xcb_xinerama_screen_info_next(&iter))
     {
        if (screen == 0)
          {
             if (x) *x = iter.data->x_org;
             if (y) *y = iter.data->y_org;
             if (width) *width = iter.data->width;
             if (height) *height = iter.data->height;
             return 1;
          }
     }
#endif /* ECORE_XCB_XINERAMA */

   if (x) *x = 0;
   if (y) *y = 0;
   if (width) *width = ((xcb_screen_t *)_ecore_xcb_screen)->width_in_pixels;
   if (height) *height = ((xcb_screen_t *)_ecore_xcb_screen)->height_in_pixels;

   return 0;
}
示例#12
0
/*
 * Get CARD32 (array) property of any length
 *
 * If the property was successfully fetched the number of items stored in
 * val is returned, otherwise -1 is returned.
 * Note: Return value 0 means that the property exists but has no elements.
 */
EAPI int
ecore_x_window_prop_card32_list_get(Ecore_X_Window win __UNUSED__,
                                    Ecore_X_Atom atom  __UNUSED__,
                                    unsigned int     **plist)
{
   xcb_get_property_reply_t *reply;
   int num = -1;

   if (plist)
      *plist = NULL;

   reply = _ecore_xcb_reply_get();
   if (!reply)
      return -1;

   if ((reply->type == XCB_NONE) ||
       (reply->value_len == 0))
      num = 0;
   else if ((reply->type == ECORE_X_ATOM_CARDINAL) &&
            (reply->format == 32))
     {
        uint32_t *val;

        num = xcb_get_property_value_length(reply);
        if (plist)
          {
             val = (uint32_t *)malloc (num);
             if (!val)
                goto error;

             memcpy(val, xcb_get_property_value(reply), num);
             *plist = val;
          }
     }

error:

   return num;
} /* ecore_x_window_prop_card32_list_get */
示例#13
0
/*
 * Get CARD32 (array) property
 *
 * At most len items are returned in val.
 * If the property was successfully fetched the number of items stored in
 * val is returned, otherwise -1 is returned.
 * Note: Return value 0 means that the property exists but has no elements.
 */
EAPI int
ecore_x_window_prop_card32_get(Ecore_X_Window win __UNUSED__,
                               Ecore_X_Atom atom  __UNUSED__,
                               unsigned int      *val,
                               unsigned int       len)
{
   xcb_get_property_reply_t *reply;

   reply = _ecore_xcb_reply_get();
   if (!reply ||
       (reply->type != ECORE_X_ATOM_CARDINAL) ||
       (reply->format != 32))
      return -1;

   if (reply->value_len < len)
      len = xcb_get_property_value_length(reply);

   if (val)
      memcpy(val, xcb_get_property_value(reply), len);

   return (int)len;
} /* ecore_x_window_prop_card32_get */
示例#14
0
/**
 * To be documented.
 * @param window   The window (Unused).
 * @param property The property atom (Unused).
 * @param type     The type atom (Unused).
 * @param size     The size (Unused).
 * @param data     The returned data.
 * @param num      The size of the data.
 * @return         1 on success, 0 otherwise.
 *
 * FIXME: To be fixed.
 */
EAPI int
ecore_x_window_prop_property_get(Ecore_X_Window window __UNUSED__,
                                 Ecore_X_Atom property __UNUSED__,
                                 Ecore_X_Atom type     __UNUSED__,
                                 int size              __UNUSED__,
                                 unsigned char       **data,
                                 int                  *num)
{
   xcb_get_property_reply_t *reply;

   /* make sure these are initialized */
   if (num)
      *num = 0L;

   if (data)
      *data = NULL;
   else /* we can't store the retrieved data, so just return */
      return 0;

   reply = _ecore_xcb_reply_get();
   if (!reply)
      return 0;

   if ((reply->format != size) ||
       (reply->value_len == 0))
      return 0;

   *data = malloc(reply->value_len);
   if (!*data)
      return 0;

   memcpy(*data, xcb_get_property_value(reply),
          xcb_get_property_value_length(reply));

   if (num)
      *num = reply->value_len;

   return reply->format;
} /* ecore_x_window_prop_property_get */
示例#15
0
/**
 * Get the refresh rates.
 * @param root The window (Unused).
 * @param num  The number of refresh rates.
 * @return     The refresh rates.
 *
 * Get the list of refresh rates for each size supported by the screen
 * associated to @p window (passed to
 * ecore_x_randr_get_screen_info_prefetch()). Each element
 * of 'sizes' has a corresponding element in 'refresh'. An empty list
 * indicates no known rates, or a device for which refresh is not
 * relevant.
 *
 * To use this function, you must call before, and in order,
 * ecore_x_randr_get_screen_info_prefetch(), which sends the GetScreenInfo request,
 * then ecore_x_randr_get_screen_info_fetch(), which gets the reply.
 * @ingroup Ecore_X_RandR_Group
 */
EAPI Ecore_X_Screen_Refresh_Rate *
ecore_x_randr_screen_refresh_rates_get(Ecore_X_Window root __UNUSED__,
                                       int            size_id __UNUSED__,
                                       int           *num)
{
#ifdef ECORE_XCB_RANDR
   xcb_randr_get_screen_info_reply_t *reply;
   Ecore_X_Screen_Refresh_Rate       *ret;
   Ecore_X_Screen_Refresh_Rate       *tmp;
   xcb_randr_refresh_rates_iterator_t iter;
   uint16_t                           n;

   if (num) *num = 0;

   reply = _ecore_xcb_reply_get();
   if (!reply)
     return NULL;

   n = reply->nSizes;
   ret = calloc(n, sizeof(Ecore_X_Screen_Refresh_Rate));
   if (!ret)
     return NULL;

   if (num) *num = n;

   /* FIXME: maybe there's a missing function in xcb randr implementation */
   iter = xcb_randr_get_screen_info_rates_iterator(reply);
   tmp = ret;
   for (; iter.rem; xcb_randr_refresh_rates_next(&iter), tmp++)
     {
       tmp->rate = iter.data->nRates;;
     }

   return ret;
#else
   if (num) *num = 0;
   return NULL;
#endif /* ECORE_XCB_RANDR */
}
/**
 * Retrieves the geometry of the given drawable.
 * @param drawable Unused.
 * @param x        Pointer to an integer into which the X position is to be stored.
 * @param y        Pointer to an integer into which the Y position is to be stored.
 * @param width    Pointer to an integer into which the width is to be stored.
 * @param height   Pointer to an integer into which the height is to be stored.
 *
 * To use this function, you must call before, and in order,
 * ecore_x_drawable_geometry_get_prefetch(), which sends the GetGeometry request,
 * then ecore_x_drawable_geometry_get_fetch(), which gets the reply.
 * @ingroup Ecore_X_Drawable_Group
 */
EAPI void
ecore_x_drawable_geometry_get(Ecore_X_Drawable drawable __UNUSED__,
                              int             *x,
                              int             *y,
                              int             *width,
                              int             *height)
{
   xcb_get_geometry_reply_t *reply;

   reply = _ecore_xcb_reply_get();
   if (!reply)
     {
        if (x) *x = 0;
        if (y) *y = 0;
        if (width) *width = 0;
        if (height) *height = 0;
        return;
     }

   if (x) *x = reply->x;
   if (y) *y = reply->y;
   if (width) *width = reply->width;
   if (height) *height = reply->height;
}
示例#17
0
/**
 * Get the current frame buffer size.
 * @param root The window (Unused).
 * @return     The active size.
 *
 * Get the active frame buffer size supported by the screen associated
 * to @p window (passed to
 * ecore_x_randr_get_screen_info_prefetch()).
 *
 * To use this function, you must call before, and in order,
 * ecore_x_randr_get_screen_info_prefetch(), which sends the GetScreenInfo request,
 * then ecore_x_randr_get_screen_info_fetch(), which gets the reply.
 * @ingroup Ecore_X_RandR_Group
 */
EAPI Ecore_X_Screen_Size
ecore_x_randr_current_screen_size_get(Ecore_X_Window root __UNUSED__)
{
   Ecore_X_Screen_Size ret = { -1, -1 };
#ifdef ECORE_XCB_RANDR
   xcb_randr_get_screen_info_reply_t *reply;
   xcb_randr_screen_size_t           *sizes;
   uint16_t                           size_index;

   reply = _ecore_xcb_reply_get();
   if (!reply)
     return ret;

   size_index = reply->sizeID;
   sizes = xcb_randr_get_screen_info_sizes(reply);
   if (size_index < reply->nSizes)
     {
        ret.width = sizes[size_index].width;
        ret.height = sizes[size_index].height;
     }
#endif /* ECORE_XCB_RANDR */

   return ret;
}
示例#18
0
/**
 * Set the screen rotation.
 * @param root The root window.
 * @param rot  The rotation.
 *
 * Set the rotation of the screen associated to @p root.
 *
 * Note that that function is blocking.
 * @ingroup Ecore_X_RandR_Group
 */
EAPI void
ecore_x_randr_screen_rotation_set(Ecore_X_Window         root,
                                  Ecore_X_Randr_Rotation rot)
{
#ifdef ECORE_XCB_RANDR
   xcb_randr_set_screen_config_cookie_t cookie;
   xcb_randr_set_screen_config_reply_t *reply_config;
   xcb_randr_get_screen_info_reply_t   *reply;

   reply = _ecore_xcb_reply_get();
   if (!reply)
     return;

   cookie = xcb_randr_set_screen_config_unchecked(_ecore_xcb_conn, root,
                                                  XCB_CURRENT_TIME,
                                                  reply->config_timestamp,
                                                  reply->sizeID,
                                                  rot,
                                                  0);
   reply_config = xcb_randr_set_screen_config_reply(_ecore_xcb_conn, cookie, NULL);
   if (reply_config)
     free(reply_config);
#endif /* ECORE_XCB_RANDR */
}
示例#19
0
 * Retrieves the atom value associated to a name. The reply is the
 * returned value of the function ecore_xcb_intern_atom_reply(). If
 * @p reply is @c NULL, the NULL atom is returned. Otherwise, the atom
 * associated to the name is returned.
 *
 * To use this function, you must call before, and in order,
 * ecore_x_atom_get_prefetch(), which sends the InternAtom request,
 * then ecore_x_atom_get_fetch(), which gets the reply.
 * @ingroup Ecore_X_Atom_Group
 */
EAPI Ecore_X_Atom
ecore_x_atom_get(const char *name __UNUSED__)
{
   xcb_intern_atom_reply_t *reply;

   reply = _ecore_xcb_reply_get();
   if (!reply) return XCB_NONE;

   return reply->atom;
}


/**
 * Sends the GetAtomName request.
 * @param atom Atom to get the name from.
 * @ingroup Ecore_X_Atom_Group
 */
EAPI void
ecore_x_get_atom_name_prefetch(Ecore_X_Atom atom)
{
   xcb_get_atom_name_cookie_t cookie;