DRAW-CONTEXT(2)                                   DRAW-CONTEXT(2)

     NAME
          Context - graphics environment

     SYNOPSIS
          include "draw.m";
          draw := load Draw Draw->PATH;

          Context: adt
          {
              screen:  ref Screen;
              display: ref Display;
              cir:     chan of int;
              ckbd:    chan of int;
              cptr:    chan of ref Pointer;
              ctoappl: chan of int;
              ctomux:  chan of int;
          };

     DESCRIPTION
          The Context type encapsulates the data types and channels
          used by an interactive application.  A reference to the
          Context is passed as the first argument to an application
          when it begins execution:

          include "draw.m"

          Command: module
          {
               init: fn(nil: ref Draw->Context; nil: list of string);
          };

          Most programs do not create Contexts but instead inherit one
          from their parent, typically a shell or window system.

          The wm(1) and mux(1) environments use Context differently as
          regards keyboard and pointer (mouse) I/O.  Mux applications
          are given a set of channels in their Context structure.  Wm
          applications provide keyboard and mouse input encoded as Tk
          events on a channel named via Tk->namechan in tk(2), and the
          channels in the Context are unused, and nil.

        Common interface
          The following elements of Context are used by both wm and
          mux:

          screen   The Screen adt to which the application is con-
                   nected; may be nil.  See draw-screen(2).

          display  The Display adt to which the application is

     Page 1                       Plan 9            (printed 11/18/24)

     DRAW-CONTEXT(2)                                   DRAW-CONTEXT(2)

                   connected; may be nil.  See draw-display(2).

        Mux-specific interface
          As mentioned above, mux(1) primes an application's argument
          Context with channels through which mux and the application
          interact.  The channels are used as follows:

          cir      A channel of type int that delivers events from an
                   infrared remote control device, if one is present.
                   See the discussion below and ir(2) for more infor-
                   mation.

          ckbd     A channel of type int that delivers keystrokes from
                   a keyboard.

          cptr     A channel of type ref Pointer that delivers events
                   from a pointing device such as a mouse.  See
                   devpointer(2).

          ctoappl  A channel of type int that delivers control mes-
                   sages from the mux(1) application multiplexer.  One
                   message is defined:

                   MAtop  Requests an application to make its set of
                          windows fully visible.

          ctomux   A channel of type int used by the application to
                   send messages to mux(1) regarding the application's
                   use of system devices.  The defined messages are:

                   AMstartir   The application is ready to accept
                               ir(2) data on the cir channel.

                   AMstartkbd  The application is ready to accept key-
                               board data on the ckbd channel.

                   AMnewpin    The application needs a PIN.

                   AMstartptr  The application is ready to accept
                               Pointer data on the cptr channel.

                   AMexit      An application should send this message
                               before it exits, to allow mux to
                               recover resources.

     SEE ALSO
          wm(1), mux(1), draw-intro(2), ir(2), prefab-intro(2), tk(2)

     Page 2                       Plan 9            (printed 11/18/24)