Skip to content

Commit

Permalink
app: fix various artifacts of the cancas' overlay children
Browse files Browse the repository at this point in the history
gimp_overlay_child_size_allocate(): invalidate the old and new
position of the child, and simplify the code by calling our own
invalidate() function instead of duplicating its code.

gimp_overlay_child_expose(): process pending updates on the overlay
child's offscreen window before getting its pixmap.
  • Loading branch information
mitchfoo committed Apr 28, 2013
1 parent 9c93df2 commit e19c7eb
Showing 1 changed file with 22 additions and 31 deletions.
53 changes: 22 additions & 31 deletions app/widgets/gimpoverlaychild.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ gimp_overlay_child_size_allocate (GimpOverlayBox *box,
GimpOverlayChild *child)
{
GtkWidget *widget;
GtkAllocation allocation;
GtkRequisition child_requisition;
GtkAllocation child_allocation;
gint x;
Expand All @@ -241,7 +240,7 @@ gimp_overlay_child_size_allocate (GimpOverlayBox *box,

widget = GTK_WIDGET (box);

gtk_widget_get_allocation (widget, &allocation);
gimp_overlay_child_invalidate (box, child);

gtk_widget_get_child_requisition (child->widget, &child_requisition);

Expand All @@ -252,30 +251,12 @@ gimp_overlay_child_size_allocate (GimpOverlayBox *box,

gtk_widget_size_allocate (child->widget, &child_allocation);

gtk_widget_get_allocation (child->widget, &child_allocation);

if (gtk_widget_get_realized (GTK_WIDGET (widget)))
{
GdkRectangle old_allocation;
GdkRectangle old_bounds;

gdk_window_get_position (child->window,
&old_allocation.x,
&old_allocation.y);
old_allocation.width = gdk_window_get_width (child->window);
old_allocation.height = gdk_window_get_height (child->window);

gimp_overlay_child_transform_bounds (child, &old_allocation, &old_bounds);

gdk_window_invalidate_rect (gtk_widget_get_window (widget),
&old_bounds, FALSE);

gdk_window_move_resize (child->window,
child_allocation.x,
child_allocation.y,
child_allocation.width,
child_allocation.height);
}
gdk_window_move_resize (child->window,
child_allocation.x,
child_allocation.y,
child_allocation.width,
child_allocation.height);

cairo_matrix_init_identity (&child->matrix);

Expand All @@ -289,10 +270,13 @@ gimp_overlay_child_size_allocate (GimpOverlayBox *box,
}
else
{
GdkRectangle bounds;
gint border;
gint available_width;
gint available_height;
GtkAllocation allocation;
GdkRectangle bounds;
gint border;
gint available_width;
gint available_height;

gtk_widget_get_allocation (widget, &allocation);

gimp_overlay_child_transform_bounds (child, &child_allocation, &bounds);

Expand All @@ -315,6 +299,8 @@ gimp_overlay_child_size_allocate (GimpOverlayBox *box,

/* local transform */
cairo_matrix_rotate (&child->matrix, child->angle);

gimp_overlay_child_invalidate (box, child);
}

gboolean
Expand Down Expand Up @@ -342,8 +328,13 @@ gimp_overlay_child_expose (GimpOverlayBox *box,
if (gtk_widget_get_visible (child->widget) &&
gdk_rectangle_intersect (&event->area, &bounds, NULL))
{
GdkPixmap *pixmap = gdk_offscreen_window_get_pixmap (child->window);
cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
GdkPixmap *pixmap;
cairo_t *cr;

gdk_window_process_updates (child->window, FALSE);

pixmap = gdk_offscreen_window_get_pixmap (child->window);
cr = gdk_cairo_create (gtk_widget_get_window (widget));

gdk_cairo_region (cr, event->region);
cairo_clip (cr);
Expand Down

0 comments on commit e19c7eb

Please sign in to comment.