PreviousUpNext

15.4.1573  src/lib/x-kit/widget/xkit/app/xevent-to-gui-event.pkg

## xevent-to-gui-event.pkg
#
# guishim_imp_for_x implements the boundary between the # 
# portable and windowsystem-specific parts of the system:
# Higher-level bits like guiboss_imp are intended to            # guiboss_imp                   is from   src/lib/x-kit/widget/gui/guiboss-imp.pkg
# be platform-agnostic, whereas lower-level stuff like
# xserver_ximp are platform-specific.                           # xserver_ximp                  is from   src/lib/x-kit/xclient/src/window/xserver-ximp.pkg
#
# Here we convert from X-specific event encodings
# to the platform-independent event encodings used
# by guiboss_imp and the widgets.
#
# At the moment the "platform-independent" event
# encoding is just a clone of the X event encoding,
# so this file is essentially an elaborate no-op,
# but it establishes a type firewall between the
# X-specific and platform-independent worlds, and
# over time the "platform-independent" event encoding
# can diverge from the X event encoding.
#                            -- 2014-06-27 CrT

# Compiled by:
#     src/lib/x-kit/widget/xkit-widget.sublib

stipulate
    include package   threadkit;                                # threadkit                     is from   src/lib/src/lib/thread-kit/src/core-thread-kit/threadkit.pkg
    #
#   package ap  =  client_to_atom;                              # client_to_atom                is from   src/lib/x-kit/xclient/src/iccc/client-to-atom.pkg
    package au  =  authentication;                              # authentication                is from   src/lib/x-kit/xclient/src/stuff/authentication.pkg
    package gtg =  guiboss_to_guishim;                          # guiboss_to_guishim            is from   src/lib/x-kit/widget/theme/guiboss-to-guishim.pkg
#   package cpm =  cs_pixmap;                                   # cs_pixmap                     is from   src/lib/x-kit/xclient/src/window/cs-pixmap.pkg
    package cpt =  cs_pixmat;                                   # cs_pixmat                     is from   src/lib/x-kit/xclient/src/window/cs-pixmat.pkg
    package dy  =  display;                                     # display                       is from   src/lib/x-kit/xclient/src/wire/display.pkg
    package exa =  exercise_x_appwindow;                        # exercise_x_appwindow          is from   src/lib/x-kit/widget/xkit/app/exercise-x-appwindow.pkg
    package w2x =  windowsystem_to_xserver;                     # windowsystem_to_xserver       is from   src/lib/x-kit/xclient/src/window/windowsystem-to-xserver.pkg
#   package fil =  file__premicrothread;                        # file__premicrothread          is from   src/lib/std/src/posix/file--premicrothread.pkg
    package fti =  font_index;                                  # font_index                    is from   src/lib/x-kit/xclient/src/window/font-index.pkg
    package gd  =  gui_displaylist;                             # gui_displaylist               is from   src/lib/x-kit/widget/theme/gui-displaylist.pkg
#   package r2k =  xevent_router_to_keymap;                     # xevent_router_to_keymap       is from   src/lib/x-kit/xclient/src/window/xevent-router-to-keymap.pkg
    package kab =  keys_and_buttons;                            # keys_and_buttons              is from   src/lib/x-kit/xclient/src/wire/keys-and-buttons.pkg
    package k2a =  keysym_to_ascii;                             # keysym_to_ascii               is from   src/lib/x-kit/xclient/src/window/keysym-to-ascii.pkg
    package k2k =  keycode_to_keysym;                           # keycode_to_keysym             is from   src/lib/x-kit/xclient/src/window/keycode-to-keysym.pkg
    package mtx =  rw_matrix;                                   # rw_matrix                     is from   src/lib/std/src/rw-matrix.pkg
    package pen =  pen;                                         # pen                           is from   src/lib/x-kit/xclient/src/window/pen.pkg
    package r8  =  rgb8;                                        # rgb8                          is from   src/lib/x-kit/xclient/src/color/rgb8.pkg
#   package rgb =  rgb;                                         # rgb                           is from   src/lib/x-kit/xclient/src/color/rgb.pkg
    package rop =  ro_pixmap;                                   # ro_pixmap                     is from   src/lib/x-kit/xclient/src/window/ro-pixmap.pkg
    package rw  =  root_window;                                 # root_window                   is from   src/lib/x-kit/widget/lib/root-window.pkg
#   package rwv =  rw_vector;                                   # rw_vector                     is from   src/lib/std/src/rw-vector.pkg
    package a2r =  windowsystem_to_xevent_router;               # windowsystem_to_xevent_router is from   src/lib/x-kit/xclient/src/window/windowsystem-to-xevent-router.pkg
    package sep =  client_to_selection;                         # client_to_selection           is from   src/lib/x-kit/xclient/src/window/client-to-selection.pkg
    package shp =  shade;                                       # shade                         is from   src/lib/x-kit/widget/lib/shade.pkg
    package sj  =  socket_junk;                                 # socket_junk                   is from   src/lib/internet/socket-junk.pkg
    package x2s =  xclient_to_sequencer;                        # xclient_to_sequencer          is from   src/lib/x-kit/xclient/src/wire/xclient-to-sequencer.pkg
