widget-tree sync eventloop - 2

This commit is contained in:
erana 2012-01-17 15:18:03 +09:00
parent c4a75d8570
commit 9b58a8ab89
1 changed files with 11 additions and 7 deletions

View File

@ -209,7 +209,7 @@
;; This is the main loop you call on your window's ;; This is the main loop you call on your window's
;; widget tree (see above) ;; widget tree (see above)
(define (widget-tree-eventloop widget-tree) (define (widget-tree-eventloop dpy win widget-tree)
(let ((mousex 0) (let ((mousex 0)
(mousey 0)) (mousey 0))
(init-sync-x-events dpy) (init-sync-x-events dpy)
@ -225,12 +225,16 @@
((motion-event? e) ((motion-event? e)
(set! mousex (motion-event-x)) (set! mousex (motion-event-x))
(set! mousey (motion-event-y))) (set! mousey (motion-event-y)))
((button-press-event? e) ((map-event? e)
(let ((widget (widget-node-collide? widget-tree mousex mouse))) (map-window dpy win))
((widget 'press!)))) ((unmap-event? e)
((button-release-event? e) (unmap-window dpy win))
(let ((widget (widget-node-collide? widget-tree mousex mouse))) ((button-event? e)
((widget 'press!)))) (let ((state button-event-state))
(let ((widget (widget-node-collide? widget-tree mousex mouse)))
(if state
((widget 'press!))
((widget 'release!))))))
(else #f)))) (else #f))))
(loop)))))) (loop))))))