From 6e9362ad4618fe3e2c0f09b258c7c50eaf74a309 Mon Sep 17 00:00:00 2001 From: Dmitry Kalyanov Date: Thu, 12 Nov 2009 00:06:04 +0300 Subject: [PATCH] Fix tracking of 'realized' state of gtkglext:gl-drawing-area (thanks to Vitaly Mayatskikh) --- gtk-glext/gtkglext-drawing-area.lisp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gtk-glext/gtkglext-drawing-area.lisp b/gtk-glext/gtkglext-drawing-area.lisp index 06d40ba..65996e1 100644 --- a/gtk-glext/gtkglext-drawing-area.lisp +++ b/gtk-glext/gtkglext-drawing-area.lisp @@ -3,7 +3,8 @@ (defclass gl-drawing-area (drawing-area) ((on-expose :initarg :on-expose :initform nil :accessor gl-drawing-area-on-expose) (on-init :initarg :on-init :initform nil :accessor gl-drawing-area-on-init) - (on-resize :initarg :on-resize :initform nil :accessor gl-drawing-area-on-resize)) + (on-resize :initarg :on-resize :initform nil :accessor gl-drawing-area-on-resize) + (realized-p :initform nil :accessor gl-drawing-area-realized-p)) (:metaclass gobject-class) (:g-type-name . "GtkGLDrawingArea")) @@ -28,7 +29,7 @@ (multiple-value-bind (width height) (gdk:drawable-get-size (widget-window widget)) #+nil(format t "configure ~Dx~D~%" width height) - (when (widget-realized-p widget) + (when (gl-drawing-area-realized-p widget) (resize widget width height)))) (defun gl-drawing-area-realize (widget) @@ -36,11 +37,16 @@ (bwhen (init-fn (gl-drawing-area-on-init widget)) (with-gl-context (widget) (funcall init-fn widget))) + (setf (gl-drawing-area-realized-p widget) t) (multiple-value-bind (width height) (gdk:drawable-get-size (widget-window widget)) (resize widget width height)) nil) +(defun gl-drawing-area-unrealize (widget) + (setf (gl-drawing-area-realized-p widget) nil) + nil) + (defun gl-drawing-area-exposed (widget event) (bwhen (draw-fn (gl-drawing-area-on-expose widget)) (with-gl-context (widget) @@ -60,6 +66,7 @@ (defmethod initialize-instance :after ((widget gl-drawing-area) &key &allow-other-keys) (connect-signal widget "realize" #'gl-drawing-area-realize) + (connect-signal widget "unrealize" #'gl-drawing-area-unrealize) (connect-signal widget "expose-event" #'gl-drawing-area-exposed) (connect-signal widget "configure-event" #'gl-drawing-area-configure) (connect-signal widget "parent-set" #'gl-drawing-area-parent-set)) -- 1.7.10.4