diff options
| author | mtgmonkey <mtgmonkey@nixos> | 2025-12-11 18:15:32 +0100 |
|---|---|---|
| committer | mtgmonkey <mtgmonkey@nixos> | 2025-12-11 18:15:32 +0100 |
| commit | 8a16c6695e62de46c4f0cce22ff48276040bcfff (patch) | |
| tree | 23786224830e40708ec4af0ae321f30e98f7aa27 /src | |
| parent | ab69702910741af752ff7ee5820bb85b1f3ddd5c (diff) | |
basic functionality on Wayland and X11
Diffstat (limited to 'src')
| -rw-r--r-- | src/Main.hs | 115 |
1 files changed, 0 insertions, 115 deletions
diff --git a/src/Main.hs b/src/Main.hs deleted file mode 100644 index 67f745e..0000000 --- a/src/Main.hs +++ /dev/null @@ -1,115 +0,0 @@ -{-# LANGUAGE CApiFFI #-} - -module Main (main) where - -import Data.Bits (shiftL, (.|.)) -import Foreign -import Foreign.C.String -import Foreign.C.Types - --------------------------------------------------------------------------------- --- main --------------------------------------------------------------------------------- - -main :: IO () -main = do - window <- withCString "a window" (\name -> - rgfwCreateWindow - name - 0 - 0 - 800 - 600 - $ mkWindowFlags - [ WindowNoResize - , WindowOpenGL - , WindowFullscreen - ] - ) - let loop ctr = do - shouldClose <- rgfwWindowShouldClose window - if 0 /= shouldClose - then return shouldClose - else loop $ ctr + 1 - exitCode <- loop 0 - putStrLn $ show exitCode - return () - --------------------------------------------------------------------------------- --- Haskell-ier abstractions --------------------------------------------------------------------------------- - -data WindowFlags - = WindowNoBorder - | WindowNoResize - | WindowAllowDND - | WindowHideMouse - | WindowFullscreen - | WindowTransparent - | WindowCenter - | WindowRawMouse - | WindowScaleToMonitor - | WindowHide - | WindowMaximize - | WindowCenterCursor - | WindowFloating - | WindowFocusOnShow - | WindowMinimize - | WindowFocus - | WindowOpenGL - | WindowEGL - | WindowedFullscreen - -mkWindowFlags :: [WindowFlags] -> RGFWwindowFlags -mkWindowFlags [] = 0 -mkWindowFlags (flag:flags) = - let - shift = - case flag of - WindowNoBorder -> 0 - WindowNoResize -> 1 - WindowAllowDND -> 2 - WindowHideMouse -> 3 - WindowFullscreen -> 4 - WindowTransparent -> 5 - WindowCenter -> 6 - WindowRawMouse -> 7 - WindowScaleToMonitor -> 8 - WindowHide -> 9 - WindowMaximize -> 10 - WindowCenterCursor -> 11 - WindowFloating -> 12 - WindowFocusOnShow -> 13 - WindowMinimize -> 14 - WindowFocus -> 15 - WindowOpenGL -> 17 - WindowEGL -> 18 - _ -> 19 -- TODO fix this silent error, implement windowedFullscreen - in - (shiftL 1 shift) .|. (mkWindowFlags flags) - --------------------------------------------------------------------------------- --- directly from RFGW.h --------------------------------------------------------------------------------- - --- RGFWindow -data RGFWwindow --- ptr -type RGFWwindowPtr = Ptr RGFWwindow --- flags to create -type RGFWwindowFlags = Word32 - -type RGFWbool = CUInt - -foreign import capi "lib/RGFW_HS.h RGFW_createWindow" rgfwCreateWindow - :: Ptr CChar - -> CInt - -> CInt - -> CInt - -> CInt - -> RGFWwindowFlags - -> IO RGFWwindowPtr - -foreign import capi "lib/RGFW_HS.h RGFW_window_shouldClose" rgfwWindowShouldClose - :: RGFWwindowPtr - -> IO RGFWbool |
