X11-1.6.1.1: A binding to the X11 graphics library

Portability | portable
Stability | provisional
Maintainer | libraries@haskell.org
Safe Haskell | None

Graphics.X11.Xlib

Contents

- Conventions
- Types
- X11 library functions

Description

A collection of FFI declarations for interfacing with Xlib.

The library aims to provide a direct translation of the X binding into Haskell so the most important documentation you should read is The Xlib Programming Manual, available online at http://tronche.com/gui/x/xlib/. Let me say that again because it is very important. Get hold of this documentation and read it: it tells you almost everything you need to know to use this library.

Synopsis

- module Graphics.X11.Types
- newtype Display = Display (Ptr Display)
- data Screen
- data Visual
- data GC
- data SetWindowAttributes
- data VisualInfo = VisualInfo {
  - visualInfo_visual :: Visual
  - visualInfo_visualID :: VisualID
  - visualInfo_screen :: ScreenNumber
  - visualInfo_depth :: CInt
  - visualInfo_class :: CInt
  - visualInfo_redMask :: CULong
  - visualInfo_greenMask :: CULong
  - visualInfo_blueMask :: CULong
  - visualInfo_colormapSize :: CInt
  - visualInfo_bitsPerRGB :: CInt
  }
- data Point = Point {
  - pt_x :: !Position
  - pt_y :: !Position
  }
- data Rectangle = Rectangle {
  - rect_x :: !Position
  - rect_y :: !Position
  - rect_width :: !Dimension
  - rect_height :: !Dimension
  }
- data Arc = Arc {
  - arc_x :: Position
  - arc_y :: Position
  - arc_width :: Dimension
  - arc_height :: Dimension
  - arc_angle1 :: Angle
  - arc_angle2 :: Angle
  }
- data Segment = Segment {
  - seg_x1 :: Position
  - seg_y1 :: Position
  - seg_x2 :: Position
  - seg_y2 :: Position
  }
- data Color = Color {
  - color_pixel :: Pixel
  - color_red :: Word16
  - color_green :: Word16
  - color_blue :: Word16
  - color_flags :: Word8
  }
- type Pixel = Word32
- type Position = Int32
- type Dimension = Word32
- type Angle = CInt
- type ScreenNumber = Word32
- type Buffer = CInt
- module Graphics.X11.Xlib.Event
- module Graphics.X11.Xlib.Display
- module Graphics.X11.Xlib.Screen
- module Graphics.X11.Xlib.Window
- module Graphics.X11.Xlib.Context
- module Graphics.X11.Xlib.Color
- module Graphics.X11.Xlib.Cursor
- module Graphics.X11.Xlib.Font
- module Graphics.X11.Xlib.Atom
- module Graphics.X11.Xlib.Region
- module Graphics.X11.Xlib.Image
- module Graphics.X11.Xlib.Misc

# Conventions

In translating the library, we had to change names to conform with Haskell's lexical syntax: function names and names of constants must start with a lowercase letter; type names must start with an uppercase letter. The case of the remaining letters is unchanged.

In addition, we chose to take advantage of Haskell's module system to allow us to drop common prefixes (`X`, `XA_`, etc.) attached to X11 identifiers.

We named enumeration types so that function types would be easier to understand. For example, we added `Status`, `WindowClass`, etc. Note that the types are synonyms for `Int` so no extra typesafety was obtained.

We consistently raise exceptions when a function returns an error code. In practice, this only affects the following functions because most Xlib functions do not return error codes: `allocColor`, `allocNamedColor`, `fetchBuffer`, `fetchBytes`, `fontFromGC`, `getGeometry`, `getIconName`, `iconifyWindow`, `loadQueryFont`, `lookupColor`, `openDisplay`, `parseColor`, `queryBestCursor`, `queryBestSize`, `queryBestStipple`, `queryBestTile`, `rotateBuffers`, `selectInput`, `storeBuffer`, `storeBytes`, `withdrawWindow`.

