{-# LINE 1 "Graphics/X11/Xrandr.hsc" #-}
{-# LANGUAGE DeriveDataTypeable #-}
--------------------------------------------------------------------
-- |
-- Module    : Graphics.X11.Xrandr
-- Copyright : (c) Haskell.org, 2012
--             (c) Jochen Keil, 2012
-- License   : BSD3
--
-- Maintainer: Ben Boeckel <mathstuf@gmail.com>
--           , Jochen Keil <jochen dot keil at gmail dot com>
--
-- Stability : provisional
-- Portability: portable
--
--------------------------------------------------------------------
--
-- Interface to Xrandr API
--

module Graphics.X11.Xrandr (
  XRRScreenSize(..),
  XRRModeInfo(..),
  XRRScreenResources(..),
  XRROutputInfo(..),
  XRRCrtcInfo(..),
  XRRPropertyInfo(..),
  XRRMonitorInfo(..),
  compiledWithXrandr,
  Rotation,
  Reflection,
  SizeID,
  XRRScreenConfiguration,
  xrrQueryExtension,
  xrrQueryVersion,
  xrrGetScreenInfo,
  xrrFreeScreenConfigInfo,
  xrrSetScreenConfig,
  xrrSetScreenConfigAndRate,
  xrrConfigRotations,
  xrrConfigTimes,
  xrrConfigSizes,
  xrrConfigRates,
  xrrConfigCurrentConfiguration,
  xrrConfigCurrentRate,
  xrrRootToScreen,
  xrrSelectInput,
  xrrUpdateConfiguration,
  xrrRotations,
  xrrSizes,
  xrrRates,
  xrrTimes,
  xrrGetScreenResources,
  xrrGetOutputInfo,
  xrrGetCrtcInfo,
  xrrGetScreenResourcesCurrent,
  xrrSetOutputPrimary,
  xrrGetOutputPrimary,
  xrrListOutputProperties,
  xrrQueryOutputProperty,
  xrrConfigureOutputProperty,
  xrrChangeOutputProperty,
  xrrGetOutputProperty,
  xrrDeleteOutputProperty,
  xrrGetMonitors,
  ) where

import Foreign
import Foreign.C.Types
import Foreign.C.String
import Control.Monad

import Graphics.X11.Xlib.Event
import Graphics.X11.Xlib.Internal
import Graphics.X11.Xlib.Types
import Graphics.X11.Types


{-# LINE 78 "Graphics/X11/Xrandr.hsc" #-}
import Data.Data

{-# LINE 80 "Graphics/X11/Xrandr.hsc" #-}

-- | Representation of the XRRScreenSize struct
data XRRScreenSize = XRRScreenSize
                     { XRRScreenSize -> CInt
xrr_ss_width   :: !CInt,
                       XRRScreenSize -> CInt
xrr_ss_height  :: !CInt,
                       XRRScreenSize -> CInt
xrr_ss_mwidth  :: !CInt,
                       XRRScreenSize -> CInt
xrr_ss_mheight :: !CInt }
                       deriving (Int -> XRRScreenSize -> ShowS
[XRRScreenSize] -> ShowS
XRRScreenSize -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [XRRScreenSize] -> ShowS
$cshowList :: [XRRScreenSize] -> ShowS
show :: XRRScreenSize -> String
$cshow :: XRRScreenSize -> String
showsPrec :: Int -> XRRScreenSize -> ShowS
$cshowsPrec :: Int -> XRRScreenSize -> ShowS
Show)

-- | Representation of the XRRModeInfo struct
data XRRModeInfo = XRRModeInfo
    { XRRModeInfo -> Atom
xrr_mi_id         :: !RRMode
    , XRRModeInfo -> CUInt
xrr_mi_width      :: !CUInt
    , XRRModeInfo -> CUInt
xrr_mi_height     :: !CUInt
    , XRRModeInfo -> CUInt
xrr_mi_dotClock   :: !CUInt
    , XRRModeInfo -> CUInt
xrr_mi_hSyncStart :: !CUInt
    , XRRModeInfo -> CUInt
xrr_mi_hSyncEnd   :: !CUInt
    , XRRModeInfo -> CUInt
xrr_mi_hTotal     :: !CUInt
    , XRRModeInfo -> CUInt
xrr_mi_hSkew      :: !CUInt
    , XRRModeInfo -> CUInt
xrr_mi_vSyncStart :: !CUInt
    , XRRModeInfo -> CUInt
xrr_mi_vSyncEnd   :: !CUInt
    , XRRModeInfo -> CUInt
xrr_mi_vTotal     :: !CUInt
    , XRRModeInfo -> String
xrr_mi_name       :: !String
    , XRRModeInfo -> Atom
xrr_mi_modeFlags  :: !XRRModeFlags
    } deriving (XRRModeInfo -> XRRModeInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: XRRModeInfo -> XRRModeInfo -> Bool
$c/= :: XRRModeInfo -> XRRModeInfo -> Bool
== :: XRRModeInfo -> XRRModeInfo -> Bool
$c== :: XRRModeInfo -> XRRModeInfo -> Bool
Eq, Int -> XRRModeInfo -> ShowS
[XRRModeInfo] -> ShowS
XRRModeInfo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [XRRModeInfo] -> ShowS
$cshowList :: [XRRModeInfo] -> ShowS
show :: XRRModeInfo -> String
$cshow :: XRRModeInfo -> String
showsPrec :: Int -> XRRModeInfo -> ShowS
$cshowsPrec :: Int -> XRRModeInfo -> ShowS
Show)

-- | Representation of the XRRScreenResources struct
data XRRScreenResources = XRRScreenResources
    { XRRScreenResources -> Atom
xrr_sr_timestamp       :: !Time
    , XRRScreenResources -> Atom
xrr_sr_configTimestamp :: !Time
    , XRRScreenResources -> [Atom]
xrr_sr_crtcs           :: [RRCrtc]
    , XRRScreenResources -> [Atom]
xrr_sr_outputs         :: [RROutput]
    , XRRScreenResources -> [XRRModeInfo]
xrr_sr_modes           :: [XRRModeInfo]
    } deriving (XRRScreenResources -> XRRScreenResources -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: XRRScreenResources -> XRRScreenResources -> Bool
$c/= :: XRRScreenResources -> XRRScreenResources -> Bool
== :: XRRScreenResources -> XRRScreenResources -> Bool
$c== :: XRRScreenResources -> XRRScreenResources -> Bool
Eq, Int -> XRRScreenResources -> ShowS
[XRRScreenResources] -> ShowS
XRRScreenResources -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [XRRScreenResources] -> ShowS
$cshowList :: [XRRScreenResources] -> ShowS
show :: XRRScreenResources -> String
$cshow :: XRRScreenResources -> String
showsPrec :: Int -> XRRScreenResources -> ShowS
$cshowsPrec :: Int -> XRRScreenResources -> ShowS
Show)

-- | Representation of the XRROutputInfo struct
data XRROutputInfo = XRROutputInfo
    { XRROutputInfo -> Atom
xrr_oi_timestamp      :: !Time
    , XRROutputInfo -> Atom
xrr_oi_crtc           :: !RRCrtc
    , XRROutputInfo -> String
xrr_oi_name           :: !String
    , XRROutputInfo -> CULong
xrr_oi_mm_width       :: !CULong
    , XRROutputInfo -> CULong
xrr_oi_mm_height      :: !CULong
    , XRROutputInfo -> Word16
xrr_oi_connection     :: !Connection
    , XRROutputInfo -> Word16
xrr_oi_subpixel_order :: !SubpixelOrder
    , XRROutputInfo -> [Atom]
xrr_oi_crtcs          :: [RRCrtc]
    , XRROutputInfo -> [Atom]
xrr_oi_clones         :: [RROutput]
    , XRROutputInfo -> CInt
xrr_oi_npreferred     :: !CInt
    , XRROutputInfo -> [Atom]
xrr_oi_modes          :: [RRMode]
    } deriving (XRROutputInfo -> XRROutputInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: XRROutputInfo -> XRROutputInfo -> Bool
$c/= :: XRROutputInfo -> XRROutputInfo -> Bool
== :: XRROutputInfo -> XRROutputInfo -> Bool
$c== :: XRROutputInfo -> XRROutputInfo -> Bool
Eq, Int -> XRROutputInfo -> ShowS
[XRROutputInfo] -> ShowS
XRROutputInfo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [XRROutputInfo] -> ShowS
$cshowList :: [XRROutputInfo] -> ShowS
show :: XRROutputInfo -> String
$cshow :: XRROutputInfo -> String
showsPrec :: Int -> XRROutputInfo -> ShowS
$cshowsPrec :: Int -> XRROutputInfo -> ShowS
Show)

-- | Representation of the XRRCrtcInfo struct
data XRRCrtcInfo = XRRCrtcInfo
    { XRRCrtcInfo -> Atom
xrr_ci_timestamp    :: !Time
    , XRRCrtcInfo -> CInt
xrr_ci_x            :: !CInt
    , XRRCrtcInfo -> CInt
xrr_ci_y            :: !CInt
    , XRRCrtcInfo -> CUInt
xrr_ci_width        :: !CUInt
    , XRRCrtcInfo -> CUInt
xrr_ci_height       :: !CUInt
    , XRRCrtcInfo -> Atom
xrr_ci_mode         :: !RRMode
    , XRRCrtcInfo -> Word16
xrr_ci_rotation     :: !Rotation
    , XRRCrtcInfo -> [Atom]
xrr_ci_outputs      :: [RROutput]
    , XRRCrtcInfo -> Word16
xrr_ci_rotations    :: !Rotation
    , XRRCrtcInfo -> [Atom]
xrr_ci_possible     :: [RROutput]
    } deriving (XRRCrtcInfo -> XRRCrtcInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: XRRCrtcInfo -> XRRCrtcInfo -> Bool
$c/= :: XRRCrtcInfo -> XRRCrtcInfo -> Bool
== :: XRRCrtcInfo -> XRRCrtcInfo -> Bool
$c== :: XRRCrtcInfo -> XRRCrtcInfo -> Bool
Eq, Int -> XRRCrtcInfo -> ShowS
[XRRCrtcInfo] -> ShowS
XRRCrtcInfo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [XRRCrtcInfo] -> ShowS
$cshowList :: [XRRCrtcInfo] -> ShowS
show :: XRRCrtcInfo -> String
$cshow :: XRRCrtcInfo -> String
showsPrec :: Int -> XRRCrtcInfo -> ShowS
$cshowsPrec :: Int -> XRRCrtcInfo -> ShowS
Show)

-- | Representation of the XRRPropertyInfo struct
data XRRPropertyInfo = XRRPropertyInfo
    { XRRPropertyInfo -> Bool
xrr_pi_pending      :: !Bool
    , XRRPropertyInfo -> Bool
xrr_pi_range        :: !Bool
    , XRRPropertyInfo -> Bool
xrr_pi_immutable    :: !Bool
    , XRRPropertyInfo -> [CLong]
xrr_pi_values       :: [CLong]
    } deriving (XRRPropertyInfo -> XRRPropertyInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: XRRPropertyInfo -> XRRPropertyInfo -> Bool
$c/= :: XRRPropertyInfo -> XRRPropertyInfo -> Bool
== :: XRRPropertyInfo -> XRRPropertyInfo -> Bool
$c== :: XRRPropertyInfo -> XRRPropertyInfo -> Bool
Eq, Int -> XRRPropertyInfo -> ShowS
[XRRPropertyInfo] -> ShowS
XRRPropertyInfo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [XRRPropertyInfo] -> ShowS
$cshowList :: [XRRPropertyInfo] -> ShowS
show :: XRRPropertyInfo -> String
$cshow :: XRRPropertyInfo -> String
showsPrec :: Int -> XRRPropertyInfo -> ShowS
$cshowsPrec :: Int -> XRRPropertyInfo -> ShowS
Show)

-- | Representation of the XRRMonitorInfo struct
data XRRMonitorInfo = XRRMonitorInfo
   { XRRMonitorInfo -> Atom
xrr_moninf_name      :: !Atom
   , XRRMonitorInfo -> Bool
xrr_moninf_primary   :: !Bool
   , XRRMonitorInfo -> Bool
xrr_moninf_automatic :: !Bool
   , XRRMonitorInfo -> CInt
xrr_moninf_x         :: !CInt
   , XRRMonitorInfo -> CInt
xrr_moninf_y         :: !CInt
   , XRRMonitorInfo -> CInt
xrr_moninf_width     :: !CInt
   , XRRMonitorInfo -> CInt
xrr_moninf_height    :: !CInt
   , XRRMonitorInfo -> CInt
xrr_moninf_mwidth    :: !CInt
   , XRRMonitorInfo -> CInt
xrr_moninf_mheight   :: !CInt
   , XRRMonitorInfo -> [Atom]
xrr_moninf_outputs   :: [RROutput]
   } deriving (XRRMonitorInfo -> XRRMonitorInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: XRRMonitorInfo -> XRRMonitorInfo -> Bool
$c/= :: XRRMonitorInfo -> XRRMonitorInfo -> Bool
== :: XRRMonitorInfo -> XRRMonitorInfo -> Bool
$c== :: XRRMonitorInfo -> XRRMonitorInfo -> Bool
Eq, Int -> XRRMonitorInfo -> ShowS
[XRRMonitorInfo] -> ShowS
XRRMonitorInfo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [XRRMonitorInfo] -> ShowS
$cshowList :: [XRRMonitorInfo] -> ShowS
show :: XRRMonitorInfo -> String
$cshow :: XRRMonitorInfo -> String
showsPrec :: Int -> XRRMonitorInfo -> ShowS
$cshowsPrec :: Int -> XRRMonitorInfo -> ShowS
Show)

-- We have Xrandr, so the library will actually work
compiledWithXrandr :: Bool
compiledWithXrandr :: Bool
compiledWithXrandr = Bool
True



newtype XRRScreenConfiguration = XRRScreenConfiguration (Ptr XRRScreenConfiguration)

{-# LINE 174 "Graphics/X11/Xrandr.hsc" #-}
        deriving (XRRScreenConfiguration -> XRRScreenConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: XRRScreenConfiguration -> XRRScreenConfiguration -> Bool
$c/= :: XRRScreenConfiguration -> XRRScreenConfiguration -> Bool
== :: XRRScreenConfiguration -> XRRScreenConfiguration -> Bool
$c== :: XRRScreenConfiguration -> XRRScreenConfiguration -> Bool
Eq, Eq XRRScreenConfiguration
XRRScreenConfiguration -> XRRScreenConfiguration -> Bool
XRRScreenConfiguration -> XRRScreenConfiguration -> Ordering
XRRScreenConfiguration
-> XRRScreenConfiguration -> XRRScreenConfiguration
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: XRRScreenConfiguration
-> XRRScreenConfiguration -> XRRScreenConfiguration
$cmin :: XRRScreenConfiguration
-> XRRScreenConfiguration -> XRRScreenConfiguration
max :: XRRScreenConfiguration
-> XRRScreenConfiguration -> XRRScreenConfiguration
$cmax :: XRRScreenConfiguration
-> XRRScreenConfiguration -> XRRScreenConfiguration
>= :: XRRScreenConfiguration -> XRRScreenConfiguration -> Bool
$c>= :: XRRScreenConfiguration -> XRRScreenConfiguration -> Bool
> :: XRRScreenConfiguration -> XRRScreenConfiguration -> Bool
$c> :: XRRScreenConfiguration -> XRRScreenConfiguration -> Bool
<= :: XRRScreenConfiguration -> XRRScreenConfiguration -> Bool
$c<= :: XRRScreenConfiguration -> XRRScreenConfiguration -> Bool
< :: XRRScreenConfiguration -> XRRScreenConfiguration -> Bool
$c< :: XRRScreenConfiguration -> XRRScreenConfiguration -> Bool
compare :: XRRScreenConfiguration -> XRRScreenConfiguration -> Ordering
$ccompare :: XRRScreenConfiguration -> XRRScreenConfiguration -> Ordering
Ord, Int -> XRRScreenConfiguration -> ShowS
[XRRScreenConfiguration] -> ShowS
XRRScreenConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [XRRScreenConfiguration] -> ShowS
$cshowList :: [XRRScreenConfiguration] -> ShowS
show :: XRRScreenConfiguration -> String
$cshow :: XRRScreenConfiguration -> String
showsPrec :: Int -> XRRScreenConfiguration -> ShowS
$cshowsPrec :: Int -> XRRScreenConfiguration -> ShowS
Show, Typeable, Typeable XRRScreenConfiguration
XRRScreenConfiguration -> DataType
XRRScreenConfiguration -> Constr
(forall b. Data b => b -> b)
-> XRRScreenConfiguration -> XRRScreenConfiguration
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> XRRScreenConfiguration -> u
forall u.
(forall d. Data d => d -> u) -> XRRScreenConfiguration -> [u]
forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> XRRScreenConfiguration
-> r
forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> XRRScreenConfiguration
-> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> XRRScreenConfiguration -> m XRRScreenConfiguration
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> XRRScreenConfiguration -> m XRRScreenConfiguration
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c XRRScreenConfiguration
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> XRRScreenConfiguration
-> c XRRScreenConfiguration
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c XRRScreenConfiguration)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c XRRScreenConfiguration)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> XRRScreenConfiguration -> m XRRScreenConfiguration
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> XRRScreenConfiguration -> m XRRScreenConfiguration
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> XRRScreenConfiguration -> m XRRScreenConfiguration
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> XRRScreenConfiguration -> m XRRScreenConfiguration
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> XRRScreenConfiguration -> m XRRScreenConfiguration
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> XRRScreenConfiguration -> m XRRScreenConfiguration
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> XRRScreenConfiguration -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> XRRScreenConfiguration -> u
gmapQ :: forall u.
(forall d. Data d => d -> u) -> XRRScreenConfiguration -> [u]
$cgmapQ :: forall u.
(forall d. Data d => d -> u) -> XRRScreenConfiguration -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> XRRScreenConfiguration
-> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> XRRScreenConfiguration
-> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> XRRScreenConfiguration
-> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> XRRScreenConfiguration
-> r
gmapT :: (forall b. Data b => b -> b)
-> XRRScreenConfiguration -> XRRScreenConfiguration
$cgmapT :: (forall b. Data b => b -> b)
-> XRRScreenConfiguration -> XRRScreenConfiguration
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c XRRScreenConfiguration)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c XRRScreenConfiguration)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c XRRScreenConfiguration)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c XRRScreenConfiguration)
dataTypeOf :: XRRScreenConfiguration -> DataType
$cdataTypeOf :: XRRScreenConfiguration -> DataType
toConstr :: XRRScreenConfiguration -> Constr
$ctoConstr :: XRRScreenConfiguration -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c XRRScreenConfiguration
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c XRRScreenConfiguration
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> XRRScreenConfiguration
-> c XRRScreenConfiguration
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> XRRScreenConfiguration
-> c XRRScreenConfiguration
Data)

