Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable GUI support in GHCi by default on MacOS X #6

Merged
merged 2 commits into from Apr 20, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions wxcore/src/haskell/Graphics/UI/WXCore.hs
Expand Up @@ -62,14 +62,21 @@ import Graphics.UI.WXCore.Layout
import Graphics.UI.WXCore.Image
import Graphics.UI.WXCore.OpenGL

import Graphics.UI.WXCore.GHCiSupport

-- | Start the event loop. Takes an initialisation action as argument.
-- Except for 'run', the functions in the WXH library can only be called
-- from this intialisation action or from event handlers, or otherwise bad
-- things will happen :-)
run :: IO a -> IO ()
run init
= do appOnInit (do wxcAppInitAllImageHandlers
= do enableGUI
appOnInit (do wxcAppInitAllImageHandlers
init
return ())
performGC
performGC
performGC




32 changes: 32 additions & 0 deletions wxcore/src/haskell/Graphics/UI/WXCore/GHCiSupport.hs
@@ -0,0 +1,32 @@
{-# LANGUAGE ForeignFunctionInterface, CPP #-}
module Graphics.UI.WXCore.GHCiSupport(enableGUI) where
-- GHCi support on MacOS X
-- TODO: preprocessor to make it conditional on the platform

#if darwin_HOST_OS

import Data.Int
import Foreign

type ProcessSerialNumber = Int64

foreign import ccall "GetCurrentProcess" getCurrentProcess :: Ptr ProcessSerialNumber -> IO Int16
foreign import ccall "_CGSDefaultConnection" cgsDefaultConnection :: IO ()
foreign import ccall "CPSEnableForegroundOperation" cpsEnableForegroundOperation :: Ptr ProcessSerialNumber -> IO ()
foreign import ccall "CPSSignalAppReady" cpsSignalAppReady :: Ptr ProcessSerialNumber -> IO ()
foreign import ccall "CPSSetFrontProcess" cpsSetFrontProcess :: Ptr ProcessSerialNumber -> IO ()

enableGUI :: IO ()
enableGUI = alloca $ \psn -> do
getCurrentProcess psn
cgsDefaultConnection
cpsEnableForegroundOperation psn
cpsSignalAppReady psn
cpsSetFrontProcess psn

#else

enableGUI :: IO ()
enableGUI = return ()

#endif
6 changes: 6 additions & 0 deletions wxcore/wxcore.cabal
Expand Up @@ -60,6 +60,12 @@ library
Graphics.UI.WXCore.WxcObject
Graphics.UI.WXCore.WxcTypes

other-modules:
Graphics.UI.WXCore.GHCiSupport

frameworks:
Carbon

build-depends:
bytestring,
filepath,
Expand Down