Mocka and X11

So once in a while I need to get some thing done in a graphical way. Not for me. Not for you, but for the guys that came to computers after Windows hijacked the machines. These guys just NEED graphical programs, mouse manipulations, the lot, to get even the simplst of operations performed.

Of course this is foolish but on the other hand: those guys rule the world. They're in the majority by far! So if they need a graphical user interface, that's what they'll get. Until now I used tcl/tk for this. Within notime I can build a screen with buttons, spinboxes, listboxes, entry fields and auxilliary screens. All very neat, but also very slow (runtime). Tcl is a scripting language. That says it all. With its severe limitations. Check out the openVote section to find out more.

So today I remembered that I still have Xmodula somewhere stashed away on my 60 GB partition. And I managed to find it. Again. They were already in a working directory in my mocka tree. Here are the files:

      
jan@Beryllium:~/modula/XMod$ ls -l
total 277
-rw-r--r-- 1 jan users 57485 2005-05-16 00:23 KeySyms.def
-rw-r--r-- 1 jan users   168 2001-08-16 18:02 KeySyms.mod
-rw-r--r-- 1 jan users  1955 1999-08-17 03:47 Makefile
-rw-r--r-- 1 jan users  3244 2005-05-16 00:26 README
-rw-r--r-- 1 jan users  2632 2005-05-16 00:27 README.Mocka
-rw-r--r-- 1 jan users 19299 2005-05-16 01:10 X.def
-rw-r--r-- 1 jan users    33 2001-08-16 18:02 X.mod
-rw-r--r-- 1 jan users  5996 1999-08-17 03:38 XMacros.def
-rw-r--r-- 1 jan users  8593 2001-08-16 18:02 XMacros.mod
-rwxr-xr-x 1 jan users 27708 2008-08-30 01:48 XTest*
-rw-r--r-- 1 jan users  5575 2008-08-30 01:46 XTest.mod
-rw-r--r-- 1 jan users  2279 2009-05-04 21:16 Xglobal.def
-rw-r--r-- 1 jan users   168 2001-08-16 18:02 Xglobal.mod
-rw-r--r-- 1 jan users 83857 2005-05-21 21:56 Xlib.def
-rw-r--r-- 1 jan users    39 2001-08-16 18:02 Xlib.mod
-rw-r--r-- 1 jan users 17345 2005-05-19 02:27 Xutil.def
-rw-r--r-- 1 jan users    41 2001-08-16 18:02 Xutil.mod
drwxr-xr-x 2 jan users   880 2008-08-30 01:48 m2bin/
jan@Beryllium:~/modula/XMod$
   
There are some HUGE files with a DEF extension. Not a good sign. Still, you cannot judge a book by the cover.

This job was undertaken by

     Nicky  (Nicky@GameBox.net)
     Institute of Informatics,
     University of Fribourg (CH).
   
I'm not sure if Nicky is a boy or a girl. Nicky Lauda was not a girl anyway. But it doesn't matter. Nicky did a great and tremendous job in porting X11 to Modula-2. As you will have found out if (ever) you reach the bottom of this page.

The Xtest program

If you compile and run the example program (XTest.mod) you get something similar to what you see to the right. Isn't it impressive? Not for the looks of it: a solid black ball. But if you keep in mind that this is a 100% Modula-2 program, it IS impressive.

Try some ways to kill the application. Press 'q', click the 'x' in the upper right hand corner, turn the mouse pointer into a skull, press Ctrl-C. Impressive too.

Below is the source code for XTest.mod (written by Nicky as well):

      
MODULE XTest;

 (*
  * This example module shows how to access X11 from a Modula-2 program.
  * To make the code easy to read, no check are performed; the program is
  * therefore likely to crash if something goes wrong.
  * A real program should always check returned values for possible errors.
  *
  * This program assumes an X display with at least 16 colors.
  *)

FROM  SYSTEM 	   IMPORT  ADDRESS, ADR;
FROM  Xglobal 	   IMPORT  CARD8, INT, CARD, CARD32, SET32;
FROM  X  	   IMPORT  Window, WindowPtr, KeySym, Expose, KeyPress, ButtonPress,
      		   	   ExposureMask, ButtonPressMask, KeyPressMask, None, Colormap, AllocAll, 
  			   DoRed, DoGreen, DoBlue;