{-# LINE 178 "Graphics/X11/Xrandr.hsc" #-}

instance Storable XRRScreenSize where
    sizeOf :: XRRScreenSize -> Int
sizeOf XRRScreenSize
_ = (Int
16)
{-# LINE 181 "Graphics/X11/Xrandr.hsc" #-}
    -- FIXME: Is this right?
    alignment :: XRRScreenSize -> Int
alignment XRRScreenSize
_ = forall a. Storable a => a -> Int
alignment (forall a. HasCallStack => a
undefined :: CInt)

    poke :: Ptr XRRScreenSize -> XRRScreenSize -> IO ()
poke Ptr XRRScreenSize
p XRRScreenSize
xrr_ss = do
        (\Ptr XRRScreenSize
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRScreenSize
hsc_ptr Int
0) Ptr XRRScreenSize
p forall a b. (a -> b) -> a -> b
$ XRRScreenSize -> CInt
xrr_ss_width XRRScreenSize
xrr_ss
{-# LINE 186 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRScreenSize
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRScreenSize
hsc_ptr Int
4) Ptr XRRScreenSize
p forall a b. (a -> b) -> a -> b
$ XRRScreenSize -> CInt
xrr_ss_height XRRScreenSize
xrr_ss
{-# LINE 187 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRScreenSize
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRScreenSize
hsc_ptr Int
8) Ptr XRRScreenSize
p forall a b. (a -> b) -> a -> b
$ XRRScreenSize -> CInt
xrr_ss_mwidth XRRScreenSize
xrr_ss
{-# LINE 188 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRScreenSize
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRScreenSize
hsc_ptr Int
12) Ptr XRRScreenSize
p forall a b. (a -> b) -> a -> b
$ XRRScreenSize -> CInt
xrr_ss_mheight XRRScreenSize
xrr_ss
{-# LINE 189 "Graphics/X11/Xrandr.hsc" #-}

    peek :: Ptr XRRScreenSize -> IO XRRScreenSize
peek Ptr XRRScreenSize
p = forall (m :: * -> *) a. Monad m => a -> m a
return CInt -> CInt -> CInt -> CInt -> XRRScreenSize
XRRScreenSize
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ((\Ptr XRRScreenSize
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRScreenSize
hsc_ptr Int
0) Ptr XRRScreenSize
p)
{-# LINE 192 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ((\Ptr XRRScreenSize
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRScreenSize
hsc_ptr Int
4) Ptr XRRScreenSize
p)
{-# LINE 193 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ((\Ptr XRRScreenSize
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRScreenSize
hsc_ptr Int
8) Ptr XRRScreenSize
p)
{-# LINE 194 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ((\Ptr XRRScreenSize
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRScreenSize
hsc_ptr Int
12) Ptr XRRScreenSize
p)
{-# LINE 195 "Graphics/X11/Xrandr.hsc" #-}

instance Storable XRRModeInfo where
    sizeOf :: XRRModeInfo -> Int
sizeOf XRRModeInfo
_ = (Int
80)
{-# LINE 198 "Graphics/X11/Xrandr.hsc" #-}
    -- FIXME: Is this right?
    alignment :: XRRModeInfo -> Int
alignment XRRModeInfo
_ = forall a. Storable a => a -> Int
alignment (forall a. HasCallStack => a
undefined :: CInt)

    poke :: Ptr XRRModeInfo -> XRRModeInfo -> IO ()
poke Ptr XRRModeInfo
p XRRModeInfo
xrr_mi = do
        (\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRModeInfo
hsc_ptr Int
0) Ptr XRRModeInfo
p forall a b. (a -> b) -> a -> b
$ XRRModeInfo -> Atom
xrr_mi_id         XRRModeInfo
xrr_mi
{-# LINE 203 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRModeInfo
hsc_ptr Int
8) Ptr XRRModeInfo
p forall a b. (a -> b) -> a -> b
$ XRRModeInfo -> CUInt
xrr_mi_width      XRRModeInfo
xrr_mi
{-# LINE 204 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRModeInfo
hsc_ptr Int
12) Ptr XRRModeInfo
p forall a b. (a -> b) -> a -> b
$ XRRModeInfo -> CUInt
xrr_mi_height     XRRModeInfo
xrr_mi
{-# LINE 205 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRModeInfo
hsc_ptr Int
16) Ptr XRRModeInfo
p forall a b. (a -> b) -> a -> b
$ XRRModeInfo -> CUInt
xrr_mi_dotClock   XRRModeInfo
xrr_mi
{-# LINE 206 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRModeInfo
hsc_ptr Int
24) Ptr XRRModeInfo
p forall a b. (a -> b) -> a -> b
$ XRRModeInfo -> CUInt
xrr_mi_hSyncStart XRRModeInfo
xrr_mi
{-# LINE 207 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRModeInfo
hsc_ptr Int
28) Ptr XRRModeInfo
p forall a b. (a -> b) -> a -> b
$ XRRModeInfo -> CUInt
xrr_mi_hSyncEnd   XRRModeInfo
xrr_mi
{-# LINE 208 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRModeInfo
hsc_ptr Int
32) Ptr XRRModeInfo
p forall a b. (a -> b) -> a -> b
$ XRRModeInfo -> CUInt
xrr_mi_hTotal     XRRModeInfo
xrr_mi
{-# LINE 209 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRModeInfo
hsc_ptr Int
36) Ptr XRRModeInfo
p forall a b. (a -> b) -> a -> b
$ XRRModeInfo -> CUInt
xrr_mi_hSkew      XRRModeInfo
xrr_mi
{-# LINE 210 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRModeInfo
hsc_ptr Int
40) Ptr XRRModeInfo
p forall a b. (a -> b) -> a -> b
$ XRRModeInfo -> CUInt
xrr_mi_vSyncStart XRRModeInfo
xrr_mi
{-# LINE 211 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRModeInfo
hsc_ptr Int
44) Ptr XRRModeInfo
p forall a b. (a -> b) -> a -> b
$ XRRModeInfo -> CUInt
xrr_mi_vSyncEnd   XRRModeInfo
xrr_mi
{-# LINE 212 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRModeInfo
hsc_ptr Int
48) Ptr XRRModeInfo
p forall a b. (a -> b) -> a -> b
$ XRRModeInfo -> CUInt
xrr_mi_vTotal     XRRModeInfo
xrr_mi
{-# LINE 213 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRModeInfo
hsc_ptr Int
72) Ptr XRRModeInfo
p forall a b. (a -> b) -> a -> b
$ XRRModeInfo -> Atom
xrr_mi_modeFlags  XRRModeInfo
xrr_mi
{-# LINE 214 "Graphics/X11/Xrandr.hsc" #-}
        -- see comment in Storable XRRScreenResources about dynamic resource allocation
        (\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRModeInfo
hsc_ptr Int
64) Ptr XRRModeInfo
p ( CInt
0 :: CInt )
{-# LINE 216 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRModeInfo
hsc_ptr Int
56) Ptr XRRModeInfo
p ( forall a. Ptr a
nullPtr :: Ptr CChar )
{-# LINE 217 "Graphics/X11/Xrandr.hsc" #-}

    peek :: Ptr XRRModeInfo -> IO XRRModeInfo
peek Ptr XRRModeInfo
p = forall (m :: * -> *) a. Monad m => a -> m a
return Atom
-> CUInt
-> CUInt
-> CUInt
-> CUInt
-> CUInt
-> CUInt
-> CUInt
-> CUInt
-> CUInt
-> CUInt
-> String
-> Atom
-> XRRModeInfo
XRRModeInfo
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRModeInfo
hsc_ptr Int
0) Ptr XRRModeInfo
p )
{-# LINE 220 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRModeInfo
hsc_ptr Int
8) Ptr XRRModeInfo
p )
{-# LINE 221 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRModeInfo
hsc_ptr Int
12) Ptr XRRModeInfo
p )
{-# LINE 222 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRModeInfo
hsc_ptr Int
16) Ptr XRRModeInfo
p )
{-# LINE 223 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRModeInfo
hsc_ptr Int
24) Ptr XRRModeInfo
p )
{-# LINE 224 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRModeInfo
hsc_ptr Int
28) Ptr XRRModeInfo
p )
{-# LINE 225 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRModeInfo
hsc_ptr Int
32) Ptr XRRModeInfo
p )
{-# LINE 226 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRModeInfo
hsc_ptr Int
36) Ptr XRRModeInfo
p )
{-# LINE 227 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRModeInfo
hsc_ptr Int
40) Ptr XRRModeInfo
p )
{-# LINE 228 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRModeInfo
hsc_ptr Int
44) Ptr XRRModeInfo
p )
{-# LINE 229 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRModeInfo
hsc_ptr Int
48) Ptr XRRModeInfo
p )
{-# LINE 230 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` IO CInt -> IO (Ptr CChar) -> IO String
peekCStringLenIO ((\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRModeInfo
hsc_ptr Int
64) Ptr XRRModeInfo
p)
{-# LINE 231 "Graphics/X11/Xrandr.hsc" #-}
                              ((\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRModeInfo
hsc_ptr Int
56) Ptr XRRModeInfo
p)
{-# LINE 232 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRModeInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRModeInfo
hsc_ptr Int
72) Ptr XRRModeInfo
p )
{-# LINE 233 "Graphics/X11/Xrandr.hsc" #-}

instance Storable XRRMonitorInfo where
    sizeOf :: XRRMonitorInfo -> Int
sizeOf XRRMonitorInfo
_ = (Int
56)
{-# LINE 236 "Graphics/X11/Xrandr.hsc" #-}
    -- FIXME: Is this right?
    alignment :: XRRMonitorInfo -> Int
alignment XRRMonitorInfo
_ = forall a. Storable a => a -> Int
alignment (forall a. HasCallStack => a
undefined :: CInt)

    poke :: Ptr XRRMonitorInfo -> XRRMonitorInfo -> IO ()
poke Ptr XRRMonitorInfo
p XRRMonitorInfo
xrr_moninf = do
        (\Ptr XRRMonitorInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRMonitorInfo
hsc_ptr Int
0) Ptr XRRMonitorInfo
p forall a b. (a -> b) -> a -> b
$ XRRMonitorInfo -> Atom
xrr_moninf_name      XRRMonitorInfo
xrr_moninf
{-# LINE 241 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRMonitorInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRMonitorInfo
hsc_ptr Int
8) Ptr XRRMonitorInfo
p forall a b. (a -> b) -> a -> b
$ XRRMonitorInfo -> Bool
xrr_moninf_primary   XRRMonitorInfo
xrr_moninf
{-# LINE 242 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRMonitorInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRMonitorInfo
hsc_ptr Int
12) Ptr XRRMonitorInfo
p forall a b. (a -> b) -> a -> b
$ XRRMonitorInfo -> Bool
xrr_moninf_automatic XRRMonitorInfo
xrr_moninf
{-# LINE 243 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRMonitorInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRMonitorInfo
hsc_ptr Int
20) Ptr XRRMonitorInfo
p forall a b. (a -> b) -> a -> b
$ XRRMonitorInfo -> CInt
xrr_moninf_x         XRRMonitorInfo
xrr_moninf
{-# LINE 244 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRMonitorInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRMonitorInfo
hsc_ptr Int
24) Ptr XRRMonitorInfo
p forall a b. (a -> b) -> a -> b
$ XRRMonitorInfo -> CInt
xrr_moninf_y         XRRMonitorInfo
xrr_moninf
{-# LINE 245 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRMonitorInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRMonitorInfo
hsc_ptr Int
28) Ptr XRRMonitorInfo
p forall a b. (a -> b) -> a -> b
$ XRRMonitorInfo -> CInt
xrr_moninf_width     XRRMonitorInfo
xrr_moninf
{-# LINE 246 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRMonitorInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRMonitorInfo
hsc_ptr Int
32) Ptr XRRMonitorInfo
p forall a b. (a -> b) -> a -> b
$ XRRMonitorInfo -> CInt
xrr_moninf_height    XRRMonitorInfo
xrr_moninf
{-# LINE 247 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRMonitorInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRMonitorInfo
hsc_ptr Int
36) Ptr XRRMonitorInfo
p forall a b. (a -> b) -> a -> b
$ XRRMonitorInfo -> CInt
xrr_moninf_mwidth    XRRMonitorInfo
xrr_moninf
{-# LINE 248 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRMonitorInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRMonitorInfo
hsc_ptr Int
40) Ptr XRRMonitorInfo
p forall a b. (a -> b) -> a -> b
$ XRRMonitorInfo -> CInt
xrr_moninf_mheight   XRRMonitorInfo
xrr_moninf
{-# LINE 249 "Graphics/X11/Xrandr.hsc" #-}
        -- see comment in Storable XRRScreenResources about dynamic resource allocation
        (\Ptr XRRMonitorInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRMonitorInfo
hsc_ptr Int
16) Ptr XRRMonitorInfo
p ( CInt
0 :: CInt )
{-# LINE 251 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRMonitorInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRMonitorInfo
hsc_ptr Int
48) Ptr XRRMonitorInfo
p ( forall a. Ptr a
nullPtr :: Ptr RROutput )
{-# LINE 252 "Graphics/X11/Xrandr.hsc" #-}

    peek :: Ptr XRRMonitorInfo -> IO XRRMonitorInfo
peek Ptr XRRMonitorInfo
p = forall (m :: * -> *) a. Monad m => a -> m a
return Atom
-> Bool
-> Bool
-> CInt
-> CInt
-> CInt
-> CInt
-> CInt
-> CInt
-> [Atom]
-> XRRMonitorInfo
XRRMonitorInfo
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRMonitorInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRMonitorInfo
hsc_ptr Int
0) Ptr XRRMonitorInfo
p )
{-# LINE 255 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRMonitorInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRMonitorInfo
hsc_ptr Int
8) Ptr XRRMonitorInfo
p )
{-# LINE 256 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRMonitorInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRMonitorInfo
hsc_ptr Int
12) Ptr XRRMonitorInfo
p )
{-# LINE 257 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRMonitorInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRMonitorInfo
hsc_ptr Int
20) Ptr XRRMonitorInfo
p )
{-# LINE 258 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRMonitorInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRMonitorInfo
hsc_ptr Int
24) Ptr XRRMonitorInfo
p )
{-# LINE 259 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRMonitorInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRMonitorInfo
hsc_ptr Int
28) Ptr XRRMonitorInfo
p )
{-# LINE 260 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRMonitorInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRMonitorInfo
hsc_ptr Int
32) Ptr XRRMonitorInfo
p )
{-# LINE 261 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRMonitorInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRMonitorInfo
hsc_ptr Int
36) Ptr XRRMonitorInfo
p )
{-# LINE 262 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRMonitorInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRMonitorInfo
hsc_ptr Int
40) Ptr XRRMonitorInfo
p )
{-# LINE 263 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` forall a. Storable a => IO CInt -> IO (Ptr a) -> IO [a]
peekCArrayIO ((\Ptr XRRMonitorInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRMonitorInfo
hsc_ptr Int
16) Ptr XRRMonitorInfo
p)
{-# LINE 264 "Graphics/X11/Xrandr.hsc" #-}
                          ((\Ptr XRRMonitorInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRMonitorInfo
hsc_ptr Int
48) Ptr XRRMonitorInfo
p)
{-# LINE 265 "Graphics/X11/Xrandr.hsc" #-}


instance Storable XRRScreenResources where
    sizeOf :: XRRScreenResources -> Int
sizeOf XRRScreenResources
_ = (Int
64)
{-# LINE 269 "Graphics/X11/Xrandr.hsc" #-}
    -- FIXME: Is this right?
    alignment :: XRRScreenResources -> Int
alignment XRRScreenResources
_ = forall a. Storable a => a -> Int
alignment (forall a. HasCallStack => a
undefined :: CInt)

    poke :: Ptr XRRScreenResources -> XRRScreenResources -> IO ()
poke Ptr XRRScreenResources
p XRRScreenResources
xrr_sr = do
        (\Ptr XRRScreenResources
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRScreenResources
hsc_ptr Int
0) Ptr XRRScreenResources
p forall a b. (a -> b) -> a -> b
$ XRRScreenResources -> Atom
xrr_sr_timestamp       XRRScreenResources
xrr_sr
{-# LINE 274 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRScreenResources
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRScreenResources
hsc_ptr Int
8) Ptr XRRScreenResources
p forall a b. (a -> b) -> a -> b
$ XRRScreenResources -> Atom
xrr_sr_configTimestamp XRRScreenResources
xrr_sr
{-# LINE 275 "Graphics/X11/Xrandr.hsc" #-}
        -- there is no simple way to handle ptrs to arrays or struct through ffi
        -- Using plain malloc will result in a memory leak, unless the poking
        -- function will free the memory manually
        -- Unfortunately a ForeignPtr with a Finalizer is not going to work
        -- either, because the Finalizer will be run after poke returns, making
        -- the allocated memory unusable.
        -- The safest option is therefore probably to have the calling function
        -- handle this issue for itself
        -- e.g.
        -- #{poke XRRScreenResources, ncrtc} p ( fromIntegral $ length $ xrr_sr_crtcs xrr_sr :: CInt )
        -- crtcp <- mallocArray $ length $ xrr_sr_crtcs xrr_sr
        -- pokeArray crtcp $ xrr_sr_crtcs xrr_sr
        -- #{poke XRRScreenResources, crtcs} p crtcp
        (\Ptr XRRScreenResources
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRScreenResources
hsc_ptr Int
16) Ptr XRRScreenResources
p ( CInt
0 :: CInt )
{-# LINE 289 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRScreenResources
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRScreenResources
hsc_ptr Int
32) Ptr XRRScreenResources
p ( CInt
0 :: CInt )
{-# LINE 290 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRScreenResources
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRScreenResources
hsc_ptr Int
48) Ptr XRRScreenResources
p ( CInt
0 :: CInt )
{-# LINE 291 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRScreenResources
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRScreenResources
hsc_ptr Int
24) Ptr XRRScreenResources
p ( forall a. Ptr a
nullPtr :: Ptr RRCrtc      )
{-# LINE 292 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRScreenResources
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRScreenResources
hsc_ptr Int
40) Ptr XRRScreenResources
p ( forall a. Ptr a
nullPtr :: Ptr RROutput    )
{-# LINE 293 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRScreenResources
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRScreenResources
hsc_ptr Int
56) Ptr XRRScreenResources
p ( forall a. Ptr a
nullPtr :: Ptr XRRModeInfo )
{-# LINE 294 "Graphics/X11/Xrandr.hsc" #-}

    peek :: Ptr XRRScreenResources -> IO XRRScreenResources
peek Ptr XRRScreenResources
p = forall (m :: * -> *) a. Monad m => a -> m a
return Atom
-> Atom -> [Atom] -> [Atom] -> [XRRModeInfo] -> XRRScreenResources
XRRScreenResources
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRScreenResources
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRScreenResources
hsc_ptr Int
0) Ptr XRRScreenResources
p )
{-# LINE 297 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRScreenResources
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRScreenResources
hsc_ptr Int
8) Ptr XRRScreenResources
p )
{-# LINE 298 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` forall a. Storable a => IO CInt -> IO (Ptr a) -> IO [a]
peekCArrayIO ((\Ptr XRRScreenResources
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRScreenResources
hsc_ptr Int
16) Ptr XRRScreenResources
p)
{-# LINE 299 "Graphics/X11/Xrandr.hsc" #-}
                          ((\Ptr XRRScreenResources
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRScreenResources
hsc_ptr Int
24) Ptr XRRScreenResources
p)
{-# LINE 300 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` forall a. Storable a => IO CInt -> IO (Ptr a) -> IO [a]
peekCArrayIO ((\Ptr XRRScreenResources
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRScreenResources
hsc_ptr Int
32) Ptr XRRScreenResources
p)
{-# LINE 301 "Graphics/X11/Xrandr.hsc" #-}
                          ((\Ptr XRRScreenResources
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRScreenResources
hsc_ptr Int
40) Ptr XRRScreenResources
p)
{-# LINE 302 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` forall a. Storable a => IO CInt -> IO (Ptr a) -> IO [a]
peekCArrayIO ((\Ptr XRRScreenResources
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRScreenResources
hsc_ptr Int
48) Ptr XRRScreenResources
p)
{-# LINE 303 "Graphics/X11/Xrandr.hsc" #-}
                          ((\Ptr XRRScreenResources
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRScreenResources
hsc_ptr Int
56) Ptr XRRScreenResources
p)
{-# LINE 304 "Graphics/X11/Xrandr.hsc" #-}


instance Storable XRROutputInfo where
    sizeOf :: XRROutputInfo -> Int
sizeOf XRROutputInfo
_ = (Int
96)
{-# LINE 308 "Graphics/X11/Xrandr.hsc" #-}
    -- FIXME: Is this right?
    alignment :: XRROutputInfo -> Int
alignment XRROutputInfo
_ = forall a. Storable a => a -> Int
alignment (forall a. HasCallStack => a
undefined :: CInt)

    poke :: Ptr XRROutputInfo -> XRROutputInfo -> IO ()
poke Ptr XRROutputInfo
p XRROutputInfo
xrr_oi = do
        (\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRROutputInfo
hsc_ptr Int
0) Ptr XRROutputInfo
p forall a b. (a -> b) -> a -> b
$ XRROutputInfo -> Atom
xrr_oi_timestamp      XRROutputInfo
xrr_oi
{-# LINE 313 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRROutputInfo
hsc_ptr Int
8) Ptr XRROutputInfo
p forall a b. (a -> b) -> a -> b
$ XRROutputInfo -> Atom
xrr_oi_crtc           XRROutputInfo
xrr_oi
{-# LINE 314 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRROutputInfo
hsc_ptr Int
32) Ptr XRROutputInfo
p forall a b. (a -> b) -> a -> b
$ XRROutputInfo -> CULong
xrr_oi_mm_width       XRROutputInfo
xrr_oi
{-# LINE 315 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRROutputInfo
hsc_ptr Int
40) Ptr XRROutputInfo
p forall a b. (a -> b) -> a -> b
$ XRROutputInfo -> CULong
xrr_oi_mm_height      XRROutputInfo
xrr_oi
{-# LINE 316 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRROutputInfo
hsc_ptr Int
48) Ptr XRROutputInfo
p forall a b. (a -> b) -> a -> b
$ XRROutputInfo -> Word16
xrr_oi_connection     XRROutputInfo
xrr_oi
{-# LINE 317 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRROutputInfo
hsc_ptr Int
50) Ptr XRROutputInfo
p forall a b. (a -> b) -> a -> b
$ XRROutputInfo -> Word16
xrr_oi_subpixel_order XRROutputInfo
xrr_oi
{-# LINE 318 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRROutputInfo
hsc_ptr Int
84) Ptr XRROutputInfo
p forall a b. (a -> b) -> a -> b
$ XRROutputInfo -> CInt
xrr_oi_npreferred     XRROutputInfo
xrr_oi
{-# LINE 319 "Graphics/X11/Xrandr.hsc" #-}
        -- see comment in Storable XRRScreenResources about dynamic resource allocation
        (\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRROutputInfo
hsc_ptr Int
24) Ptr XRROutputInfo
p ( CInt
0 :: CInt )
{-# LINE 321 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRROutputInfo
hsc_ptr Int
52) Ptr XRROutputInfo
p ( CInt
0 :: CInt )
{-# LINE 322 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRROutputInfo
hsc_ptr Int
64) Ptr XRROutputInfo
p ( CInt
0 :: CInt )
{-# LINE 323 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRROutputInfo
hsc_ptr Int
80) Ptr XRROutputInfo
p ( CInt
0 :: CInt )
{-# LINE 324 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRROutputInfo
hsc_ptr Int
16) Ptr XRROutputInfo
p ( forall a. Ptr a
nullPtr :: Ptr CChar    )
{-# LINE 325 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRROutputInfo
hsc_ptr Int
56) Ptr XRROutputInfo
p ( forall a. Ptr a
nullPtr :: Ptr RRCrtc   )
{-# LINE 326 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRROutputInfo
hsc_ptr Int
72) Ptr XRROutputInfo
p ( forall a. Ptr a
nullPtr :: Ptr RROutput )
{-# LINE 327 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRROutputInfo
hsc_ptr Int
88) Ptr XRROutputInfo
p ( forall a. Ptr a
nullPtr :: Ptr RRMode   )
{-# LINE 328 "Graphics/X11/Xrandr.hsc" #-}

    peek :: Ptr XRROutputInfo -> IO XRROutputInfo
peek Ptr XRROutputInfo
p = forall (m :: * -> *) a. Monad m => a -> m a
return Atom
-> Atom
-> String
-> CULong
-> CULong
-> Word16
-> Word16
-> [Atom]
-> [Atom]
-> CInt
-> [Atom]
-> XRROutputInfo
XRROutputInfo
            forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRROutputInfo
hsc_ptr Int
0) Ptr XRROutputInfo
p )
{-# LINE 331 "Graphics/X11/Xrandr.hsc" #-}
            forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRROutputInfo
hsc_ptr Int
8) Ptr XRROutputInfo
p )
{-# LINE 332 "Graphics/X11/Xrandr.hsc" #-}
            forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` IO CInt -> IO (Ptr CChar) -> IO String
peekCStringLenIO ((\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRROutputInfo
hsc_ptr Int
24) Ptr XRROutputInfo
p)
{-# LINE 333 "Graphics/X11/Xrandr.hsc" #-}
                                  ((\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRROutputInfo
hsc_ptr Int
16) Ptr XRROutputInfo
p)
{-# LINE 334 "Graphics/X11/Xrandr.hsc" #-}
            forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRROutputInfo
hsc_ptr Int
32) Ptr XRROutputInfo
p )
{-# LINE 335 "Graphics/X11/Xrandr.hsc" #-}
            forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRROutputInfo
hsc_ptr Int
40) Ptr XRROutputInfo
p )
{-# LINE 336 "Graphics/X11/Xrandr.hsc" #-}
            forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRROutputInfo
hsc_ptr Int
48) Ptr XRROutputInfo
p )
{-# LINE 337 "Graphics/X11/Xrandr.hsc" #-}
            forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRROutputInfo
hsc_ptr Int
50) Ptr XRROutputInfo
p )
{-# LINE 338 "Graphics/X11/Xrandr.hsc" #-}
            forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` forall a. Storable a => IO CInt -> IO (Ptr a) -> IO [a]
peekCArrayIO ((\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRROutputInfo
hsc_ptr Int
52) Ptr XRROutputInfo
p)
{-# LINE 339 "Graphics/X11/Xrandr.hsc" #-}
                              ((\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRROutputInfo
hsc_ptr Int
56) Ptr XRROutputInfo
p)
{-# LINE 340 "Graphics/X11/Xrandr.hsc" #-}
            forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` forall a. Storable a => IO CInt -> IO (Ptr a) -> IO [a]
peekCArrayIO ((\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRROutputInfo
hsc_ptr Int
64) Ptr XRROutputInfo
p)
{-# LINE 341 "Graphics/X11/Xrandr.hsc" #-}
                              ((\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRROutputInfo
hsc_ptr Int
72) Ptr XRROutputInfo
p)
{-# LINE 342 "Graphics/X11/Xrandr.hsc" #-}
            forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRROutputInfo
hsc_ptr Int
84) Ptr XRROutputInfo
p )
{-# LINE 343 "Graphics/X11/Xrandr.hsc" #-}
            forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` forall a. Storable a => IO CInt -> IO (Ptr a) -> IO [a]
peekCArrayIO ((\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRROutputInfo
hsc_ptr Int
80) Ptr XRROutputInfo
p)
{-# LINE 344 "Graphics/X11/Xrandr.hsc" #-}
                              ((\Ptr XRROutputInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRROutputInfo
hsc_ptr Int
88) Ptr XRROutputInfo
p)
{-# LINE 345 "Graphics/X11/Xrandr.hsc" #-}


instance Storable XRRCrtcInfo where
    sizeOf :: XRRCrtcInfo -> Int
sizeOf XRRCrtcInfo
_ = (Int
64)
{-# LINE 349 "Graphics/X11/Xrandr.hsc" #-}
    -- FIXME: Is this right?
    alignment :: XRRCrtcInfo -> Int
alignment XRRCrtcInfo
_ = forall a. Storable a => a -> Int
alignment (forall a. HasCallStack => a
undefined :: CInt)

    poke :: Ptr XRRCrtcInfo -> XRRCrtcInfo -> IO ()
poke Ptr XRRCrtcInfo
p XRRCrtcInfo
xrr_ci = do
        (\Ptr XRRCrtcInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRCrtcInfo
hsc_ptr Int
0) Ptr XRRCrtcInfo
p forall a b. (a -> b) -> a -> b
$ XRRCrtcInfo -> Atom
xrr_ci_timestamp XRRCrtcInfo
xrr_ci
{-# LINE 354 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRCrtcInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRCrtcInfo
hsc_ptr Int
8) Ptr XRRCrtcInfo
p forall a b. (a -> b) -> a -> b
$ XRRCrtcInfo -> CInt
xrr_ci_x         XRRCrtcInfo
xrr_ci
{-# LINE 355 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRCrtcInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRCrtcInfo
hsc_ptr Int
12) Ptr XRRCrtcInfo
p forall a b. (a -> b) -> a -> b
$ XRRCrtcInfo -> CInt
xrr_ci_y         XRRCrtcInfo
xrr_ci
{-# LINE 356 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRCrtcInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRCrtcInfo
hsc_ptr Int
16) Ptr XRRCrtcInfo
p forall a b. (a -> b) -> a -> b
$ XRRCrtcInfo -> CUInt
xrr_ci_width     XRRCrtcInfo
xrr_ci
{-# LINE 357 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRCrtcInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRCrtcInfo
hsc_ptr Int
20) Ptr XRRCrtcInfo
p forall a b. (a -> b) -> a -> b
$ XRRCrtcInfo -> CUInt
xrr_ci_height    XRRCrtcInfo
xrr_ci
{-# LINE 358 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRCrtcInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRCrtcInfo
hsc_ptr Int
24) Ptr XRRCrtcInfo
p forall a b. (a -> b) -> a -> b
$ XRRCrtcInfo -> Atom
xrr_ci_mode      XRRCrtcInfo
xrr_ci
{-# LINE 359 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRCrtcInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRCrtcInfo
hsc_ptr Int
32) Ptr XRRCrtcInfo
p forall a b. (a -> b) -> a -> b
$ XRRCrtcInfo -> Word16
xrr_ci_rotation  XRRCrtcInfo
xrr_ci
{-# LINE 360 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRCrtcInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRCrtcInfo
hsc_ptr Int
48) Ptr XRRCrtcInfo
p forall a b. (a -> b) -> a -> b
$ XRRCrtcInfo -> Word16
xrr_ci_rotations XRRCrtcInfo
xrr_ci
{-# LINE 361 "Graphics/X11/Xrandr.hsc" #-}
        -- see comment in Storable XRRScreenResources about dynamic resource allocation
        (\Ptr XRRCrtcInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRCrtcInfo
hsc_ptr Int
36) Ptr XRRCrtcInfo
p ( CInt
0 :: CInt )
{-# LINE 363 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRCrtcInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRCrtcInfo
hsc_ptr Int
52) Ptr XRRCrtcInfo
p ( CInt
0 :: CInt )
{-# LINE 364 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRCrtcInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRCrtcInfo
hsc_ptr Int
40) Ptr XRRCrtcInfo
p ( forall a. Ptr a
nullPtr :: Ptr RROutput )
{-# LINE 365 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRCrtcInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRCrtcInfo
hsc_ptr Int
56) Ptr XRRCrtcInfo
p ( forall a. Ptr a
nullPtr :: Ptr RROutput )
{-# LINE 366 "Graphics/X11/Xrandr.hsc" #-}

    peek :: Ptr XRRCrtcInfo -> IO XRRCrtcInfo
peek Ptr XRRCrtcInfo
p = forall (m :: * -> *) a. Monad m => a -> m a
return Atom
-> CInt
-> CInt
-> CUInt
-> CUInt
-> Atom
-> Word16
-> [Atom]
-> Word16
-> [Atom]
-> XRRCrtcInfo
XRRCrtcInfo
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRCrtcInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRCrtcInfo
hsc_ptr Int
0) Ptr XRRCrtcInfo
p )
{-# LINE 369 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRCrtcInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRCrtcInfo
hsc_ptr Int
8) Ptr XRRCrtcInfo
p )
{-# LINE 370 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRCrtcInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRCrtcInfo
hsc_ptr Int
12) Ptr XRRCrtcInfo
p )
{-# LINE 371 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRCrtcInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRCrtcInfo
hsc_ptr Int
16) Ptr XRRCrtcInfo
p )
{-# LINE 372 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRCrtcInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRCrtcInfo
hsc_ptr Int
20) Ptr XRRCrtcInfo
p )
{-# LINE 373 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRCrtcInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRCrtcInfo
hsc_ptr Int
24) Ptr XRRCrtcInfo
p )
{-# LINE 374 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRCrtcInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRCrtcInfo
hsc_ptr Int
32) Ptr XRRCrtcInfo
p )
{-# LINE 375 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` forall a. Storable a => IO CInt -> IO (Ptr a) -> IO [a]
peekCArrayIO ((\Ptr XRRCrtcInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRCrtcInfo
hsc_ptr Int
36) Ptr XRRCrtcInfo
p)
{-# LINE 376 "Graphics/X11/Xrandr.hsc" #-}
                          ((\Ptr XRRCrtcInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRCrtcInfo
hsc_ptr Int
40) Ptr XRRCrtcInfo
p)
{-# LINE 377 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRCrtcInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRCrtcInfo
hsc_ptr Int
48) Ptr XRRCrtcInfo
p )
{-# LINE 378 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` forall a. Storable a => IO CInt -> IO (Ptr a) -> IO [a]
peekCArrayIO ((\Ptr XRRCrtcInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRCrtcInfo
hsc_ptr Int
52) Ptr XRRCrtcInfo
p)
{-# LINE 379 "Graphics/X11/Xrandr.hsc" #-}
                          ((\Ptr XRRCrtcInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRCrtcInfo
hsc_ptr Int
56) Ptr XRRCrtcInfo
p)
{-# LINE 380 "Graphics/X11/Xrandr.hsc" #-}


instance Storable XRRPropertyInfo where
    sizeOf :: XRRPropertyInfo -> Int
sizeOf XRRPropertyInfo
_ = (Int
24)
{-# LINE 384 "Graphics/X11/Xrandr.hsc" #-}
    -- FIXME: Is this right?
    alignment :: XRRPropertyInfo -> Int
alignment XRRPropertyInfo
_ = forall a. Storable a => a -> Int
alignment (forall a. HasCallStack => a
undefined :: CInt)

    poke :: Ptr XRRPropertyInfo -> XRRPropertyInfo -> IO ()
poke Ptr XRRPropertyInfo
p XRRPropertyInfo
xrr_pi = do
        (\Ptr XRRPropertyInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRPropertyInfo
hsc_ptr Int
0) Ptr XRRPropertyInfo
p forall a b. (a -> b) -> a -> b
$ XRRPropertyInfo -> Bool
xrr_pi_pending   XRRPropertyInfo
xrr_pi
{-# LINE 389 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRPropertyInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRPropertyInfo
hsc_ptr Int
4) Ptr XRRPropertyInfo
p forall a b. (a -> b) -> a -> b
$ XRRPropertyInfo -> Bool
xrr_pi_range     XRRPropertyInfo
xrr_pi
{-# LINE 390 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRPropertyInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRPropertyInfo
hsc_ptr Int
8) Ptr XRRPropertyInfo
p forall a b. (a -> b) -> a -> b
$ XRRPropertyInfo -> Bool
xrr_pi_immutable XRRPropertyInfo
xrr_pi
{-# LINE 391 "Graphics/X11/Xrandr.hsc" #-}
        -- see comment in Storable XRRScreenResources about dynamic resource allocation
        (\Ptr XRRPropertyInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRPropertyInfo
hsc_ptr Int
12) Ptr XRRPropertyInfo
p ( CInt
0 :: CInt )
{-# LINE 393 "Graphics/X11/Xrandr.hsc" #-}
        (\Ptr XRRPropertyInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr XRRPropertyInfo
hsc_ptr Int
16) Ptr XRRPropertyInfo
p ( forall a. Ptr a
nullPtr :: Ptr CLong )
{-# LINE 394 "Graphics/X11/Xrandr.hsc" #-}

    peek :: Ptr XRRPropertyInfo -> IO XRRPropertyInfo
peek Ptr XRRPropertyInfo
p = forall (m :: * -> *) a. Monad m => a -> m a
return Bool -> Bool -> Bool -> [CLong] -> XRRPropertyInfo
XRRPropertyInfo
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRPropertyInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRPropertyInfo
hsc_ptr Int
0) Ptr XRRPropertyInfo
p )
{-# LINE 397 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRPropertyInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRPropertyInfo
hsc_ptr Int
4) Ptr XRRPropertyInfo
p )
{-# LINE 398 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` ( (\Ptr XRRPropertyInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRPropertyInfo
hsc_ptr Int
8) Ptr XRRPropertyInfo
p )
{-# LINE 399 "Graphics/X11/Xrandr.hsc" #-}
        forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
`ap` forall a. Storable a => IO CInt -> IO (Ptr a) -> IO [a]
peekCArrayIO ( (\Ptr XRRPropertyInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRPropertyInfo
hsc_ptr Int
12) Ptr XRRPropertyInfo
p)
{-# LINE 400 "Graphics/X11/Xrandr.hsc" #-}
                          ( (\Ptr XRRPropertyInfo
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr XRRPropertyInfo
hsc_ptr Int
16) Ptr XRRPropertyInfo
p)
{-# LINE 401 "Graphics/X11/Xrandr.hsc" #-}


xrrQueryExtension :: Display -> IO (Maybe (CInt, CInt))
xrrQueryExtension :: Display -> IO (Maybe (CInt, CInt))
xrrQueryExtension Display
dpy = forall a b c d.
(Storable a, Storable b) =>
(Ptr a -> Ptr b -> IO c) -> (c -> a -> b -> d) -> IO d
wrapPtr2 (Display -> Ptr CInt -> Ptr CInt -> IO Bool
cXRRQueryExtension Display
dpy) forall {a} {a} {a} {b}.
(Integral a, Integral a, Num a, Num b) =>
Bool -> a -> a -> Maybe (a, b)
go
  where go :: Bool -> a -> a -> Maybe (a, b)
go Bool
False a
_ a
_                = forall a. Maybe a
Nothing
        go Bool
True a
eventbase a
errorbase = forall a. a -> Maybe a
Just (forall a b. (Integral a, Num b) => a -> b
fromIntegral a
eventbase, forall a b. (Integral a, Num b) => a -> b
fromIntegral a
errorbase)
foreign import ccall "XRRQueryExtension"
  cXRRQueryExtension :: Display -> Ptr CInt -> Ptr CInt -> IO Bool

xrrQueryVersion :: Display -> IO (Maybe (CInt, CInt))
xrrQueryVersion :: Display -> IO (Maybe (CInt, CInt))
xrrQueryVersion Display
dpy = forall a b c d.
(Storable a, Storable b) =>
(Ptr a -> Ptr b -> IO c) -> (c -> a -> b -> d) -> IO d
wrapPtr2 (Display -> Ptr CInt -> Ptr CInt -> IO Bool
cXRRQueryVersion Display
dpy) forall {a} {a} {a} {b}.
(Integral a, Integral a, Num a, Num b) =>
Bool -> a -> a -> Maybe (a, b)
go
  where go :: Bool -> a -> a -> Maybe (a, b)
go Bool
False a
_ a
_        = forall a. Maybe a
Nothing
        go Bool
True a
major a
minor = forall a. a -> Maybe a
Just (forall a b. (Integral a, Num b) => a -> b
fromIntegral a
major, forall a b. (Integral a, Num b) => a -> b
fromIntegral a
minor)
foreign import ccall "XRRQueryVersion"
  cXRRQueryVersion :: Display -> Ptr CInt -> Ptr CInt -> IO Bool

xrrGetScreenInfo :: Display -> Drawable -> IO (Maybe XRRScreenConfiguration)
xrrGetScreenInfo :: Display -> Atom -> IO (Maybe XRRScreenConfiguration)
xrrGetScreenInfo Display
dpy Atom
draw = do
  Ptr XRRScreenConfiguration
p <- Display -> Atom -> IO (Ptr XRRScreenConfiguration)
cXRRGetScreenInfo Display
dpy Atom
draw
  if Ptr XRRScreenConfiguration
p forall a. Eq a => a -> a -> Bool
== forall a. Ptr a
nullPtr
     then forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
     else forall (m :: * -> *) a. Monad m => a -> m a
return (forall a. a -> Maybe a
Just (Ptr XRRScreenConfiguration -> XRRScreenConfiguration
XRRScreenConfiguration Ptr XRRScreenConfiguration
p))
foreign import ccall "XRRGetScreenInfo"
  cXRRGetScreenInfo :: Display -> Drawable -> IO (Ptr XRRScreenConfiguration)

xrrFreeScreenConfigInfo :: XRRScreenConfiguration -> IO ()
xrrFreeScreenConfigInfo :: XRRScreenConfiguration -> IO ()
xrrFreeScreenConfigInfo = XRRScreenConfiguration -> IO ()
cXRRFreeScreenConfigInfo
foreign import ccall "XRRFreeScreenConfigInfo"
  cXRRFreeScreenConfigInfo :: XRRScreenConfiguration -> IO ()

xrrSetScreenConfig :: Display -> XRRScreenConfiguration -> Drawable -> CInt -> Rotation -> Time -> IO Status
xrrSetScreenConfig :: Display
-> XRRScreenConfiguration
-> Atom
-> CInt
-> Word16
-> Atom
-> IO CInt
xrrSetScreenConfig = Display
-> XRRScreenConfiguration
-> Atom
-> CInt
-> Word16
-> Atom
-> IO CInt
cXRRSetScreenConfig
foreign import ccall "XRRSetScreenConfig"
  cXRRSetScreenConfig :: Display -> XRRScreenConfiguration -> Drawable -> CInt -> Rotation -> Time -> IO Status

xrrSetScreenConfigAndRate :: Display -> XRRScreenConfiguration -> Drawable -> CInt -> Rotation -> CShort -> Time -> IO Status
xrrSetScreenConfigAndRate :: Display
-> XRRScreenConfiguration
-> Atom
-> CInt
-> Word16
-> CShort
-> Atom
-> IO CInt
xrrSetScreenConfigAndRate = Display
-> XRRScreenConfiguration
-> Atom
-> CInt
-> Word16
-> CShort
-> Atom
-> IO CInt
cXRRSetScreenConfigAndRate
foreign import ccall "XRRSetScreenConfigAndRate"
  cXRRSetScreenConfigAndRate :: Display -> XRRScreenConfiguration -> Drawable -> CInt -> Rotation -> CShort -> Time -> IO Status

xrrConfigRotations :: XRRScreenConfiguration -> IO (Rotation, Rotation)
xrrConfigRotations :: XRRScreenConfiguration -> IO (Word16, Word16)
xrrConfigRotations XRRScreenConfiguration
config =
  forall b. (Pool -> IO b) -> IO b
withPool forall a b. (a -> b) -> a -> b
$ \Pool
pool -> do Ptr Word16
rptr <- forall a. Storable a => Pool -> IO (Ptr a)
pooledMalloc Pool
pool
                         Word16
rotations <- XRRScreenConfiguration -> Ptr Word16 -> IO Word16
cXRRConfigRotations XRRScreenConfiguration
config Ptr Word16
rptr
                         Word16
cur_rotation <- forall a. Storable a => Ptr a -> IO a
peek Ptr Word16
rptr
                         forall (m :: * -> *) a. Monad m => a -> m a
return (Word16
rotations, Word16
cur_rotation)
foreign import ccall "XRRConfigRotations"
  cXRRConfigRotations :: XRRScreenConfiguration -> Ptr Rotation -> IO Rotation

xrrConfigTimes :: XRRScreenConfiguration -> IO (Time, Time)
xrrConfigTimes :: XRRScreenConfiguration -> IO (Atom, Atom)
xrrConfigTimes XRRScreenConfiguration
config =
  forall b. (Pool -> IO b) -> IO b
withPool forall a b. (a -> b) -> a -> b
$ \Pool
pool -> do Ptr Atom
tptr <- forall a. Storable a => Pool -> IO (Ptr a)
pooledMalloc Pool
pool
                         Atom
time <- XRRScreenConfiguration -> Ptr Atom -> IO Atom
cXRRConfigTimes XRRScreenConfiguration
config Ptr Atom
tptr
                         Atom
cur_time <- forall a. Storable a => Ptr a -> IO a
peek Ptr Atom
tptr
                         forall (m :: * -> *) a. Monad m => a -> m a
return (Atom
time, Atom
cur_time)
foreign import ccall "XRRConfigTimes"
  cXRRConfigTimes :: XRRScreenConfiguration -> Ptr Time -> IO Time

xrrConfigSizes :: XRRScreenConfiguration -> IO (Maybe [XRRScreenSize])
xrrConfigSizes :: XRRScreenConfiguration -> IO (Maybe [XRRScreenSize])
xrrConfigSizes XRRScreenConfiguration
config =
  forall b. (Pool -> IO b) -> IO b
withPool forall a b. (a -> b) -> a -> b
$ \Pool
pool -> do Ptr CInt
intp <- forall a. Storable a => Pool -> IO (Ptr a)
pooledMalloc Pool
pool
                         Ptr XRRScreenSize
p <- XRRScreenConfiguration -> Ptr CInt -> IO (Ptr XRRScreenSize)
cXRRConfigSizes XRRScreenConfiguration
config Ptr CInt
intp
                         if Ptr XRRScreenSize
p forall a. Eq a => a -> a -> Bool
== forall a. Ptr a
nullPtr
                            then forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
                            else do CInt
nsizes <- forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
intp
                                    Maybe [XRRScreenSize]
sizes <- if CInt
nsizes forall a. Eq a => a -> a -> Bool
== CInt
0
                                                then forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
                                                else forall a. Storable a => Int -> Ptr a -> IO [a]
peekArray (forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
nsizes) Ptr XRRScreenSize
p forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (m :: * -> *) a. Monad m => a -> m a
return forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> Maybe a
Just
                                    forall (m :: * -> *) a. Monad m => a -> m a
return Maybe [XRRScreenSize]
sizes
foreign import ccall "XRRConfigSizes"
  cXRRConfigSizes :: XRRScreenConfiguration -> Ptr CInt -> IO (Ptr XRRScreenSize)

xrrConfigRates :: XRRScreenConfiguration -> CInt -> IO (Maybe [CShort])
xrrConfigRates :: XRRScreenConfiguration -> CInt -> IO (Maybe [CShort])
xrrConfigRates XRRScreenConfiguration
config CInt
size_index =
  forall b. (Pool -> IO b) -> IO b
withPool forall a b. (a -> b) -> a -> b
$ \Pool
pool -> do Ptr CInt
intp <- forall a. Storable a => Pool -> IO (Ptr a)
pooledMalloc Pool
pool
                         Ptr CShort
p <- XRRScreenConfiguration -> CInt -> Ptr CInt -> IO (Ptr CShort)
cXRRConfigRates XRRScreenConfiguration
config CInt
size_index Ptr CInt
intp
                         if Ptr CShort
p forall a. Eq a => a -> a -> Bool
== forall a. Ptr a
nullPtr
                            then forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
                            else do CInt
nrates <- forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
intp
                                    Maybe [CShort]
rates <- if CInt
nrates forall a. Eq a => a -> a -> Bool
== CInt
0
                                                then forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
                                                else forall a. Storable a => Int -> Ptr a -> IO [a]
peekArray (forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
nrates) Ptr CShort
p forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (m :: * -> *) a. Monad m => a -> m a
return forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> Maybe a
Just
                                    forall (m :: * -> *) a. Monad m => a -> m a
return Maybe [CShort]
rates
foreign import ccall "XRRConfigRates"
  cXRRConfigRates :: XRRScreenConfiguration -> CInt -> Ptr CInt -> IO (Ptr CShort)

xrrConfigCurrentConfiguration :: XRRScreenConfiguration -> IO (Rotation, SizeID)
xrrConfigCurrentConfiguration :: XRRScreenConfiguration -> IO (Word16, Word16)
xrrConfigCurrentConfiguration XRRScreenConfiguration
config =
  forall b. (Pool -> IO b) -> IO b
withPool forall a b. (a -> b) -> a -> b
$ \Pool
pool -> do Ptr Word16
rptr <- forall a. Storable a => Pool -> IO (Ptr a)
pooledMalloc Pool
pool
                         Word16
sizeid <- XRRScreenConfiguration -> Ptr Word16 -> IO Word16
cXRRConfigCurrentConfiguration XRRScreenConfiguration
config Ptr Word16
rptr
                         Word16
rotation <- forall a. Storable a => Ptr a -> IO a
peek Ptr Word16
rptr
                         forall (m :: * -> *) a. Monad m => a -> m a
return (Word16
rotation, Word16
sizeid)
foreign import ccall "XRRConfigCurrentConfiguration"
  cXRRConfigCurrentConfiguration :: XRRScreenConfiguration -> Ptr Rotation -> IO SizeID

xrrConfigCurrentRate :: XRRScreenConfiguration -> IO CShort
xrrConfigCurrentRate :: XRRScreenConfiguration -> IO CShort
xrrConfigCurrentRate = XRRScreenConfiguration -> IO CShort
cXRRConfigCurrentRate
foreign import ccall "XRRConfigCurrentRate"
  cXRRConfigCurrentRate :: XRRScreenConfiguration -> IO CShort

xrrRootToScreen :: Display -> Window -> IO CInt
xrrRootToScreen :: Display -> Atom -> IO CInt
xrrRootToScreen = Display -> Atom -> IO CInt
cXRRRootToScreen
foreign import ccall "XRRRootToScreen"
  cXRRRootToScreen :: Display -> Window -> IO CInt

xrrSelectInput :: Display -> Window -> EventMask -> IO ()
xrrSelectInput :: Display -> Atom -> Atom -> IO ()
xrrSelectInput Display
dpy Atom
window Atom
mask = Display -> Atom -> CInt -> IO ()
cXRRSelectInput Display
dpy Atom
window (forall a b. (Integral a, Num b) => a -> b
fromIntegral Atom
mask)
foreign import ccall "XRRSelectInput"
  cXRRSelectInput :: Display -> Window -> CInt -> IO ()

xrrUpdateConfiguration :: XEventPtr -> IO CInt
xrrUpdateConfiguration :: XEventPtr -> IO CInt
xrrUpdateConfiguration = XEventPtr -> IO CInt
cXRRUpdateConfiguration
foreign import ccall "XRRUpdateConfiguration"
  cXRRUpdateConfiguration :: XEventPtr -> IO CInt

xrrRotations :: Display -> CInt -> IO (Rotation, Rotation)
xrrRotations :: Display -> CInt -> IO (Word16, Word16)
xrrRotations Display
dpy CInt
screen =
  forall b. (Pool -> IO b) -> IO b
withPool forall a b. (a -> b) -> a -> b
$ \Pool
pool -> do Ptr Word16
rptr <- forall a. Storable a => Pool -> IO (Ptr a)
pooledMalloc Pool
pool
                         Word16
rotations <- Display -> CInt -> Ptr Word16 -> IO Word16
cXRRRotations Display
dpy CInt
screen Ptr Word16
rptr
                         Word16
cur_rotation <- forall a. Storable a => Ptr a -> IO a
peek Ptr Word16
rptr
                         forall (m :: * -> *) a. Monad m => a -> m a
return (Word16
rotations, Word16
cur_rotation)
foreign import ccall "XRRRotations"
  cXRRRotations :: Display -> CInt -> Ptr Rotation -> IO Rotation

xrrSizes :: Display -> CInt -> IO (Maybe [XRRScreenSize])
xrrSizes :: Display -> CInt -> IO (Maybe [XRRScreenSize])
xrrSizes Display
dpy CInt
screen =
  forall b. (Pool -> IO b) -> IO b
withPool forall a b. (a -> b) -> a -> b
$ \Pool
pool -> do Ptr CInt
intp <- forall a. Storable a => Pool -> IO (Ptr a)
pooledMalloc Pool
pool
                         Ptr XRRScreenSize
p <- Display -> CInt -> Ptr CInt -> IO (Ptr XRRScreenSize)
cXRRSizes Display
dpy CInt
screen Ptr CInt
intp
                         if Ptr XRRScreenSize
p forall a. Eq a => a -> a -> Bool
== forall a. Ptr a
nullPtr
                            then forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
                            else do CInt
nsizes <- forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
intp
                                    Maybe [XRRScreenSize]
sizes <- if CInt
nsizes forall a. Eq a => a -> a -> Bool
== CInt
0
                                                then forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
                                                else forall a. Storable a => Int -> Ptr a -> IO [a]
peekArray (forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
nsizes) Ptr XRRScreenSize
p forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (m :: * -> *) a. Monad m => a -> m a
return forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> Maybe a
Just
                                    forall (m :: * -> *) a. Monad m => a -> m a
return Maybe [XRRScreenSize]
sizes
foreign import ccall "XRRSizes"
  cXRRSizes :: Display -> CInt -> Ptr CInt -> IO (Ptr XRRScreenSize)

xrrRates :: Display -> CInt -> CInt -> IO (Maybe [CShort])
xrrRates :: Display -> CInt -> CInt -> IO (Maybe [CShort])
xrrRates Display
dpy CInt
screen CInt
size_index =
  forall b. (Pool -> IO b) -> IO b
withPool forall a b. (a -> b) -> a -> b
$ \Pool
pool -> do Ptr CInt
intp <- forall a. Storable a => Pool -> IO (Ptr a)
pooledMalloc Pool
pool
                         Ptr CShort
p <- Display -> CInt -> CInt -> Ptr CInt -> IO (Ptr CShort)
cXRRRates Display
dpy CInt
screen CInt
size_index Ptr CInt
intp
                         if Ptr CShort
p forall a. Eq a => a -> a -> Bool
== forall a. Ptr a
nullPtr
                            then forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
                            else do CInt
nrates <- forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
intp
                                    Maybe [CShort]
rates <- if CInt
nrates forall a. Eq a => a -> a -> Bool
== CInt
0
                                                then forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
                                                else forall a. Storable a => Int -> Ptr a -> IO [a]
peekArray (forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
nrates) Ptr CShort
p forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (m :: * -> *) a. Monad m => a -> m a
return forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> Maybe a
Just
                                    forall (m :: * -> *) a. Monad m => a -> m a
return Maybe [CShort]
rates
foreign import ccall "XRRRates"
  cXRRRates :: Display -> CInt -> CInt -> Ptr CInt -> IO (Ptr CShort)

xrrTimes :: Display -> CInt -> IO (Time, Time)
xrrTimes :: Display -> CInt -> IO (Atom, Atom)
xrrTimes Display
dpy CInt
screen =
  forall b. (Pool -> IO b) -> IO b
withPool forall a b. (a -> b) -> a -> b
$ \Pool
pool -> do Ptr Atom
tptr <- forall a. Storable a => Pool -> IO (Ptr a)
pooledMalloc Pool
pool
                         Atom
time <- Display -> CInt -> Ptr Atom -> IO Atom
cXRRTimes Display
dpy CInt
screen Ptr Atom
tptr
                         Atom
config_time <- forall a. Storable a => Ptr a -> IO a
peek Ptr Atom
tptr
                         forall (m :: * -> *) a. Monad m => a -> m a
return (Atom
time, Atom
config_time)
foreign import ccall "XRRTimes"
  cXRRTimes :: Display -> CInt -> Ptr Time -> IO Time

xrrGetScreenResources :: Display -> Window -> IO (Maybe XRRScreenResources)
xrrGetScreenResources :: Display -> Atom -> IO (Maybe XRRScreenResources)
xrrGetScreenResources Display
dpy Atom
win = do
    Ptr XRRScreenResources
srp <- Display -> Atom -> IO (Ptr XRRScreenResources)
cXRRGetScreenResources Display
dpy Atom
win
    if Ptr XRRScreenResources
srp forall a. Eq a => a -> a -> Bool
== forall a. Ptr a
nullPtr
        then forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
        else do
            XRRScreenResources
res <- forall a. Storable a => Ptr a -> IO a
peek Ptr XRRScreenResources
srp
            Ptr XRRScreenResources -> IO ()
cXRRFreeScreenResources Ptr XRRScreenResources
srp
            forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just XRRScreenResources
res

foreign import ccall "XRRGetScreenResources"
    cXRRGetScreenResources :: Display -> Window -> IO (Ptr XRRScreenResources)

foreign import ccall "XRRFreeScreenResources"
    cXRRFreeScreenResources :: Ptr XRRScreenResources -> IO ()

xrrGetOutputInfo :: Display -> XRRScreenResources -> RROutput -> IO (Maybe XRROutputInfo)
xrrGetOutputInfo :: Display -> XRRScreenResources -> Atom -> IO (Maybe XRROutputInfo)
xrrGetOutputInfo Display
dpy XRRScreenResources
xrr_sr Atom
rro = forall b. (Pool -> IO b) -> IO b
withPool forall a b. (a -> b) -> a -> b
$ \Pool
pool -> do
    -- XRRGetOutputInfo only uses the timestamp field from the
    -- XRRScreenResources struct, so it's probably ok to pass the incomplete
    -- structure here (see also the poke implementation for the Storable
    -- instance of XRRScreenResources)
    -- Alternative version below; This is extremely slow, though!
    {- xrrGetOutputInfo :: Display -> Window -> RROutput -> IO (Maybe XRROutputInfo)
       xrrGetOutputInfo dpy win rro = do
           srp <- cXRRGetScreenResources dpy win
           oip <- cXRRGetOutputInfo dpy srp rro
           cXRRFreeScreenResources srp
    -}
    Ptr XRROutputInfo
oip <- forall a. Storable a => Pool -> IO (Ptr a)
pooledMalloc Pool
pool forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr XRRScreenResources
srp -> do
        forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr XRRScreenResources
srp XRRScreenResources
xrr_sr
        Display -> Ptr XRRScreenResources -> Atom -> IO (Ptr XRROutputInfo)
cXRRGetOutputInfo Display
dpy Ptr XRRScreenResources
srp Atom
rro -- no need to free srp, because pool mem

    if Ptr XRROutputInfo
oip forall a. Eq a => a -> a -> Bool
== forall a. Ptr a
nullPtr
        then forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
        else do
            XRROutputInfo
oi <- forall a. Storable a => Ptr a -> IO a
peek Ptr XRROutputInfo
oip
            ()
_ <- Ptr XRROutputInfo -> IO ()
cXRRFreeOutputInfo Ptr XRROutputInfo
oip
            forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just XRROutputInfo
oi

foreign import ccall "XRRGetOutputInfo"
    cXRRGetOutputInfo :: Display -> Ptr XRRScreenResources -> RROutput -> IO (Ptr XRROutputInfo)

foreign import ccall "XRRFreeOutputInfo"
    cXRRFreeOutputInfo :: Ptr XRROutputInfo -> IO ()

xrrGetCrtcInfo :: Display -> XRRScreenResources -> RRCrtc -> IO (Maybe XRRCrtcInfo)
xrrGetCrtcInfo :: Display -> XRRScreenResources -> Atom -> IO (Maybe XRRCrtcInfo)
xrrGetCrtcInfo Display
dpy XRRScreenResources
xrr_sr Atom
crtc = forall b. (Pool -> IO b) -> IO b
withPool forall a b. (a -> b) -> a -> b
$ \Pool
pool -> do
    -- XRRGetCrtcInfo only uses the timestamp field from the
    -- XRRScreenResources struct, so it's probably ok to pass the incomplete
    -- structure here (see also the poke implementation for the Storable
    -- instance of XRRScreenResources)
    Ptr XRRCrtcInfo
cip <- forall a. Storable a => Pool -> IO (Ptr a)
pooledMalloc Pool
pool forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Ptr XRRScreenResources
srp -> do
        forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr XRRScreenResources
srp XRRScreenResources
xrr_sr
        Display -> Ptr XRRScreenResources -> Atom -> IO (Ptr XRRCrtcInfo)
cXRRGetCrtcInfo Display
dpy Ptr XRRScreenResources
srp Atom
crtc -- no need to free srp, because pool mem

    if Ptr XRRCrtcInfo
cip forall a. Eq a => a -> a -> Bool
== forall a. Ptr a
nullPtr
        then forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
        else do
            XRRCrtcInfo
ci <- forall a. Storable a => Ptr a -> IO a
peek Ptr XRRCrtcInfo
cip
            Ptr XRRCrtcInfo -> IO ()
cXRRFreeCrtcInfo Ptr XRRCrtcInfo
cip
            forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just XRRCrtcInfo
ci

foreign import ccall "XRRGetCrtcInfo"
    cXRRGetCrtcInfo :: Display -> Ptr XRRScreenResources -> RRCrtc -> IO (Ptr XRRCrtcInfo)

foreign import ccall "XRRFreeCrtcInfo"
    cXRRFreeCrtcInfo :: Ptr XRRCrtcInfo -> IO ()

foreign import ccall "XRRSetOutputPrimary"
    xrrSetOutputPrimary :: Display -> Window -> RROutput -> IO ()

foreign import ccall "XRRGetOutputPrimary"
    xrrGetOutputPrimary :: Display -> Window -> IO RROutput

xrrGetScreenResourcesCurrent :: Display -> Window -> IO (Maybe XRRScreenResources)
xrrGetScreenResourcesCurrent :: Display -> Atom -> IO (Maybe XRRScreenResources)
xrrGetScreenResourcesCurrent Display
dpy Atom
win = do
    Ptr XRRScreenResources
srcp <- Display -> Atom -> IO (Ptr XRRScreenResources)
cXRRGetScreenResourcesCurrent Display
dpy Atom
win
    if Ptr XRRScreenResources
srcp forall a. Eq a => a -> a -> Bool
== forall a. Ptr a
nullPtr
        then forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
        else do
            XRRScreenResources
res <- forall a. Storable a => Ptr a -> IO a
peek Ptr XRRScreenResources
srcp
            Ptr XRRScreenResources -> IO ()
cXRRFreeScreenResources Ptr XRRScreenResources
srcp
            forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just XRRScreenResources
res

foreign import ccall "XRRGetScreenResourcesCurrent"
    cXRRGetScreenResourcesCurrent :: Display -> Window -> IO (Ptr XRRScreenResources)

xrrListOutputProperties :: Display -> RROutput -> IO (Maybe [Atom])
xrrListOutputProperties :: Display -> Atom -> IO (Maybe [Atom])
xrrListOutputProperties Display
dpy Atom
rro = forall b. (Pool -> IO b) -> IO b
withPool forall a b. (a -> b) -> a -> b
$ \Pool
pool -> do
    Ptr CInt
intp <- forall a. Storable a => Pool -> IO (Ptr a)
pooledMalloc Pool
pool
    Ptr Atom
p <- Display -> Atom -> Ptr CInt -> IO (Ptr Atom)
cXRRListOutputProperties Display
dpy Atom
rro Ptr CInt
intp
    if Ptr Atom
p forall a. Eq a => a -> a -> Bool
== forall a. Ptr a
nullPtr
        then forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
        else do
            CInt
nprop <- forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
intp
            Maybe [Atom]
res <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall a. Storable a => CInt -> Ptr a -> IO [a]
peekCArray CInt
nprop Ptr Atom
p
            CInt
_ <- forall a. Ptr a -> IO CInt
xFree Ptr Atom
p
            forall (m :: * -> *) a. Monad m => a -> m a
return Maybe [Atom]
res

foreign import ccall "XRRListOutputProperties"
    cXRRListOutputProperties :: Display -> RROutput -> Ptr CInt -> IO (Ptr Atom)

xrrQueryOutputProperty :: Display -> RROutput -> Atom -> IO (Maybe XRRPropertyInfo)
xrrQueryOutputProperty :: Display -> Atom -> Atom -> IO (Maybe XRRPropertyInfo)
xrrQueryOutputProperty Display
dpy Atom
rro Atom
prop = do
    Ptr XRRPropertyInfo
p <- Display -> Atom -> Atom -> IO (Ptr XRRPropertyInfo)
cXRRQueryOutputProperty Display
dpy Atom
rro Atom
prop
    if Ptr XRRPropertyInfo
p forall a. Eq a => a -> a -> Bool
== forall a. Ptr a
nullPtr
        then forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
        else do
            XRRPropertyInfo
res <- forall a. Storable a => Ptr a -> IO a
peek Ptr XRRPropertyInfo
p
            CInt
_ <- forall a. Ptr a -> IO CInt
xFree Ptr XRRPropertyInfo
p
            forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just XRRPropertyInfo
res

foreign import ccall "XRRQueryOutputProperty"
    cXRRQueryOutputProperty :: Display -> RROutput -> Atom -> IO (Ptr XRRPropertyInfo)

xrrConfigureOutputProperty :: Display -> RROutput -> Atom -> Bool -> Bool -> [CLong] -> IO ()
xrrConfigureOutputProperty :: Display -> Atom -> Atom -> Bool -> Bool -> [CLong] -> IO ()
xrrConfigureOutputProperty Display
dpy Atom
rro Atom
prop Bool
pend Bool
range [CLong]
xs = forall a b. Storable a => [a] -> (Int -> Ptr a -> IO b) -> IO b
withArrayLen [CLong]
xs forall a b. (a -> b) -> a -> b
$
    Display
-> Atom -> Atom -> Bool -> Bool -> CInt -> Ptr CLong -> IO ()
cXRRConfigureOutputProperty Display
dpy Atom
rro Atom
prop Bool
pend Bool
range forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (Integral a, Num b) => a -> b
fromIntegral

foreign import ccall "XRRConfigureOutputProperty"
    cXRRConfigureOutputProperty :: Display -> RROutput -> Atom -> Bool -> Bool -> CInt ->  Ptr CLong -> IO ()

xrrChangeOutputProperty :: Display -> RROutput -> Atom -> Atom -> CInt -> CInt -> [Word32] -> IO ()
xrrChangeOutputProperty :: Display
-> Atom -> Atom -> Atom -> CInt -> CInt -> [Word32] -> IO ()
xrrChangeOutputProperty Display
dpy Atom
rro Atom
prop Atom
typ CInt
format CInt
mode [Word32]
xs = forall b. (Pool -> IO b) -> IO b
withPool forall a b. (a -> b) -> a -> b
$ \Pool
pool -> do
    Ptr Word8
ptr <- case CInt
format of
        CInt
8 ->  forall a. Storable a => Pool -> [a] -> IO (Ptr a)
pooledNewArray Pool
pool (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (Integral a, Num b) => a -> b
fromIntegral [Word32]
xs :: [Word8])
        CInt
16 -> forall a b. Ptr a -> Ptr b
castPtr forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` forall a. Storable a => Pool -> [a] -> IO (Ptr a)
pooledNewArray Pool
pool (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (Integral a, Num b) => a -> b
fromIntegral [Word32]
xs :: [Word16])
        CInt
32 -> forall a b. Ptr a -> Ptr b
castPtr forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` forall a. Storable a => Pool -> [a] -> IO (Ptr a)
pooledNewArray Pool
pool [Word32]
xs
        CInt
_  -> forall a. HasCallStack => String -> a
error String
"invalid format"

    Display
-> Atom
-> Atom
-> Atom
-> CInt
-> CInt
-> Ptr Word8
-> CInt
-> IO ()
cXRRChangeOutputProperty Display
dpy Atom
rro Atom
prop Atom
typ CInt
format CInt
mode Ptr Word8
ptr (forall a b. (Integral a, Num b) => a -> b
fromIntegral forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. Foldable t => t a -> Int
length [Word32]
xs)

foreign import ccall "XRRChangeOutputProperty"
    cXRRChangeOutputProperty :: Display -> RROutput -> Atom -> Atom -> CInt -> CInt -> Ptr Word8 -> CInt -> IO ()

-- | @xrrGetOutputProperty display output property offset length delete pending propertyType@
-- | returns @Maybe (actualType, format, bytesAfter, data)@.
xrrGetOutputProperty ::
    Display -> RROutput -> Atom -> CLong -> CLong -> Bool -> Bool -> Atom ->
    IO (Maybe (Atom, Int, CULong, [Word32]))
xrrGetOutputProperty :: Display
-> Atom
-> Atom
-> CLong
-> CLong
-> Bool
-> Bool
-> Atom
-> IO (Maybe (Atom, Int, CULong, [Word32]))
xrrGetOutputProperty Display
dpy Atom
rro Atom
prop CLong
offset CLong
len Bool
delete Bool
preferPending Atom
reqType = forall b. (Pool -> IO b) -> IO b
withPool forall a b. (a -> b) -> a -> b
$ \Pool
pool -> do
    Ptr Atom
actualTypep <- forall a. Storable a => Pool -> IO (Ptr a)
pooledMalloc Pool
pool
    Ptr CInt
actualFormatp <- forall a. Storable a => Pool -> IO (Ptr a)
pooledMalloc Pool
pool
    Ptr CULong
nItemsp <- forall a. Storable a => Pool -> IO (Ptr a)
pooledMalloc Pool
pool
    Ptr CULong
bytesAfterp <- forall a. Storable a => Pool -> IO (Ptr a)
pooledMalloc Pool
pool
    Ptr (Ptr Word8)
datapp <- forall a. Storable a => Pool -> IO (Ptr a)
pooledMalloc Pool
pool
    CInt
status <- Display
-> Atom
-> Atom
-> CLong
-> CLong
-> Bool
-> Bool
-> Atom
-> Ptr Atom
-> Ptr CInt
-> Ptr CULong
-> Ptr CULong
-> Ptr (Ptr Word8)
-> IO CInt
cXRRGetOutputProperty Display
dpy Atom
rro Atom
prop CLong
offset CLong
len
        Bool
delete Bool
preferPending Atom
reqType
        Ptr Atom
actualTypep Ptr CInt
actualFormatp Ptr CULong
nItemsp Ptr CULong
bytesAfterp Ptr (Ptr Word8)
datapp

    if CInt
status forall a. Eq a => a -> a -> Bool
/= CInt
0
        then forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
        else do
          Int
format <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
actualFormatp)
          Int
nitems <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall a. Storable a => Ptr a -> IO a
peek Ptr CULong
nItemsp)
          Ptr Word8
ptr <- forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr Word8)
datapp

          [Word32]
dat <- case Int
format of
            Int
0 -> forall (m :: * -> *) a. Monad m => a -> m a
return []
            Int
8 -> forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (Integral a, Num b) => a -> b
fromIntegral) forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Int -> Ptr a -> IO [a]
peekArray Int
nitems Ptr Word8
ptr
            Int
16 -> forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (Integral a, Num b) => a -> b
fromIntegral) forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Int -> Ptr a -> IO [a]
peekArray Int
nitems (forall a b. Ptr a -> Ptr b
castPtr Ptr Word8
ptr :: Ptr Word16)
            Int
32 -> forall a. Storable a => Int -> Ptr a -> IO [a]
peekArray Int
nitems (forall a b. Ptr a -> Ptr b
castPtr Ptr Word8
ptr :: Ptr Word32)
            Int
_  -> forall a. HasCallStack => String -> a
error forall a b. (a -> b) -> a -> b
$ String
"impossible happened: prop format is not in 0,8,16,32 (" forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show Int
format forall a. [a] -> [a] -> [a]
++ String
")"

          CInt
_ <- if Int
format forall a. Eq a => a -> a -> Bool
/= Int
0
                  then forall a. Ptr a -> IO CInt
xFree Ptr Word8
ptr
                  else forall (m :: * -> *) a. Monad m => a -> m a
return CInt
0

          Atom
typ <- forall a. Storable a => Ptr a -> IO a
peek Ptr Atom
actualTypep
          CULong
bytesAfter <- forall a. Storable a => Ptr a -> IO a
peek Ptr CULong
bytesAfterp
          forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just (Atom
typ, Int
format, CULong
bytesAfter, [Word32]
dat)

foreign import ccall "XRRGetOutputProperty"
    cXRRGetOutputProperty :: Display -> RROutput -> Atom -> CLong -> CLong -> Bool -> Bool
      -> Atom -> Ptr Atom -> Ptr CInt -> Ptr CULong -> Ptr CULong -> Ptr (Ptr Word8) -> IO CInt

xrrDeleteOutputProperty :: Display -> RROutput -> Atom -> IO ()
xrrDeleteOutputProperty :: Display -> Atom -> Atom -> IO ()
xrrDeleteOutputProperty = Display -> Atom -> Atom -> IO ()
cXRRDeleteOutputProperty
foreign import ccall "XRRDeleteOutputProperty"
    cXRRDeleteOutputProperty :: Display -> RROutput -> Atom -> IO ()

xrrGetMonitors :: Display -> Drawable -> Bool -> IO (Maybe [XRRMonitorInfo])
xrrGetMonitors :: Display -> Atom -> Bool -> IO (Maybe [XRRMonitorInfo])
xrrGetMonitors Display
dpy Atom
draw Bool
get_active = forall b. (Pool -> IO b) -> IO b
withPool forall a b. (a -> b) -> a -> b
$ \Pool
pool -> do
    Ptr CInt
intp <- forall a. Storable a => Pool -> IO (Ptr a)
pooledMalloc Pool
pool
    Ptr XRRMonitorInfo
p <- Display -> Atom -> Bool -> Ptr CInt -> IO (Ptr XRRMonitorInfo)
cXRRGetMonitors Display
dpy Atom
draw Bool
get_active Ptr CInt
intp
    if Ptr XRRMonitorInfo
p forall a. Eq a => a -> a -> Bool
== forall a. Ptr a
nullPtr
        then forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
        else do
            CInt
nmonitors <- forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
intp
            Maybe [XRRMonitorInfo]
res <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall a. Storable a => CInt -> Ptr a -> IO [a]
peekCArray CInt
nmonitors Ptr XRRMonitorInfo
p
            Ptr XRRMonitorInfo -> IO ()
cXRRFreeMonitors Ptr XRRMonitorInfo
p
            forall (m :: * -> *) a. Monad m => a -> m a
return Maybe [XRRMonitorInfo]
res

foreign import ccall "XRRGetMonitors"
    cXRRGetMonitors :: Display -> Drawable -> Bool -> Ptr CInt -> IO (Ptr XRRMonitorInfo)

foreign import ccall "XRRFreeMonitors"
    cXRRFreeMonitors :: Ptr XRRMonitorInfo -> IO ()

wrapPtr2 :: (Storable a, Storable b) => (Ptr a -> Ptr b -> IO c) -> (c -> a -> b -> d) -> IO d
wrapPtr2 :: forall a b c d.
(Storable a, Storable b) =>
(Ptr a -> Ptr b -> IO c) -> (c -> a -> b -> d) -> IO d
wrapPtr2 Ptr a -> Ptr b -> IO c
cfun c -> a -> b -> d
f =
  forall b. (Pool -> IO b) -> IO b
withPool forall a b. (a -> b) -> a -> b
$ \Pool
pool -> do Ptr a
aptr <- forall a. Storable a => Pool -> IO (Ptr a)
pooledMalloc Pool
pool
                         Ptr b
bptr <- forall a. Storable a => Pool -> IO (Ptr a)
pooledMalloc Pool
pool
                         c
ret <- Ptr a -> Ptr b -> IO c
cfun Ptr a
aptr Ptr b
bptr
                         a
a <- forall a. Storable a => Ptr a -> IO a
peek Ptr a
aptr
                         b
b <- forall a. Storable a => Ptr a -> IO a
peek Ptr b
bptr
                         forall (m :: * -> *) a. Monad m => a -> m a
return (c -> a -> b -> d
f c
ret a
a b
b)

peekCArray :: Storable a => CInt -> Ptr a -> IO [a]
peekCArray :: forall a. Storable a => CInt -> Ptr a -> IO [a]
peekCArray CInt
n = forall a. Storable a => Int -> Ptr a -> IO [a]
peekArray (forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
n)

peekCArrayIO :: Storable a => IO CInt -> IO (Ptr a) -> IO [a]
peekCArrayIO :: forall a. Storable a => IO CInt -> IO (Ptr a) -> IO [a]
peekCArrayIO IO CInt
n = forall (m :: * -> *) a. Monad m => m (m a) -> m a
join forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 forall a. Storable a => CInt -> Ptr a -> IO [a]
peekCArray IO CInt
n

peekCStringLenIO :: IO CInt -> IO (Ptr CChar) -> IO String
peekCStringLenIO :: IO CInt -> IO (Ptr CChar) -> IO String
peekCStringLenIO IO CInt
n IO (Ptr CChar)
p = forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (,) IO (Ptr CChar)
p (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (Integral a, Num b) => a -> b
fromIntegral IO CInt
n) forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= CStringLen -> IO String
peekCStringLen