PreviousUpNext

15.3.781  src/lib/x-kit/xclient/src/window/window-old.api

## window-old.api
#
#   The three kinds of X server rectangular arrays of pixels
#   supported by x-kit are window, rw_pixmap and ro_pixmap.
#
#      o 'window': are on-screen  and on the X-server.
#      o 'rw_pixmap': are off-screen and on the X-server.
#      o 'ro_pixmap': offscreeen, immutable and on the X-server.
#
#   These all have 'depth' (bits per pixel) and
#   'size' (in pixel rows and cols) information.
#   Windows have in addition 'upperleft' position
#   (relative to parent window) and border width in pixels.
#
#   (A fourth kind of rectangular array of pixels is the
#   client-side 'cs_pixmap_old'.  These are not 'drawable', but
#   pixels can be bitblt-ed between them and server-side
#   windows and pixmaps.)
#
# See also:
#     src/lib/x-kit/widget/old/basic/hostwindow.api
#     src/lib/x-kit/xclient/src/window/ro-pixmap-old.api
#     src/lib/x-kit/xclient/src/window/cs-pixmap-old.pkg
#     src/lib/x-kit/xclient/src/window/rw-pixmap-old.pkg

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

# This api is implemented in:
#     src/lib/x-kit/xclient/src/window/window-old.pkg

stipulate
    include package   threadkit;                # threadkit                     is from   src/lib/src/lib/thread-kit/src/core-thread-kit/threadkit.pkg
    #
    package dt  =  draw_types_old;              # draw_types_old                is from   src/lib/x-kit/xclient/src/window/draw-types-old.pkg
    package xt  =  xtypes;                      # xtypes                        is from   src/lib/x-kit/xclient/src/wire/xtypes.pkg
    package g2d =  geometry2d;                  # geometry2d                    is from   src/lib/std/2d/geometry2d.pkg
    package xr  =  cursors_old;                 # cursors_old                   is from   src/lib/x-kit/xclient/src/window/cursors-old.pkg
    package sn  =  xsession_old;                # xsession_old                  is from   src/lib/x-kit/xclient/src/window/xsession-old.pkg
    package ip  =  iccc_property_old;           # iccc_property_old             is from   src/lib/x-kit/xclient/src/iccc/iccc-property-old.pkg
    package wc  =  widget_cable_old;            # widget_cable_old              is from   src/lib/x-kit/xclient/src/window/widget-cable-old.pkg
    package wh  =  window_manager_hint_old;     # window_manager_hint_old       is from   src/lib/x-kit/xclient/src/iccc/window-manager-hint-old.pkg
