244 lines · 5.4 KB · Text
RawDownload
.TH WINDOW 2.SH NAMEScreen, allocscreen, publicscreen, freescreen, allocwindow, bottomwindow, bottomnwindows, topwindow, topnwindows, originwindow \- window management.SH SYNOPSIS.nf.B#include <u.h>.B#include <libc.h>.B#include <draw.h>.PP.ft L.nftypedefstruct Screen{	Display	*display;	/* display holding data */	int		id;		/* id of system-held Screen */	Image	*image;	/* unused; for reference only */	Image	*fill;	/* color to paint behind windows */} Screen;.fi.ta \w'\fLScreen* 'u.PP.BScreen*	allocscreen(Image *image, Image *fill, int public).PP.BScreen*	publicscreen(Display *d, int id, ulong chan).PP.Bint	freescreen(Screen *s).PP.BImage*	allocwindow(Screen *s, Rectangle r, int ref, int val).PP.Bvoid	bottomwindow(Image *w).PP.Bvoid	bottomnwindows(Image **wp, int nw).PP.Bvoid	topwindow(Image *w).PP.Bvoid	topnwindows(Image **wp, int nw).PP.Bint	originwindow(Image *w, Point log, Point scr).PP.ft L.nfenum{	/* refresh methods */	Refbackup	= 0,	Refnone		= 1,	Refmesg		= 2};.fi.ft P.SH DESCRIPTIONWindows are represented as.B Imagesand may be treated as regular images for all drawing operations.The routines discussed here permit the creation, deletion, and shufflingof windows, facilities that do not apply to regular images..PPTo create windows, it is first necessary to allocate a.B Screendata structure to gather them together.A.B Screenturns an arbitrary image into something that may have windows upon it.It is created by.BR allocscreen ,which takes an.I imageupon which to place the windows (typically.BR display->image ),a.I fillimage to paint the background behind all the windows on the image,and a flag specifying whether the result should be publicly visible.If it is public, an arbitrary other program connected to the samedisplay may acquire a pointer to the same screen by calling.B publicscreenwith the.B Displaypointer and the.I idof the published.BR Screen ,as well as the expected channel descriptor, as a safety check.It will usually require some out-of-band coordination for programs to share a screen profitably..B Freescreenreleases a.BR Screen ,although it may not actually disappear from view until all the windows upon it have also been deallocated..PPUnlike.BR allocwindow ,.B allocscreendoes.I notinitialize the appearance of the.BR Screen ..PPWindows are created by.BR allocwindow ,which takes a pointer to the.B Screenupon which to create the window, a rectangle.I rdefining its geometry, an integer pixel value.I valto color the window initially, and a refresh method.BR ref .The refresh methods are.BR Refbackup ,which provides backing store and is the method used by.IR rio (1)for its clients;.BR Refnone ,which provides no refresh and is designed for temporary usessuch as sweeping a display rectangle, for windows that arecompletely covered by other windows, and for windows thatare already protected by backing store; and.BR Refmesg ,which causes messages to be delivered to the owner of the windowwhen it needs to be repainted..B Refmesgis not fully implemented..PPThe result of.B allocwindowis an.B Imagepointer that may be treated like any other image.In particular, it is freed by calling.B freeimage(see.IR allocimage (2)).The following functions, however, apply only to windows, not regular images..PP.B Bottomwindowpushes window.I wto the bottom of the stack of windows on its.BR Screen ,perhaps obscuring it..B Topwindowpulls window.I wto the top, making it fully visible on its.BR Screen .(This.B Screenmay itself be within a window that is not fully visible;.B topwindowwill not affect the stacking of this parent window.).B Bottomnwindowsand.B Topnwindowsare analogous, but push or pull a group of.I nwwindows listed in the array.IR wp .The order within.IR wpis unaffected..PPEach window is created as an.B Imagewhose.B Rectangle.B rcorresponds to the rectangle given to.B allocwindowwhen it was created.  Thus, a newly created window.I wresides on its.B Screen->imageat.IB w ->rand has internal coordinates.IB w ->r .Both these may be changed by a call to.BR originwindow .The two.B Pointarguments to.B originwindowdefine the upper left corner of the logical coordinate system.RI ( log )and screen position.RI ( scr ).Their usage is shown in the Examples section..PP.IR Rio (1)creates its client windows with backing store,.BR Refbackup .The graphics initialization routine,.B initdraw(see.IR graphics (2)),builds a.B Screenupon this, and then allocates upon that another window indentedto protect the border.  That window is created.BR Refnone ,since the backing store created by.B rioprotects its contents.  That window is the one known in thelibrary by the global name.B screen(a historic but confusing choice)..SH EXAMPLESTo move a window to the upper left corner of the display,.EX	originwindow(w, w->r.min, Pt(0, 0));.EETo leave a window where it is on the screen but change its internalcoordinate system so (0,\ 0) is the upper left corner of the window,.EX	originwindow(w, Pt(0, 0), w->r.min);.EEAfter this is done,.B w->ris translated to the origin and there will be no way to discover theactual screen position of the window unless it is recorded separately..SH SOURCE.B /sys/src/libdraw.SH SEE ALSO.IR graphics (2),.IR draw (2),.IR cachechars (2),.IR draw (3).SH BUGSThe refresh method.B Refmesgshould be finished.