{-# LANGUAGE MultiParamTypeClasses #-}
module Graphics.XHB.Requests.Internal.Instances.DRI2 () where
import Graphics.XHB.Gen.DRI2
import Graphics.XHB.Requests.Internal.Classes
import Prelude (fmap)
import Data.Bifunctor (second)
import Graphics.XHB (getReply)

instance RequestWithReply QueryVersion QueryVersionReply where
        requestWithReplyIO (MkQueryVersion a b) conn
          = fmap getReply (queryVersion conn a b)

instance RequestWithReply Connect ConnectReply where
        requestWithReplyIO (MkConnect a b) conn
          = fmap getReply (connect conn a b)

instance RequestWithReply Authenticate AuthenticateReply where
        requestWithReplyIO (MkAuthenticate a b) conn
          = fmap (fmap (second MkAuthenticateReply))
              (fmap getReply (authenticate conn a b))

instance Request CreateDrawable where
        requestIO (MkCreateDrawable a) conn = createDrawable conn a

instance Request DestroyDrawable where
        requestIO (MkDestroyDrawable a) conn = destroyDrawable conn a

instance RequestWithReply GetBuffers GetBuffersReply where
        requestWithReplyIO req conn = fmap getReply (getBuffers conn req)

instance RequestWithReply CopyRegion CopyRegionReply where
        requestWithReplyIO req conn = fmap getReply (copyRegion conn req)

instance RequestWithReply GetBuffersWithFormat
         GetBuffersWithFormatReply where
        requestWithReplyIO req conn
          = fmap getReply (getBuffersWithFormat conn req)