#   package xet =  xevent_types;                # xevent_types                  is from   src/lib/x-kit/xclient/src/wire/xevent-types.pkg
herein

    api Window_Old {
        #
        Window = dt::Window;

        # User-level window attributes:
        #
        package a: api {

            Window_Attribute
              #
              = BACKGROUND_NONE
              | BACKGROUND_PARENT_RELATIVE
              | BACKGROUND_RW_PIXMAP          dt::Rw_Pixmap
              | BACKGROUND_RO_PIXMAP          dt::Ro_Pixmap
              | BACKGROUND_COLOR              rgb::Rgb
              #
              | BORDER_COPY_FROM_PARENT
              | BORDER_RW_PIXMAP              dt::Rw_Pixmap
              | BORDER_RO_PIXMAP              dt::Ro_Pixmap
              | BORDER_COLOR                  rgb::Rgb
              #
              | BIT_GRAVITY                   xt::Gravity
              | WINDOW_GRAVITY                xt::Gravity
              #
              | CURSOR_NONE
              | CURSOR                        xr::Xcursor
              ;
        };

        # Window configuration values:
        #
        package c: api {

            Window_Config
              # 
              = ORIGIN      g2d::Point
              | SIZE        g2d::Size
              | BORDER_WID  Int
              | STACK_MODE               xt::Stack_Mode
              | REL_STACK_MODE  (Window, xt::Stack_Mode)
              ;
        };

        exception BAD_WINDOW_SITE;

        # Window location is relative to parent and
        # does not take border width into account.
        #
        # For higher-level toplevel-window functionality see:
        #     src/lib/x-kit/widget/old/basic/hostwindow.api
        #  
        make_simple_top_window
            :
            sn::Screen
            ->
            { site:             g2d::Window_Site,
              border_color:     rgb::Rgb,
              background_color: rgb8::Rgb8
            }
            ->
            ( Window,
              wc::Kidplug,
              Mailslot( Void )
            );

        make_simple_subwindow
            :
            Window
            ->
            { site:              g2d::Window_Site,
              border_color:      Null_Or( rgb::Rgb ),
              background_color:  Null_Or( rgb8::Rgb8 )
            }
            ->
            Window;

        make_transient_window
            :
            Window
            ->
            { site:              g2d::Window_Site,
              border_color:      rgb::Rgb,
              background_color:  rgb8::Rgb8
            }
            ->
            (Window, wc::Kidplug);

        make_simple_popup_window
            :
            sn::Screen
            ->
            { site:              g2d::Window_Site,
              border_color:      rgb::Rgb,
              background_color:  rgb8::Rgb8
            }
            ->
            (Window, wc::Kidplug);

        make_input_only_window
            :
            Window -> g2d::Box -> Window;

        # We raise this exception on operations such as drawing
        # that are illegal for InputOnly windows:
        #
        exception OP_UNSUPPORTED_ON_INPUT_ONLY_WINDOWS;

                                                                                        # iccc_property_old     is from   src/lib/x-kit/xclient/src/iccc/iccc-property-old.pkg
                                                                                        # commandline           is from   src/lib/std/commandline.pkg
        # Set the properties of a top-level window.
        #
        # This should be done before showing (mapping)
        # the window:
        #
        set_window_manager_properties
            :
            Window
            ->
            {
              window_name:   Null_Or( String ),
              icon_name:     Null_Or( String ),
              #
              commandline_arguments:    List( String ),                                 # Typically from:   commandline::get_arguments ().
              size_hints:               List( wh::Window_Manager_Size_Hint ),
              nonsize_hints:            List( wh::Window_Manager_Nonsize_Hint ),
              #
              class_hints:   Null_Or { resource_class:   String,
                                       resource_name:  String
                                     }
            }
            ->
            Void;

        # Set window's window-manager protocols:
        #
        set_window_manager_protocols:  Window -> List( xt::Atom ) -> Bool;

        # Various routines to reconfigure window layout 
        #
        configure_window:        Window -> List(c::Window_Config) -> Void;
        #
        move_window:             Window -> g2d::Point     -> Void;
        resize_window:           Window -> g2d::Size      -> Void;
        move_and_resize_window:  Window -> g2d::Box -> Void;

        # Map a point in the window's coordinate system
        # to the screen's coordinate system
        #
        window_point_to_screen_point:  Window -> g2d::Point -> g2d::Point;

        set_cursor:  Window ->  Null_Or( xr::Xcursor ) -> Void;

        set_background_color:  Window ->  Null_Or( rgb::Rgb ) -> Void;
            #
            # Set the background color attribute of the window.
            # This does not have an immediate effect on the
            # window's contents but if it is done before the
            # window is shown (mapped) the window will come up
            # with the right color.


        change_window_attributes:  Window -> List( a::Window_Attribute ) -> Void;
            #
            # Set various window attributes.

        show_window:          Window -> Void;           # Show ("map") window. Won't actually show unless all ancestors show.
        hide_window:          Window -> Void;           # Opposide of show.
        withdraw_window:      Window -> Void;           # Sends UnmapNotify to root window of window. I don't get this one yet.
        destroy_window:       Window -> Void;           # In X, destroying a window destroys all its subwindows also, recursively.

        screen_of_window:     Window -> sn::Screen;
        xsession_of_window:   Window -> sn::Xsession;

        grab_keyboard:        Window -> Int;
        ungrab_keyboard:      Window -> Int;

        standard_xevent_mask: xt::Event_Mask;

        rgb8_of:              rgb::Rgb -> rgb8::Rgb8;


        get_window_site:        Window -> g2d::Box;
            #
            # Get size of window plus its location
            # relative to parent.

        note_''seen_first_expose''_oneshot:   Window -> Oneshot_Maildrop(Void) -> Void;
            #
            # Infrastructure -- see comments in src/lib/x-kit/xclient/src/window/window-old.pkg

        get_''seen_first_expose''_oneshot_of:     Window -> Null_Or(Oneshot_Maildrop(Void));
            #
            # This function makes the above oneshot
            # available to clients with access to
            # the Window but not the Widget.  Clients
            # with access to the Widget should use the
            #
            #     widget::seen_first_redraw_oneshot_of
            #
            # call because it is guaranteed to return
            # the required oneshot;  the above call may
            # return NULL, in which case the client thread
            # will have to sleep a bit and then retry.


        get_''gui_startup_complete''_oneshot_of                         # get_''gui_startup_complete''_oneshot_of       def in    src/lib/x-kit/xclient/src/window/xsession-old.pkg
            :
            Window -> Oneshot_Maildrop(Void);                           # See comments in   src/lib/x-kit/xclient/src/window/xsocket-to-hostwindow-router-old.api

        # Make 'window' receive a (faked) keyboard keypress at 'point'.
        # 'window' should be the sub/window actually holding the widget to be activate.
        # 'point'  should be the click point in that window's coordinate system.
        #
        # NOTE! We send the event via the X server to provide full end-to-end testing;
        # the resulting network round trip will be quite slow, making this call
        # generally inappropriate for anything other than unit test code.
        #
        send_fake_key_press_xevent
            :
            { window:           Window,                         # Window handling the keyboard key press event.
              keycode:          xt::Keycode,                    # Keyboard key just clicked down.
              point:            g2d::Point
            }
            ->
            Void
            ;

        # Make 'window' receive a (faked) keyboard key release at 'point'.
        # 'window' should be the sub/window actually holding the widget to be activate.
        # 'point'  should be the click point in that window's coordinate system.
        #
        # NOTE! We send the event via the X server to provide full end-to-end testing;
        # the resulting network round trip will be quite slow, making this call
        # generally inappropriate for anything other than unit test code.
        #
        send_fake_key_release_xevent
            :
            { window:           Window,                         # Window handling the keyboard key press event.
              keycode:          xt::Keycode,                    # Keyboard key just clicked down.
              point:            g2d::Point
            }
            ->
            Void
            ;

        # Make 'window' receive a (faked) mousebutton click at 'point'.
        # 'window' should be the sub/window actually holding the widget to be activate.
        # 'point'  should be the click point in that window's coordinate system.
        #
        # NOTE! We send the event via the X server to provide full end-to-end testing;
        # the resulting network round trip will be quite slow, making this call
        # generally inappropriate for anything other than unit test code.
        #
        send_fake_mousebutton_press_xevent
            :
            { window:           Window,                         # Window handling the mouse-button click event.
              button:           xt::Mousebutton,                # Mouse button just clicked down.
              point:            g2d::Point
            }
            ->
            Void
            ;

        # Counterpart of previous:  make 'window' receive a (faked) mousebutton release at 'point'.
        # 'window' should be the sub/window actually holding the widget to be activate.
        # 'point'  should be the button-release point in that window's coordinate system.
        #
        #
        # NOTE! We send the event via the X server to provide full end-to-end testing;
        # the resulting network round trip will be quite slow, making this call
        # generally inappropriate for anything other than unit test code.
        #
        send_fake_mousebutton_release_xevent
            :
            { window:           Window,                         # Window handling the mouse-button release event.
              button:           xt::Mousebutton,                # Mouse button just released.
              point:            g2d::Point
            }
            ->
            Void
            ;

        # This call may be used to simulate mouse "drag" operations in unit-test code.
        # 'window' should be the sub/window actually holding the widget to be activate.
        # 'point'  should be the supposed mouse-pointer location in that window's coordinate system.
        #
        # NOTE! We send the event via the X server to provide full end-to-end testing;
        # the resulting network round trip will be quite slow, making this call
        # generally inappropriate for anything other than unit test code.
        #
        send_fake_mouse_motion_xevent
            :
            { window:           Window,                         # Window handling the mouse-button release event.
              buttons:          List(xt::Mousebutton),          # Mouse button(s) being dragged.
              point:            g2d::Point
            }
            ->
            Void
            ;

        # The xkit buttons react not just to mouse-up and mouse-down events but also
        # to mouse-enter and mouse-leave events, so to auto-test them propertly we
        # must synthesize those also:
        #
        send_fake_''mouse_enter''_xevent
            :
            { window:           Window,                         # Window handling the event.
              point:            g2d::Point                      # End-of-event coordinate, thus should be just inside window.
            }
            ->
            Void
            ;
        #
        send_fake_''mouse_leave''_xevent
            :
            { window:           Window,                         # Window handling the event.
              point:            g2d::Point                      # End-of-event coordinate, thus should be just outside window.
            }
            ->
            Void
            ;
    };

end;

## COPYRIGHT (c) 1990, 1991 by John H. Reppy.  See SMLNJ-COPYRIGHT file for details.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext