 |
Index for Section 9 |
|
 |
Alphabetical listing for S |
|
 |
Bottom of page |
|
set_cursor_position(9r)
NAME
set_cursor_position - Graphics: Moves the cursor hotspot to a location on
the screen
SYNOPSIS
int (*ws_cursor_functions->set_cursor_position)(
caddr_t cursor_handle,
ws_screen_descriptor *screen,
int x, y );
ARGUMENTS
cursor_handle
Specifies the virtual address (handle) of device-specific information.
Typically this is a pointer to a private data structure that may
contain information such as the address of the hardware, state
information, and other information that may be shared between drivers.
The Workstation Subsystem allows separate handles for the cursor,
colormap, and the screen functions.
screen
Specifies a pointer to the ws_screen_descriptor structure, which
describes the attributes of the screen.
x, y
Specify the absolute position of the cursor's hotspot within the
screen's resolution.
DESCRIPTION
The set_cursor_position function moves the cursor hotspot to a location on
the screen specified by x, y. The function must deal with any offsets
required for video or the cursor's hotspot. In addition, the Workstation
Subsystem guarantees that the hotspot will be confined to the screen and
cursor handles by updating the screen coordinates in the screen structure
after this function has been called.
DATA STRUCTURES
The set_cursor_position function accesses the ws_screen_descriptor
structure defined in /usr/sys/include/sys/workstation.h.
RETURN VALUES
On success, the set_cursor_position function returns 0 (zero). If an error
occurs, it returns -1.
EXAMPLES
The following example shows how the set_cursor_position function is written
for an ATI Mach64 graphics adapter:
ati64_set_cursor_position(caddr_t cursor_handle,
ws_screen_descriptor sp,
int x,
int y)
{
register struct vga_info *vp =
(struct vga_info *)cursor_handle;
register struct ati64_type *ap =
&ati64_info[vp->unit];
register int xt, yt, xo, yo, offset, temp, viol;
/* Initialized the first time only */
static int previol = 0;
/*
* Bias position by where the hotspot is.
* Want to move hot spot to new location x.
*/
xt = x - vp->x_hot;
yt = y - vp->y_hot;
/*
* Location in memory where cursor
* definition area (64x64) begins
*/
offset = vp->cursor_offset;
viol = 0;
/* Cursor display will begin at xo (origin) */
if (xt < 0) {
xo = -xt;
xt = 0;
viol = 1;
} else
xo = 0;
/*
* If yt < 0, cursor y_hot is to move down. For each
* y0 unit moved, add 1 scanline to location in memory
* where cursor position begins. A scanline is 64
* pixels (64*2 bits=16 bytes)
*/
/*
* For each y0 unit, add 1 scanline
* a scanline is 64*2 bits=16 bytes
*/
if (yt < 0) {
yo = -yt;
yt = 0;
offset += (yo << 4);
viol = 1;
} else
yo = 0;
/*
* The following code keeps the cursor POSTION
* up-to-date, even while the cursor is off,
* so that code (ati64_cursor_on_off) that
* simply turns the cursor on will find it at
* the desired spot.
*/
if (viol || previol) {
temp = REGR(vp, ap, GEN_TEST_CNTL);
/* Turn OFF cursor. */
REGW(vp, ap, GEN_TEST_CNTL, temp & ~0x80);
/* Offset is QWORD index. */
REGWZ(vp, ap, CUR_OFFSET, offset >> 3);
REGWZ(vp, ap, CUR_HORZ_VERT_OFF, (yo << 16) | xo);
mb();
/* Turn ON cursor. */
REGW(vp, ap, GEN_TEST_CNTL, temp | 0x80);
}
previol = viol;
/* Write cursor position to chip. */
REGW(vp, ap, CUR_HORZ_VERT_POSN, (yt << 16) | xt);
return(0);
}
FILES
/usr/sys/include/sys/workstation.h
/usr/sys/include/sys/wsdevice.h
SEE ALSO
Data Structures: ws_screen_descriptor(9s), ws_cursor_functions(9s)
 |
Index for Section 9 |
|
 |
Alphabetical listing for S |
|
 |
Top of page |
|