FROM  Xlib         IMPORT  Display, DisplayPtr, Screen, ScreenPtr, GC, XOpenDisplay,
      		   	   XCreateSimpleWindow, XSelectInput, XCreateGC, XSetBackground,
			   XSetForeground, XClearWindow, XMapRaised, XFreeGC, XDestroyWindow,
			   XCloseDisplay, XEvent, XNextEvent, XFillRectangle, XFillArc,
			   XDrawString, XColor, XCreateColormap, XStoreColors, XSetWindowColormap,
			   XFreeColormap, XDrawString16, XChar2b; 
FROM  Xutil        IMPORT  XSetStandardProperties, XLookupString;
FROM  XMacros 	   IMPORT  DefaultScreen, BlackPixel, WhitePixel, DefaultRootWindow, RootWindow,
   		   	   DefaultVisual
   
Quite an impressive IMPORT list. This is more than I hoped for. Not too assuring (after my experiments with the other GUI programming languages).
      
VAR    dis		   : DisplayPtr;  	(* Connection to the X server *)
       screen		   : INT; 		(* Default screen number *)
       win		   : Window; 		(* My window *)
       gc		   : GC; 		(* Graphics context *)
       cmap 		   : Colormap; 		(* My private Colormap *)
       black, white	   : CARD32; 		(* Pixel numbers for black and white colors *)
       res    		   : INT; 		(* dummy variable to fetch X calls' results *)


PROCEDURE InitX;	   (* Create everythings that is necessary to draw on a window *)

CONST  WindowName   = "My window";
       IconName     = "HI!";

VAR    windowName, iconName 	: ARRAY[0..59] OF CHAR;

BEGIN
  windowName := WindowName; 	(* Mocka does not allow ADR(Const) *)
  iconName := IconName;     	(* therefore copy it in a variable. *)


  dis := XOpenDisplay (NIL);	   	(* Connect to the X server *)
  screen := DefaultScreen (dis);
  black := BlackPixel (dis, screen);
  white := WhitePixel (dis, screen);
  cmap := 0; 	      	    	    	(* No colormap created yet *)

 (* Create a window *)
  win := XCreateSimpleWindow (dis, DefaultRootWindow(dis), 0, 0, 200, 300, 5, white, black);
  res := XSetStandardProperties (dis, win, ADR(windowName), ADR(iconName), None, NIL, 0, NIL);
  res := XSelectInput (dis, win, ExposureMask + ButtonPressMask + KeyPressMask);

 (* Create a graphic context *)
  gc  := XCreateGC (dis, win, SET32 {}, NIL);
  res := XSetBackground (dis, gc, white);
  res := XSetForeground (dis, gc, black);

 (* Bring the window to the front *)
  res := XMapRaised (dis, win)
END InitX;
   
The feeling that I got when I was trying my lucks with GTK are coming back. These incredibly long names for functions and variables. None, NIL and 0 as parameters. It looks like Nikki translated all C names to Modula-2. And I'm not particularly fond of the SYSTEM.ADR call inside the function parameter list.

I have a bad feeling....

PROCEDURE CreateColormap;	(* Create a grayscale colormap and attach it to the window *)

VAR	  i	   : INT;
   	  tmp	   : ARRAY[0..15] OF XColor;

BEGIN
  FOR i:= 0 TO 15 DO	(* Create a grayscale *)
    WITH tmp [i] DO
      pixel := i;  	(* By default, Xglobal.CARD8 = CHAR; therefore, use CHR() *)
      flags := CHR (DoRed + DoGreen + DoBlue);
      red := i * 4369; 	   	     	     	(* 15x4369 = 65535 = 2^16 - 1  :-) *)
      green := i * 4369;
      blue := i * 4369
    END
  END;

 (* Create the Colormap *)
  cmap := XCreateColormap (dis, RootWindow(dis, screen), DefaultVisual(dis, screen), AllocAll);
  res := XStoreColors (dis, cmap, ADR(tmp), 16);

  res := XSetWindowColormap (dis, win, cmap);		 (* Attach it to the window *)
  black := 0;		    	       			 (* Update black and white *)
  white := 15
END CreateColormap;


PROCEDURE CloseX;

BEGIN
  res := XFreeGC (dis, gc);
  res := XDestroyWindow (dis, win);
  IF cmap <> 0 THEN  res := XFreeColormap (dis, cmap)  END;
  res := XCloseDisplay (dis)
