Hi,
I've been reading the "Guided Tour" paper included in mcclim/Doc, and I've found a peculiar behavior for the "Hello World" example on my system (latest mcclim from CVS, sbcl 0.9.13, Mac OS X 10.4.7 on PPC running X11.app) and I'm not sure if it's - a bug in mcclim, or - a bug in X11.app, or - a bug in my understanding of how CLIM works, or - a feature! In any event, the issue is as follows.
I run the following code (taken verbatim from the paper) in the CLIM-USER package at the REPL: ------------------------------------------------------------------------ (define-application-frame hello-world () ((greeting :initform "Hello World" :accessor greeting)) (:pane (make-pane 'hello-world-pane)))
(defclass hello-world-pane (clim-stream-pane) ())
(defmethod handle-repaint ((pane hello-world-pane) region) (let ((w (bounding-rectangle-width pane)) (h (bounding-rectangle-height pane))) ;; Blank the pane out (draw-rectangle* pane 0 0 w h :filled t :ink (pane-background pane)) ;; Draw greeting in center of pane (draw-text* pane (greeting *application-frame*) (floor w 2) (floor h 2) :align-x :center :align-y :center)))
(defun make-and-run-hello-world () (run-frame-top-level (make-application-frame 'hello-world)))
(make-and-run-hello-world) ------------------------------------------------------------------------ and I do indeed get a very small window popping up with "Hello World" in it. (The window is so tiny, in fact, that it only shows about 5 letters, and that only thanks to the window manager requirement to make the window large enough to accomodate the usual "expand, hide, kill" buttons of the Mac OS X window manager.) I then grab the manual "resizing" corner of the window and make it bigger, and things are fine, with the text of "Hello World" dynamically readjusting itself to stay centered in the window.
The problem comes when I try to use the same mechanism to make the window smaller. Whenever dragging the corner of the window is used to reduce the size of the window, the text does not automatically recenter but rather stays in the same absolute position on the screen. (I am attaching a PNG which shows the effect of expanding a window and then shrinking it again using the "resizer" in the lower right corner of the window -- the text is clearly no longer centered.) Any attempt to enlarge the window (in either or both dimensions) will instantly recenter the text again.
Clearly, the "shrink window" event is not being acted on for recentering purposes. But is this a bug in McClim (i.e., it should be repainting on shrink but is not), or is it a bug in the Mac OS X X11.app (i.e., it should be sending some sort of message on shrink but is not) or is it my misunderstanding (i.e., I should be adding some code to get the repaint to activate on shrink, and I have not done so)?
Thanks for any insight you can provide!
Dan
At Sun, 10 Sep 2006 08:54:36 -0400, Daniel Katz dpkatz@gmail.com wrote:
Clearly, the "shrink window" event is not being acted on for recentering purposes. But is this a bug in McClim (i.e., it should be repainting on shrink but is not), or is it a bug in the Mac OS X X11.app (i.e., it should be sending some sort of message on shrink but is not) or is it my misunderstanding (i.e., I should be adding some code to get the repaint to activate on shrink, and I have not done so)?
I think McCLIM acts alright to not send repaint events as no window damage is reported.
To fix this, Hello World should also listen to the window-configuration-event.
(defmethod handle-event ((pane hello-world-pane) (event window-configuration-event)) (handle-repaint paint +everwhere+))
..I hope +everywhere+ is the correct constant for the everywhere region..
So maybe add a mental rule (and/or as footnote to the Hello World example): whenever the content of a window is dependend on the window size and we are using handle-repaint, remember to trigger this repaint also on a window-configuration-event.
On Sep 10, 2006, at 15:29, Clemens Fruhwirth wrote:
At Sun, 10 Sep 2006 08:54:36 -0400, Daniel Katz dpkatz@gmail.com wrote:
Clearly, the "shrink window" event is not being acted on for recentering purposes. But is this a bug in McClim (i.e., it should be repainting on shrink but is not), or is it a bug in the Mac OS X X11.app (i.e., it should be sending some sort of message on shrink but is not) or is it my misunderstanding (i.e., I should be adding some code to get the repaint to activate on shrink, and I have not done so)?
I think McCLIM acts alright to not send repaint events as no window damage is reported.
Okay -- this makes sense. The 'handle-repaint' function says what to do when a repaint is triggered, but doesn't say anything about the circumstances under which a repaint will happen (e.g., when the text becomes de-centered due to some window manipulation). That was the source of my confusion, I think.
To fix this, Hello World should also listen to the window- configuration-event.
(defmethod handle-event ((pane hello-world-pane) (event window- configuration-event)) (handle-repaint paint +everwhere+))
I assume that the final subform is meant to be (handle-repaint pane +everywhere+).
For the record, I tried this and didn't get the behavior of having the text re-center when shrinking the window. I then tried to test whether I was getting window-configuration-event's with the following
(defmethod handle-event ((pane hello-world-pane) (event window- configuration-event)) (print (class-of event)) (terpri) (handle-repaint pane +everywhere+))
and found that I was getting no events anywhere. Finally, I tried to examine all of the relevant window-events with
(defmethod handle-event ((pane hello-world-pane) (event window-event)) (print (class-of event)) (terpri) (handle-repaint pane +everywhere+))
and found that every time I expanded the window I was getting a #<STANDARD-CLASS WINDOW-REPAINT-EVENT>, and no event at all for shrinking the window. Seems peculiar to me (perhaps something in the interaction of the window manager and CLIM?), but it's not what I was really going after when I started this thread so I'm going to ignore it for now and continue with the paper.
Thanks for your help!
Dan