fix transparent canvases on GTK+ 3

For GTK+ 2, we used `gdk_window_ensure_native` to make sure
that freeze and thaw work. For GTK+ 3, `gdk_window_ensure_native`
seems not to be needed and prevents a canvas from drawing over
its background.
This commit is contained in:
Matthew Flatt 2015-08-17 20:11:40 -06:00
parent 6184a0d5c9
commit 8ee481840c
2 changed files with 7 additions and 18 deletions

View File

@ -209,11 +209,6 @@
(not (send wx is-panel?)))
#f))))
(define-gdk gdk_window_get_background_pattern (_fun _GdkWindow -> (_or-null _cairo_pattern_t))
#:make-fail make-not-available)
(define-gdk gdk_window_get_effective_parent (_fun _GdkWindow -> _GdkWindow)
#:make-fail make-not-available)
(define-signal-handler connect-draw "draw"
(_fun _GtkWidget _cairo_t -> _gboolean)
(lambda (gtk cr)
@ -221,13 +216,6 @@
(if wx
(let ([col (send wx get-canvas-background-for-backing)]
[win (widget-window gtk)])
(when (and win (not col))
;; Before transparent drawing, we need to install the
;; parent window's pattern.
(cairo_set_source cr (gdk_window_get_background_pattern
(gdk_window_get_effective_parent win)))
(cairo_rectangle cr 0 0 32000 32000)
(cairo_fill cr))
(unless (send wx paint-or-queue-paint cr)
(when col
(cairo_set_source_rgb cr

View File

@ -129,7 +129,7 @@
(lambda (gtk)
(GtkWidgetT-window (cast gtk _GtkWidget _GtkWidgetT-pointer)))))
(define-gtk widget-parent (_fun _GtkWidget -> _GdkWindow)
(define-gtk widget-parent (_fun _GtkWidget -> _GtkWidget)
#:c-id gtk_widget_get_parent
#:fail (lambda ()
(lambda (gtk)
@ -864,11 +864,12 @@
(lambda (win-box)
(let ([win (mcar win-box)])
(and win
;; The freeze/thaw state is actually with the window's
;; implementation, so force a native implementation of the
;; window to try to avoid it changing out from underneath
;; us between the freeze and thaw actions.
(gdk_window_ensure_native win)
(unless gtk3?
;; The freeze/thaw state is actually with the window's
;; implementation, so force a native implementation of the
;; window to try to avoid it changing out from underneath
;; us between the freeze and thaw actions.
(gdk_window_ensure_native win))
(begin
(gdk_window_freeze_updates win)
(set-mcdr! win-box (add1 (mcdr win-box)))