END CloseX;


PROCEDURE Redraw;		(* Redraw our window's content *)

VAR      i, j	     : INT;

BEGIN
  res := XSetForeground (dis, gc, white);
  res := XFillRectangle (dis, win, gc, 0, 0, 200, 300);
  FOR i := 0 TO 15 DO
    res := XSetForeground (dis, gc, i);
    j := i * 6;
    res := XFillArc (dis, win, gc, j, j + 100, 200 - j * 2, 200 - j * 2, 0, 360 * 64)
  END;
  res := XSetForeground (dis, gc, black);
  res := XDrawString (dis, win, gc, 10, 10, "Press 'q' to quit")
END Redraw;


PROCEDURE ClearTextArea;

BEGIN
  res := XSetForeground (dis, gc, white);
  res := XFillRectangle (dis, win, gc, 10, 12, 190, 32);
  res := XSetForeground (dis, gc, black)
END ClearTextArea;


VAR
  event		: XEvent;
  key		: KeySym;
  text		: ARRAY [0..255] OF CHAR;
  ch		: ARRAY [0..15] OF XChar2b;
  length	: CARDINAL;

BEGIN
  InitX;
  (* You can remove the next line to use the standard colors *)
  (* CreateColormap; *)

  LOOP
    res := XNextEvent(dis, event);
    IF  (event.type = Expose) THEN  Redraw  END;
    IF  (event.type = KeyPress) AND
       (XLookupString(ADR(event.xkey), text, key, NIL) = 1) THEN
      IF (text[0] = "q") THEN EXIT END;
      ClearTextArea;

      (* Convert CHAR to XChar2b so we can use a custom string length *)
      length := 0;
      WHILE (text [length] <> 0C) AND (length < 16) DO
        ch [length].byte2 := text[length]; 
	ch [length].byte1 := 0C;
    	INC (length)
      END;

      res := XDrawString (dis, win, gc, 10, 26, "You pressed the key:");
      res := XDrawString16 (dis, win, gc, 10, 42, ADR(ch[0]), length)
    END;
    IF  (event.type = ButtonPress)  THEN
      ClearTextArea;
      res := XDrawString (dis, win, gc, 10, 26, "Button pressed")
    END
  END;

  CloseX;

END XTest.
   
I think I know again why I didn't go for Xmodula after all. Hmm. Let's see if things can be improved by tweaking the library files.

Xlib.def

Let's see what we can do with the X.lib module. X.mod is just there to satisfy the compiler. X.def is a foreign module that interacts with the object file which was compiled with the gcc compiler.

This file is 700 lines of CONST and TYPE definitions.... And this is just for starters. If you take a look at Xlib.def (3500 lines of CONST, TYPE and PROCEDURE definitions) you get the message. Nikki did a great job in porting X1 to Mocka and Modula-2 in general. Yet, you either need a C-mind to get along with this version or make a complete rewrite of the DEF modules with new TYPES and SETS and functions so that all of it complies with what we got used to in Modula-2.

A job too great to carry out for one man..... Switch to Oberon again???? Or use tcl/tk for the user interface and use mocka for what's under the bonnet?

      
(*
 *	$XConsortium: X.h,v 1.69 94/04/17 20:10:48 dpw Exp $
 *)

(* Definitions for the X window system likely to be used by applications *)


(***********************************************************

Copyright (c) 1987  X Consortium

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT.  IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of the X Consortium shall not be used in advertising
or otherwise to promote the sale, use or other dealings in this Software without prior written
authorization from the X Consortium.


Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.

                        All Rights Reserved

Permission to use, copy, modify, and distribute this software and its documentation for any
purpose and without fee is hereby granted, provided that the above copyright notice appear in all
copies and that both that copyright notice and this permission notice appear in supporting
documentation, and that the name of Digital not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior permission.

DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

******************************************************************)
(*
 *	Aug-1999:
 *	Translated to Modula-2 by Nicky.
 *      Use it at your own risks !
 *)

FOREIGN MODULE X;

FROM  SYSTEM   	 IMPORT  BYTE, ADDRESS;
FROM  Xglobal 	 IMPORT  CARD8, INT16, CARD16, INT, CARD, INT32, CARD32, SET32,
      		 BOOL, StringPtr, INTPtr, CARD32Ptr, StringPtrPtr, Many;


CONST	    XlibSpecificationRelease =  6;
	    XProtocol 		     = 11;		(* current protocol version *)
 	    XProtocolRev 	     =  0;		(* current minor version *)

(* Resources *)

TYPE	 XID   	       	= CARD32;		(* Therefore compatible with 0 *)
 	 Mask  		= CARD32;
 	 Atom 		= CARD32;		
	 AtomPtr 	= POINTER TO Atom;
 	 VisualID      	= CARD32;
 	 Time 		= CARD32;

 	 Window 	= XID;		
	 WindowPtr 	= POINTER TO Window;
 	 Drawable 	= XID;	     	    	(* A Window or a Pixmap *)
 	 Font 		= XID;
 	 Pixmap 	= XID;
 	 Cursor 	= XID;
 	 Colormap 	= XID;	
	 ColormapPtr 	= POINTER TO Colormap;
 	 GContext 	= XID;
 	 KeySym 	= CARD32;	
	 KeySymPtr 	= POINTER TO KeySym;
  	 		  	     	    	(* Not opaque, for XMacros *)

 	 KeyCode        = CARD8;
 	 KeyCodePtr 	= POINTER TO KeyCode;

 	 XFontSet 	= ADDRESS;

	 XIM 		= ADDRESS;
 	 XIC 		= ADDRESS;
 	 XOM 		= ADDRESS;
 	 XOC 		= ADDRESS;

(*****************************************************************
 * RESERVED RESOURCE AND CONSTANT DEFINITIONS
 *****************************************************************)

CONST
 None 			= 0;	(* universal null resource or null atom *)
 ParentRelative        	= 1;	(* background pixmap in CreateWindow and ChangeWindowAttributes *)

 CopyFromParent 	= 0;	(* border pixmap in CreateWindow and ChangeWindowAttributes
 		       		   special VisualID and special window class passed to CreateWindow *)
 PointerWindow 		= 0;	(* destination window in SendEvent *)
 InputFocus 		= 1;	(* destination window in SendEvent *)
 PointerRoot 		= 1;	(* focus window in SetInputFocus *)
 AnyPropertyType 	= 0;	(* special Atom, passed to GetProperty *)
 AnyKey		 	= 0;	(* special Key Code, passed to GrabKey *)
 AnyButton 		= 0;	(* special Button Code, passed to GrabButton *)
 AllTemporary 		= 0;	(* special Resource ID passed to KillClient *)
 CurrentTime 		= 0;	(* special Time *)
 NoSymbol	 	= 0;	(* special KeySym *)

(*****************************************************************
 * EVENT DEFINITIONS
 *****************************************************************)

(* Input Event Masks. Used as event-mask window attribute and as arguments to Grab requests.  Not
   to be confused with event names.  *)

CONST
 NoEventMask 		  = SET32 {};
 KeyPressMask 		  = SET32 {0};
 KeyReleaseMask 	  = SET32 {1};
 ButtonPressMask 	  = SET32 {2};
 ButtonReleaseMask 	  = SET32 {3};
 EnterWindowMask 	  = SET32 {4};
 LeaveWindowMask 	  = SET32 {5};
 PointerMotionMask 	  = SET32 {6};
 PointerMotionHintMask 	  = SET32 {7};
 Button1MotionMask 	  = SET32 {8};
 Button2MotionMask 	  = SET32 {9};
 Button3MotionMask 	  = SET32 {10};
 Button4MotionMask 	  = SET32 {11};
 Button5MotionMask 	  = SET32 {12};
 ButtonMotionMask 	  = SET32 {13};
 KeymapStateMask 	  = SET32 {14};
 ExposureMask 		  = SET32 {15};
 VisibilityChangeMask 	  = SET32 {16};
 StructureNotifyMask 	  = SET32 {17};
 ResizeRedirectMask 	  = SET32 {18};
 SubstructureNotifyMask   = SET32 {19};
 SubstructureRedirectMask = SET32 {20};
 FocusChangeMask 	  = SET32 {21};
 PropertyChangeMask 	  = SET32 {22};
 ColormapChangeMask 	  = SET32 {23};
 OwnerGrabButtonMask 	  = SET32 {24};

(* Event names.  Used in "type" field in XEvent structures.  Not to be confused with event masks
   above.  They start from 2 because 0 and 1 are reserved in the protocol for errors and replies.
   *)

 KeyPress    		= 2;
 KeyRelease 		= 3;
 ButtonPress 		= 4;
 ButtonRelease 		= 5;
 MotionNotify 		= 6;
 EnterNotify 		= 7;
 LeaveNotify 		= 8;
 FocusIn 		= 9;
 FocusOut 		= 10;
 KeymapNotify 		= 11;
 Expose 		= 12;
 GraphicsExpose 	= 13;
 NoExpose 		= 14;
 VisibilityNotify 	= 15;
 CreateNotify 		= 16;
 DestroyNotify 		= 17;
 UnmapNotify 		= 18;
 MapNotify 		= 19;
 MapRequest 		= 20;
 ReparentNotify 	= 21;
 ConfigureNotify 	= 22;
 ConfigureRequest 	= 23;
 GravityNotify 		= 24;
 ResizeRequest 		= 25;
 CirculateNotify 	= 26;
 CirculateRequest 	= 27;
 PropertyNotify 	= 28;
 SelectionClear 	= 29;
 SelectionRequest 	= 30;
 SelectionNotify 	= 31;
 ColormapNotify 	= 32;
 ClientMessage 		= 33;
 MappingNotify 		= 34;
 LASTEvent 		= 35;		(* must be bigger than any event # *)


(* Key masks. Used as modifiers to GrabButton and GrabKey, results of QueryPointer,
   state in various key-, mouse-, and button-related events. *)

 ShiftMask  	    = SET32 {0};
 LockMask 	    = SET32 {1};
 ControlMask 	    = SET32 {2};
 Mod1Mask 	    = SET32 {3};
 Mod2Mask 	    = SET32 {4};
 Mod3Mask 	    = SET32 {5};
 Mod4Mask 	    = SET32 {6};
 Mod5Mask 	    = SET32 {7};

(* modifier names.  Used to build a SetModifierMapping request or to read a GetModifierMapping
   request.  These correspond to the masks defined above. *)

 ShiftMapIndex 	   = 0;
 LockMapIndex 	   = 1;
 ControlMapIndex   = 2;
 Mod1MapIndex 	   = 3;
 Mod2MapIndex 	   = 4;
 Mod3MapIndex 	   = 5;
 Mod4MapIndex 	   = 6;
 Mod5MapIndex 	   = 7;

(* button masks.  Used in same manner as Key masks above. Not to be confused with button names
   below. *)

 Button1Mask 	= SET32 {8};
 Button2Mask 	= SET32 {9};
 Button3Mask 	= SET32 {10};
 Button4Mask 	= SET32 {11};
 Button5Mask 	= SET32 {12};

 AnyModifier 	= SET32 {15};  		(* used in GrabButton, GrabKey *)


(* button names. Used as arguments to GrabButton and as detail in ButtonPress and ButtonRelease
   events.  Not to be confused with button masks above. Note that 0 is already defined above as
   "AnyButton".  *)

 Button1 	 = 1;
 Button2 	 = 2;
 Button3 	 = 3;
 Button4 	 = 4;
 Button5 	 = 5;

(* Notify modes *)

 NotifyNormal 	    = 0;
 NotifyGrab 	    = 1;
 NotifyUngrab 	    = 2;
 NotifyWhileGrabbed = 3;

 NotifyHint 	    = 1			(* for MotionNotify events *);

(* Notify detail *)

 NotifyAncestor	   	= 0;
 NotifyVirtual 		= 1;
 NotifyInferior 	= 2;
 NotifyNonlinear 	= 3;
 NotifyNonlinearVirtual = 4;
 NotifyPointer 		= 5;
 NotifyPointerRoot 	= 6;
 NotifyDetailNone 	= 7;

(* Visibility notify *)

 VisibilityUnobscured  		= 0;
 VisibilityPartiallyObscured 	= 1;
 VisibilityFullyObscured 	= 2;

(* Circulation request *)

 PlaceOnTop    	       = 0;
 PlaceOnBottom 	       = 1;

(* protocol families *)

 FamilyInternet        = 0;
 FamilyDECnet 	       = 1;
 FamilyChaos 	       = 2;

(* Property notification *)

 PropertyNewValue      = 0;
 PropertyDelete        = 1;

(* Color Map notification *)

 ColormapUninstalled   = 0;
 ColormapInstalled     = 1;

(* GrabPointer, GrabButton, GrabKeyboard, GrabKey Modes *)

 GrabModeSync 	       = 0;
 GrabModeAsync 	       = 1;

(* GrabPointer, GrabKeyboard reply status *)

 GrabSuccess 	       = 0;
 AlreadyGrabbed        = 1;
 GrabInvalidTime       = 2;
 GrabNotViewable       = 3;
 GrabFrozen 	       = 4;

(* AllowEvents modes *)

 AsyncPointer  	       = 0;
 SyncPointer 	       = 1;
 ReplayPointer 	       = 2;
 AsyncKeyboard 	       = 3;
 SyncKeyboard 	       = 4;
 ReplayKeyboard        = 5;
 AsyncBoth 	       = 6;
 SyncBoth 	       = 7;

(* Used in SetInputFocus, GetInputFocus *)

 RevertToNone 	       = None;
 RevertToPointerRoot   = PointerRoot;
 RevertToParent        = 2;

(*****************************************************************
 * ERROR CODES
 *****************************************************************)

 Success 	   = 0	(* everything's okay *);
 BadRequest 	   = 1	(* bad request code *);
 BadValue 	   = 2	(* int parameter out of range *);
 BadWindow 	   = 3	(* parameter not a Window *);
 BadPixmap 	   = 4	(* parameter not a Pixmap *);
 BadAtom 	   = 5	(* parameter not an Atom *);
 BadCursor 	   = 6	(* parameter not a Cursor *);
 BadFont 	   = 7	(* parameter not a Font *);
 BadMatch 	   = 8	(* parameter mismatch *);
 BadDrawable 	   = 9	(* parameter not a Pixmap or Window *);
 BadAccess 	   = 10	(* depending on context:
			   - key/button already grabbed
			   - attempt to free an illegal cmap entry
			   - attempt to store into a read-only color map entry.
 			   - attempt to modify the access control list from other than the local
			     host. *);
 BadAlloc 	   = 11	(* insufficient resources *);
 BadColor 	   = 12	(* no such colormap *);
 BadGC 		   = 13	(* parameter not a GC *);
 BadIDChoice 	   = 14	(* choice not in range or already used *);
 BadName	   = 15	(* font or color name doesn't exist *);
 BadLength 	   = 16	(* Request length incorrect *);
 BadImplementation = 17	(* server is defective *);

 FirstExtensionError  =	128;
 LastExtensionError   =	255;

(*****************************************************************
 * WINDOW DEFINITIONS
 *****************************************************************)

(* Window classes used by CreateWindow *)
(* Note that CopyFromParent is already defined as 0 above *)

 InputOutput 		    = 1;
 InputOnly 		    = 2;

(* Window attributes for CreateWindow and ChangeWindowAttributes *)

 CWBackPixmap 	     	 = SET32 { 0};
 CWBackPixel 		 = SET32 { 1};
 CWBorderPixmap 	 = SET32 { 2};
 CWBorderPixel 		 = SET32 { 3};
 CWBitGravity 		 = SET32 { 4};
 CWWinGravity 		 = SET32 { 5};
 CWBackingStore 	 = SET32 { 6};
 CWBackingPlanes 	 = SET32 { 7};
 CWBackingPixel 	 = SET32 { 8};
 CWOverrideRedirect 	 = SET32 { 9};
 CWSaveUnder 		 = SET32 {10};
 CWEventMask 		 = SET32 {11};
 CWDontPropagate 	 = SET32 {12};
 CWColormap 		 = SET32 {13};
 CWCursor 		 = SET32 {14};

(* ConfigureWindow structure *)

 CWX 		         = SET32 {0};
 CWY 			 = SET32 {1};
 CWWidth 		 = SET32 {2};
 CWHeight 		 = SET32 {3};
 CWBorderWidth 		 = SET32 {4};
 CWSibling 		 = SET32 {5};
 CWStackMode 		 = SET32 {6};

(* Bit Gravity *)

 ForgetGravity 	 	 = 0;
 NorthWestGravity 	 = 1;
 NorthGravity 		 = 2;
 NorthEastGravity 	 = 3;
 WestGravity 		 = 4;
 CenterGravity 		 = 5;
 EastGravity 		 = 6;
 SouthWestGravity 	 = 7;
 SouthGravity 		 = 8;
 SouthEastGravity 	 = 9;
 StaticGravity 		 = 10;

(* Window gravity + bit gravity above *)

 UnmapGravity 	         = 0;

(* Used in CreateWindow for backing-store hint *)

 NotUseful 		 = 0;
 WhenMapped 		 = 1;
 Always 		 = 2;

(* Used in GetWindowAttributes reply *)

 IsUnmapped 		 = 0;
 IsUnviewable 		 = 1;
 IsViewable 		 = 2;

(* Used in ChangeSaveSet *)

 SetModeInsert 		 = 0;
 SetModeDelete 		 = 1;

(* Used in ChangeCloseDownMode *)

 DestroyAll      	 = 0;
 RetainPermanent 	 = 1;
 RetainTemporary 	 = 2;

(* Window stacking method (in configureWindow) *)

 Above     	         = 0;
 Below     		 = 1;
 TopIf     		 = 2;
 BottomIf  		 = 3;
 Opposite  		 = 4;

(* Circulation direction *)

 RaiseLowest   		 = 0;
 LowerHighest 		 = 1;

(* Property modes *)

 PropModeReplace    	 = 0;
 PropModePrepend 	 = 1;
 PropModeAppend  	 = 2;

(*****************************************************************
 * GRAPHICS DEFINITIONS
 *****************************************************************)

(* graphics functions, as in GC.alu *)

 GXclear    	      =	00H		(* 0 *);
 GXand 		      =	01H		(* src AND dst *);
 GXandReverse 	      =	02H		(* src AND NOT dst *);
 GXcopy 	      =	03H		(* src *);
 GXandInverted 	      =	04H		(* NOT src AND dst *);
 GXnoop 	      =	05H		(* dst *);
 GXxor 		      =	06H		(* src XOR dst *);
 GXor 		      =	07H		(* src OR dst *);
 GXnor 		      =	08H		(* NOT src AND NOT dst *);
 GXequiv 	      =	09H		(* NOT src XOR dst *);
 GXinvert 	      =	0AH		(* NOT dst *);
 GXorReverse 	      =	0BH		(* src OR NOT dst *);
 GXcopyInverted       =	0CH		(* NOT src *);
 GXorInverted 	      =	0DH		(* NOT src OR dst *);
 GXnand 	      =	0EH		(* NOT src OR NOT dst *);
 GXset 		      =	0FH		(* 1 *);

(* LineStyle *)

 LineSolid     	      =	0;
 LineOnOffDash 	      =	1;
 LineDoubleDash       =	2;

(* capStyle *)

 CapNotLast   	      =	0;
 CapButt 	      =	1;
 CapRound 	      =	2;
 CapProjecting 	      =	3;

(* joinStyle *)

 JoinMiter     	      =	0;
 JoinRound 	      =	1;
 JoinBevel 	      =	2;

(* fillStyle *)

 FillSolid     	      =	0;
 FillTiled 	      =	1;
 FillStippled 	      =	2;
 FillOpaqueStippled   =	3;

(* fillRule *)

 EvenOddRule  		= 0;
 WindingRule 		= 1;

(* subwindow mode *)

 ClipByChildren     	= 0;
 IncludeInferiors 	= 1;

(* SetClipRectangles ordering *)

 Unsorted 	     	= 0;
 YSorted 		= 1;
 YXSorted 		= 2;
 YXBanded 		= 3;

(* CoordinateMode for drawing routines *)

 CoordModeOrigin        = 0;	(* relative to the origin *)
 CoordModePrevious 	= 1;	(* relative to previous point *)

(* Polygon shapes *)

 Complex   	    	= 0;	(* paths may intersect *)
 Nonconvex 		= 1;	(* no paths intersect, but not convex *)
 Convex 		= 2;	(* wholly convex *)

(* Arc modes for PolyFillArc *)

 ArcChord    	        = 0;	(* join endpoints of arc *)
 ArcPieSlice 		= 1;	(* join endpoints to center of arc *)

(* GC components: masks used in CreateGC, CopyGC, ChangeGC, OR'ed into GC.stateChanges *)

 GCFunction 	  	= SET32 { 1};
 GCPlaneMask 		= SET32 { 1};
 GCForeground 		= SET32 { 2};
 GCBackground 		= SET32 { 3};
 GCLineWidth 		= SET32 { 4};
 GCLineStyle 		= SET32 { 5};
 GCCapStyle 		= SET32 { 6};
 GCJoinStyle 		= SET32 { 7};
 GCFillStyle 		= SET32 { 8};
 GCFillRule 		= SET32 { 9};
 GCTile 		= SET32 {10};
 GCStipple 		= SET32 {11};
 GCTileStipXOrigin 	= SET32 {12};
 GCTileStipYOrigin 	= SET32 {13};
 GCFont  		= SET32 {14};
 GCSubwindowMode 	= SET32 {15};
 GCGraphicsExposures 	= SET32 {16};
 GCClipXOrigin 		= SET32 {17};
 GCClipYOrigin 		= SET32 {18};
 GCClipMask 		= SET32 {19};
 GCDashOffset 		= SET32 {20};
 GCDashList 		= SET32 {21};
 GCArcMode 		= SET32 {22};

 GCLastBit 		= 22;

(*****************************************************************
 * FONTS
 *****************************************************************)

(* used in QueryFont -- draw direction *)

 FontLeftToRight     	= 0;
 FontRightToLeft 	= 1;

 FontChange 		= 255;

(*****************************************************************
 *  IMAGING
 *****************************************************************)

(* ImageFormat -- PutImage, GetImage *)

 XYBitmap      	        = 0;	(* depth 1, XYFormat *)
 XYPixmap 		= 1;	(* depth == drawable depth *)
 ZPixmap 		= 2;	(* depth == drawable depth *)

(*****************************************************************
 *  COLOR MAP STUFF
 *****************************************************************)

(* For CreateColormap *)

 AllocNone 	        = 0;	(* create map with no entries *)
 AllocAll 		= 1;	(* allocate entire map writeable *)

(* Flags used in StoreNamedColor, StoreColors *)

 DoRed 	      	 	= 1;
 DoGreen 		= 2;
 DoBlue 		= 4;

(*****************************************************************
 * CURSOR STUFF
 *****************************************************************)

(* QueryBestSize Class *)

 CursorShape 	       	= 0;	(* largest size that can be displayed *)
 TileShape 		= 1;	(* size tiled fastest *)
 StippleShape 		= 2;	(* size stippled fastest *)

(*****************************************************************
 * KEYBOARD/POINTER STUFF
 *****************************************************************)

 AutoRepeatModeOff 	= 0;
 AutoRepeatModeOn 	= 1;
 AutoRepeatModeDefault 	= 2;

 LedModeOff 		= 0;
 LedModeOn 		= 1;

(* masks for ChangeKeyboardControl *)

 KBKeyClickPercent      = SET32 {0};
 KBBellPercent 		= SET32 {1};
 KBBellPitch 		= SET32 {2};
 KBBellDuration 	= SET32 {3};
 KBLed 			= SET32 {4};
 KBLedMode 		= SET32 {5};
 KBKey 			= SET32 {6};
 KBAutoRepeatMode 	= SET32 {7};

 MappingSuccess      	= 0;
 MappingBusy         	= 1;
 MappingFailed 		= 2;

 MappingModifier 	= 0;
 MappingKeyboard 	= 1;
 MappingPointer 	= 2;

(*****************************************************************
 * SCREEN SAVER STUFF
 *****************************************************************)

 DontPreferBlanking     = 0;
 PreferBlanking 	= 1;
 DefaultBlanking 	= 2;

 DisableScreenSaver 	= 0;
 DisableScreenInterval 	= 0;

 DontAllowExposures 	= 0;
 AllowExposures 	= 1;
 DefaultExposures 	= 2;

(* for ForceScreenSaver *)

 ScreenSaverReset       = 0;
 ScreenSaverActive 	= 1;

(*****************************************************************
 * HOSTS AND CONNECTIONS
 *****************************************************************)

(* for ChangeHosts *)

 HostInsert 	        = 0;
 HostDelete 		= 1;

(* for ChangeAccessControl *)

 EnableAccess 		= 1;
 DisableAccess 		= 0;

(* Display classes used in opening the connection Note that the statically allocated ones are even
   numbered and the dynamically changeable ones are odd numbered *)

 StaticGray 	        = 0;
 GrayScale 		= 1;
 StaticColor 		= 2;
 PseudoColor 		= 3;
 TrueColor 		= 4;
 DirectColor 		= 5;

(* Byte order  used in imageByteOrder and bitmapBitOrder *)

 LSBFirst      = 0;
 MSBFirst      = 1;

END X.
   

Page created 4 May 2009 and