Skip to content

Commit 68594f0

Browse files
committed
better clipping for client views
clip clients, client should use regular coordinate space
1 parent 45deb29 commit 68594f0

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/imagedisplay.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -672,29 +672,28 @@ imagedisplay_snapshot(GtkWidget *widget, GtkSnapshot *snapshot)
672672

673673
GTK_WIDGET_CLASS(imagedisplay_parent_class)->snapshot(widget, snapshot);
674674

675+
/* Clip to the widget area, or we may paint over the display control
676+
* bar.
677+
*/
678+
gtk_snapshot_push_clip(snapshot,
679+
&GRAPHENE_RECT_INIT(0, 0,
680+
gtk_widget_get_width(widget), gtk_widget_get_height(widget)));
681+
682+
gtk_snapshot_save(snapshot);
683+
675684
/* This can change on each repaint as windows are dragged.
676685
*/
677686
GtkNative *native = gtk_widget_get_native(widget);
678687
GdkSurface *surface = gtk_native_get_surface(native);
679688
double pixel_size = 1.0 / gdk_surface_get_scale(surface);
680689
g_object_set(imagedisplay, "pixel-size", pixel_size, NULL);
681690

682-
gtk_snapshot_save(snapshot);
683-
684691
#ifdef HAVE_GTK_SNAPSHOT_SET_SNAP
685692
gtk_snapshot_set_snap(snapshot, GSK_RECT_SNAP_ROUND);
686693
#endif /*HAVE_GTK_SNAPSHOT_SET_SNAP*/
687694

688695
gtk_snapshot_scale(snapshot, pixel_size, pixel_size);
689696

690-
/* Clip to the widget area, or we may paint over the display control
691-
* bar.
692-
*/
693-
gtk_snapshot_push_clip(snapshot,
694-
&GRAPHENE_RECT_INIT(0, 0,
695-
gtk_widget_get_width(widget) / pixel_size,
696-
gtk_widget_get_height(widget) / pixel_size));
697-
698697
graphene_rect_t paint;
699698
paint.origin.x = imagedisplay->paint_rect.left / pixel_size;
700699
paint.origin.y = imagedisplay->paint_rect.top / pixel_size;
@@ -709,13 +708,14 @@ imagedisplay_snapshot(GtkWidget *widget, GtkSnapshot *snapshot)
709708
imagedisplay->y / pixel_size,
710709
&paint, imagedisplay->debug);
711710

712-
// end of clip
713-
gtk_snapshot_pop(snapshot);
714-
711+
// undo snap and scale
715712
gtk_snapshot_restore(snapshot);
716713

717-
// draw any overlays
714+
// draw any overlays back in the regular coordinate space
718715
imagedisplay_overlay_snapshot(imagedisplay, snapshot);
716+
717+
// end of clip
718+
gtk_snapshot_pop(snapshot);
719719
}
720720

721721
static void

0 commit comments

Comments
 (0)