[glabels/glabels-3_4] Fix drawing beyond drawing area viewport (bug #762307).



commit 7a66286430281f7ea1fb1ccb3055fe293ae726ba
Author: Jim Evins <evins snaught com>
Date:   Sun Feb 28 22:02:38 2016 -0500

    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.

 src/view.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/src/view.c b/src/view.c
index b7eff71..69590b8 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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]