WINDOW(3)
π WINDOW(3) π
Manual: Library Functions Manual. Page: WINDOW(3). It's giving window management, bestie β windows are literally Images here, and we're about to create, delete, and shuffle them. πͺβ¨
πΈ NAME πΈ
Screen, allocscreen, publicscreen, freescreen, allocwindow, bottomwindow, bottomnwindows, topwindow, topnwindows, originwindow β window management.
β¨ SYNOPSIS β¨
#include <u.h>
#include <libc.h>
#include <draw.h>
typedef
struct 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;
Screen* allocscreen(Image *image, Image *fill, int public)
Screen* publicscreen(Display *d, int id, ulong chan)
int freescreen(Screen *s)
Image* allocwindow(Screen *s, Rectangle r, int ref, int val)
void bottomwindow(Image *w)
void bottomnwindows(Image **wp, int nw)
void topwindow(Image *w)
void topnwindows(Image **wp, int nw)
int originwindow(Image *w, Point log, Point scr)
enum
{
/* refresh methods */
Refbackup= 0,
Refnone= 1,
Refmesg= 2
};
π DESCRIPTION π
Ok so windows are represented as Images. That means you can treat them like regular images for all drawing operations. The routines below are the special window-only stuff: creating, deleting, and shuffling windows. Those facilities do not apply to regular images. π«
To create windows, first you gotta allocate a Screen data structure to gather them together. A Screen turns an arbitrary image into something that may have windows upon it. It's created by allocscreen, which takes:
- an image upon which to place the windows (typically
display->image) πΌοΈ - a fill image to paint the background behind all the windows on the image π¨
- a flag specifying whether the result should be publicly visible π
If it is public, an arbitrary other program connected to the same display may acquire a pointer to the same screen by calling publicscreen with the Display pointer and the id of the published 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. freescreen releases a Screen, although it may not actually disappear from view until all the windows upon it have also been deallocated. π«
Unlike allocwindow, allocscreen does not initialize the appearance of the Screen. No cap.
Windows are created by allocwindow, which takes:
- a pointer to the
Screenupon which to create the window πͺ - a rectangle
rdefining its geometry π - an integer pixel value
valto color the window initially π¨ - a refresh method
refπ
The refresh methods are:
Refbackupβ provides backing store and is the method used byrio(1)for its clients. Literally iconic. πΎRefnoneβ provides no refresh and is designed for temporary uses such as sweeping a display rectangle, for windows that are completely covered by other windows, and for windows that are already protected by backing store. πRefmesgβ causes messages to be delivered to the owner of the window when it needs to be repainted. Heads up:Refmesgis not fully implemented. π¨
The result of allocwindow is an Image pointer that may be treated like any other image. In particular, it is freed by calling freeimage (see allocimage(3)). The following functions, however, apply only to windows, not regular images. π«Ά
bottomwindow pushes window w to the bottom of the stack of windows on its Screen, perhaps obscuring it. topwindow pulls window w to the top, making it fully visible on its Screen. (This Screen may itself be within a window that is not fully visible; topwindow will not affect the stacking of this parent window.) bottomnwindows and topnwindows are analogous, but push or pull a group of nw windows listed in the array wp. The order within wp is unaffected. π
Each window is created as an Image whose Rectangle r corresponds to the rectangle given to allocwindow when it was created. Thus, a newly created window w resides on its Screen->image at w->r and has internal coordinates w->r. Both these may be changed by a call to originwindow. The two Point arguments to originwindow define the upper left corner of the logical coordinate system (log) and screen position (scr). Their usage is shown in the Examples section. π§
Rio(1) creates its client windows with backing store, Refbackup. The graphics initialization routine, initdraw (see graphics(3)), builds a Screen upon this, and then allocates upon that another window indented to protect the border. That window is created Refnone, since the backing store created by rio protects its contents. That window is the one known in the library by the global name screen (a historic but confusing choice). π« β¨
π¦ EXAMPLES π¦
To move a window to the upper left corner of the display:
originwindow(w, w->r.min, Pt(0, 0));
To leave a window where it is on the screen but change its internal coordinate system so (0, 0) is the upper left corner of the window:
originwindow(w, Pt(0, 0), w->r.min);
After this is done, w->r is translated to the origin and there will be no way to discover the actual screen position of the window unless it is recorded separately. ππ
π SOURCE π
/src/libdraw β that's the source path, bestie. π
π SEE ALSO π
π BUGS π
The refresh method Refmesg should be finished. That's the bug note, fr fr. π
Sign-off vibes: WINDOW(3) Β· Library Functions Manual Β· source: /src/libdraw Β· date: not printed on this page, so it's giving timeless. π«Άππ
π¦ where this page comes from
- alpine 3.24: plan9port-doc 0_git20260208-r0 Β· LPL-1.02
- arch rolling: plan9port 20261021-2 Β· custom
- nixos 26.05: plan9port 0-unstable-2025-11-10
- nixos 26.05: plan9port-wayland 0-unstable-2025-11-26
- nixpkgs unstable: plan9port 0-unstable-2025-11-10
- nixpkgs unstable: plan9port-wayland 0-unstable-2025-11-26
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms