From 9b58a8ab89ed2c63abab81ff8da787cd4dfcf971 Mon Sep 17 00:00:00 2001 From: erana Date: Tue, 17 Jan 2012 15:18:03 +0900 Subject: [PATCH] widget-tree sync eventloop - 2 --- scsh/scgame/scgamewidgets.scm | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/scsh/scgame/scgamewidgets.scm b/scsh/scgame/scgamewidgets.scm index 7c96a6c..568be8b 100644 --- a/scsh/scgame/scgamewidgets.scm +++ b/scsh/scgame/scgamewidgets.scm @@ -209,7 +209,7 @@ ;; This is the main loop you call on your window's ;; widget tree (see above) -(define (widget-tree-eventloop widget-tree) +(define (widget-tree-eventloop dpy win widget-tree) (let ((mousex 0) (mousey 0)) (init-sync-x-events dpy) @@ -225,12 +225,16 @@ ((motion-event? e) (set! mousex (motion-event-x)) (set! mousey (motion-event-y))) - ((button-press-event? e) - (let ((widget (widget-node-collide? widget-tree mousex mouse))) - ((widget 'press!)))) - ((button-release-event? e) - (let ((widget (widget-node-collide? widget-tree mousex mouse))) - ((widget 'press!)))) + ((map-event? e) + (map-window dpy win)) + ((unmap-event? e) + (unmap-window dpy win)) + ((button-event? e) + (let ((state button-event-state)) + (let ((widget (widget-node-collide? widget-tree mousex mouse))) + (if state + ((widget 'press!)) + ((widget 'release!)))))) (else #f)))) (loop))))))