# Types

module Graphics.X11.Types

newtype Display

pointer to an X11 `Display` structure

Constructors

Display (Ptr Display) |

Instances

Eq Display |
Data Display |
Ord Display |
Show Display |
Typeable Display |

data Screen

pointer to an X11 `Screen` structure

Instances

Eq Screen |
Data Screen |
Ord Screen |
Show Screen |
Typeable Screen |

data Visual

pointer to an X11 `Visual` structure

Instances

Eq Visual |
Data Visual |
Ord Visual |
Show Visual |
Typeable Visual |

data GC

pointer to an X11 `GC` structure

Instances

Eq GC |
Data GC |
Ord GC |
Show GC |
Typeable GC |

data SetWindowAttributes

pointer to an X11 `XSetWindowAttributes` structure

Instances

Eq SetWindowAttributes |
Data SetWindowAttributes |
Ord SetWindowAttributes |
Show SetWindowAttributes |
Typeable SetWindowAttributes |

data VisualInfo

counterpart of an X11 `XVisualInfo` structure

Constructors

VisualInfo |

Fields

visualInfo_visual :: Visual
visualInfo_visualID :: VisualID
visualInfo_screen :: ScreenNumber
visualInfo_depth :: CInt
visualInfo_class :: CInt
visualInfo_redMask :: CULong
visualInfo_greenMask :: CULong
visualInfo_blueMask :: CULong
visualInfo_colormapSize :: CInt
visualInfo_bitsPerRGB :: CInt

Instances

Eq VisualInfo |
Show VisualInfo |
Typeable VisualInfo |
Storable VisualInfo |
Default VisualInfo |

data Point

counterpart of an X11 `XPoint` structure

Constructors

Point |

Fields

pt_x :: !Position
pt_y :: !Position

Instances

Eq Point |
Data Point |
Show Point |
Typeable Point |
Storable Point |

data Rectangle

counterpart of an X11 `XRectangle` structure

Constructors

Rectangle |

Fields

rect_x :: !Position
rect_y :: !Position
rect_width :: !Dimension
rect_height :: !Dimension

Instances

Eq Rectangle |
Data Rectangle |
Read Rectangle |
Show Rectangle |
Typeable Rectangle |
Storable Rectangle |

data Arc

counterpart of an X11 `XArc` structure

Constructors

Arc |

Fields

arc_x :: Position
arc_y :: Position
arc_width :: Dimension
arc_height :: Dimension
arc_angle1 :: Angle
arc_angle2 :: Angle

Instances

Eq Arc |
Show Arc |
Typeable Arc |
Storable Arc |

data Segment

counterpart of an X11 `XSegment` structure

Constructors

Segment |

Fields

seg_x1 :: Position
seg_y1 :: Position
seg_x2 :: Position
seg_y2 :: Position

Instances

Eq Segment |
Data Segment |
Show Segment |
Typeable Segment |
Storable Segment |

data Color

counterpart of an X11 `XColor` structure

Constructors

Color |

Fields

color_pixel :: Pixel
color_red :: Word16
color_green :: Word16
color_blue :: Word16
color_flags :: Word8

Instances

Eq Color |
Data Color |
Show Color |
Typeable Color |
Storable Color |

type Pixel = Word32

type Position = Int32

type Dimension = Word32

type Angle = CInt

type ScreenNumber = Word32

type Buffer = CInt

# X11 library functions

module Graphics.X11.Xlib.Event

module Graphics.X11.Xlib.Display

module Graphics.X11.Xlib.Screen

module Graphics.X11.Xlib.Window

module Graphics.X11.Xlib.Context

module Graphics.X11.Xlib.Color

module Graphics.X11.Xlib.Cursor

module Graphics.X11.Xlib.Font

module Graphics.X11.Xlib.Atom

module Graphics.X11.Xlib.Region

module Graphics.X11.Xlib.Image

module Graphics.X11.Xlib.Misc