From: Jim Evins Date: Mon, 29 Feb 2016 03:02:38 +0000 (-0500) Subject: Fix drawing beyond drawing area viewport (bug #762307). X-Git-Tag: glabels-3_4_0~34 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7a66286430281f7ea1fb1ccb3055fe293ae726ba;p=glabels Fix drawing beyond drawing area viewport (bug #762307). Fixes Bug #762307. Clip the drawing area's bin_window to a viewport determined by the widget's physical window size and current scroll adjustments. --- diff --git a/src/view.c b/src/view.c index b7eff714..69590b89 100644 --- a/src/view.c +++ b/src/view.c @@ -563,6 +563,17 @@ draw_cb (glView *view, bin_window = gtk_layout_get_bin_window (GTK_LAYOUT (view->canvas)); bin_cr = gdk_cairo_create (bin_window); + /* Figure out viewport and clip to this region. */ + GtkAdjustment *hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (view->canvas)); + GtkAdjustment *vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (view->canvas)); + GdkWindow *window = gtk_widget_get_window (GTK_WIDGET (view->canvas)); + gdouble window_x0 = gtk_adjustment_get_value (hadj); + gdouble window_y0 = gtk_adjustment_get_value (vadj); + gdouble window_w = gdk_window_get_width (window); + gdouble window_h = gdk_window_get_height (window); + cairo_rectangle (bin_cr, window_x0, window_y0, window_w, window_h); + cairo_clip (bin_cr); + draw_layers (view, bin_cr); cairo_destroy (bin_cr);