From: Duncan C. <dun...@wo...> - 2007-06-30 00:39:59
|
Fri Jun 29 11:21:28 PDT 2007 Duncan Coutts <du...@ha...> * More SOE fixes The main loop now uses a single call to mainGUI which makes threading simpler. Mouse button release events are now collected as well as button down ones. Don't specify position of the window for the BouncingBall demo; having it appear at (800,800) is not very helpful on a 1024x768 screen :-) hunk ./demo/soe/BouncingBall.hs 9 - do w <- openWindowEx "Bouncing Ball" (Just (800,800)) (Just (200, 600)) drawBufferedGraphic (Just 30) + do w <- openWindowEx "Bouncing Ball" Nothing (Just (300, 300)) drawBufferedGraphic (Just 30) hunk ./soegtk/Graphics/SOE/Gtk.hs.pp 109 - quitVar <- newIORef False - forkIO (main >> writeIORef quitVar True) - let loop = do - yield - Gtk.mainIteration - quit <- readIORef quitVar - if quit then return () - else loop - loop - -- give any windows a chance to close - Gtk.flush - return () + forkIO (main >> Gtk.postGUIAsync Gtk.mainQuit) + Gtk.mainGUI hunk ./soegtk/Graphics/SOE/Gtk.hs.pp 203 + Gtk.widgetHide window hunk ./soegtk/Graphics/SOE/Gtk.hs.pp 211 - Gtk.onButtonPress canvas $ \event@Gtk.Button { Gtk.eventX=x, Gtk.eventY=y } -> - writeChan eventsChan Button { - pt = (round x,round y), - isLeft = Gtk.eventButton event == Gtk.LeftButton, - isDown = case Gtk.eventClick event of - Gtk.ReleaseClick -> False - _ -> True - } >> return True + let mouseButtonHandler event@Gtk.Button { Gtk.eventX=x, Gtk.eventY=y } = do + writeChan eventsChan Button { + pt = (round x,round y), + isLeft = Gtk.eventButton event == Gtk.LeftButton, + isDown = case Gtk.eventClick event of + Gtk.ReleaseClick -> False + _ -> True + } + return True + Gtk.onButtonPress canvas mouseButtonHandler + Gtk.onButtonRelease canvas mouseButtonHandler |