2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
5 #include "ecore_xcb_private.h"
9 * @defgroup Ecore_X_Fixes_Group X Fixes Extension Functions
11 * Functions related to the X Fixes extension.
15 #ifdef ECORE_XCB_FIXES
16 static int _xfixes_available = 0;
17 static xcb_xfixes_query_version_cookie_t _ecore_xcb_xfixes_init_cookie;
18 #endif /* ECORE_XCB_FIXES */
21 /* To avoid round trips, the initialization is separated in 2
22 functions: _ecore_xcb_xfixes_init and
23 _ecore_xcb_xfixes_init_finalize. The first one gets the cookies and
24 the second one gets the replies and set the atoms. */
27 _ecore_x_xfixes_init(const xcb_query_extension_reply_t *reply)
29 #ifdef ECORE_XCB_FIXES
30 if (reply && (reply->present))
31 _ecore_xcb_xfixes_init_cookie = xcb_xfixes_query_version_unchecked(_ecore_xcb_conn, 4, 0);
32 #endif /* ECORE_XCB_FIXES */
36 _ecore_x_xfixes_init_finalize(void)
38 #ifdef ECORE_XCB_FIXES
39 xcb_xfixes_query_version_reply_t *reply;
41 reply = xcb_xfixes_query_version_reply(_ecore_xcb_conn,
42 _ecore_xcb_xfixes_init_cookie, NULL);
46 if (reply->major_version >= 3)
47 _xfixes_available = 1;
50 #endif /* ECORE_XCB_FIXES */
55 * Return whether the X server supports the Fixes Extension.
56 * @return 1 if the X Fixes Extension is available, 0 otherwise.
58 * Return 1 if the X server supports the Fixes Extension version 3.0,
60 * @ingroup Ecore_X_Fixes_Group
63 ecore_x_xfixes_query(void)
65 #ifdef ECORE_XCB_FIXES
66 return _xfixes_available;
69 #endif /* ECORE_XCB_FIXES */
74 * Create a region from rectangles.
75 * @param rects The rectangles used to initialize the region.
76 * @param num The number of rectangles.
77 * @return The newly created region.
79 * Create a region initialized to the specified list of rectangles
80 * @p rects. The rectangles may be specified in any order, their union
82 * @ingroup Ecore_X_Fixes_Group
85 ecore_x_region_new(Ecore_X_Rectangle *rects,
88 Ecore_X_Region region = XCB_NONE;
90 #ifdef ECORE_XCB_FIXES
91 region = xcb_generate_id(_ecore_xcb_conn);
92 xcb_xfixes_create_region(_ecore_xcb_conn, region, num, (xcb_rectangle_t *)rects);
93 #endif /* ECORE_XCB_FIXES */
100 * Create a region from a pixmap.
101 * @param bitmap The bitmap used to initialize the region.
102 * @return The newly created region.
104 * Creates a region initialized to the set of 'one' pixels in @p bitmap
105 * (which must be of depth 1, else Match error).
106 * @ingroup Ecore_X_Fixes_Group
109 ecore_x_region_new_from_bitmap(Ecore_X_Pixmap bitmap)
111 Ecore_X_Region region = XCB_NONE;
113 #ifdef ECORE_XCB_FIXES
114 region = xcb_generate_id(_ecore_xcb_conn);
115 xcb_xfixes_create_region_from_bitmap(_ecore_xcb_conn, region, bitmap);
116 #endif /* ECORE_XCB_FIXES */
123 * Create a region from a window.
124 * @param window The window used to initialize the region.
125 * @param type The type of the region.
126 * @return The newly created region.
128 * Creates a region initialized to the specified @p window region. See
129 * the Shape extension for the definition of Bounding and Clip
131 * @ingroup Ecore_X_Fixes_Group
134 ecore_x_region_new_from_window(Ecore_X_Window window,
135 Ecore_X_Region_Type type)
137 Ecore_X_Region region = XCB_NONE;
139 #ifdef ECORE_XCB_FIXES
140 region = xcb_generate_id(_ecore_xcb_conn);
141 xcb_xfixes_create_region_from_window(_ecore_xcb_conn, region, window, type);
142 #endif /* ECORE_XCB_FIXES */
149 * Create a region from a graphic context.
150 * @param gc The graphic context used to initialize the region.
151 * @return The newly created region.
153 * Creates a region initialized from the clip list of @p gc.
154 * @ingroup Ecore_X_Fixes_Group
157 ecore_x_region_new_from_gc(Ecore_X_GC gc)
159 Ecore_X_Region region = XCB_NONE;
161 #ifdef ECORE_XCB_FIXES
162 region = xcb_generate_id(_ecore_xcb_conn);
163 xcb_xfixes_create_region_from_gc(_ecore_xcb_conn, region, gc);
164 #endif /* ECORE_XCB_FIXES */
171 * Create a region from a picture.
172 * @param picture The picture used to initialize the region.
173 * @return The newly created region.
175 * Creates a region initialized from the clip list of @p picture.
176 * @ingroup Ecore_X_Fixes_Group
179 ecore_x_region_new_from_picture(Ecore_X_Picture picture)
181 Ecore_X_Region region = XCB_NONE;
183 #ifdef ECORE_XCB_FIXES
184 region = xcb_generate_id(_ecore_xcb_conn);
185 xcb_xfixes_create_region_from_picture(_ecore_xcb_conn, region, picture);
186 #endif /* ECORE_XCB_FIXES */
194 * @param region The region to destroy.
196 * Destroy the specified @p region.
197 * @ingroup Ecore_X_Fixes_Group
200 ecore_x_region_free(Ecore_X_Region region)
202 #ifdef ECORE_XCB_FIXES
203 xcb_xfixes_destroy_region(_ecore_xcb_conn, region);
204 #endif /* ECORE_XCB_FIXES */
209 * Set the content of a region.
210 * @param region The region to destroy.
211 * @param rects The rectangles used to set the region.
212 * @param num The number of rectangles.
214 * Replace the current contents of @p region with the region formed
215 * by the union of the rectangles @p rects.
216 * @ingroup Ecore_X_Fixes_Group
219 ecore_x_region_set(Ecore_X_Region region,
220 Ecore_X_Rectangle *rects,
223 #ifdef ECORE_XCB_FIXES
224 xcb_xfixes_set_region(_ecore_xcb_conn, region, num, (xcb_rectangle_t *)rects);
225 #endif /* ECORE_XCB_FIXES */
230 * Copy the content of a region.
231 * @param dest The destination region.
232 * @param source The source region.
234 * Replace the contents of @p dest with the contents of @p source.
235 * @ingroup Ecore_X_Fixes_Group
238 ecore_x_region_copy(Ecore_X_Region dest,
239 Ecore_X_Region source)
241 #ifdef ECORE_XCB_FIXES
242 xcb_xfixes_copy_region(_ecore_xcb_conn, source, dest);
243 #endif /* ECORE_XCB_FIXES */
248 * Make the union of two regions.
249 * @param dest The destination region.
250 * @param source1 The first source region.
251 * @param source2 The second source region.
253 * Replace the contents of @p dest with the union of @p source1 and
255 * @ingroup Ecore_X_Fixes_Group
258 ecore_x_region_combine(Ecore_X_Region dest,
259 Ecore_X_Region source1,
260 Ecore_X_Region source2)
262 #ifdef ECORE_XCB_FIXES
263 xcb_xfixes_union_region(_ecore_xcb_conn, source1, source2, dest);
264 #endif /* ECORE_XCB_FIXES */
269 * Make the intersection of two regions.
270 * @param dest The destination region.
271 * @param source1 The first source region.
272 * @param source2 The second source region.
274 * Replace the contents of @p dest with the intersection of @p source1 and
276 * @ingroup Ecore_X_Fixes_Group
279 ecore_x_region_intersect(Ecore_X_Region dest,
280 Ecore_X_Region source1,
281 Ecore_X_Region source2)
283 #ifdef ECORE_XCB_FIXES
284 xcb_xfixes_intersect_region(_ecore_xcb_conn, source1, source2, dest);
285 #endif /* ECORE_XCB_FIXES */
290 * Make the substraction of two regions.
291 * @param dest The destination region.
292 * @param source1 The first source region.
293 * @param source2 The second source region.
295 * Replace the contents of @p dest with the substraction of @p source1 by
297 * @ingroup Ecore_X_Fixes_Group
300 ecore_x_region_subtract(Ecore_X_Region dest,
301 Ecore_X_Region source1,
302 Ecore_X_Region source2)
304 #ifdef ECORE_XCB_FIXES
305 xcb_xfixes_subtract_region(_ecore_xcb_conn, source1, source2, dest);
306 #endif /* ECORE_XCB_FIXES */
311 * Make the substraction of regions by bounds.
312 * @param dest The destination region.
313 * @param bounds The bounds.
314 * @param source The source region.
316 * The @p source region is subtracted from the region specified by
317 * @p bounds. The result is placed in @p dest, replacing its
319 * @ingroup Ecore_X_Fixes_Group
322 ecore_x_region_invert(Ecore_X_Region dest,
323 Ecore_X_Rectangle *bounds,
324 Ecore_X_Region source)
326 #ifdef ECORE_XCB_FIXES
327 xcb_rectangle_t rect;
331 rect.width = bounds->width;
332 rect.height = bounds->height;
333 xcb_xfixes_invert_region(_ecore_xcb_conn, source, rect, dest);
334 #endif /* ECORE_XCB_FIXES */
339 * Translate a region.
340 * @param region The region to translate.
341 * @param dx The horizontal translation.
342 * @param dy The vertical translation.
344 * The @p region is translated by @p dx and @p dy in place.
345 * @ingroup Ecore_X_Fixes_Group
348 ecore_x_region_translate(Ecore_X_Region region,
352 #ifdef ECORE_XCB_FIXES
353 xcb_xfixes_translate_region(_ecore_xcb_conn, region, dx, dy);
354 #endif /* ECORE_XCB_FIXES */
360 * @param dest The destination region.
361 * @param source The source region.
363 * The extents of the @p source region are placed in @p dest.
364 * @ingroup Ecore_X_Fixes_Group
367 ecore_x_region_extents(Ecore_X_Region dest,
368 Ecore_X_Region source)
370 #ifdef ECORE_XCB_FIXES
371 xcb_xfixes_region_extents(_ecore_xcb_conn, source, dest);
372 #endif /* ECORE_XCB_FIXES */
377 * Sends the XFixesFetchRegion request.
378 * @param region Requested region.
379 * @ingroup Ecore_X_Fixes_Group
382 ecore_x_region_fetch_prefetch(Ecore_X_Region region)
384 #ifdef ECORE_XCB_FIXES
385 xcb_xfixes_fetch_region_cookie_t cookie;
387 cookie = xcb_xfixes_fetch_region_unchecked(_ecore_xcb_conn, region);
388 _ecore_xcb_cookie_cache(cookie.sequence);
389 #endif /* ECORE_XCB_FIXES */
394 * Gets the reply of the XFixesFetchRegion request sent by ecore_xcb_region_fetch_prefetch().
395 * @ingroup Ecore_X_Fixes_Group
398 ecore_x_region_fetch_fetch(void)
400 #ifdef ECORE_XCB_FIXES
401 xcb_xfixes_fetch_region_cookie_t cookie;
402 xcb_xfixes_fetch_region_reply_t *reply;
404 cookie.sequence = _ecore_xcb_cookie_get();
405 reply = xcb_xfixes_fetch_region_reply(_ecore_xcb_conn, cookie, NULL);
406 _ecore_xcb_reply_cache(reply);
407 #endif /* ECORE_XCB_FIXES */
412 * Return the rectangles that compose a region.
413 * @param region The region (Unused).
414 * @param num The number of returned rectangles.
415 * @param bounds The returned bounds of the region.
416 * @return The returned rectangles.
418 * The @p region passed to ecore_xcb_region_fetch_prefetch() is
419 * returned as a list of rectagles in XY-banded order.
421 * To use this function, you must call before, and in order,
422 * ecore_xcb_region_fetch_prefetch(), which sends the XFixesFetchRegion request,
423 * then ecore_xcb_region_fetch_fetch(), which gets the reply.
424 * @ingroup Ecore_X_Fixes_Group
426 EAPI Ecore_X_Rectangle *
427 ecore_x_region_fetch(Ecore_X_Region region __UNUSED__,
429 Ecore_X_Rectangle *bounds)
431 Ecore_X_Rectangle extents = { 0, 0, 0, 0};
432 Ecore_X_Rectangle *rects = NULL;
433 #ifdef ECORE_XCB_FIXES
435 xcb_xfixes_fetch_region_reply_t *reply;
437 reply = _ecore_xcb_reply_get();
441 if (bounds) *bounds = extents;
444 n = xcb_xfixes_fetch_region_rectangles_length(reply);
445 rects = (Ecore_X_Rectangle *)malloc(n * sizeof(Ecore_X_Rectangle));
449 if (bounds) *bounds = extents;
457 bounds->x = reply->extents.x;
458 bounds->y = reply->extents.y;
459 bounds->width = reply->extents.width;
460 bounds->height = reply->extents.height;
463 xcb_xfixes_fetch_region_rectangles(reply),
464 sizeof(Ecore_X_Rectangle) * n);
469 if (bounds) *bounds = extents;
471 #endif /* ECORE_XCB_FIXES */
477 * @param dest The destination region.
478 * @param source The source region.
479 * @param left The number of pixels to add on the left.
480 * @param right The number of pixels to add on the right.
481 * @param top The number of pixels to add at the top.
482 * @param bottom The number of pixels to add at the bottom.
484 * Put in @p dest the area specified by expanding each rectangle in
485 * the @p source region by the specified number of pixels to the
486 * @p left, @p right, @p top and @p bottom.
487 * @ingroup Ecore_X_Fixes_Group
490 ecore_x_region_expand(Ecore_X_Region dest,
491 Ecore_X_Region source,
497 #ifdef ECORE_XCB_FIXES
498 xcb_xfixes_expand_region(_ecore_xcb_conn, source, dest, left, right, top, bottom);
499 #endif /* ECORE_XCB_FIXES */
504 * Change clip-mask in a graphic context to the specified region.
505 * @param region The region to change.
506 * @param gc The clip-mask graphic context.
507 * @param x_origin The horizontal translation.
508 * @param y_origin The vertical translation.
510 * Changes clip-mask in @p gc to the specified @p region and
511 * sets the clip origin with the values of @p x_origin and @p y_origin.
512 * Output will be clippped to remain contained within the region. The
513 * clip origin is interpreted relative to the origin of whatever
514 * destination drawable is specified in a graphics request. The
515 * region is interpreted relative to the clip origin. Future changes
516 * to region have no effect on the gc clip-mask.
517 * @ingroup Ecore_X_Fixes_Group
520 ecore_x_region_gc_clip_set(Ecore_X_Region region,
525 #ifdef ECORE_XCB_FIXES
526 xcb_xfixes_set_gc_clip_region(_ecore_xcb_conn, gc, region, x_origin, y_origin);
527 #endif /* ECORE_XCB_FIXES */
532 * Change the shape extension of a window.
533 * @param region The region.
534 * @param dest The window whose shape is changed.
535 * @param type The kind of shape.
536 * @param x_offset The horizontal offset.
537 * @param y_offset The vertical offset.
539 * Set the specified Shape extension region of @p window to @p region,
540 * offset by @p x_offset and @p y_offset. Future changes to region
541 * have no effect on the window shape.
542 * @ingroup Ecore_X_Fixes_Group
545 ecore_x_region_window_shape_set(Ecore_X_Region region,
547 Ecore_X_Shape_Type type,
551 #ifdef ECORE_XCB_FIXES
552 xcb_xfixes_set_window_shape_region(_ecore_xcb_conn, dest, type, x_offset, y_offset, region);
553 #endif /* ECORE_XCB_FIXES */
558 * Change clip-mask in picture to the specified region.
559 * @param region The region.
560 * @param picture The picture.
561 * @param x_origin The X coordinate of the origin.
562 * @param y_origin The Y coordinate of the origin.
564 * Changes clip-mask in picture to the specified @p region
565 * and sets the clip origin. Input and output will be clipped to
566 * remain contained within the region. The clip origin is interpreted
567 * relative to the origin of the drawable associated with @p picture. The
568 * region is interpreted relative to the clip origin. Future changes
569 * to region have no effect on the picture clip-mask.
570 * @ingroup Ecore_X_Fixes_Group
573 ecore_x_region_picture_clip_set(Ecore_X_Region region,
574 Ecore_X_Picture picture,
578 #ifdef ECORE_XCB_FIXES
579 xcb_xfixes_set_picture_clip_region(_ecore_xcb_conn, picture, region, x_origin, y_origin);
580 #endif /* ECORE_XCB_FIXES */