english
version "1.0"
identify "%Z%%M% %I% %E%"

#: Copyright (c) 1995 by Wayne C. Gramlich.
#, All rights reserved.
#,
#, Permission to use, copy, modify, distribute, and sell this software
#, for any purpose is hereby granted without fee provided that the above
#, copyright notice and this permission are retained.  The author makes
#, no representations about the suitability of this software for any purpose.
#, It is provided "as is" without express or implied warranty.

module x_key_event_generate

#: This module tests the {c_import} module.

import
    c_import
    character
    format
    in_stream
    logical
    out_stream
    string
    system
    vector
    unsigned

procedure main
    takes
	system system
    returns unsigned

    #: This procedure will test out the c_import code.

    c_stream :@= system.standard_out_stream
    stipple_stream :@= c_stream

    c_import :@= create@c_import("x_key_event")
    import_standard@(c_import)

    type_integer :@= c_import.type_integer
    type_unsigned :@= c_import.type_unsigned
    type_logical :@= c_import.type_logical

    include_append@(c_import, "X11/Xlib.h")
    include_append@(c_import, "X11/Xutil.h")
    import_append@(c_import, "x_display")

    c_record :@= record_create@(c_import, typedef_struct, "XKeyEvent",
      "x_key_event", "X11 Keyboard Event record", true, true, true)
    field_append@(c_record, "type", type_integer, "type",
      '#: Type of event', true, false)
    field_append@(c_record, "serial", type_integer, "",
      '#: Number of last request processed', true, false)
    field_append@(c_record, "send_event", type_logical, "",
      '#: {true} if this came from a {SendEvent} request', true, false)
    type_display :@= pointer_create@c_sub_type("Display", "x_display")
    field_append@(c_record, "display", type_display, "",
      '#: Display the evernt was read from', true, false)
    field_append@(c_record, "window", type_unsigned, "",
      '#: "event" window it is reported relative to', true, false)
    field_append@(c_record, "root", type_unsigned, "",
      '#: Root window that the event occured on', true, false)
    field_append@(c_record, "subwindow", type_unsigned, "",
      '#: Child window', true, false)
    field_append@(c_record, "time", type_unsigned, "",
      '#: Milliseconds', true, false)
    field_append@(c_record, "x", type_integer, "",
      '#: X coordinate', true, false)
    field_append@(c_record, "y", type_integer, "",
      '#: Y coordinate', true, false)
    field_append@(c_record, "x_root", type_integer, "",
      '#: X coordinate relative to root', true, false)
    field_append@(c_record, "y_root", type_integer, "",
      '#: Y coordinate relative to root', true, false)
    field_append@(c_record, "state", type_unsigned, "",
      '#: Key or button mask', true, false)
    field_append@(c_record, "keycode", type_integer, "",
      '#: Detail', true, false)
    field_append@(c_record, "same_screen", type_logical, "",
      '#: same screen flag', true, true)

    # Declare interface routines:
    comment :@= allocate@string()
    string_append@(comment,
      '    #: This procedure will lookup and return the keyboard character\n\')
    string_append@(comment,
      '    #, number associated with {event} and {index}.\n\')
    #procedure2_append@(c_import,
    #  "XLookupKeysym", "keyboard_symbol_lookup", "x_key_event",
    #  type_unsigned,
    # 'event', type_x_key_event, 'index', type_unsigned, comment)

    if process@(c_import, 'x_key_event_generate', system)
	return 1
    return 0
