PreviousUpNext

15.3.808  src/lib/x-kit/xclient/src/wire/xsocket-old.api

## xsocket-old.api
#
# Manage binary socket I/O to an X server for an X client.

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

                                                                        # Socket__Premicrothread        is from   src/lib/std/src/socket/socket--premicrothread.api
                                                                        # socket_guts                   is from   src/lib/std/src/socket/socket-guts.pkg
                                                                        # xerrors                       is from   src/lib/x-kit/xclient/src/wire/xerrors.pkg
# This API is implemented by:
#     src/lib/x-kit/xclient/src/wire/xsocket-old.pkg

stipulate
    include package   threadkit;                                        # threadkit                     is from   src/lib/src/lib/thread-kit/src/core-thread-kit/threadkit.pkg
    #
    package sok =  socket__premicrothread;                              # socket__premicrothread        is from   src/lib/std/socket--premicrothread.pkg
    package g2d =  geometry2d;                                          # geometry2d                    is from   src/lib/std/2d/geometry2d.pkg
    package xt  =  xtypes;                                              # xtypes                        is from   src/lib/x-kit/xclient/src/wire/xtypes.pkg
    package v1u =  vector_of_one_byte_unts;                             # vector_of_one_byte_unts       is from   src/lib/std/src/vector-of-one-byte-unts.pkg
    package w1u =  one_word_unt;                                        # one_word_unt                  is from   src/lib/std/one-word-unt.pkg
herein

    api Xsocket_Old {

        exception LOST_REPLY;
        exception ERROR_REPLY  xerrors::Xerror;

        Xsocket;

        make_xsocket:       sok::Socket (X, sok::Stream(sok::Active)) -> Xsocket;

        close_xsocket:      Xsocket -> Void;
        flush_xsocket:      Xsocket -> Void;

        same_xsocket:      (Xsocket, Xsocket) -> Bool;

        send_xrequest:                                  Xsocket -> v1u::Vector -> Void;
        send_xrequest_and_return_completion_mailop:     Xsocket -> v1u::Vector -> Mailop( Void );
        send_xrequest_and_read_reply:                   Xsocket -> v1u::Vector -> Mailop( v1u::Vector );

        sent_xrequest_and_read_replies:     Xsocket -> (v1u::Vector, (v1u::Vector -> Int)) ->  Mailop( v1u::Vector );

        send_xrequest_and_handle_exposures: Xsocket -> (v1u::Vector,  Oneshot_Maildrop( Void -> List( g2d::Box ))) -> Void;


        take_xevent':  Xsocket -> Mailop( xevent_types::x::Event );

        read_xerror:  Xsocket -> (Unt, v1u::Vector);



        ################################################################################
        # X-server queries

        # A convenience function for querying the X server.
        # It is designed to be used via curried application
        # to define specific queries, e.g
        #
        #     query_font = query (v2w::encode_query_font, w2v::decode_query_font_reply);
        #
        query: (X -> v1u::Vector, v1u::Vector -> Y) -> Xsocket -> X -> Y;       
                                                                       # The reply.
                                                                  # The actual query info.
                                                       # Connection to the X server.
                                  # The decode-reply fn, from   src/lib/x-kit/xclient/src/wire/wire-to-value.api
                # The encode-query fn, from   src/lib/x-kit/xclient/src/wire/value-to-wire.api

        # Some predefined queries based on the above.
        # (Maybe we should predefine them all here?)
        #
        # It is possible these should be a separate
        # package, but for now it seems simplest to
        # just fold them into xsocket:

        # See   p23 http://mythryl.org/pub/exene/X-protocol-R6.pdf
        #
        query_tree:  Xsocket  ->  { window_id: xt::Xid }  ->  { children: List(xt::Xid),  parent: Null_Or(xt::Xid),  root: xt::Xid };

        query_colors: Xsocket -> { cmap: xt::Xid, pixels: List(rgb8::Rgb8) } -> List(rgb::Rgb);

        query_best_size: Xsocket -> { drawable: xt::Xid,  ilk: xt::Best_Size_Ilk, size: g2d::Size } -> { high: Int, wide: Int };
        
        query_font
            :
            Xsocket
            ->
            { font:            xt::Xid }
            ->
            {
              all_chars_exist: Bool, 
              default_char:    Int, 
              #
              char_infos:      List(xt::Char_Info), 
              draw_dir:        xt::Font_Drawing_Direction, 
              #
              font_ascent:     Int,
              font_descent:    Int, 
              #
              min_bounds:      xt::Char_Info, 
              max_bounds:      xt::Char_Info,
              #
              max_byte1:       Int, 
              min_byte1:       Int,
              #
              min_char:        Int, 
              max_char:        Int,
              #
              properties:      List(xt::Font_Prop)
            }
            ;

        # See   p34 http://mythryl.org/pub/exene/X-protocol-R6.pdf
        #
        query_pointer
            :   
            Xsocket
            ->
            { window_id:    xt::Xid }
            ->
            { child:                    Null_Or(xt::Xid),               # Child window containing the mouse pointer.
              #
              mousebuttons_state:       xt::Mousebuttons_State, 
              modifier_keys_state:      xt::Modifier_Keys_State, 
              #
              root:                     xt::Xid,                        # Root window containing the mouse pointer.
              #
              root_point:               g2d::Point,                     # Mouse position in root  window coordinates.
              window_point:             g2d::Point,                     # Mouse position in local window coordinates.
              #
              same_screen:              Bool                            # Normally TRUE; FALSE if mouse pointer is not on this screen.
            }
            ;

        query_text_extents:
            Xsocket
            ->
            { font:     xt::Xid,
              string:   String
            }
            ->
            { draw_direction:  xt::Font_Drawing_Direction,
              #
              font_ascent:     w1u::Unt,
              font_descent:    w1u::Unt, 
              #
              overall_ascent:  w1u::Unt, 
              overall_descent: w1u::Unt,
              #
              overall_left:    w1u::Unt, 
              overall_right:   w1u::Unt,
              #
              overall_width:   w1u::Unt
            }
            ;

        string_to_hex:                 String -> String;
        string_to_ascii:               String -> String;

        bytes_to_hex:     v1u::Vector -> String;
        bytes_to_ascii:   v1u::Vector -> String;

        # XXX BUGGO FIXME the above four belong somewhere like string:: and v1u::
    };

end;



Comments and suggestions to: bugs@mythryl.org

PreviousUpNext