#   package tr  =  logger;                                      # logger                        is from   src/lib/src/lib/thread-kit/src/lib/logger.pkg
#   package tsr =  thread_scheduler_is_running;                 # thread_scheduler_is_running   is from   src/lib/src/lib/thread-kit/src/core-thread-kit/thread-scheduler-is-running.pkg
#   package u1  =  one_byte_unt;                                # one_byte_unt                  is from   src/lib/std/one-byte-unt.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 v2w =  value_to_wire;                               # value_to_wire                 is from   src/lib/x-kit/xclient/src/wire/value-to-wire.pkg
#   package wg  =  widget;                                      # widget                        is from   src/lib/x-kit/widget/old/basic/widget.pkg
    package wi  =  window;                                      # window                        is from   src/lib/x-kit/xclient/src/window/window.pkg
    package wme =  window_map_event_sink;                       # window_map_event_sink         is from   src/lib/x-kit/xclient/src/window/window-map-event-sink.pkg
    package wpp =  client_to_window_watcher;                    # client_to_window_watcher      is from   src/lib/x-kit/xclient/src/window/client-to-window-watcher.pkg
    package wy  =  widget_style;                                # widget_style                  is from   src/lib/x-kit/widget/lib/widget-style.pkg
#   package xc  =  xclient;                                     # xclient                       is from   src/lib/x-kit/xclient/xclient.pkg
    package g2d =  geometry2d;                                  # geometry2d                    is from   src/lib/std/2d/geometry2d.pkg
    package xj  =  xsession_junk;                               # xsession_junk                 is from   src/lib/x-kit/xclient/src/window/xsession-junk.pkg
#   package xtr =  xlogger;                                     # xlogger                       is from   src/lib/x-kit/xclient/src/stuff/xlogger.pkg

    package xet =  xevent_types;                                # xevent_types                  is from   src/lib/x-kit/xclient/src/wire/xevent-types.pkg
    package e2s =  xevent_to_string;                            # xevent_to_string              is from   src/lib/x-kit/xclient/src/to-string/xevent-to-string.pkg
    package xt  =  xtypes;                                      # xtypes                        is from   src/lib/x-kit/xclient/src/wire/xtypes.pkg
    package ts  =  xserver_timestamp;                           # xserver_timestamp             is from   src/lib/x-kit/xclient/src/wire/xserver-timestamp.pkg
    #
    # The above three are the X-specific versions of the
    # below two platform-independent packages.  X events
    # come to us from the X server in xet:: encoding.  We       # For the big dataflow diagram see   src/lib/x-kit/xclient/src/window/xclient-ximps.pkg
    # translate them to evt:: encoding and forward them to
    # guiboss_imp, which forwards them to appropriate imps.     # guiboss_imp                   is from   src/lib/x-kit/widget/gui/guiboss-imp.pkg
    #
    package evt =  gui_event_types;                             # gui_event_types               is from   src/lib/x-kit/widget/gui/gui-event-types.pkg
    package gts =  gui_event_to_string;                         # gui_event_to_string           is from   src/lib/x-kit/widget/gui/gui-event-to-string.pkg

    nb = log::note_on_stderr;                                   # log                           is from   src/lib/std/src/log.pkg

    tracefile   =  "widget-unit-test.trace.log";
