Thanks to visit codestin.com
Credit goes to github.com

Skip to content

RandR Deserialisation Error #13

@thedward

Description

@thedward

I am getting an error when I try to access the returned Graphics.XHB.Gen.RandR.GetScreenInfoReply value.

When I try and run my program, I get the following output:

HAS XRANDR!
jrandr: Data.Binary.Get.runGet at position 72: not enough bytes

I am using version 0.6.2015.8.1.

Here is my program:

module Main where

import Foreign.C.String
import qualified Data.ByteString.Lazy as BS
import Control.Concurrent
import Control.Monad

import qualified Graphics.XHB as X
import qualified Graphics.XHB.Gen.RandR as R

import System.IO

main = do
  connectionM <- X.connect

  case connectionM of
    Nothing -> putStrLn "failed to get connection"
    Just c -> randr c

randr :: X.Connection -> IO ()
randr c = do

  listReceipt <- X.listExtensions c

  replyOrError <- X.getReply listReceipt
  let extensions = case replyOrError of
                        Left e -> error $ "error in extensions request" ++ show e
                        Right listRep ->  listExtensionNames listRep

  screenInfoReceipt <-
    if "RANDR" `elem` extensions
       then putStrLn "HAS XRANDR!" >> R.getScreenInfo c (X.getRoot c)
       else error "NO XRANDR :-("

  replyOrError <- X.getReply screenInfoReceipt
  let info = case replyOrError of
                  Left e -> error (show e)
                  Right info -> info

  print info

listExtensionNames :: X.ListExtensionsReply -> [String]
listExtensionNames = map strToString . X.names_ListExtensionsReply

strToString :: X.STR -> String
strToString = map castCCharToChar . X.name_STR

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions