Skip to content

Commit

Permalink
[project @ 2004-03-14 13:45:36 by ross]
Browse files Browse the repository at this point in the history
basic docs
  • Loading branch information
ross committed Mar 14, 2004
1 parent ee04b23 commit bd633f1
Show file tree
Hide file tree
Showing 14 changed files with 517 additions and 24 deletions.
55 changes: 53 additions & 2 deletions Graphics/X11/Types.hsc
Expand Up @@ -27,9 +27,16 @@ module Graphics.X11.Types
Cursor, Cursor,
Colormap, Colormap,
GContext, GContext,
KeyCode,

-- * Enumeration types
-- | These types were introduced to make function types clearer.
-- Note that the types are synonyms for 'Int', so no extra
-- typesafety was obtained.

-- ** Key symbols
KeySym, KeySym,


KeyCode,
xK_VoidSymbol, xK_VoidSymbol,
xK_BackSpace, xK_BackSpace,
xK_Tab, xK_Tab,
Expand Down Expand Up @@ -374,6 +381,7 @@ module Graphics.X11.Types
xK_thorn, xK_thorn,
xK_ydiaeresis, xK_ydiaeresis,


-- ** Event masks
EventMask, EventMask,
noEventMask, noEventMask,
keyPressMask, keyPressMask,
Expand Down Expand Up @@ -402,6 +410,7 @@ module Graphics.X11.Types
colormapChangeMask, colormapChangeMask,
ownerGrabButtonMask, ownerGrabButtonMask,


-- ** Event types
EventType, EventType,
keyPress, keyPress,
keyRelease, keyRelease,
Expand Down Expand Up @@ -438,6 +447,7 @@ module Graphics.X11.Types
mappingNotify, mappingNotify,
lASTEvent, lASTEvent,


-- ** Modifiers
Modifier, Modifier,
shiftMapIndex, shiftMapIndex,
lockMapIndex, lockMapIndex,
Expand All @@ -449,6 +459,7 @@ module Graphics.X11.Types
mod5MapIndex, mod5MapIndex,
anyModifier, anyModifier,


-- ** Key masks
KeyMask, KeyMask,
shiftMask, shiftMask,
lockMask, lockMask,
Expand All @@ -459,27 +470,31 @@ module Graphics.X11.Types
mod4Mask, mod4Mask,
mod5Mask, mod5Mask,


-- ** Button masks
ButtonMask, ButtonMask,
button1Mask, button1Mask,
button2Mask, button2Mask,
button3Mask, button3Mask,
button4Mask, button4Mask,
button5Mask, button5Mask,


-- ** Buttons
Button, Button,
button1, button1,
button2, button2,
button3, button3,
button4, button4,
button5, button5,


-- ** Notify modes
NotifyMode, NotifyMode,
notifyNormal, notifyNormal,
notifyGrab, notifyGrab,
notifyUngrab, notifyUngrab,
notifyWhileGrabbed, notifyWhileGrabbed,
notifyHint, notifyHint,


-- ** Notify details
NotifyDetail, NotifyDetail,
notifyAncestor, notifyAncestor,
notifyVirtual, notifyVirtual,
Expand All @@ -490,39 +505,47 @@ module Graphics.X11.Types
notifyPointerRoot, notifyPointerRoot,
notifyDetailNone, notifyDetailNone,


-- ** Visibility
Visibility, Visibility,
visibilityUnobscured, visibilityUnobscured,
visibilityPartiallyObscured, visibilityPartiallyObscured,
visibilityFullyObscured, visibilityFullyObscured,


-- ** Place of window
Place, Place,
placeOnTop, placeOnTop,
placeOnBottom, placeOnBottom,


-- ** Protocols
Protocol, Protocol,
familyInternet, familyInternet,
familyDECnet, familyDECnet,
familyChaos, familyChaos,


-- ** Property notification
PropertyNotification, PropertyNotification,
propertyNewValue, propertyNewValue,
propertyDelete, propertyDelete,


-- ** Colormap notification
ColormapNotification, ColormapNotification,
colormapUninstalled, colormapUninstalled,
colormapInstalled, colormapInstalled,


-- ** Grab modes
GrabMode, GrabMode,
grabModeSync, grabModeSync,
grabModeAsync, grabModeAsync,


-- ** Grab status
GrabStatus, GrabStatus,
grabSuccess, grabSuccess,
alreadyGrabbed, alreadyGrabbed,
grabInvalidTime, grabInvalidTime,
grabNotViewable, grabNotViewable,
grabFrozen, grabFrozen,


-- ** Allow events
AllowEvents, AllowEvents,
asyncPointer, asyncPointer,
syncPointer, syncPointer,
Expand All @@ -533,11 +556,13 @@ module Graphics.X11.Types
asyncBoth, asyncBoth,
syncBoth, syncBoth,


-- ** Focus modes
FocusMode, FocusMode,
revertToNone, revertToNone,
revertToPointerRoot, revertToPointerRoot,
revertToParent, revertToParent,


-- ** Return status
Status, Status,
success, success,
badRequest, badRequest,
Expand All @@ -560,14 +585,17 @@ module Graphics.X11.Types
firstExtensionError, firstExtensionError,
lastExtensionError, lastExtensionError,


-- *** Exceptions
throwUnlessSuccess, throwUnlessSuccess,
throwIfZero, throwIfZero,


-- ** WindowClass
WindowClass, WindowClass,
copyFromParent, copyFromParent,
inputOutput, inputOutput,
inputOnly, inputOnly,


-- ** Attribute masks
AttributeMask, AttributeMask,
cWBackPixmap, cWBackPixmap,
cWBackPixel, cWBackPixel,
Expand All @@ -585,16 +613,19 @@ module Graphics.X11.Types
cWColormap, cWColormap,
cWCursor, cWCursor,


-- ** Close down modes
CloseDownMode, CloseDownMode,
destroyAll, destroyAll,
retainPermanent, retainPermanent,
retainTemporary, retainTemporary,


-- ** QueryBestSize classes
QueryBestSizeClass, QueryBestSizeClass,
cursorShape, cursorShape,
tileShape, tileShape,
stippleShape, stippleShape,


-- ** Graphics functions
GXFunction, GXFunction,
gXclear, gXclear,
gXand, gXand,
Expand All @@ -613,49 +644,59 @@ module Graphics.X11.Types
gXnand, gXnand,
gXset, gXset,


-- ** Line styles
LineStyle, LineStyle,
lineSolid, lineSolid,
lineOnOffDash, lineOnOffDash,
lineDoubleDash, lineDoubleDash,


-- ** Cap styles
CapStyle, CapStyle,
capNotLast, capNotLast,
capButt, capButt,
capRound, capRound,
capProjecting, capProjecting,


-- ** Join styles
JoinStyle, JoinStyle,
joinMiter, joinMiter,
joinRound, joinRound,
joinBevel, joinBevel,


-- ** Fill styles
FillStyle, FillStyle,
fillSolid, fillSolid,
fillTiled, fillTiled,
fillStippled, fillStippled,
fillOpaqueStippled, fillOpaqueStippled,


-- ** Fill rules
FillRule, FillRule,
evenOddRule, evenOddRule,
windingRule, windingRule,


-- ** Subwindow modes
SubWindowMode, SubWindowMode,
clipByChildren, clipByChildren,
includeInferiors, includeInferiors,


-- ** Coordinate modes
CoordinateMode, CoordinateMode,
coordModeOrigin, coordModeOrigin,
coordModePrevious, coordModePrevious,


-- ** Polygon shapes
PolygonShape, PolygonShape,
complex, complex,
nonconvex, nonconvex,
convex, convex,


-- ** Arc modes
ArcMode, ArcMode,
arcChord, arcChord,
arcPieSlice, arcPieSlice,


-- ** GC masks
GCMask, GCMask,
gCFunction, gCFunction,
gCPlaneMask, gCPlaneMask,
Expand All @@ -682,27 +723,33 @@ module Graphics.X11.Types
gCArcMode, gCArcMode,
gCLastBit, gCLastBit,


-- ** Circulation direction
CirculationDirection, CirculationDirection,
raiseLowest, raiseLowest,
lowerHighest, lowerHighest,


-- ** Byte order
ByteOrder, ByteOrder,
lSBFirst, lSBFirst,
mSBFirst, mSBFirst,


