From dd677a4587ec6abf9e41573c2a9ae7708387afe0 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 25 Jan 2013 14:16:51 -0700 Subject: [PATCH] racket/gui gtk: fix canvas/panel border drawing The code to draw a border has to determine the widget's position within the drawing window. Gtk 3.0 has a function to provide that transformation, but Gtk 2.0 doesn't seem to have one, and it seems that the transformation implemented in `racket/gui' wasn't right. Closes PR 13453 original commit: e22977667dc4efb171bced7f6984644490d5306d --- collects/mred/private/wx/gtk/panel.rkt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/collects/mred/private/wx/gtk/panel.rkt b/collects/mred/private/wx/gtk/panel.rkt index 15600daa..4109c47f 100644 --- a/collects/mred/private/wx/gtk/panel.rkt +++ b/collects/mred/private/wx/gtk/panel.rkt @@ -38,11 +38,15 @@ (let* ([a (widget-allocation gtk)] [w (sub1 (GtkAllocation-width a))] [h (sub1 (GtkAllocation-height a))]) - (let loop ([gtk gtk] [x 0] [y 0]) - (if (not (zero? (bitwise-and (get-gtk-object-flags gtk) GTK_NO_WINDOW))) + (let loop ([gtk gtk] [x 0] [y 0] [can-super? #t]) + (if (and can-super? + (not (zero? (bitwise-and (get-gtk-object-flags gtk) GTK_NO_WINDOW)))) ;; no window: (let ([a (widget-allocation gtk)]) - (loop (widget-parent gtk) (+ x (GtkAllocation-x a)) (+ y (GtkAllocation-y a)))) + (loop (widget-parent gtk) (+ x (GtkAllocation-x a)) (+ y (GtkAllocation-y a)) + ;; It seems that a widget's allocation is with respect + ;; to a window, not its parent. + #f)) ;; found window: (gdk_draw_rectangle win gc #f x y w h)))) (gdk_gc_unref gc)))