summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--area_unix.go7
-rw-r--r--gtkcalls_unix.go4
-rw-r--r--sysdata_unix.go1
-rw-r--r--test/main.go1
4 files changed, 7 insertions, 6 deletions
diff --git a/area_unix.go b/area_unix.go
index 83aafc5..8f9fc8f 100644
--- a/area_unix.go
+++ b/area_unix.go
@@ -45,11 +45,18 @@ func gtkAreaGetControl(scrollarea *gtkWidget) *gtkWidget {
//export our_area_draw_callback
func our_area_draw_callback(widget *C.GtkWidget, cr *C.cairo_t, data C.gpointer) C.gboolean {
var x, y, w, h C.double
+ var maxwid, maxht C.gint
s := (*sysData)(unsafe.Pointer(data))
// thanks to desrt in irc.gimp.net/#gtk+
C.cairo_clip_extents(cr, &x, &y, &w, &h)
cliprect := image.Rect(int(x), int(y), int(w), int(h))
+ // the cliprect can actually fall outside the size of the Area; clip it by intersecting the two rectangles
+ C.gtk_widget_get_size_request(widget, &maxwid, &maxht)
+ cliprect = image.Rect(0, 0, int(maxwid), int(maxht)).Intersect(cliprect)
+ if cliprect.Empty() { // no intersection; nothing to paint
+ return C.FALSE // signals handled without stopping the event chain (thanks to desrt again)
+ }
i := s.handler.Paint(cliprect)
// pixel order is [R G B A] (see Example 1 on https://developer.gnome.org/gdk-pixbuf/2.26/gdk-pixbuf-The-GdkPixbuf-Structure.html) so we don't have to convert anything
// gdk-pixbuf is not alpha-premultiplied (thanks to desrt in irc.gimp.net/#gtk+)
diff --git a/gtkcalls_unix.go b/gtkcalls_unix.go
index 3591e65..c7b409a 100644
--- a/gtkcalls_unix.go
+++ b/gtkcalls_unix.go
@@ -217,7 +217,3 @@ func gtk_progress_bar_set_fraction(w *gtkWidget, percent int) {
func gtk_progress_bar_pulse(w *gtkWidget) {
C.gtk_progress_bar_pulse(togtkprogressbar(w))
}
-
-func gtk_widget_queue_draw(widget *gtkWidget) {
- C.gtk_widget_queue_draw(togtkwidget(widget))
-}
diff --git a/sysdata_unix.go b/sysdata_unix.go
index 6100606..be9a827 100644
--- a/sysdata_unix.go
+++ b/sysdata_unix.go
@@ -357,7 +357,6 @@ func (s *sysData) setAreaSize(width int, height int) {
uitask <- func() {
c := gtkAreaGetControl(s.widget)
gtk_widget_set_size_request(c, width, height)
- gtk_widget_queue_draw(c) // force repaint (TODO doesn't have an effect when shrinking?)
ret <- struct{}{}
}
<-ret
diff --git a/test/main.go b/test/main.go
index a2d683e..056ab1a 100644
--- a/test/main.go
+++ b/test/main.go
@@ -194,7 +194,6 @@ func areaTest() {
if err != nil { println(err); continue }
height, err := strconv.Atoi(heightbox.Text())
if err != nil { println(err); continue }
-println(width, height)
a.SetSize(width, height)
}
}