Add _gdk_windowing_window_get_shape

This commit is contained in:
Alexander Larsson 2008-12-16 14:38:10 +01:00 committed by Alexander Larsson
parent 0d540e935b
commit 062da50b9f
4 changed files with 73 additions and 1 deletions

View File

@ -335,6 +335,7 @@ gchar *_gdk_windowing_substitute_screen_number (const gchar *display_name,
void _gdk_windowing_window_get_offsets (GdkWindow *window,
gint *x_offset,
gint *y_offset);
GdkRegion *_gdk_windowing_window_get_shape (GdkWindow *window);
void _gdk_windowing_get_pointer (GdkDisplay *display,
GdkScreen **screen,
@ -521,7 +522,7 @@ GdkRegion *_gdk_window_calculate_full_clip_region (GdkWindow *window,
gint *base_y_offset);
gboolean _gdk_window_has_impl (GdkWindow *window);
GdkWindow * _gdk_window_get_impl_window (GdkWindow *window);
GdkRegion *_gdk_region_new_from_yxbanded_rects (GdkRectangle *rects, int n_rects);
/*****************************
* offscreen window routines *

View File

@ -96,6 +96,7 @@ static void miRegionOp (GdkRegion *newReg,
overlapFunc overlapFn,
nonOverlapFunc nonOverlap1Fn,
nonOverlapFunc nonOverlap2Fn);
static void miSetExtents (GdkRegion *pReg);
/**
* gdk_region_new:
@ -122,6 +123,31 @@ gdk_region_new (void)
return temp;
}
GdkRegion *
_gdk_region_new_from_yxbanded_rects (GdkRectangle *rects,
int num_rects)
{
GdkRegion *temp;
int i;
temp = g_slice_new (GdkRegion);
temp->rects = g_new (GdkRegionBox, num_rects);
temp->size = num_rects;
temp->numRects = num_rects;
for (i = 0; i < num_rects; i++)
{
temp->rects[i].x1 = rects[i].x;
temp->rects[i].y1 = rects[i].y;
temp->rects[i].x2 = rects[i].x + rects[i].width;
temp->rects[i].y2 = rects[i].y + rects[i].height;
}
miSetExtents (temp);
return temp;
}
/**
* gdk_region_rectangle:
* @rectangle: a #GdkRectangle

View File

@ -6650,6 +6650,7 @@ static gboolean
point_in_window (GdkWindowObject *window,
double x, double y)
{
/* TODO: Input Shape */
return
x >= 0 && x < window->width &&
y >= 0 && y < window->height;

View File

@ -4757,6 +4757,50 @@ gdk_add_to_span (struct _gdk_span **s,
return;
}
GdkRegion *
_gdk_windowing_window_get_shape (GdkWindow *window)
{
GdkRegion *shape;
shape = NULL;
#if defined(HAVE_SHAPE_EXT)
if (!GDK_WINDOW_DESTROYED (window) &&
gdk_display_supports_shapes (GDK_WINDOW_DISPLAY (window)))
{
GdkRectangle *rl;
XRectangle *xrl;
gint rn, ord, i;
xrl = XShapeGetRectangles (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
ShapeBounding, &rn, &ord);
if (ord != YXBanded)
{
/* This really shouldn't happen with any xserver, as they
generally convert regions to YXBanded internally */
g_warning ("non YXBanded shape masks not supported");
XFree (rl);
return NULL;
}
rl = g_new (GdkRectangle, rn);
for (i = 0; i < rn; i++)
{
rl[i].x = xrl[i].x;
rl[i].y = xrl[i].y;
rl[i].width = xrl[i].width;
rl[i].height = xrl[i].height;
}
shape = _gdk_region_new_from_yxbanded_rects (rl, rn);
g_free (rl);
XFree (rl);
}
#endif
}
static void
gdk_add_rectangles (Display *disp,
Window win,