-- ** ColormapAlloc
ColormapAlloc, ColormapAlloc,
allocNone, allocNone,
allocAll, allocAll,


-- ** Mapping requests
MappingRequest, MappingRequest,
mappingModifier, mappingModifier,
mappingKeyboard, mappingKeyboard,
mappingPointer, mappingPointer,


-- ** ChangeSaveSetMode
ChangeSaveSetMode, ChangeSaveSetMode,
setModeInsert, setModeInsert,
setModeDelete, setModeDelete,


-- ** Bit gravity
BitGravity, BitGravity,
forgetGravity, forgetGravity,
northWestGravity, northWestGravity,
Expand All @@ -716,9 +763,11 @@ module Graphics.X11.Types
southEastGravity, southEastGravity,
staticGravity, staticGravity,


-- ** Window gravity
WindowGravity, WindowGravity,
unmapGravity, unmapGravity,


-- ** Backing store
BackingStore, BackingStore,
notUseful, notUseful,
whenMapped, whenMapped,
Expand All @@ -727,6 +776,7 @@ module Graphics.X11.Types
doGreen, doGreen,
doBlue, doBlue,


-- ** Font direction
FontDirection, FontDirection,
fontLeftToRight, fontLeftToRight,
fontRightToLeft, fontRightToLeft,
Expand Down Expand Up @@ -1282,7 +1332,8 @@ type Visibility = Int
, visibilityFullyObscured = VisibilityFullyObscured , visibilityFullyObscured = VisibilityFullyObscured
} }


-- Window's place relative to siblings (used in Circulation requests/events) -- | Place of window relative to siblings
-- (used in Circulation requests or events)
type Place = Int type Place = Int
#{enum Place, #{enum Place,
, placeOnTop = PlaceOnTop , placeOnTop = PlaceOnTop
Expand Down
48 changes: 44 additions & 4 deletions Graphics/X11/Xlib.hs
Expand Up @@ -10,13 +10,28 @@
-- --
-- A collection of FFI declarations for interfacing with Xlib. -- 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.
--
----------------------------------------------------------------------------- -----------------------------------------------------------------------------


module Graphics.X11.Xlib module Graphics.X11.Xlib
( module Graphics.X11.Types, ( -- * Conventions
free, -- $conventions

-- * Types
module Graphics.X11.Types,
-- module Graphics.X11.Xlib.Types,
Display, Screen, Visual, FontStruct, GC, XSetWindowAttributes,
Pixel, Position, Dimension, Angle,
ScreenNumber, Byte, Buffer,
Point, Rectangle, Arc, Segment, Color,


module Graphics.X11.Xlib.Types, -- * X11 library functions
module Graphics.X11.Xlib.Event, module Graphics.X11.Xlib.Event,
module Graphics.X11.Xlib.Display, module Graphics.X11.Xlib.Display,
module Graphics.X11.Xlib.Screen, module Graphics.X11.Xlib.Screen,
Expand All @@ -43,7 +58,32 @@ import Graphics.X11.Xlib.Atom
import Graphics.X11.Xlib.Region import Graphics.X11.Xlib.Region
import Graphics.X11.Xlib.Misc import Graphics.X11.Xlib.Misc


import Foreign.Marshal.Alloc( free ) {- $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'.
-}


---------------------------------------------------------------- ----------------------------------------------------------------
-- End -- End
Expand Down
2 changes: 2 additions & 0 deletions Graphics/X11/Xlib/Atom.hsc
Expand Up @@ -99,6 +99,8 @@ import Foreign.C.String
---------------------------------------------------------------- ----------------------------------------------------------------


-- AC, 1/9/2000: Added definition for XInternAtom -- AC, 1/9/2000: Added definition for XInternAtom

-- | interface to the X11 library function @XInternAtom()@.
internAtom :: Display -> String -> Bool -> IO Atom internAtom :: Display -> String -> Bool -> IO Atom
internAtom display atom_name only_if_exists = internAtom display atom_name only_if_exists =
withCString atom_name $ \ c_atom_name -> withCString atom_name $ \ c_atom_name ->
Expand Down

0 comments on commit bd633f1

Please sign in to comment.