示例#1
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 */
示例#2
0
static
bool windowInteractsWithPosition(xcb_connection_t *connection, const QPoint & pos, xcb_window_t w, xcb_shape_sk_t shapeType)
{
    bool interacts = false;
    xcb_shape_get_rectangles_reply_t *reply = xcb_shape_get_rectangles_reply(connection, xcb_shape_get_rectangles(connection, w, shapeType), NULL);
    if (reply) {
        xcb_rectangle_t *rectangles = xcb_shape_get_rectangles_rectangles(reply);
        if (rectangles) {
            const int nRectangles = xcb_shape_get_rectangles_rectangles_length(reply);
            for (int i = 0; !interacts && i < nRectangles; ++i) {
                interacts = QRect(rectangles[i].x, rectangles[i].y, rectangles[i].width, rectangles[i].height).contains(pos);
            }
        }
        free(reply);
    }

    return interacts;
}