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
;; 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)
((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)))
((widget 'press!))))
((button-release-event? e)
(let ((widget (widget-node-collide? widget-tree mousex mouse)))
((widget 'press!))))
(if state
((widget 'press!))
((widget 'release!))))))
(else #f))))
(loop))))))