Charles.Forsyth20060303-partialeea662d19 years agoHistory
235 lines · 5.6 KB · Text
RawDownload
.TH WMCLIENT 2.SH NAMEwmclient: makedrawcontext, window, snarfput, snarfget \-window manager interface for Draw-based applications..SH SYNOPSIS.EXinclude "tk.m";include "wmclient.m";wmclient := load Wmclient Wmclient->PATH; Resize,Hide,Help,OK,Plain:     con 1 << iota; Appl:   con Resize | Hide; init:       fn();makedrawcontext: fn():  ref Draw->Context;window:	fn(ctxt: ref Draw->Context, title: string, buts: int): ref Window;snarfput:   fn(buf: string);snarfget:   fn(): string;Window: adt{	display:	ref Draw->Display;	r: Draw->Rect;		# full rectangle of window, including titlebar.	image: ref Draw->Image;	screenr: Draw->Rect;	ctxt: ref Draw->Wmcontext;	focused:	int;	ctl:		chan of string; 	startinput:	fn(w: self ref Window, devs: list of string);	wmctl:	fn(w: self ref Window, request: string): string;	settitle:	fn(w: self ref Window, name: string): string;	reshape:	fn(w: self ref Window, r: Draw->Rect);	onscreen:	fn(w: self ref Window, how: string);	screenr2imager:	fn(w: self ref Window, sr: Draw->Rect): Draw->Rect;	imager2screenr:	fn(w: self ref Window, ir: Draw->Rect): Draw->Rect;	pointer:	fn(w: self ref Window, p: Draw->Pointer): int;}; .EE.SH DESCRIPTIONThe.B Wmclientmodule provides routines for making windows controlled by.IR wm (1)containing an image that can be drawn on with theroutines described in.IR draw-image (2)..PP.B Initshould be called once to initialise the internal state of.BR wmclient ..PP.B Makedrawcontextestablishes an initial connection with the window manager,creating a new.B Drawcontext suitable for creating new windows. It is onlynecessary to call this if the application has not alreadybeen provided with a context..PP.B Windowcreates a new window through.IR ctxtand returns it..I Titlegives a label that will be displayed in the title barof the window;.I butsdetermines which buttons are created in the titlebar,a bitwise combination of the constants.BR Resize ,.BR Help ,.BR OK,and.BR Hide .If.B Plainis given, the window is given no decoration at all..PPWhen a window, say.IR w ,is first created, its size has not been determinedand its image is not yet allocated..IB W .reshapesets the requested rectangle for the window,(and requests a new image for the windowif it has already been made visible),where.I rgives the requested rectangle of the newimage, excluding window decoration, such as thetitle bar and the window border.An application can use.IB w .screenr2imagerto find out the usable rectangle within screenrectangle.I srwhen window decorations are taken into account..IB W .imager2screenrconverts in the other direction..IB W .screenrcontains the current rectangle of the screen containingthe window..PP.IB W .imageholds the window's image when it has been successfully created;.IB w .ctxtholds the window manager context for the window, from whichkeyboard and mouse events can be received.No such events will be received until.IB w .startinputis called, with a list of devices (e.g..BR ptr ,.BR kbd )to start input for..IB W .settitlesets the title that is shown on the window's title bar;it can make the window's size (and therefore the window's image)change..PP.IB W .ctlis a channel down which requests from the titlebar are sent.Messages received on it should be processed bythe application or passed to.IB w \.wmctl\fR.Requests are formattedas with.B quotedin.IR string (2).The messages include:.TP.B exitThe window should be closed..IB W .wmctlwill kill all processes in the currentprocess group..TP.B !move \fIx\fP \fIy\fPThe user has started to try to drag the window..I Xand.I ygive the location of the initial pointer click..TP.B !size \fImindx\fP \fImindy\fPThe user wishes to resize the window..I Mindxand.I mindygive the minimum size acceptable for the window..TP.B helpThe help button has been clicked..TP.B okThe OK  button has been clicked..TP.B hideThe Hide button has been clicked..IB W .wmctlwill delete the window, and an entrywill be shown on the toolbar..PPIn order to function correctly, an applicationshould process not only events from thetitle bar channel, but also events received from the windowmanager itself (via.IB w .ctxt.ctl\fR),\fPand pointer and keyboard events received fromthe window manager (via.IB top .ctxt.ptrand.IB top .ctxt.kbdrespectively).Control events can be passed to.IB w .wmctl \fR;keyboard events can be processed by the application;pointer events should be passed to.IB w .pointerfor processing; if this returns zero, theapplication should process the pointer event,otherwise the event has been consumed by thetitlebar..PPWhen created, the window is not visible;.IB w .onscreenmakes it visible, and possibly chooses aposition and a size for it..I Howspecifies what sort of placement is requiredfor the window; it can be one of.TP.B placetries to choose a suitable place on the screenwith respect to other windows; it may size thewindow as it feels appropriate. This the default(if.I howis nil)..TP.B onscreentries to keep the position and size the sameas specified on the window, adjusting them onlyto bring the window fully on screen, and making surethat the window is no bigger than the entire display..TP.B exactdoes not change the specified size or positionof the window unless absolutely necessary..PP.B Snarfgetand.B snarfputretrieve and replace the contents of the windowmanager's snarf buffer..SH FILES.TF /chan/snarf.TP.B /chan/snarfsnarf buffer maintained by.IR wm (1).TP.B /chan/wmchannel for interaction with.IR wm (1).SH SOURCE.B /appl/lib/wmclient.b.SH SEE ALSO.IR wm (1),.IR tk (2)