diff options
author | Owen W. Taylor <otaylor@fishsoup.net> | 2015-10-20 16:45:52 -0400 |
---|---|---|
committer | Owen W. Taylor <otaylor@fishsoup.net> | 2015-10-22 11:05:04 -0400 |
commit | 26d8a56506447e17a3f2505c8a7907e526f93ffc (patch) | |
tree | f793a309779bea5846d328728140560b01f63d4b /tests | |
parent | 1571d2872feb7a2bca03d22b615550e2a5d7a23c (diff) | |
download | gtk+-26d8a56506447e17a3f2505c8a7907e526f93ffc.tar.gz |
testgtk/Alpha Window: fix the drawn area when we are drawing decorations
A GtkWindow's allocation includes the titlebar, borders, and shadows; we
only want to draw our custom alpha content over the child allocation of
the GtkWindow.
https://bugzilla.gnome.org/show_bug.cgi?id=756886
Diffstat (limited to 'tests')
-rw-r--r-- | tests/testgtk.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/testgtk.c b/tests/testgtk.c index eeb8c1794b..fa3914db83 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -129,6 +129,22 @@ on_alpha_window_draw (GtkWidget *widget, cairo_pattern_t *pattern; int radius, width, height; + /* Get the child allocation to avoid painting over the borders */ + GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget)); + GtkAllocation child_allocation; + int border_width = gtk_container_get_border_width (GTK_CONTAINER (child)); + + gtk_widget_get_allocation (child, &child_allocation); + child_allocation.x -= border_width; + child_allocation.y -= border_width; + child_allocation.width += 2 * border_width; + child_allocation.height += 2 * border_width; + + cairo_translate (cr, child_allocation.x, child_allocation.y); + + cairo_rectangle (cr, 0, 0, child_allocation.width, child_allocation.height); + cairo_clip (cr); + width = gtk_widget_get_allocated_width (widget); height = gtk_widget_get_allocated_height (widget); radius = MIN (width, height) / 2; |