Charles.Forsyth20060303-partialeea662d19 years agoHistory
167 lines · 4.0 KB · Text
RawDownload
.TH DRAW-CONTEXT 2.SH NAMEContext \-graphics environment.SH SYNOPSIS.EXinclude "draw.m";draw := load Draw Draw->PATH; Context: adt{   display: ref Display;      # frame buffer on which windows reside   wm:      chan of (string,               chan of (string, ref Wmcontext)); # wmgr connection}; # connection to window manager for one or more windows (as Images)Wmcontext: adt{   kbd:     chan of int;         # incoming characters from keyboard   ptr:     chan of ref Pointer; # incoming stream of mouse positions   ctl:     chan of string;      # commands from wm to application   wctl:    chan of string;      # commands from application to wm   images:  chan of ref Image;   # exchange of images   connfd:  ref Sys->FD;         # connection control   ctxt:    ref Draw->Context;};.EE.SH DESCRIPTIONThe.B Contexttype encapsulates the data types and channels used by an interactive application,and establishes a context for graphics output and window management.A reference to the.B Contextis passed as the first argument to an application when it begins execution:.PP.EXinclude "draw.m" Command: module{	init: fn(nil: ref Draw->Context; nil: list of string);};.EE.PPMost programs do not create.B Contextsbut instead inherit one from their parent, typically a shell or window system..PP.SS Context interface.PPThe following elements of.B Contextare used by.IR wm :.TF display.PD.TP.B displayThe.B Displayadt to which the application is connected; may be.BR nil .See.IR draw-display (2)..TP.B wmA shared channel through which a private channelcan be set up with a window manager.A client application sends a tuple containing a request string(of a format defined by the window manager) and a private reply channel.It receives a tuple in reply on that channel; the tuple containsa string (eg, an acknowledgement or diagnostic) and a reference toa.B Wmcontextvalue containing channels by which the application can interact with thewindow manager..SS Wmcontext interfaceThe.B Wmcontextprovides a set of channels and file descriptorsthrough which the window manager and application interact.The elements of the adt are used as follows:.PP.TF connfd.PD.TP.B kbdA channel of type.B intthat delivers keystrokes from a keyboard..TP.B ptrA channel of type.B ref.B Pointerthat delivers events from a pointing device such as a mouse.See.IR devpointer (2)..TP.B ctlA channel of type.B stringthat delivers control messages from thewindow manager to the application..TP.B wctlA channel of type.BR string ,which if initialised isused by the application to send control messages to the window manager.It is not used by the current.IR wm (1)or.IR tkclient (2)..TP.B imagesA channel of type.B ref.B Imagethat allows the window manager and application to exchange images(eg, when resizing, or to supply a cursor image)..TP.B connfdA file descriptor that can be used to provide per-client connection control.For instance, a client can store a file descriptor open on a.IR sys-file2chan (2)provided by the window manager, and the window manager will shut downinput to the application when the connection closes (eg, if the applicationexits unexpectedly)..B Connfdis also used to write requests to the window manager.Conventionally a request is a list of words formatted asby.B quotedin.IR string (2).A request starting with an exclamation mark.BR "" ( ! )if successful will result in an image being sent down the.B imagechannel; the rectangle of the image indicates the rectanglethat has been allocated on the screen. If only the originis to be changed by the window manager, a nil image issent first (giving the application a chance to suspend operationson the window), and then the original image, with its origin setappropriately..TP.B imageThis is used as described above..TP.B ctxtInitialised with the.B ctxtvalue that provided the initial connection on the.B wmchannel..RE.SH SEE ALSO.IR wm (1),.IR wmlib (2),.IR mux (1),.IR draw-intro (2),.IR ir (2),.IR prefab-intro (2),.IR tk (2)