herein

    api Xevent_To_Gui_Event {
        #
        xevent_to_gui_event
            :
            (xet::x::Event, k2k::Key_Mapping)
            ->
            evt::x::Event;
    };


    package xevent_to_gui_event
    :       Xevent_To_Gui_Event 
    {
        stipulate
            #
            fun do_xid  (xid:  xt::Xid)
                =
                evt::xid_from_int  (xt::xid_to_int  xid);

            do_window_id                =  do_xid;
            do_pixmap_id                =  do_xid;
            do_drawable_id              =  do_xid;
            do_font_id                  =  do_xid;
            do_graphics_context_id      =  do_xid;
            do_fontable_id              =  do_xid;
            do_cursor_id                =  do_xid;
            do_colormap_id              =  do_xid;

            fun do_keysym (xt::NO_SYMBOL ) =>  evt::NO_SYMBOL;
                do_keysym (xt::KEYSYM int) =>  evt::KEYSYM int;
            end;

            fun do_keycode ((xt::KEYCODE int): xt::Keycode)
                =
                evt::KEYCODE int;

            fun do_modifier_keys_state  (state: xt::Modifier_Keys_State)
                =
                { shift_key_was_down     =>  kab::shift_key_is_set      state,
                  shiftlock_key_was_down =>  kab::shiftlock_key_is_set  state,
                  control_key_was_down   =>  kab::control_key_is_set    state,
                  mod1_key_was_down      =>  kab::modifier_key_is_set   (state, 1),
                  mod2_key_was_down      =>  kab::modifier_key_is_set   (state, 2),
                  mod3_key_was_down      =>  kab::modifier_key_is_set   (state, 3),
                  mod4_key_was_down      =>  kab::modifier_key_is_set   (state, 4),
                  mod5_key_was_down      =>  kab::modifier_key_is_set   (state, 5)
                };

            fun do_mousebuttons_state  (state: xt::Mousebuttons_State)
                =
                { mousebutton_1_was_down  =>  kab::mousebutton_1_is_set  state,
                  mousebutton_2_was_down  =>  kab::mousebutton_2_is_set  state,
                  mousebutton_3_was_down  =>  kab::mousebutton_3_is_set  state,
                  mousebutton_4_was_down  =>  kab::mousebutton_4_is_set  state,
                  mousebutton_5_was_down  =>  kab::mousebutton_5_is_set  state
                };

            fun do_mousebutton         ((xt::MOUSEBUTTON int):          xt::Mousebutton)
                =
                evt::MOUSEBUTTON int;

            fun do_timestamp (ts::XSERVER_TIMESTAMP unt)
                =
                evt::t::XSERVER_TIMESTAMP unt;

            fun do_timestamp' (timestamp: xt::Timestamp)
                =
                case timestamp
                    #
                    xt::CURRENT_TIME    => evt::CURRENT_TIME;
                    xt::TIMESTAMP t     => evt::TIMESTAMP (do_timestamp t);
                esac;

            fun do_null_or (null_or_val, do_val_fn)
                =
                case null_or_val
                    #
                    NULL    =>  NULL;
                    THE val =>  THE (do_val_fn val);
                esac;

            fun do_focus_mode (focus: xt::Focus_Mode)
                =       
                case focus
                    #
                    xt::FOCUS_NORMAL            =>  evt::FOCUS_NORMAL           ;
                    xt::FOCUS_WHILE_GRABBED     =>  evt::FOCUS_WHILE_GRABBED    ;
                    xt::FOCUS_GRAB              =>  evt::FOCUS_GRAB             ;
                    xt::FOCUS_UNGRAB            =>  evt::FOCUS_UNGRAB           ;
                esac;

            fun do_focus_detail (detail: xt::Focus_Detail)
                =       
                case detail
                    #
                    xt::FOCUS_ANCESTOR          =>  evt::FOCUS_ANCESTOR         ;
                    xt::FOCUS_VIRTUAL           =>  evt::FOCUS_VIRTUAL          ;
                    xt::FOCUS_INFERIOR          =>  evt::FOCUS_INFERIOR         ;
                    xt::FOCUS_NONLINEAR         =>  evt::FOCUS_NONLINEAR                ;
                    xt::FOCUS_NONLINEAR_VIRTUAL =>  evt::FOCUS_NONLINEAR_VIRTUAL        ;
                    xt::FOCUS_POINTER           =>  evt::FOCUS_POINTER          ;
                    xt::FOCUS_POINTER_ROOT      =>  evt::FOCUS_POINTER_ROOT     ;
                    xt::FOCUS_NONE              =>  evt::FOCUS_NONE             ;
                esac;

            fun do_visibility (visibility: xt::Visibility)
                =
                case visibility
                    #
                    xt::VISIBILITY_UNOBSCURED           =>  evt::VISIBILITY_UNOBSCURED          ;
                    xt::VISIBILITY_PARTIALLY_OBSCURED   =>  evt::VISIBILITY_PARTIALLY_OBSCURED  ;
                    xt::VISIBILITY_FULLY_OBSCURED       =>  evt::VISIBILITY_FULLY_OBSCURED      ;
                esac;

            fun do_stack_mode (stack_mode: xt::Stack_Mode)
                =
                case stack_mode
                    #
                    xt::ABOVE           =>  evt::ABOVE          ;
                    xt::BELOW           =>  evt::BELOW          ;
                    xt::TOP_IF          =>  evt::TOP_IF         ;
                    xt::BOTTOM_IF       =>  evt::BOTTOM_IF      ;
                    xt::OPPOSITE        =>  evt::OPPOSITE       ;
                esac;

            fun do_stack_pos (stack_pos:  xt::Stack_Pos)
                =
                case stack_pos
                    #
                    xt::PLACE_ON_TOP    =>  evt::PLACE_ON_TOP   ;
                    xt::PLACE_ON_BOTTOM =>  evt::PLACE_ON_BOTTOM;
                esac;

            fun do_atom ((xt::XATOM unt): xt::Atom)
                =
                evt::XATOM unt;

            fun do_raw_format (raw_format: xt::Raw_Format)
                =
                case raw_format
                    #
                    xt::RAW08   =>  evt::RAW08  ;
                    xt::RAW16   =>  evt::RAW16  ;
                    xt::RAW32   =>  evt::RAW32  ;
                esac;
                    

            fun do_raw_data
                  (
                    xt::RAW_DATA 
                      { format:  xt::Raw_Format,
                        data:    vector_of_one_byte_unts::Vector
                      }
                  )
                =
                  evt::RAW_DATA
                    { format    => do_raw_format format,
                      data
                    };


            fun do_key_xevtinfo                                                                                         # KeyPress and KeyRelease 
                  (
                    i:                  xet::Key_Xevtinfo,
                    key_mapping:        k2k::Key_Mapping
                  )
              =
              { 
                keysym' =  k2k::translate_keycode_to_keysym key_mapping (i.keycode, i.modifier_keys_state);
                keysym  =  do_keysym  keysym';

                ascii   =  k2a::translate_keysym_to_ascii
                                k2a::default_keysym_to_ascii_mapping
                                (keysym',  i.modifier_keys_state);

                  {
                    root_window_id      =>  do_window_id                i.root_window_id,                               # Root of the source window.
                    event_window_id     =>  do_window_id                i.event_window_id,                              # Window in which this was generated.
                    child_window_id     =>  do_null_or                 (i.child_window_id, do_window_id),               # The child of the event window that is the ancestor of the source window.
                    #
                    same_screen         =>                              i.same_screen,
                    root_point          =>                              i.root_point,
                    event_point         =>                              i.event_point,
                    #
                    keycode             =>  do_keycode                  i.keycode,
                    keysym,
                    ascii,
                    #
                    modifier_keys_state =>  do_modifier_keys_state      i.modifier_keys_state,
                    mousebuttons_state  =>  do_mousebuttons_state       i.mousebuttons_state,
                    timestamp           =>  do_timestamp                i.timestamp
                  };
              };

            fun do_button_xevtinfo (i: xet::Button_Xevtinfo)                                                            # ButtonPress and ButtonRelease.
             =
             {
                root_window_id          =>  do_window_id                i.root_window_id,                               # Root of the source window.
                event_window_id         =>  do_window_id                i.event_window_id,                              # Window in which this was generated.
                child_window_id         =>  do_null_or                 (i.child_window_id, do_window_id),               # The child of the event window that is the ancestor of the source window.
                #
                same_screen             =>                              i.same_screen,
                root_point              =>                              i.root_point,
                event_point             =>                              i.event_point,
                #
                mouse_button            =>  do_mousebutton              i.mouse_button,                                 # The button that was pressed.
                #
                modifier_keys_state     =>  do_modifier_keys_state      i.modifier_keys_state,
                mousebuttons_state      =>  do_mousebuttons_state       i.mousebuttons_state,
                timestamp               =>  do_timestamp                i.timestamp
             };

            fun do_motion_notify (i: xet::Motion_Xevtinfo)                                                              # MotionNotify
             =
             {
                root_window_id          =>  do_window_id                i.root_window_id,                               # Root of the source window.
                event_window_id         =>  do_window_id                i.event_window_id,                              # Window in which this was generated.
                child_window_id         =>  do_null_or                 (i.child_window_id, do_window_id),               # The child of the event window that is the ancestor of the source window.
                #
                same_screen             =>                              i.same_screen,
                root_point              =>                              i.root_point,
                event_point             =>                              i.event_point,
                #
                hint                    =>                              i.hint,                                         # TRUE if PointerMotionHint is selected.
                #
                modifier_keys_state     =>  do_modifier_keys_state      i.modifier_keys_state,
                mousebuttons_state      =>  do_mousebuttons_state       i.mousebuttons_state,
                timestamp               =>  do_timestamp                i.timestamp
             };

            fun do_inout_xevtinfo (i: xet::Inout_Xevtinfo)                                                              #  EnterNotify and LeaveNotify 
               =
               {
                root_window_id          =>  do_window_id                i.root_window_id,                               # Root of the source window.
                event_window_id         =>  do_window_id                i.event_window_id,                              # Window in which this was generated.
                child_window_id         =>  do_null_or                 (i.child_window_id, do_window_id),               # The child of the event window that is the ancestor of the source window.
                #
                same_screen             =>                              i.same_screen,
                root_point              =>                              i.root_point,
                event_point             =>                              i.event_point,
                #
                mode                    =>  do_focus_mode               i.mode,                                         # 
                detail                  =>  do_focus_detail             i.detail,                                       #  
                #
                modifier_keys_state     =>  do_modifier_keys_state      i.modifier_keys_state,
                mousebuttons_state      =>  do_mousebuttons_state       i.mousebuttons_state,
                focus                   =>                              i.focus,                                        # TRUE, if event is the focus 
                timestamp               =>  do_timestamp                i.timestamp
               };

            fun do_focus_xevtinfo (i: xet::Focus_Xevtinfo)                                                              # FocusIn and FocusOut 
               =
               { event_window_id        =>  do_window_id                i.event_window_id,                              # The window that gained the focus 
                 mode                   =>  do_focus_mode               i.mode,
                 detail                 =>  do_focus_detail             i.detail
               };

            fun do_expose
                  { exposed_window_id:  xt::Window_Id,                          # The exposed window. 
                    boxes:              List( g2d::Box ),                       # The exposed rectangle.  The list is so that multiple events can be packed.
                    count:              Int                                     # Number of subsequent expose events.
                  }
                =
                  { exposed_window_id   =>  do_window_id  exposed_window_id,    # The exposed window. 
                    boxes,                                                      # The exposed rectangle.  The list is so that multiple events can be packed.
                    count                                                       # Number of subsequent expose events.
                  };

            fun do_graphics_expose
                  { drawable:      xt::Drawable_Id,
                    box:           g2d::Box,                                    # The obscured rectangle. 
                    count:         Int,                                         # The number of additional GraphicsExpose events.
                    major_opcode:  Unt,                                         # The graphics operation code.
                    minor_opcode:  Unt                                          # Always 0 for core protocol.
                  }
                =
                  { drawable            =>  do_drawable_id  drawable,
                    box,                                                        # The obscured rectangle. 
                    count,                                                      # The number of additional GraphicsExpose events.
                    major_opcode,                                               # The graphics operation code.
                    minor_opcode                                                # Always 0 for core protocol.
                  };

            fun do_no_expose
                  { drawable:                   xt::Drawable_Id,
                    major_opcode:               Unt,                            # The graphics operation code.
                    minor_opcode:               Unt                             # Always 0 for core protocol.
                  }
                =
                  { drawable            =>  do_drawable_id  drawable,
                    major_opcode,                                               # The graphics operation code.
                    minor_opcode                                                # Always 0 for core protocol.
                  };

            fun do_visibility_notify
                  { changed_window_id:  xt::Window_Id,                          # The window with changed visibility state.
                    state:              xt::Visibility                          # The new visibility state.
                  }
                =
                  { changed_window_id   => do_window_id  changed_window_id,     # The window with changed visibility state.
                    state               => do_visibility state                  # The new visibility state.
                  };

            fun do_create_notify
                  { parent_window_id:   xt::Window_Id,                          # The created window's parent.
                    created_window_id:  xt::Window_Id,                          # The created window.
                    box:                g2d::Box,                               # The window's rectangle.
                    border_wid:         Int,                                    # The width of the border.
                    override_redirect:  Bool                                    #  
                  }
                =
                  { parent_window_id    => do_window_id  parent_window_id,      # The created window's parent.
                    created_window_id   => do_window_id  created_window_id,     # The created window.
                    box,                                                        # The window's rectangle.
                    border_wid,                                                 # The width of the border.
                    override_redirect                                           #  
                  };

            fun do_destroy_notify
                  { event_window_id:            xt::Window_Id,                  # The window on which this was generated.
                    destroyed_window_id:        xt::Window_Id                   # The destroyed window.
                  }
                =
                  { event_window_id     => do_window_id  event_window_id,       # The window on which this was generated.
                    destroyed_window_id => do_window_id  destroyed_window_id    # The destroyed window.
                  };

            fun do_unmap_notify
                  { event_window_id:            xt::Window_Id,                  # The window on which this was generated.
                    unmapped_window_id:         xt::Window_Id,                  # The window being unmapped.
                    from_config:                Bool                            # TRUE if parent was resized.
                  }
                =
                  { event_window_id     => do_window_id  event_window_id,       # The window on which this was generated.
                    unmapped_window_id  => do_window_id  unmapped_window_id,    # The window being unmapped.
                    from_config                                                 # TRUE if parent was resized.
                  };

            fun do_map_notify
                  { event_window_id:            xt::Window_Id,                  # The window on which this was generated.
                    mapped_window_id:           xt::Window_Id,                  # The window being mapped.
                    override_redirect:          Bool                            #  
                  }
                =
                  { event_window_id     => do_window_id  event_window_id,       # The window on which this was generated.
                    mapped_window_id    => do_window_id  mapped_window_id,      # The window being mapped.
                    override_redirect                                           #  
                  };

            fun do_map_request
                  { parent_window_id:           xt::Window_Id,                  # The parent.
                    mapped_window_id:           xt::Window_Id                   # The mapped window.
                  }
                =
                  { parent_window_id    => do_window_id  parent_window_id,      # The parent.
                    mapped_window_id    => do_window_id  mapped_window_id       # The mapped window.
                  };

            fun do_reparent_notify
                  { event_window_id:            xt::Window_Id,                  # The window on which this was generated.
                    parent_window_id:           xt::Window_Id,                  # The new parent.
                    rerooted_window_id:         xt::Window_Id,                  # The re-rooted window.
                    upperleft_corner:           g2d::Point,                     # The upper-left corner.
                    override_redirect:          Bool                            #  
                  }
                =
                  { event_window_id     => do_window_id  event_window_id,       # The window on which this was generated.
                    parent_window_id    => do_window_id  parent_window_id,      # The new parent.
                    rerooted_window_id  => do_window_id  rerooted_window_id,    # The re-rooted window.
                    upperleft_corner,                                           # The upper-left corner.
                    override_redirect                                           #  
                  };

            fun do_configure_notify
                  { event_window_id:            xt::Window_Id,                  # The window on which this was generated.
                    configured_window_id:       xt::Window_Id,                  # The reconfigured window.
                    sibling_window_id:  Null_Or(xt::Window_Id),                 # The sibling that window is above (if any).
                    box:                        g2d::Box,                       # The window's rectangle.
                    border_wid:                 Int,                            # The width of the border.
                    override_redirect:          Bool                            #  
                  }
                =
                  { event_window_id      => do_window_id  event_window_id,                      # The window on which this was generated.
                    configured_window_id => do_window_id  configured_window_id,                 # The reconfigured window.
                    sibling_window_id    => do_null_or (sibling_window_id, do_window_id),       # The sibling that window is above (if any).
                    box,                                                                        # The window's rectangle.
                    border_wid,                                                                 # The width of the border.
                    override_redirect                                                           #  
                  };

            fun do_configure_request
                  { parent_window_id:           xt::Window_Id,                  # The parent.
                    configure_window_id:        xt::Window_Id,                  # The window to reconfigure.
                    sibling_window_id:  Null_Or(xt::Window_Id),                 # The new sibling (if any).
                    x:                          Null_Or(Int),                   # The window's rectangle.
                    y:                          Null_Or(Int),
                    wide:                       Null_Or(Int),
                    high:                       Null_Or(Int),
                    border_wid:                 Null_Or(Int),                   # The width of the border.
                    stack_mode:  Null_Or(xt::Stack_Mode)                        # The mode for stacking windows.
                  }
                =
                  { parent_window_id    => do_window_id  parent_window_id,                      # The parent.
                    configure_window_id => do_window_id  configure_window_id,                   # The window to reconfigure.
                    sibling_window_id   => do_null_or (sibling_window_id, do_window_id),        # The new sibling (if any).
                    x,                                                                          # The window's rectangle.
                    y,
                    wide,
                    high,
                    border_wid,                                                                 # The width of the border.
                    stack_mode          => do_null_or (stack_mode, do_stack_mode)               # The mode for stacking windows.
                  };

            fun do_gravity_notify
                  {
                    event_window_id:            xt::Window_Id,                  # The window on which this was generated.
                    moved_window_id:            xt::Window_Id,                  # The window being moved.
                    upperleft_corner:           g2d::Point                      # Upper-left corner of window.
                  }             
                =
                  {
                    event_window_id     => do_window_id  event_window_id,       # The window on which this was generated.
                    moved_window_id     => do_window_id  moved_window_id,       # The window being moved.
                    upperleft_corner                                            # Upper-left corner of window.
                  };

            fun do_resize_request
                  {
                    resize_window_id:           xt::Window_Id,                  # The window to resize.
                    req_size:                   g2d::Size                       # The requested new size.
                  }
                =
                  {
                    resize_window_id    => do_window_id  resize_window_id,      # The window to resize.
                    req_size                                                    # The requested new size.
                  };

            fun do_circulate_notify
                  {
                    event_window_id:            xt::Window_Id,                  # The window on which this was generated.
                    circulated_window_id:       xt::Window_Id,                  # The window being circulated.
                    parent_window_id:           xt::Window_Id,                  # The parent.
                    place:                      xt::Stack_Pos                   # The new place.
                  }
                =
                  {
                    event_window_id      => do_window_id  event_window_id,      # The window on which this was generated.
                    circulated_window_id => do_window_id  circulated_window_id, # The window being circulated.
                    parent_window_id     => do_window_id  parent_window_id,     # The parent.
                    place                => do_stack_pos  place                 # The new place.
                  };

            fun do_circulate_request
                  {
                    parent_window_id:           xt::Window_Id,                  # The parent.
                    circulate_window_id:        xt::Window_Id,                  # The window to circulate.
                    place:                      xt::Stack_Pos                   # The place to circulate the window to.
                  }
                =
                  {
                    parent_window_id    => do_window_id  parent_window_id,      # The parent.
                    circulate_window_id => do_window_id  circulate_window_id,   # The window to circulate.
                    place               => do_stack_pos  place                  # The place to circulate the window to.
                  };

            fun do_property_notify
                  {
                    changed_window_id:          xt::Window_Id,                  # The window with the changed property.
                    atom:                       xt::Atom,                       # The affected property.
                    timestamp:                  ts::Xserver_Timestamp,          # When the property was changed.
                    deleted:                    Bool                            # TRUE if the property was deleted.
                  }
                =
                  {
                    changed_window_id   => do_window_id  changed_window_id,     # The window with the changed property.
                    atom                => do_atom       atom,                  # The affected property.
                    timestamp           => do_timestamp  timestamp,             # When the property was changed.
                    deleted                                                     # TRUE if the property was deleted.
                  };

            fun do_selection_clear
                  {
                    owning_window_id:           xt::Window_Id,                  # The current owner of the selection.
                    selection:                  xt::Atom,                       # The selection.
                    timestamp:                  ts::Xserver_Timestamp           # The last-change time.
                  }             
                =
                  {
                    owning_window_id    => do_window_id  owning_window_id,      # The current owner of the selection.
                    selection           => do_atom       selection,             # The selection.
                    timestamp           => do_timestamp  timestamp              # The last-change time.
                  };

            fun do_selection_request
                  {
                    owning_window_id:           xt::Window_Id,                  # The owner of the selection.
                    selection:                  xt::Atom,                       # The selection.
                    target:                     xt::Atom,                       # The requested type for the selection.
                    requesting_window_id:       xt::Window_Id,                  # The requesting window.
                    property:                   Null_Or( xt::Atom ),            # The property to store the selection in. 
                    timestamp:                  xt::Timestamp                   #  
                  }
                =
                  {
                    owning_window_id    => do_window_id  owning_window_id,      # The owner of the selection.
                    selection           => do_atom       selection,             # The selection.
                    target              => do_atom       target,                # The requested type for the selection.
                    requesting_window_id=> do_window_id  requesting_window_id,  # The requesting window.
                    property            => do_null_or   (property, do_atom),    # The property to store the selection in. 
                    timestamp           => do_timestamp' timestamp              #  
                  };

            fun do_selection_notify
                  {
                    requesting_window_id:       xt::Window_Id,                  # The requestor of the selection.
                    selection:                  xt::Atom,                       # The selection.
                    target:                     xt::Atom,                       # The requested type of the selection.
                    property:                   Null_Or( xt::Atom ),            # The property to store the selection in.
                    timestamp:                  xt::Timestamp                   #  
                  }
                =
                  {
                    requesting_window_id => do_window_id  requesting_window_id, # The requestor of the selection.
                    selection            => do_atom       selection,            # The selection.
                    target               => do_atom       target,               # The requested type of the selection.
                    property             => do_null_or   (property, do_atom),   # The property to store the selection in.
                    timestamp            => do_timestamp' timestamp             #  
                  };

            fun do_colormap_notify
                  {
                    window_id:                  xt::Window_Id,                  # The affected window.
                    cmap:                       Null_Or( xt::Colormap_Id ),     # The colormap.
                    new:                        Bool,                           # TRUE, if the colormap attribute is changed.
                    installed:                  Bool                            # TRUE, if the colormap is installed.
                  }
                =
                  {
                    window_id           => do_window_id  window_id,             # The affected window.
                    cmap                => do_null_or (cmap, do_colormap_id),   # The colormap.
                    new,                                                        # TRUE, if the colormap attribute is changed.
                    installed                                                   # TRUE, if the colormap is installed.
                  };

            fun do_client_message
                  {
                    window_id:                  xt::Window_Id,                  #  
                    type:                       xt::Atom,                       # The type of the message.
                    value:                      xt::Raw_Data                    # The message value.
                  }
                =
                  {
                    window_id           => do_window_id  window_id,             #  
                    type                => do_atom       type,                  # The type of the message.
                    value               => do_raw_data   value                  # The message value.
                  };

            fun do_keyboard_mapping_notify
                  {
                    first_keycode:  xt::Keycode,
                    count:          Int
                  }
                =
                  {
                    first_keycode       => do_keycode  first_keycode,
                    count
                  };

        herein

            fun xevent_to_gui_event
                  (
                    xevent:             xet::x::Event,
                    key_mapping:        k2k::Key_Mapping
                  )
                =
                case xevent
                    #
                    xet::x::KEY_PRESS               x =>  evt::x::KEY_PRESS               (do_key_xevtinfo     (x,  key_mapping));
                    xet::x::KEY_RELEASE             x =>  evt::x::KEY_RELEASE             (do_key_xevtinfo     (x,  key_mapping));
                    #
                    xet::x::BUTTON_PRESS            x =>  evt::x::BUTTON_PRESS            (do_button_xevtinfo   x);
                    xet::x::BUTTON_RELEASE          x =>  evt::x::BUTTON_RELEASE          (do_button_xevtinfo   x);
                    #
                    xet::x::MOTION_NOTIFY           x =>  evt::x::MOTION_NOTIFY           (do_motion_notify     x);
                    #
                    xet::x::ENTER_NOTIFY            x =>  evt::x::ENTER_NOTIFY            (do_inout_xevtinfo    x);
                    xet::x::LEAVE_NOTIFY            x =>  evt::x::LEAVE_NOTIFY            (do_inout_xevtinfo    x);
                    #
                    xet::x::FOCUS_IN                x =>  evt::x::FOCUS_IN                (do_focus_xevtinfo    x);
                    xet::x::FOCUS_OUT               x =>  evt::x::FOCUS_OUT               (do_focus_xevtinfo    x);
                    #
                    xet::x::KEYMAP_NOTIFY           x =>  evt::x::KEYMAP_NOTIFY           x ;
                    #
                    xet::x::EXPOSE                  x =>  evt::x::EXPOSE                  (do_expose            x);
                    xet::x::GRAPHICS_EXPOSE         x =>  evt::x::GRAPHICS_EXPOSE         (do_graphics_expose   x);
                    xet::x::NO_EXPOSE               x =>  evt::x::NO_EXPOSE               (do_no_expose         x);
                    xet::x::VISIBILITY_NOTIFY       x =>  evt::x::VISIBILITY_NOTIFY       (do_visibility_notify x);
                    #
                    xet::x::CREATE_NOTIFY           x =>  evt::x::CREATE_NOTIFY           (do_create_notify     x);
                    xet::x::DESTROY_NOTIFY          x =>  evt::x::DESTROY_NOTIFY          (do_destroy_notify    x);
                    #
                    xet::x::UNMAP_NOTIFY            x =>  evt::x::UNMAP_NOTIFY            (do_unmap_notify      x);
                    xet::x::MAP_NOTIFY              x =>  evt::x::MAP_NOTIFY              (do_map_notify        x);
                    #
                    xet::x::MAP_REQUEST             x =>  evt::x::MAP_REQUEST             (do_map_request       x);
                    xet::x::REPARENT_NOTIFY         x =>  evt::x::REPARENT_NOTIFY         (do_reparent_notify   x);
                    #
                    xet::x::CONFIGURE_NOTIFY        x =>  evt::x::CONFIGURE_NOTIFY        (do_configure_notify  x);
                    xet::x::CONFIGURE_REQUEST       x =>  evt::x::CONFIGURE_REQUEST       (do_configure_request x);
                    #
                    xet::x::GRAVITY_NOTIFY          x =>  evt::x::GRAVITY_NOTIFY          (do_gravity_notify    x);
                    xet::x::RESIZE_REQUEST          x =>  evt::x::RESIZE_REQUEST          (do_resize_request    x);
                    #
                    xet::x::CIRCULATE_NOTIFY        x =>  evt::x::CIRCULATE_NOTIFY        (do_circulate_notify  x);
                    xet::x::CIRCULATE_REQUEST       x =>  evt::x::CIRCULATE_REQUEST       (do_circulate_request x);
                    #
                    xet::x::PROPERTY_NOTIFY         x =>  evt::x::PROPERTY_NOTIFY         (do_property_notify   x);
                    #
                    xet::x::SELECTION_CLEAR         x =>  evt::x::SELECTION_CLEAR         (do_selection_clear   x);
                    xet::x::SELECTION_REQUEST       x =>  evt::x::SELECTION_REQUEST       (do_selection_request x);
                    xet::x::SELECTION_NOTIFY        x =>  evt::x::SELECTION_NOTIFY        (do_selection_notify  x);
                    #
                    xet::x::COLORMAP_NOTIFY         x =>  evt::x::COLORMAP_NOTIFY         (do_colormap_notify   x);
                    xet::x::CLIENT_MESSAGE          x =>  evt::x::CLIENT_MESSAGE          (do_client_message    x);
                    xet::x::KEYBOARD_MAPPING_NOTIFY x =>  evt::x::KEYBOARD_MAPPING_NOTIFY (do_keyboard_mapping_notify x);
                    #
                    xet::x::MODIFIER_MAPPING_NOTIFY   =>  evt::x::MODIFIER_MAPPING_NOTIFY                         ;
                    xet::x::POINTER_MAPPING_NOTIFY    =>  evt::x::POINTER_MAPPING_NOTIFY                          ;
                esac;
        end;                                                    # stipulate
    };
end;





Comments and suggestions to: bugs@mythryl.org

PreviousUpNext