diff --git a/contrib/x11/x11-wrunt/README.txt b/contrib/x11/x11-wrunt/README.txt new file mode 100644 index 0000000000..94ee7ce6e1 --- /dev/null +++ b/contrib/x11/x11-wrunt/README.txt @@ -0,0 +1,20 @@ +Most of these files take their content from corresponding C files: +x.factor -- X.h +xlib.factor -- Xlib.h +xutil.factor -- Xutil.h +glx.factor -- glx.h and glxtokens.h +keysymdef.factor -- keysymdef.h + +x-events.factor defines x-event predicates (see lesson2.factor for usage) + +Not all of these are complete, but they are complete to run lesson 2 of the +nehe opengl tutorials (and the other tutorials with small changes). To see a +demo run from factor's root dir: + "contrib/x11/x11-wrunt/load.factor" run-file + ( then wait for everything to compile... ) + USE: nehe + main + +Pressing 'q' or esc, or clicking the mouse will exit. If something goes wrong +you can kill off the window with: + current-window get kill-gl-window diff --git a/contrib/x11/x11-wrunt/glx.factor b/contrib/x11/x11-wrunt/glx.factor new file mode 100644 index 0000000000..9c6f3be4db --- /dev/null +++ b/contrib/x11/x11-wrunt/glx.factor @@ -0,0 +1,84 @@ +#! based on glx.h from xfree86, and some of glxtokens.h +IN: x11 +USING: alien ; + +LIBRARY: gl + +! Visual Config Attributes (glXGetConfig, glXGetFBConfigAttrib) +: GLX_USE_GL 1 ; ! support GLX rendering +: GLX_BUFFER_SIZE 2 ; ! depth of the color buffer +: GLX_LEVEL 3 ; ! level in plane stacking +: GLX_RGBA 4 ; ! true if RGBA mode +: GLX_DOUBLEBUFFER 5 ; ! double buffering supported +: GLX_STEREO 6 ; ! stereo buffering supported +: GLX_AUX_BUFFERS 7 ; ! number of aux buffers +: GLX_RED_SIZE 8 ; ! number of red component bits +: GLX_GREEN_SIZE 9 ; ! number of green component bits +: GLX_BLUE_SIZE 10 ; ! number of blue component bits +: GLX_ALPHA_SIZE 11 ; ! number of alpha component bits +: GLX_DEPTH_SIZE 12 ; ! number of depth bits +: GLX_STENCIL_SIZE 13 ; ! number of stencil bits +: GLX_ACCUM_RED_SIZE 14 ; ! number of red accum bits +: GLX_ACCUM_GREEN_SIZE 15 ; ! number of green accum bits +: GLX_ACCUM_BLUE_SIZE 16 ; ! number of blue accum bits +: GLX_ACCUM_ALPHA_SIZE 17 ; ! number of alpha accum bits + +TYPEDEF: XID GLXContextID +TYPEDEF: XID GLXPixmap +TYPEDEF: XID GLXDrawable +TYPEDEF: XID GLXPbuffer +TYPEDEF: XID GLXWindow +TYPEDEF: XID GLXFBConfigID +TYPEDEF: void* GLXContext ! typedef struct __GLXcontextRec *GLXContext; +TYPEDEF: void* GLXFBConfig ! typedef struct __GLXFBConfigRec *GLXFBConfig; + +FUNCTION: XVisualInfo* glXChooseVisual ( Display* dpy, int screen, int* attribList ) ; +FUNCTION: void glXCopyContext ( Display* dpy, GLXContext src, GLXContext dst, ulong mask ) ; +FUNCTION: GLXContext glXCreateContext ( Display* dpy, XVisualInfo* vis, GLXContext shareList, bool direct ) ; +FUNCTION: GLXPixmap glXCreateGLXPixmap ( Display* dpy, XVisualInfo* vis, Pixmap pixmap ) ; +FUNCTION: void glXDestroyContext ( Display* dpy, GLXContext ctx ) ; +FUNCTION: void glXDestroyGLXPixmap ( Display* dpy, GLXPixmap pix ) ; +FUNCTION: int glXGetConfig ( Display* dpy, XVisualInfo* vis, int attrib, int* value) ; +FUNCTION: GLXContext glXGetCurrentContext ( ) ; +FUNCTION: GLXDrawable glXGetCurrentDrawable ( ) ; +FUNCTION: bool glXIsDirect ( Display* dpy, GLXContext ctx ) ; +FUNCTION: bool glXMakeCurrent ( Display* dpy, GLXDrawable drawable, GLXContext ctx ) ; +FUNCTION: bool glXQueryExtension ( Display* dpy, int* errorBase, int* eventBase ) ; +FUNCTION: bool glXQueryVersion ( Display* dpy, int* major, int* minor ) ; +FUNCTION: void glXSwapBuffers ( Display* dpy, GLXDrawable drawable ) ; +FUNCTION: void glXUseXFont ( Font font, int first, int count, int listBase ) ; +FUNCTION: void glXWaitGL ( ) ; +FUNCTION: void glXWaitX ( ) ; +FUNCTION: char* glXGetClientString ( Display* dpy, int name ) ; +FUNCTION: char* glXQueryServerString ( Display* dpy, int screen, int name ) ; +FUNCTION: char* glXQueryExtensionsString ( Display* dpy, int screen ) ; + +! New for GLX 1.3 +FUNCTION: GLXFBConfig* glXGetFBConfigs ( Display* dpy, int screen, int* nelements ) ; +FUNCTION: GLXFBConfig* glXChooseFBConfig ( Display* dpy, int screen, int* attrib_list, int* nelements ) ; +FUNCTION: int glXGetFBConfigAttrib ( Display* dpy, GLXFBConfig config, int attribute, int* value ) ; +FUNCTION: XVisualInfo* glXGetVisualFromFBConfig ( Display* dpy, GLXFBConfig config ) ; +FUNCTION: GLXWindow glXCreateWindow ( Display* dpy, GLXFBConfig config, Window win, int* attrib_list ) ; +FUNCTION: void glXDestroyWindow ( Display* dpy, GLXWindow win ) ; +FUNCTION: GLXPixmap glXCreatePixmap ( Display* dpy, GLXFBConfig config, Pixmap pixmap, int* attrib_list ) ; +FUNCTION: void glXDestroyPixmap ( Display* dpy, GLXPixmap pixmap ) ; +FUNCTION: GLXPbuffer glXCreatePbuffer ( Display* dpy, GLXFBConfig config, int* attrib_list ) ; +FUNCTION: void glXDestroyPbuffer ( Display* dpy, GLXPbuffer pbuf ) ; +FUNCTION: void glXQueryDrawable ( Display* dpy, GLXDrawable draw, int attribute, uint* value ) ; +FUNCTION: GLXContext glXCreateNewContext ( Display* dpy, GLXFBConfig config, int render_type, GLXContext share_list, bool direct ) ; +FUNCTION: bool glXMakeContextCurrent ( Display* display, GLXDrawable draw, GLXDrawable read, GLXContext ctx ) ; +FUNCTION: GLXDrawable glXGetCurrentReadDrawable ( ) ; +FUNCTION: Display* glXGetCurrentDisplay ( ) ; +FUNCTION: int glXQueryContext ( Display* dpy, GLXContext ctx, int attribute, int* value ) ; +FUNCTION: void glXSelectEvent ( Display* dpy, GLXDrawable draw, ulong event_mask ) ; +FUNCTION: void glXGetSelectedEvent ( Display* dpy, GLXDrawable draw, ulong* event_mask ) ; + +! GLX 1.4 and later +! extern void (*glXGetProcAddress(const GLubyte* procname))(void ) ; + +! glxext stuff skipped + + +! GLX Events +! (also skipped for now. only has GLXPbufferClobberEvent, the rest is handled by xlib methinks + diff --git a/contrib/x11/x11-wrunt/keysymdef.factor b/contrib/x11/x11-wrunt/keysymdef.factor new file mode 100644 index 0000000000..a93fbf40b5 --- /dev/null +++ b/contrib/x11/x11-wrunt/keysymdef.factor @@ -0,0 +1,69 @@ +! remarkably similar to parts of keysymdef.h +IN: x11 + +: XK_BackSpace HEX: FF08 ; ! back space, back char +: XK_Tab HEX: FF09 ; +: XK_Linefeed HEX: FF0A ; ! Linefeed, LF +: XK_Clear HEX: FF0B ; +: XK_Return HEX: FF0D ; ! Return, enter +: XK_Pause HEX: FF13 ; ! Pause, hold +: XK_Scroll_Lock HEX: FF14 ; +: XK_Sys_Req HEX: FF15 ; +: XK_Escape HEX: FF1B ; +: XK_Delete HEX: FFFF ; ! Delete, rubout + +! Cursor control & motion + +: XK_Home HEX: FF50 ; +: XK_Left HEX: FF51 ; ! Move left, left arrow +: XK_Up HEX: FF52 ; ! Move up, up arrow +: XK_Right HEX: FF53 ; ! Move right, right arrow +: XK_Down HEX: FF54 ; ! Move down, down arrow +: XK_Prior HEX: FF55 ; ! Prior, previous +: XK_Page_Up HEX: FF55 ; +: XK_Next HEX: FF56 ; ! Next +: XK_Page_Down HEX: FF56 ; +: XK_End HEX: FF57 ; ! EOL +: XK_Begin HEX: FF58 ; ! BOL + +! Keypad Functions, keypad numbers cleverly chosen to map to ascii + +: XK_KP_Space HEX: FF80 ; ! space +: XK_KP_Tab HEX: FF89 ; +: XK_KP_Enter HEX: FF8D ; ! enter +: XK_KP_F1 HEX: FF91 ; ! PF1, KP_A, ... +: XK_KP_F2 HEX: FF92 ; +: XK_KP_F3 HEX: FF93 ; +: XK_KP_F4 HEX: FF94 ; +: XK_KP_Home HEX: FF95 ; +: XK_KP_Left HEX: FF96 ; +: XK_KP_Up HEX: FF97 ; +: XK_KP_Right HEX: FF98 ; +: XK_KP_Down HEX: FF99 ; +: XK_KP_Prior HEX: FF9A ; +: XK_KP_Page_Up HEX: FF9A ; +: XK_KP_Next HEX: FF9B ; +: XK_KP_Page_Down HEX: FF9B ; +: XK_KP_End HEX: FF9C ; +: XK_KP_Begin HEX: FF9D ; +: XK_KP_Insert HEX: FF9E ; +: XK_KP_Delete HEX: FF9F ; +: XK_KP_Equal HEX: FFBD ; ! equals +: XK_KP_Multiply HEX: FFAA ; +: XK_KP_Add HEX: FFAB ; +: XK_KP_Separator HEX: FFAC ; ! separator, often comma +: XK_KP_Subtract HEX: FFAD ; +: XK_KP_Decimal HEX: FFAE ; +: XK_KP_Divide HEX: FFAF ; + +: XK_KP_0 HEX: FFB0 ; +: XK_KP_1 HEX: FFB1 ; +: XK_KP_2 HEX: FFB2 ; +: XK_KP_3 HEX: FFB3 ; +: XK_KP_4 HEX: FFB4 ; +: XK_KP_5 HEX: FFB5 ; +: XK_KP_6 HEX: FFB6 ; +: XK_KP_7 HEX: FFB7 ; +: XK_KP_8 HEX: FFB8 ; +: XK_KP_9 HEX: FFB9 ; + diff --git a/contrib/x11/x11-wrunt/lesson2.factor b/contrib/x11/x11-wrunt/lesson2.factor new file mode 100644 index 0000000000..a738949573 --- /dev/null +++ b/contrib/x11/x11-wrunt/lesson2.factor @@ -0,0 +1,170 @@ +IN: nehe +USING: opengl x11 syntax kernel sequences alien namespaces math threads generic io prettyprint ; + +TUPLE: gl-window dpy screen win ctx x y width height depth ; +SYMBOL: current-window + +SYMBOL: dpy +SYMBOL: screen +SYMBOL: root +SYMBOL: win +SYMBOL: ctx +SYMBOL: title +SYMBOL: vi +SYMBOL: x +SYMBOL: y +SYMBOL: width +SYMBOL: height + +: >int-array ( seq -- int-array ) + dup length dup -rot [ + pick set-int-nth + ] 2each ; + +: attr-list ( -- c-array ) + [ + GLX_RGBA , GLX_DOUBLEBUFFER , + GLX_RED_SIZE , 4 , + GLX_GREEN_SIZE , 4 , + GLX_BLUE_SIZE , 4 , + GLX_DEPTH_SIZE , 16 , + None , + ] f make >int-array ; + +: resize-gl-scene ( glwin -- ) + 0 0 rot [ gl-window-width ] keep [ gl-window-height ] keep >r glViewport + GL_PROJECTION glMatrixMode + glLoadIdentity + 45 r> [ gl-window-width ] keep gl-window-height / 0.1 100 gluPerspective + GL_MODELVIEW glMatrixMode ; + +: gl-init ( glwin -- ) + GL_SMOOTH glShadeModel + 0 0 0 0 glClearColor + 1 glClearDepth + GL_DEPTH_TEST glEnable + GL_LEQUAL glDepthFunc + GL_PERSPECTIVE_CORRECTION_HINT GL_NICEST glHint + resize-gl-scene + glFlush ; + +: normal-XSetWindowAttributes ( cmap -- valuemask attr ) + [ + set-XSetWindowAttributes-colormap + ] keep + ExposureMask KeyPressMask bitor ButtonPressMask bitor StructureNotifyMask bitor + over set-XSetWindowAttributes-event_mask +! dup 1 swap set-XSetWindowAttributes-border_pixel + CWColormap CWEventMask bitor swap ; +! CWBorderPixel CWColormap bitor CWEventMask bitor swap ; + +: make-display ( display-num -- display ) + XOpenDisplay dup dpy set ; + +: make-screen ( display -- screen ) + XDefaultScreen dup screen set ; + +: make-vi ( display screen -- vi ) + attr-list glXChooseVisual dup vi set ; + +: make-ctx ( display vi -- ) + 0 GL_TRUE glXCreateContext ctx set ; + +: make-colormap ( -- cmap ) + dpy get vi get 2dup XVisualInfo-screen XRootWindow dup root set + swap XVisualInfo-visual AllocNone XCreateColormap ; + +: make-win ( valuemask attr -- win ) + >r >r dpy get root get x get y get width get height get 0 vi get + dup XVisualInfo-depth InputOutput rot XVisualInfo-visual r> r> XCreateWindow dup win set ; + +: make-gl-window ( display-num x y width height depth title -- glwin ) + [ + title set depth set height set width set y set x set + make-display dup dup make-screen make-vi make-ctx + make-colormap normal-XSetWindowAttributes make-win + dpy get swap 2dup over "WM_DELETE_WINDOW" t XInternAtom 1 XSetWMProtocols drop + 2dup title get dup None 0 0 over XSetStandardProperties drop + 2dup XMapRaised drop + 2dup ctx get glXMakeCurrent 2drop + screen get win get ctx get x get y get width get height get depth get + dup gl-init + dup global [ current-window set ] bind + ] with-scope ; + +: draw-gl-scene ( -- ) + GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT bitor glClear + glLoadIdentity + -1.5 0 -6 glTranslatef + GL_TRIANGLES [ + 0 1 0 glVertex3f + -1 -1 0 glVertex3f + 1 -1 0 glVertex3f + ] do-state + 3 0 0 glTranslatef + GL_QUADS [ + -1 1 1 glVertex3f + 1 1 0 glVertex3f + 1 -1 0 glVertex3f + -1 -1 0 glVertex3f + ] do-state + current-window get dup gl-window-dpy swap gl-window-win glXSwapBuffers ; + +: kill-gl-window ( glwin -- ) + dup gl-window-ctx [ + over gl-window-dpy dup None 0 glXMakeCurrent drop + swap glXDestroyContext + 0 over set-gl-window-ctx + ] when* + gl-window-dpy XCloseDisplay ; + +GENERIC: (handle-event) ( glwin xevent -- continue? ) + +M: x-expose-event (handle-event) + nip XExposeEvent-count 0 = [ draw-gl-scene ] when t ; + +M: x-configure-notify-event (handle-event) + #! resize if the width or height has changed + [ XConfigureEvent-width swap gl-window-width = ] 2keep + [ XConfigureEvent-height swap gl-window-height = and ] 2keep rot [ + 2drop + ] [ + [ XConfigureEvent-width swap set-gl-window-width ] 2keep + [ XConfigureEvent-height swap set-gl-window-height ] 2keep + drop resize-gl-scene + ] if t ; + +M: x-button-press-event (handle-event) + #! quit if a mouse button is pressed + 2drop f ; + +PREDICATE: x-key-press-event quit-key-event +! 0 XLookupKeysym XK_Escape = ; + 0 XLookupKeysym dup CHAR: q = swap XK_Escape = or ; + +M: quit-key-event (handle-event) + 2drop f ; + +M: x-client-message-event (handle-event) + swap gl-window-dpy swap XClientMessageEvent-message_type XGetAtomName + "WM_PROTOCOLS" = not ; + +M: object (handle-event) + #! unknown event, ignore and continue + 2drop t ; + +: handle-event ( glwin -- continue? ) + ! TODO: don't create a new XEvent object each time (but don't use a global) + dup gl-window-dpy tuck XNextEvent drop (handle-event) ; + +: (loop) ( glwin -- continue? ) + dup gl-window-dpy XPending 0 > [ + dup handle-event [ (loop) ] [ drop f ] if + ] [ drop t ] if ; + +: loop ( glwin -- ) + dup (loop) [ draw-gl-scene loop ] [ drop ] if ; + +: main ( -- ) + ":0.0" 10 10 640 480 16 "NeHe Lesson 2" make-gl-window + dup loop kill-gl-window ; diff --git a/contrib/x11/x11-wrunt/load.factor b/contrib/x11/x11-wrunt/load.factor new file mode 100644 index 0000000000..a7b22c3b7d --- /dev/null +++ b/contrib/x11/x11-wrunt/load.factor @@ -0,0 +1,9 @@ +USING: kernel alien parser sequences words compiler ; + +"X11" "libX11.so" "cdecl" add-library + +[ "x.factor" "xlib.factor" "xutil.factor" "keysymdef.factor" "x-events.factor" + "glx.factor" "lesson2.factor" ] [ "contrib/x11/x11-wrunt/" swap append run-file ] each + +"x11" words [ try-compile ] each + diff --git a/contrib/x11/x11-wrunt/x-events.factor b/contrib/x11/x11-wrunt/x-events.factor new file mode 100644 index 0000000000..3286c79e58 --- /dev/null +++ b/contrib/x11/x11-wrunt/x-events.factor @@ -0,0 +1,40 @@ +IN: x11 +USING: alien kernel sequences namespaces strings syntax math generic parser ; + +: x-event-type + #! XEvent is a union of the various X*Event structs. All of them have + #! 'int type' as their first field. + 0 alien-signed-4 ; + +PREDICATE: integer upper + dup CHAR: A >= swap CHAR: Z <= and ; + +: uncapitalise ( "Capitalised" | "capitalised" -- "capitalised" ) + dup first ch>lower swap >sbuf 0 swap [ set-nth ] keep >string ; + +GENERIC: (camel>dashed) +M: upper (camel>dashed) ( CHAR: X -- ) + CHAR: - , ch>lower , ; +M: object (camel>dashed) ( CHAR: x -- ) , ; + +: camel>dashed ( "SomeName" -- "some-name" ) + uncapitalise [ [ (camel>dashed) ] each ] "" make ; + +: x-event-predicate ( EventName -- ) + #! creates a predicate for x-event-name-event + #! EventName should be a valid XEvent.type (defined in x.factor) + #! note: c structs are represented as byte-arrays in factor + [ "IN: x11 PREDICATE: byte-array x-" % dup camel>dashed % "-event x-event-type " % + % " = ;" % ] "" make eval ; + +[ + "KeyPress" "KeyRelease" "ButtonPress" "ButtonRelease" "MotionNotify" + "EnterNotify" "LeaveNotify" "FocusIn" "FocusOut" "KeymapNotify" + "Expose" "GraphicsExpose" "NoExpose" "VisibilityNotify" "CreateNotify" + "DestroyNotify" "UnmapNotify" "MapNotify" "MapRequest" "ReparentNotify" + "ConfigureNotify" "ConfigureRequest" "GravityNotify" "ResizeRequest" + "CirculateNotify" "CirculateRequest" "PropertyNotify" "SelectionClear" + "SelectionRequest" "SelectionNotify" "ColormapNotify" "ClientMessage" + "MappingNotify" +] [ x-event-predicate ] each + diff --git a/contrib/x11/x11-wrunt/x.factor b/contrib/x11/x11-wrunt/x.factor new file mode 100644 index 0000000000..6d9ce5e2d0 --- /dev/null +++ b/contrib/x11/x11-wrunt/x.factor @@ -0,0 +1,597 @@ +! Based on X.h +IN: x11 +USING: alien math ; + +TYPEDEF: ulong XID +TYPEDEF: ulong Mask +TYPEDEF: ulong Atom +TYPEDEF: ulong VisualID +TYPEDEF: ulong Time +TYPEDEF: ulong VisualID +TYPEDEF: XID Window +TYPEDEF: XID Drawable +TYPEDEF: XID Font +TYPEDEF: XID Pixmap +TYPEDEF: XID Cursor +TYPEDEF: XID Colormap +TYPEDEF: XID GContext +TYPEDEF: XID KeySym +TYPEDEF: uchar KeyCode + +! Reserved Resource and Constant Definitions +: None 0 ; +: ParentRelative 1 ; +: CopyFromParent 0 ; +: PointerWindow 0 ; +: InputFocus 1 ; +: PointerRoot 1 ; +: AnyPropertyType 0 ; +: AnyKey 0 ; +: AnyButton 0 ; +: AllTemporary 0 ; +: CurrentTime 0 ; +: NoSymbol 0 ; + +! Event Definitions +: NoEventMask 0 ; +: KeyPressMask 1 0 shift ; +: KeyReleaseMask 1 1 shift ; +: ButtonPressMask 1 2 shift ; +: ButtonReleaseMask 1 3 shift ; +: EnterWindowMask 1 4 shift ; +: LeaveWindowMask 1 5 shift ; +: PointerMotionMask 1 6 shift ; +: PointerMotionHintMask 1 7 shift ; +: Button1MotionMask 1 8 shift ; +: Button2MotionMask 1 9 shift ; +: Button3MotionMask 1 10 shift ; +: Button4MotionMask 1 11 shift ; +: Button5MotionMask 1 12 shift ; +: ButtonMotionMask 1 13 shift ; +: KeymapStateMask 1 14 shift ; +: ExposureMask 1 15 shift ; +: VisibilityChangeMask 1 16 shift ; +: StructureNotifyMask 1 17 shift ; +: ResizeRedirectMask 1 18 shift ; +: SubstructureNotifyMask 1 19 shift ; +: SubstructureRedirectMask 1 20 shift ; +: FocusChangeMask 1 21 shift ; +: PropertyChangeMask 1 22 shift ; +: ColormapChangeMask 1 23 shift ; +: OwnerGrabButtonMask 1 24 shift ; + +! 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 1 0 shift ; +: LockMask 1 1 shift ; +: ControlMask 1 2 shift ; +: Mod1Mask 1 3 shift ; +: Mod2Mask 1 4 shift ; +: Mod3Mask 1 5 shift ; +: Mod4Mask 1 6 shift ; +: Mod5Mask 1 7 shift ; + +! 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 1 8 shift ; +: Button2Mask 1 9 shift ; +: Button3Mask 1 10 shift ; +: Button4Mask 1 11 shift ; +: Button5Mask 1 12 shift ; + +: AnyModifier 1 15 shift ; ! 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 ; ( IPv4 ) +: FamilyDECnet 1 ; +: FamilyChaos 2 ; +: FamilyInternet6 6 ; ( IPv6 ) + +! authentication families not tied to a specific protocol +: FamilyServerInterpreted 5 ; + +! 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 1 0 shift ; +: CWBackPixel 1 1 shift ; +: CWBorderPixmap 1 2 shift ; +: CWBorderPixel 1 3 shift ; +: CWBitGravity 1 4 shift ; +: CWWinGravity 1 5 shift ; +: CWBackingStore 1 6 shift ; +: CWBackingPlanes 1 7 shift ; +: CWBackingPixel 1 8 shift ; +: CWOverrideRedirect 1 9 shift ; +: CWSaveUnder 1 10 shift ; +: CWEventMask 1 11 shift ; +: CWDontPropagate 1 12 shift ; +: CWColormap 1 13 shift ; +: CWCursor 1 14 shift ; + +! ConfigureWindow structure + +: CWX 1 0 shift ; +: CWY 1 1 shift ; +: CWWidth 1 2 shift ; +: CWHeight 1 3 shift ; +: CWBorderWidth 1 4 shift ; +: CWSibling 1 5 shift ; +: CWStackMode 1 6 shift ; + + +! 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 HEX: 0 ; ! 0 +: GXand HEX: 1 ; ! src AND dst +: GXandReverse HEX: 2 ; ! src AND NOT dst +: GXcopy HEX: 3 ; ! src +: GXandInverted HEX: 4 ; ! NOT src AND dst +: GXnoop HEX: 5 ; ! dst +: GXxor HEX: 6 ; ! src XOR dst +: GXor HEX: 7 ; ! src OR dst +: GXnor HEX: 8 ; ! NOT src AND NOT dst +: GXequiv HEX: 9 ; ! NOT src XOR dst +: GXinvert HEX: a ; ! NOT dst +: GXorReverse HEX: b ; ! src OR NOT dst +: GXcopyInverted HEX: c ; ! NOT src +: GXorInverted HEX: d ; ! NOT src OR dst +: GXnand HEX: e ; ! NOT src OR NOT dst +: GXset HEX: f ; ! 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 1 0 shift ; +: GCPlaneMask 1 1 shift ; +: GCForeground 1 2 shift ; +: GCBackground 1 3 shift ; +: GCLineWidth 1 4 shift ; +: GCLineStyle 1 5 shift ; +: GCCapStyle 1 6 shift ; +: GCJoinStyle 1 7 shift ; +: GCFillStyle 1 8 shift ; +: GCFillRule 1 9 shift ; +: GCTile 1 10 shift ; +: GCStipple 1 11 shift ; +: GCTileStipXOrigin 1 12 shift ; +: GCTileStipYOrigin 1 13 shift ; +: GCFont 1 14 shift ; +: GCSubwindowMode 1 15 shift ; +: GCGraphicsExposures 1 16 shift ; +: GCClipXOrigin 1 17 shift ; +: GCClipYOrigin 1 18 shift ; +: GCClipMask 1 19 shift ; +: GCDashOffset 1 20 shift ; +: GCDashList 1 21 shift ; +: GCArcMode 1 22 shift ; +: 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 0 shift ; +: DoGreen 1 1 shift ; +: DoBlue 1 2 shift ; + +! ***************************************************************** +! * 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 1 0 shift ; +: KBBellPercent 1 1 shift ; +: KBBellPitch 1 2 shift ; +: KBBellDuration 1 3 shift ; +: KBLed 1 4 shift ; +: KBLedMode 1 5 shift ; +: KBKey 1 6 shift ; +: KBAutoRepeatMode 1 7 shift ; + +: 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 ; + diff --git a/contrib/x11/x11-wrunt/xlib.factor b/contrib/x11/x11-wrunt/xlib.factor new file mode 100644 index 0000000000..760d3c9152 --- /dev/null +++ b/contrib/x11/x11-wrunt/xlib.factor @@ -0,0 +1,682 @@ +! based on Xlib.h from x.org, incomplete +IN: x11 +USING: alien ; + +LIBRARY: X11 + +TYPEDEF: char* XPointer +TYPEDEF: void* Display* +TYPEDEF: void* XExtData* +TYPEDEF: int Status +TYPEDEF: void* GC + +BEGIN-STRUCT: XSetWindowAttributes + FIELD: Pixmap background_pixmap + FIELD: ulong background_pixel + FIELD: Pixmap border_pixmap + FIELD: ulong border_pixel + FIELD: int bit_gravity + FIELD: int win_gravity + FIELD: int backing_store + FIELD: ulong backing_planes + FIELD: ulong backing_pixel + FIELD: bool save_under + FIELD: long event_mask + FIELD: long do_not_propagate_mask + FIELD: bool override_redirect + FIELD: Colormap colormap + FIELD: Cursor cursor +END-STRUCT + +BEGIN-STRUCT: XColor + FIELD: ulong pixel + FIELD: ushort red + FIELD: ushort green + FIELD: ushort blue + FIELD: char flags ! do_red, do_green, do_blue + FIELD: char pad +END-STRUCT + +BEGIN-STRUCT: XKeyEvent + FIELD: int type ! of event + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Window window ! "event" window it is reported relative to + FIELD: Window root ! root window that the event occurred on + FIELD: Window subwindow ! child window + FIELD: Time time ! milliseconds + FIELD: int x ! pointer x, y coordinates in event window + FIELD: int y + FIELD: int x_root ! coordinates relative to root + FIELD: int y_root + FIELD: uint state ! key or button mask + FIELD: uint keycode ! detail + FIELD: bool same_screen ! same screen flag +END-STRUCT + +TYPEDEF: XKeyEvent XKeyPressedEvent +TYPEDEF: XKeyEvent XKeyReleasedEvent + +BEGIN-STRUCT: XButtonEvent + FIELD: int type ! of event + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Window window ! "event" window it is reported relative to + FIELD: Window root ! root window that the event occurred on + FIELD: Window subwindow ! child window + FIELD: Time time ! milliseconds + FIELD: int x ! pointer x, y coordinates in event window + FIELD: int y + FIELD: int x_root ! coordinates relative to root + FIELD: int y_root + FIELD: uint state ! key or button mask + FIELD: uint button ! detail + FIELD: bool same_screen ! same screen flag +END-STRUCT + +TYPEDEF: XButtonEvent XButtonPressedEvent +TYPEDEF: XButtonEvent XButtonReleasedEvent + +BEGIN-STRUCT: XMotionEvent + FIELD: int type ! of event + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Window window ! "event" window reported relative to + FIELD: Window root ! root window that the event occurred on + FIELD: Window subwindow ! child window + FIELD: Time time ! milliseconds + FIELD: int x ! pointer x, y coordinates in event window + FIELD: int y + FIELD: int x_root ! coordinates relative to root + FIELD: int y_root + FIELD: uint state ! key or button mask + FIELD: char is_hint ! detail + FIELD: bool same_screen ! same screen flag +END-STRUCT + +TYPEDEF: XMotionEvent XPointerMovedEvent + +BEGIN-STRUCT: XCrossingEvent + FIELD: int type ! of event + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Window window ! "event" window reported relative to + FIELD: Window root ! root window that the event occurred on + FIELD: Window subwindow ! child window + FIELD: Time time ! milliseconds + FIELD: int x ! pointer x, y coordinates in event window + FIELD: int y + FIELD: int x_root ! coordinates relative to root + FIELD: int y_root + FIELD: int mode ! NotifyNormal, NotifyGrab, NotifyUngrab + FIELD: int detail + ! NotifyAncestor, NotifyVirtual, NotifyInferior, + ! NotifyNonlinear,NotifyNonlinearVirtual + FIELD: bool same_screen ! same screen flag + FIELD: bool focus ! boolean focus + FIELD: uint state ! key or button mask +END-STRUCT + +TYPEDEF: XCrossingEvent XEnterWindowEvent +TYPEDEF: XCrossingEvent XLeaveWindowEvent + +BEGIN-STRUCT: XFocusChangeEvent + FIELD: int type ! FocusIn or FocusOut + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Window window ! window of event + FIELD: int mode ! NotifyNormal, NotifyGrab, NotifyUngrab + FIELD: int detail + ! NotifyAncestor, NotifyVirtual, NotifyInferior, + ! NotifyNonlinear,NotifyNonlinearVirtual, NotifyPointer, + ! NotifyPointerRoot, NotifyDetailNone +END-STRUCT + +TYPEDEF: XFocusChangeEvent XFocusInEvent +TYPEDEF: XFocusChangeEvent XFocusOutEvent + +! generated on EnterWindow and FocusIn when KeyMapState selected +BEGIN-STRUCT: XKeymapEvent + FIELD: int type + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Window window + ! char key_vector[32]; + FIELD: int pad ( TODO: get rid of this padding ) + FIELD: int pad + FIELD: int pad + FIELD: int pad + FIELD: int pad + FIELD: int pad + FIELD: int pad + FIELD: int pad +END-STRUCT + +BEGIN-STRUCT: XExposeEvent + FIELD: int type + FIELD: ulong serial ! # of last request processed by server */ + FIELD: bool send_event ! true if this came from a SendEvent request */ + FIELD: Display* display ! Display the event was read from */ + FIELD: Window window + FIELD: int x + FIELD: int y + FIELD: int width + FIELD: int height + FIELD: int count ! if non-zero, at least this many more */ +END-STRUCT + +BEGIN-STRUCT: XGraphicsExposeEvent + FIELD: int type + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Drawable drawable + FIELD: int x + FIELD: int y + FIELD: int width + FIELD: int height + FIELD: int count ! if non-zero, at least this many more + FIELD: int major_code ! core is CopyArea or CopyPlane + FIELD: int minor_code ! not defined in the core +END-STRUCT + +BEGIN-STRUCT: XNoExposeEvent + FIELD: int type + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Drawable drawable + FIELD: int major_code ! core is CopyArea or CopyPlane + FIELD: int minor_code ! not defined in the core +END-STRUCT + +BEGIN-STRUCT: XVisibilityEvent + FIELD: int type + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Window window + FIELD: int state ! Visibility state +END-STRUCT + +BEGIN-STRUCT: XCreateWindowEvent + FIELD: int type + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Window parent ! parent of the window + FIELD: Window window ! window id of window created + FIELD: int x ! window location + FIELD: int y + FIELD: int width ! size of window + FIELD: int height + FIELD: int border_width ! border width + FIELD: bool override_redirect ! creation should be overridden +END-STRUCT + +BEGIN-STRUCT: XDestroyWindowEvent + FIELD: int type + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Window event + FIELD: Window window +END-STRUCT + +BEGIN-STRUCT: XUnmapEvent + FIELD: int type + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Window event + FIELD: Window window + FIELD: bool from_configure +END-STRUCT + +BEGIN-STRUCT: XMapEvent + FIELD: int type + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Window event + FIELD: Window window + FIELD: bool override_redirect ! boolean, is override set... +END-STRUCT + +BEGIN-STRUCT: XMapRequestEvent + FIELD: int type + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Window parent + FIELD: Window window +END-STRUCT + +BEGIN-STRUCT: XReparentEvent + FIELD: int type + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Window event + FIELD: Window window + FIELD: Window parent + FIELD: int x + FIELD: int y + FIELD: bool override_redirect +END-STRUCT + +BEGIN-STRUCT: XConfigureEvent + FIELD: int type + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Window event + FIELD: Window window + FIELD: int x + FIELD: int y + FIELD: int width + FIELD: int height + FIELD: int border_width + FIELD: Window above + FIELD: bool override_redirect +END-STRUCT + +BEGIN-STRUCT: XGravityEvent + FIELD: int type + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Window event + FIELD: Window window + FIELD: int x + FIELD: int y +END-STRUCT + +BEGIN-STRUCT: XResizeRequestEvent + FIELD: int type + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Window window + FIELD: int width + FIELD: int height +END-STRUCT + +BEGIN-STRUCT: XConfigureRequestEvent + FIELD: int type + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Window parent + FIELD: Window window + FIELD: int x + FIELD: int y + FIELD: int width + FIELD: int height + FIELD: int border_width + FIELD: Window above + FIELD: int detail ! Above, Below, TopIf, BottomIf, Opposite + FIELD: ulong value_mask +END-STRUCT + +BEGIN-STRUCT: XCirculateEvent + FIELD: int type + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Window event + FIELD: Window window + FIELD: int place ! PlaceOnTop, PlaceOnBottom +END-STRUCT + +BEGIN-STRUCT: XCirculateRequestEvent + FIELD: int type + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Window parent + FIELD: Window window + FIELD: int place ! PlaceOnTop, PlaceOnBottom +END-STRUCT + +BEGIN-STRUCT: XPropertyEvent + FIELD: int type + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Window window + FIELD: Atom atom + FIELD: Time time + FIELD: int state ! NewValue, Deleted +END-STRUCT + +BEGIN-STRUCT: XSelectionClearEvent + FIELD: int type + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Window window + FIELD: Atom selection + FIELD: Time time +END-STRUCT + +BEGIN-STRUCT: XSelectionRequestEvent + FIELD: int type + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Window owner + FIELD: Window requestor + FIELD: Atom selection + FIELD: Atom target + FIELD: Atom property + FIELD: Time time +END-STRUCT + +BEGIN-STRUCT: XSelectionEvent + FIELD: int type + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Window requestor + FIELD: Atom selection + FIELD: Atom target + FIELD: Atom property ! ATOM or None + FIELD: Time time +END-STRUCT + +BEGIN-STRUCT: XColormapEvent + FIELD: int type + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Window window + FIELD: Colormap colormap ! COLORMAP or None +! #if defined(__cplusplus) || defined(c_plusplus) +! Bool c_new; /* C++ */ +! #else + FIELD: bool new +! #endif + FIELD: int state ! ColormapInstalled, ColormapUninstalled +END-STRUCT + +BEGIN-STRUCT: XClientMessageEvent + FIELD: int type + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Window window + FIELD: Atom message_type + FIELD: int format + ! union { char b[20]; short s[10]; long l[5]; } data; + FIELD: int pad ! TODO + FIELD: int pad + FIELD: int pad + FIELD: int pad + FIELD: int pad +END-STRUCT + +BEGIN-STRUCT: XMappingEvent + FIELD: int type + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Window window ! unused + FIELD: int request ! one of MappingModifier, MappingKeyboard, MappingPointer + FIELD: int first_keycode ! first keycode + FIELD: int count ! defines range of change w. first_keycod +END-STRUCT + +BEGIN-STRUCT: XErrorEvent + FIELD: int type + FIELD: Display* display ! Display the event was read from + FIELD: XID resourceid ! resource id + FIELD: ulong serial ! serial number of failed request + FIELD: uchar error_code ! error code of failed request + FIELD: uchar request_code ! Major op-code of failed request + FIELD: uchar minor_code ! Minor op-code of failed request +END-STRUCT + +BEGIN-STRUCT: XAnyEvent + FIELD: int type + FIELD: ulong serial ! # of last request processed by server + FIELD: bool send_event ! true if this came from a SendEvent request + FIELD: Display* display ! Display the event was read from + FIELD: Window window ! window on which event was requested in event mask +END-STRUCT + +! this union is defined so Xlib can always use the same sized +! event structure internally, to avoid memory fragmentation. +BEGIN-UNION: XEvent + MEMBER: int + MEMBER: XAnyEvent + MEMBER: XKeyEvent + MEMBER: XButtonEvent + MEMBER: XMotionEvent + MEMBER: XCrossingEvent + MEMBER: XFocusChangeEvent + MEMBER: XExposeEvent + MEMBER: XGraphicsExposeEvent + MEMBER: XNoExposeEvent + MEMBER: XVisibilityEvent + MEMBER: XCreateWindowEvent + MEMBER: XDestroyWindowEvent + MEMBER: XUnmapEvent + MEMBER: XMapEvent + MEMBER: XMapRequestEvent + MEMBER: XReparentEvent + MEMBER: XConfigureEvent + MEMBER: XGravityEvent + MEMBER: XResizeRequestEvent + MEMBER: XConfigureRequestEvent + MEMBER: XCirculateEvent + MEMBER: XCirculateRequestEvent + MEMBER: XPropertyEvent + MEMBER: XSelectionClearEvent + MEMBER: XSelectionRequestEvent + MEMBER: XSelectionEvent + MEMBER: XColormapEvent + MEMBER: XClientMessageEvent + MEMBER: XMappingEvent + MEMBER: XErrorEvent + MEMBER: XKeymapEvent +! long pad[24] + MEMBER: long ! TODO: fixme + MEMBER: long + MEMBER: long + MEMBER: long + MEMBER: long + MEMBER: long + MEMBER: long + MEMBER: long + MEMBER: long + MEMBER: long + MEMBER: long + MEMBER: long + MEMBER: long + MEMBER: long + MEMBER: long + MEMBER: long + MEMBER: long + MEMBER: long + MEMBER: long + MEMBER: long + MEMBER: long + MEMBER: long + MEMBER: long + MEMBER: long +END-UNION + +BEGIN-STRUCT: Visual + FIELD: XExtData* ext_data ! hook for extension to hang data + FIELD: VisualID visualid ! visual id of this visual +! #if defined(__cplusplus) || defined(c_plusplus) +! int c_class; /* C++ class of screen (monochrome, etc.) +! #else + FIELD: int class ! class of screen (monochrome, etc.) +! #endif + FIELD: ulong red_mask ! mask values + FIELD: ulong green_mask + FIELD: ulong blue_mask + FIELD: int bits_per_rgb ! log base 2 of distinct color values + FIELD: int map_entries ! color map entries +END-STRUCT + +FUNCTION: int XCloseDisplay ( Display* display ) ; +FUNCTION: Colormap XCreateColormap ( Display* display, Window w, Visual* visual, int alloc ) ; +FUNCTION: Window XCreateWindow ( Display* display, Window parent, int x, int y, uint width, uint height, uint border_width, int depth, uint class, Visual* visual, ulong valuemask, XSetWindowAttributes* attributes ) ; +FUNCTION: Atom XInternAtom ( Display* display, char* atom_name, bool only_if_exists ) ; +FUNCTION: int XMapRaised ( Display* display, Window w ) ; +FUNCTION: Status XGetGeometry ( Display* display, Drawable d, Window* root_return, int* x_return, int* y_return, uint* width_return, uint* height_return, uint* border_width_return, uint* depth_return ) ; +FUNCTION: KeySym XLookupKeysym ( XKeyEvent* key_event, int index ) ; +FUNCTION: char* XGetAtomName ( Display* display, Atom atom ) ; +FUNCTION: Status XSetWMProtocols ( Display* display, Window w, Atom* protocols, int count ) ; + +! dharmatech's stuff + +! The most popular guides to programming the X Window System are the +! series from Oreilly. For programming with Xlib, there is the +! reference manual and the programmers guide. However, a lesser known +! manual is the free Xlib manual that comes with the MIT X +! distribution. The arrangement and order of these bindings follows +! the structure of the free Xlib manual. If you add to this library +! and are wondering what part of the file to modify, just find the +! function or data structure in the manual and note the section. + +! +! 2 - Display Functions +! + +FUNCTION: Display* XOpenDisplay ( char* display_name ) ; + +! 2.2 Obtaining Information about the Display, Image Formats, or Screens + +FUNCTION: ulong XBlackPixel ( Display* display, int screen_number ) ; +FUNCTION: ulong XWhitePixel ( Display* display, int screen_number ) ; +FUNCTION: Colormap XDefaultColormap ( Display* display, int screen_number ) ; +FUNCTION: int XDefaultDepth ( Display* display, int screen_number ) ; +FUNCTION: GC XDefaultGC ( Display* display, int screen_number ) ; +FUNCTION: int XDefaultScreen ( Display* display ) ; +FUNCTION: Window XRootWindow ( Display* display, int screen_number ) ; +FUNCTION: Window XDefaultRootWindow ( Display* display ) ; +FUNCTION: int XProtocolVersion ( Display* display ) ; +FUNCTION: int XProtocolRevision ( Display* display ) ; +FUNCTION: int XQLength ( Display* display ) ; +FUNCTION: int XScreenCount ( Display* display ) ; +FUNCTION: int XConnectionNumber ( Display* display ) ; + +! +! 3 - Window Functions +! + +FUNCTION: Window XCreateSimpleWindow ( Display* display, Window parent, int x, int y, uint width, uint height, uint border_width, ulong border, ulong background ) ; +FUNCTION: Status XDestroyWindow ( Display* display, Window w ) ; +FUNCTION: Status XMapWindow ( Display* display, Window window ) ; +FUNCTION: Status XMapSubwindows ( Display* display, Window window ) ; +FUNCTION: Status XUnmapWindow ( Display* display, Window w ) ; +FUNCTION: Status XUnmapSubwindows ( Display* display, Window w ) ; +FUNCTION: Status XConfigureWindow ( Display* display, Window w, uint value_mask, XWindowChanges* values ) ; +FUNCTION: Status XMoveWindow ( Display* display, Window w, int x, int y ) ; +FUNCTION: Status XResizeWindow ( Display* display, Window w, uint width, uint height ) ; +FUNCTION: Status XSetWindowBorderWidth ( Display* display, ulong w, uint width ) ; +FUNCTION: Status XRaiseWindow ( Display* display, Window w ) ; +FUNCTION: Status XLowerWindow ( Display* display, Window w ) ; +FUNCTION: Status XChangeWindowAttributes ( Display* display, Window w, ulong valuemask, XSetWindowAttributes* attr ) ; +FUNCTION: Status XSetWindowBackground ( Display* display, Window w, ulong background_pixel ) ; +FUNCTION: Status XDefineCursor ( Display* display, Window w, Cursor cursor ) ; +FUNCTION: Status XUndefineCursor ( Display* display, Window w ) ; + +! +! 4 - Window Information Functions +! + +FUNCTION: Status XQueryTree ( Display* display, Window w, Window* root_return, Window* parent_return, Window** children_return, uint* nchildren_return ) ; +FUNCTION: Status XGetWindowAttributes ( Display* display, Window w, XWindowAttributes* attr ) ; +FUNCTION: bool XQueryPointer ( Display* display, Window w, Window* root_return, Window* child_return, int* root_x_return, int* root_y_return, int* win_x_return, int* win_y_return, uint* mask_return ) ; + +! +! 6 - Color Management Functions +! + +FUNCTION: Status XLookupColor ( Display* display, Colormap colormap, char* color_name, XColor* exact_def_return, XColor* screen_def_return ) ; +FUNCTION: Status XAllocColor ( Display* display, Colormap colormap, XColor* screen_in_out ) ; +FUNCTION: Status XQueryColor ( Display* display, Colormap colormap, XColor* def_in_out ) ; + +! +! 7 - Graphics Context Functions +! + +FUNCTION: GC XCreateGC ( Display* display, Window d, ulong valuemask, XGCValues* values ) ; +FUNCTION: int XChangeGC ( Display* display, GC gc, ulong valuemask, XGCValues* values ) ; +FUNCTION: Status XGetGCValues ( Display* display, GC gc, ulong valuemask, XGCValues* values_return ) ; +FUNCTION: Status XSetForeground ( Display* display, GC gc, ulong foreground ) ; +FUNCTION: Status XSetBackground ( Display* display, GC gc, ulong background ) ; +FUNCTION: Status XSetFunction ( Display* display, GC gc, int function ) ; +FUNCTION: Status XSetSubwindowMode ( Display* display, GC gc, int subwindow_mode ) ; +FUNCTION: Status XSetFont ( Display* display, GC gc, Font font ) ; + +! +! 8 - Graphics Functions +! + +FUNCTION: Status XClearWindow ( Display* display, Window w ) ; +FUNCTION: Status XDrawPoint ( Display* display, Drawable d, GC gc, int x, int y ) ; +FUNCTION: Status XDrawLine ( Display* display, Drawable d, GC gc, int x1, int y1, int x2, int y2 ) ; +FUNCTION: Status XDrawArc ( Display* display, Drawable d, GC gc, int x, int y, uint width, uint height, int angle1, int angle2 ) ; +FUNCTION: Status XFillArc ( Display* display, Drawable d, GC gc, int x, int y, uint width, uint height, int angle1, int angle2 ) ; +FUNCTION: Font XLoadFont ( Display* display, char* name ) ; +FUNCTION: XFontStruct* XLoadQueryFont ( Display* display, char* name ) ; +FUNCTION: int XTextWidth ( XFontStruct* font_struct, char* string, int count ) ; +FUNCTION: Status XDrawString ( Display* display, Drawable d, GC gc, int x, int y, char* string, int length ) ; + +! +! 9 - Window and Session Manager Functions +! + +FUNCTION: Status XReparentWindow ( Display* display, Window w, Window parent, int x, int y ) ; +FUNCTION: Status XAddToSaveSet ( Display* display, Window w ) ; +FUNCTION: Status XRemoveFromSaveSet ( Display* display, Window w ) ; +FUNCTION: Status XGrabServer ( Display* display ) ; +FUNCTION: Status XUngrabServer ( Display* display ) ; +FUNCTION: Status XKillClient ( Display* display, XID resource ) ; + +! +! 11 - Event Handling Functions +! + +FUNCTION: Status XSelectInput ( Display* display, Window w, long event_mask ) ; +FUNCTION: Status XFlush ( Display* display ) ; +FUNCTION: Status XSync ( Display* display, int discard ) ; +FUNCTION: int XPending ( Display* display ) ; +FUNCTION: Status XNextEvent ( Display* display, XEvent* event ) ; +FUNCTION: Status XMaskEvent ( Display* display, long event_mask, XEvent* event_return ) ; + +! +! 12 - Input Device Functions +! + +FUNCTION: int XGrabPointer ( Display* display, Window grab_window, bool owner_events, uint event_mask, int pointer_mode, int keyboard_mode, Window confine_to, Cursor cursor, Time time ) ; +FUNCTION: Status XUngrabPointer ( Display* display, Time time ) ; +FUNCTION: Status XChangeActivePointerGrab ( Display* display, uint event_mask, Cursor cursor, Time time ) ; +FUNCTION: Status XGrabKey ( Display* display, int keycode, uint modifiers, Window grab_window, bool owner_events, int pointer_mode, int keyboard_mode ) ; +FUNCTION: Status XSetInputFocus ( Display* display, Window focus, int revert_to, Time time ) ; +FUNCTION: Status XWarpPointer ( Display* display, Window src_w, Window dest_w, int src_x, int src_y, uint src_width, uint src_height, int dest_x, int dest_y ) ; +! +! 14 - Inter-Client Communication Functions +! + +FUNCTION: Status XFetchName ( Display* display, Window w, char** window_name_return ) ; +FUNCTION: Status XGetTransientForHint ( Display* display, Window w, Window* prop_window_return ) ; + +! +! 16 - Application Utility Functions +! + +FUNCTION: int XLookupString ( XKeyEvent* event_struct, char* buffer_return, int bytes_buffer, KeySym* keysym_return, XComposeStatus* status_in_out ) ; + diff --git a/contrib/x11/x11-wrunt/xutil.factor b/contrib/x11/x11-wrunt/xutil.factor new file mode 100644 index 0000000000..b226272eee --- /dev/null +++ b/contrib/x11/x11-wrunt/xutil.factor @@ -0,0 +1,58 @@ +! from Xutil.h, incomplete +IN: x11 +USING: alien ; + +LIBRARY: X11 + +BEGIN-STRUCT: XSizeHints + FIELD: long flags ! marks which fields in this structure are defined + FIELD: int x ! obsolete for new window mgrs, but clients + FIELD: int y ! should set so old wm's don't mess up + FIELD: int width + FIELD: int height + FIELD: int min_width + FIELD: int min_height + FIELD: int max_width + FIELD: int max_height + FIELD: int width_inc + FIELD: int height_inc + ! struct { + ! int x; /* numerator */ + ! int y; /* denominator */ + ! } min_aspect, max_aspect; + FIELD: int min_aspect_x + FIELD: int min_aspect_y + FIELD: int max_aspect_x + FIELD: int max_aspect_y + FIELD: int base_width ! added by ICCCM version 1 + FIELD: int base_height + FIELD: int win_gravity; ! added by ICCCM version 1 +END-STRUCT + +FUNCTION: int XSetStandardProperties ( Display* display, Window w, char* window_name, char* icon_name, Pixmap icon_pixmap, char** argv, int argc, XSizeHints* hints ) ; + +! Information used by the visual utility routines to find desired visual +! type from the many visuals a display may support. + +BEGIN-STRUCT: XVisualInfo + FIELD: Visual* visual + FIELD: VisualID visualid + FIELD: int screen + FIELD: int depth +! #if defined(__cplusplus) || defined(c_plusplus) +! int c_class; /* C++ */ +! #else + FIELD: int class +! #endif + FIELD: ulong red_mask + FIELD: ulong green_mask + FIELD: ulong blue_mask + FIELD: int colormap_size + FIELD: int bits_per_rgb +END-STRUCT + +BEGIN-STRUCT: XComposeStatus + FIELD: XPointer compose_ptr ! state table pointer + FIELD: int chars_matched ! match state +END-STRUCT +