PreviousUpNext

15.3.810  src/lib/x-kit/xclient/src/wire/xtypes.api

## xtypes.api
#
# Some of these may be printed via:
#
#     src/lib/x-kit/xclient/src/to-string/xerror-to-string.pkg
#     src/lib/x-kit/xclient/src/to-string/xevent-to-string.pkg
#     src/lib/x-kit/xclient/src/to-string/xserver-info-to-string.pkg

# Compiled by:
#     src/lib/x-kit/xclient/xclient-internals.sublib



# X11 protocol low-level base types.


stipulate
    package ts = xserver_timestamp;                     # xserver_timestamp     is from   src/lib/x-kit/xclient/src/wire/xserver-timestamp.pkg
herein

    # This api is implemented in:
    #
    #     src/lib/x-kit/xclient/src/wire/xtypes.pkg
    #
    api Xtypes {

        # X authentication information.
        # This gets exported via duplication in:
        # 
        #     src/lib/x-kit/xclient/xclient.api
        #
        Xauthentication
            =
            XAUTHENTICATION
              {
                family:   Int,
                address:  String,
                display:  String,
                name:     String,
                data:     vector_of_one_byte_unts::Vector
              };

        # X atoms 
        #
        Atom = XATOM  Unt;

        # X resource ids.  These are used to name
        # windows, pixmaps, fonts, graphics contexts,
        # cursors and colormaps.  We collapse all of
        # these types into xid and leave it to a higher
        # level interface to distinguish them.
        # Type synonyms are defined for documentary purposes.
        # 
        # NOTE: the X11 protocol spec guarantees that XIDs
        # can be represented in 29 bits.
        #
        Xid;
        #
        same_xid:     (Xid, Xid) -> Bool;
        xid_compare:  (Xid, Xid) -> Order;
        #
        xid_to_int:    Xid       -> Int;
        xid_to_unt:    Xid       -> Unt;
        #
        xid_from_int:  Int       -> Xid;
        xid_from_unt:  Unt       -> Xid;
        #
        xid_to_string: Xid       -> String;

        # More type-safety would be good,
        # but for now these are all just Xid:
        #
        Window_Id           = Xid;
        Pixmap_Id           = Xid;
        Drawable_Id         = Xid;              # Either window_id or pixmap_id.
        #
        Font_Id             = Xid;
        Graphics_Context_Id = Xid;
        Fontable_Id         = Xid;              # Either Font_id or Graphics_Context_id.
        Cursor_Id           = Xid;
        Colormap_Id         = Xid;

        Plane_Mask = PLANEMASK  Unt;

        Visual_Id = VISUAL_ID  Unt;             #  should this be int?? 

        # Keysyms are a portable representation
        # of keycap symbols.
        #
        # It is nontrivial to translate a keysym with matching
        # modifier keys state to an ASCII char -- see
        #
        #     src/lib/x-kit/xclient/src/window/keysym-to-ascii.pkg
        #       
        #
        Keysym = NO_SYMBOL
               | KEYSYM  Int
               ;

        Keycode = KEYCODE  Int;

        any_key: Keycode;

        # X time stamps are either the
        # Current Time or an X Server time value: 
        #
        Timestamp = CURRENT_TIME
                  | TIMESTAMP  ts::Xserver_Timestamp
                  ;


        # Raw data from server (in ClientMessage, property values, ...) 
        #
        Raw_Format = RAW08
                   | RAW16
                   | RAW32
                   ;
        #
        Raw_Data =  RAW_DATA
                      { format:  Raw_Format,
                        data:    vector_of_one_byte_unts::Vector
                      };

        # X property values.  A property value has a type,
        # which is an atom, and a value.  The value is a
        # sequence of 8, 16 or 32-bit items, represented
        # as a format and a string.
        #
        Property_Value
            =
            PROPERTY_VALUE
              { type:   Atom,
                value:  Raw_Data
              };

        # Modes for  src/lib/x-kit/xclient/src/iccc/window-property-old.pkg
        #
        Change_Property_Mode
          #
          = REPLACE_PROPERTY
          | PREPEND_PROPERTY
          |  APPEND_PROPERTY
          ;

        # Polygon shapes 
        #
        Shape =   COMPLEX_SHAPE
              | NONCONVEX_SHAPE
              |    CONVEX_SHAPE
              ;

        # Color items 
        #
        Color_Item
            =
            COLORITEM
              { rgb8:   rgb8::Rgb8,
                red:    Null_Or( Unt ),
                green:  Null_Or( Unt ),
                blue:   Null_Or( Unt )
              };

        # Text/font items, used by PolyText[8, 16] 
        #
        Text_Font
          = FONT_ITEM  Font_Id          #  set new font 
          | TEXT_ITEM  (Int, String)    #  text item 
          ;

        # Modifier keys and mouse buttons 
        #
        Modifier_Key
          #
          = SHIFT_KEY
          | LOCK_KEY
          | CONTROL_KEY
          | MOD1KEY
          | MOD2KEY
          | MOD3KEY
          | MOD4KEY
          | MOD5KEY
          | ANY_MODIFIER
          ;

        Mousebutton =  MOUSEBUTTON Int;                 # We use the X protocol "BUTTON" wire encoding.
        #
        button1: Mousebutton;
        button2: Mousebutton;
        button3: Mousebutton;
        button4: Mousebutton;
        button5: Mousebutton;
            #
            # The X protocol docs are not overly specific
            # about mouse button encodings.  p7 of
            #
            #     http://mythryl.org/pub/exene/X-protocol-R6.pdf
            #
            # says laconically
            #
            #     6. Pointers
            #     Buttons are always numbered starting with one.
            #
            # On my system
            #
            #     /usr/include/X11/X.h
            #
            # is more explicit:
            #
            #     /* 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".  */
            #
            #     #define Button1                       1
            #     #define Button2                       2
            #     #define Button3                       3
            #     #define Button4                       4
            #     #define Button5                       5


        # A modifier key (shift, ctrl...) state vector:
        #
        Modifier_Keys_State
          #
          = ANY_MOD_KEY
          | MKSTATE  Unt
          ;

        # A Mouse button state vector:
        #
        Mousebuttons_State
          =
          MOUSEBUTTON_STATE  Unt;               # We keep these in the X protocol wire encoding bitmap format.
                #                               # For the actual bit layout see   src/lib/x-kit/xclient/src/wire/keys-and-buttons.pkg
                # Having the above value        # or p114-115 (117-118)           http://mythryl.org/pub/exene/X-protocol-R6.pdf
                # be an Unt (vs Int)    
                # is a nuisance and doesn't
                # seem to do any real good.
                # XXX BUGGO FIXME

        # Modes for AllowEvents 
        #
        Event_Mode
          #
          = ASYNC_POINTER
          | SYNC_POINTER
          | REPLAY_POINTER
          | ASYNC_KEYBOARD
          | SYNC_KEYBOARD
          | REPLAY_KEYBOARD
          | ASYNC_BOTH
          | SYNC_BOTH
          ;

        # Keyboard focus modes 
        #
        Focus_Mode
          #
          = FOCUS_NORMAL
          | FOCUS_WHILE_GRABBED
          | FOCUS_GRAB
          | FOCUS_UNGRAB
          ;
        #
        Focus_Detail
          #
          = FOCUS_ANCESTOR
          | FOCUS_VIRTUAL
          | FOCUS_INFERIOR
          | FOCUS_NONLINEAR
          | FOCUS_NONLINEAR_VIRTUAL
          | FOCUS_POINTER
          | FOCUS_POINTER_ROOT
          | FOCUS_NONE
          ;

        # Input focus modes:
        #
        Input_Focus
          #
          = INPUT_FOCUS_NONE
          | INPUT_FOCUS_POINTER_ROOT
          | INPUT_FOCUS_WINDOW       Window_Id
          ;
        #
        Focus_Revert
          #
          = REVERT_TO_NONE
          | REVERT_TO_POINTER_ROOT
          | REVERT_TO_PARENT
          ;

        # SendEvent targets 
        #
        Send_Event_To
          #
          = SEND_EVENT_TO_POINTER_WINDOW
          | SEND_EVENT_TO_INPUT_FOCUS
          | SEND_EVENT_TO_WINDOW        Window_Id
          ;

        # Input device grab modes 
        #
        Grab_Mode = SYNCHRONOUS_GRAB | ASYNCHRONOUS_GRAB;

        # Input device grab status:
        #
        Grab_Status
          #
          = GRAB_SUCCESS
          | ALREADY_GRABBED
          | GRAB_INVALID_TIME
          | GRAB_NOT_VIEWABLE
          | GRAB_FROZEN
          ;

        # Input device mapping status:
        #
        Mapping_Status
          #
          = MAPPING_SUCCESS
          | MAPPING_BUSY
          | MAPPING_FAILED
          ;

        # Visibility 
        #
        Visibility
          = VISIBILITY_UNOBSCURED
          | VISIBILITY_PARTIALLY_OBSCURED
          | VISIBILITY_FULLY_OBSCURED
          ;

        # Window stacking modes:
        #
        Stack_Mode
          #
          = ABOVE
          | BELOW
          | TOP_IF
          | BOTTOM_IF
          | OPPOSITE
          ;

        # Window circulation request:
        #
        Stack_Pos
          #
          = PLACE_ON_TOP
          | PLACE_ON_BOTTOM
          ;

        # Window backing-store ilks:
        #
        Backing_Store
          #
          = BS_NOT_USEFUL
          | BS_WHEN_MAPPED
          | BS_ALWAYS
          ;

        # Window map states:
        #
        Map_State
          #
          = WINDOW_IS_UNMAPPED
          | WINDOW_IS_UNVIEWABLE
          | WINDOW_IS_VIEWABLE
          ;

        # Rectangle list orderings for SetClipRectangles 
        #
        Box_Order
          #
          = UNSORTED_ORDER
          | YSORTED_ORDER
          | YXSORTED_ORDER
          | YXBANDED_ORDER
          ;

        # Font drawing direction:
        # 
        Font_Drawing_Direction
          #
          = DRAW_FONT_LEFT_TO_RIGHT
          | DRAW_FONT_RIGHT_TO_LEFT
          ;

        # Font properties:
        #
        Font_Prop
            =
            FONT_PROP
              { name:   Atom,                   # Name of the property.
                value:  one_word_unt::Unt               # Property value: interpret according to the property. 
              };

        # Per-character font info 
        #
        Char_Info
            =
            CHAR_INFO
              {
                left_bearing:   Int,
                right_bearing:  Int,
                char_width:     Int,
                ascent:         Int,
                descent:        Int,
                #
                attributes:     Unt
              };

        # Graphics functions:
        #
        Graphics_Op
          #
          = OP_CLR                      #  0 
          | OP_AND                      #  src AND dst 
          | OP_AND_NOT                  #  src AND NOT dst 
          | OP_COPY                     #  src 
          | OP_AND_INVERTED             #  NOT src AND dst 
          | OP_NOP                      #  Dst 
          | OP_XOR                      #  src XOR dst 
          | OP_OR                       #  src OR dst 
          | OP_NOR                      #  NOT src AND NOT dst 
          | OP_EQUIV                    #  NOT src XOR dst 
          | OP_NOT                      #  NOT dst 
          | OP_OR_NOT                   #  src OR NOT dst 
          | OP_COPY_NOT                 #  NOT src 
          | OP_OR_INVERTED              #  NOT src OR dst 
          | OP_NAND                     #  NOT src OR NOT dst 
          | OP_SET                      #  1 
          ;


        # Gravity. (Both window-gravity and bit-gravity.)
        # Used in window-manager hints -- see:
        #
        #     src/lib/x-kit/xclient/src/wire/wire-to-value-pith.pkg
        #     src/lib/x-kit/xclient/src/wire/value-to-wire-pith.pkg
        #
        Gravity
          #
          =    FORGET_GRAVITY           #  Bit gravity only 
          |     UNMAP_GRAVITY           #  window gravity only 
          | NORTHWEST_GRAVITY
          |     NORTH_GRAVITY
          | NORTHEAST_GRAVITY
          |      WEST_GRAVITY
          |    CENTER_GRAVITY
          |      EAST_GRAVITY
          | SOUTHWEST_GRAVITY
          |     SOUTH_GRAVITY
          | SOUTHEAST_GRAVITY
          |    STATIC_GRAVITY
          ;

        # Event masks:
        #
        Event_Mask = EVENT_MASK  Unt;

        # Value "lists".
        #
        # We call these lists because that is
        # the X protocol doc terminology;
        # they are actually vectors:
        #
        Value_Mask = VALUE_MASK  Unt;
        Value_List = VALUE_LIST  rw_vector::Rw_Vector( Null_Or( Unt ) );

        # Ilks for QueryBestSize:
        #
        Best_Size_Ilk
          = CURSOR_SHAPE                # Largest size that can be displayed.
          | TILE_SHAPE                  # Size tiled fastest.
          | STIPPLE_SHAPE               # Size stippled fastest.
          ;

        # Resource close-down modes: 
        #
        Close_Down_Mode
          #
          = DESTROY_ALL
          | RETAIN_PERMANENT
          | RETAIN_TEMPORARY
          ;

        # 'io_class' arg for create_window
        # and  encode_create_window:
        #
        Io_Class
          #
          = SAME_IO_AS_PARENT
          | INPUT_OUTPUT
          | INPUT_ONLY
          ;

        # 'visual_id' arg for create_window
        # and          encode_create_window:
        #
        Visual_Id_Choice
          #
          = SAME_VISUAL_AS_PARENT
          | OVERRIDE_PARENT_VISUAL Visual_Id
          ;

        # X hosts 
        #
        Xhost
          #
          = INTERNET_HOST  String
          | DECNET_HOST  String
          | CHAOS_HOST  String
          ;

        # Image byte-orders and bitmap bit-orders 
        #
        Order = MSBFIRST | LSBFIRST;

        # Image formats 
        #
        Image_Format
          #
          = XYBITMAP            #  Depth 1, XYFormat 
          | XYPIXMAP            #  Depth == drawable depth 
          | ZPIXMAP             #  Depth == drawable depth 
          ;     

        Pixmap_Format
            =
            FORMAT
              { depth:           Int,
                bits_per_pixel:  Int,
                scanline_pad:    Raw_Format 
              };

        Display_Class
          #
          = STATIC_GRAY
          | GRAY_SCALE
          | STATIC_COLOR
          | PSEUDO_COLOR
          | TRUE_COLOR
          | DIRECT_COLOR
          ;

        # Our type "Visual" here is actually a merging of
        # the X protocol types of "depth" and "visual":
        #
        Visual
          #
          = NO_VISUAL_FOR_THIS_DEPTH  Int               # A depth with no visuals.
          #
          | VISUAL
              {
                visual_id:     Visual_Id,               # The associated visual id.
                depth:         Int,                     # The depth.
                ilk:           Display_Class,
                cmap_entries:  Int,
                bits_per_rgb:  Int,
                red_mask:      Unt,
                green_mask:    Unt,
                blue_mask:     Unt
              };


        # This holds the information we get back from
        # a (successful) connect request to the X server.
        # These values get constructed by
        #
        #     decode_connect_request_reply
        #
        # from   src/lib/x-kit/xclient/src/wire/wire-to-value.pkg
        #
        # and may be rendered into a human-readable string via
        #
        #     xserver_info_to_string
        #
        # from   src/lib/x-kit/xclient/src/to-string/xserver-info-to-string.pkg
        #     
        Xserver_Screen
            =
            { backing_store:    Backing_Store, 
              #
              black_rgb8:       rgb8::Rgb8,
              white_rgb8:       rgb8::Rgb8,
              #
              default_colormap: Xid, 
              input_masks:      Event_Mask, 
              #
              installed_colormaps
                  :
                  { min:        Int,
                    max:        Int
                  }, 

              millimeters_high: Int,
              millimeters_wide: Int, 
              #
              pixels_high:      Int,
              pixels_wide:      Int, 
              #
              root_depth:       Int,
              root_visualid:    Visual_Id, 
              root_window:      Xid,
              #
              save_unders:      Bool,
              visuals:          List( Visual )
            };

        Xserver_Info
            =
            { bitmap_order:         Order, 
              image_byte_order:     Order, 
              #
              bitmap_scanline_pad:  Raw_Format, 
              bitmap_scanline_unit: Raw_Format, 
              #
              pixmap_formats:  List(Pixmap_Format), 
              #
              max_keycode:          Keycode,
              min_keycode:          Keycode,
              #
              motion_buf_size:      Int, 
              max_request_length:   Int, 
              #
              protocol_version: { minor: Int,
                                  major: Int
                                }, 
              release_number: Int, 

              screens:   List( Xserver_Screen ),

              xid_base:  Unt,           # See Note[1], below.
              xid_mask:  Unt,           # "                ".

              vendor:    String
            };

        # These are used as arguments to
        #
        #     value::make_window_attribute_list
        #
        # whose result in turn is an argument for:
        #
        #     value_to_wire::encode_create_window
        #     value_to_wire::encode_change_window_attributes
        #
        package a: api {

            Window_Attribute
              #
              = BACKGROUND_PIXMAP_NONE
              | BACKGROUND_PIXMAP_PARENT_RELATIVE
              | BACKGROUND_PIXMAP               Pixmap_Id
              | BACKGROUND_PIXEL                rgb8::Rgb8
              #
              | BORDER_PIXMAP_COPY_FROM_PARENT
              | BORDER_PIXMAP                   Pixmap_Id
              | BORDER_PIXEL                    rgb8::Rgb8
              #
              | BIT_GRAVITY                     Gravity
              | WINDOW_GRAVITY                  Gravity
              #
              | BACKING_STORE                   Backing_Store
              | BACKING_PLANES                  Plane_Mask
              | BACKING_PIXEL                   rgb8::Rgb8
              #
              | EVENT_MASK                      Event_Mask
              | DO_NOT_PROPAGATE_MASK           Event_Mask
              #
              | SAVE_UNDER                      Bool
              | OVERRIDE_REDIRECT               Bool
              #
              | COLOR_MAP_COPY_FROM_PARENT
              | COLOR_MAP                       Colormap_Id
              | CURSOR_NONE
              | CURSOR                          Cursor_Id
              ;
        };

        package xid_map:   Map
                           where  key::Key == Xid;

    };                  #  xtypes 

end;




Comments and suggestions to: bugs@mythryl.org

PreviousUpNext