GLOBALS(3R)

NAME
globals: physical, display, Drect, Jrect, PtCurrent, P, mouse - globals describing display and mouse

SYNOPSIS
#include <dmd.h>

Bitmap physical;

Bitmap display;

Rectangle Drect;

Rectangle Jrect;

Point PtCurrent;

#define XMAX 1024
#define YMAX 1024

#define INSET 4

struct Mouse {
    Point xy;
    Point jxy;
    short buttons;
} mouse;

Proc *P;

DESCRIPTION
Each global is defined when dmd.h is included. One should not include these definitions in their source code.

The global physical is a Bitmap describing the entire screen display in screen coordinates.

The global display is the Bitmap describing an individual window in screen coordinates.

The global Drect is a Rectangle defining, in screen coordinates, the display area available to the program. It is not display.rect, which includes the border around each window.

The global Jrect is the Rectangle { 0, 0, XMAX, YMAX }

The global PtCurrent is the current Point in window coordinates which the j-routines reference and update.

The values XMAX and YMAX define the maximum x and y coordinates of the 630 MTG screen. These are the same as physical.rect.corner.x and physical.rect.corner.y.

The value INSET is the width of the border around a window. Therefore, Drect is the same as inset(display.rect,INSET).

The global mouse is a location containing the current mouse coordinates and button states. The Point xy is in screen coordinates; jxy is in window coordinates. The buttons field is a bit vector of the mouse buttons that is most easily interpreted by using the button macros. The mouse is updated only when requested and the window is current.

P is a special variable used by the 630 MTG. It represents the running process. A process can be a downloaded application or the default terminal emulator or an internal maintenance process. An example is the ``control'' process that puts up the button 3 global menu.

The 630 MTG changes the value of P whenever one process switches out through ``wait'' or ``sleep'' to let another run. It always points to the running process's table (Proc). Many routines either update P or use P to find information specific to the process. For example, the memory allocator ``alloc'' uses P to record who owns the memory requested. The ``allocown'' routine can be used to change this.

SEE ALSO
alloc(3R), btoc(3R), buttons(3R/3L), inset(3R), resources(3R), sleep(3R), structures(3R), transform(3R/3L).

WARNING
These globals (except XMAX, YMAX, and INSET) reside in the terminal. They cannot be used in automatic initializations of a program's global variables.