Cursors

The USER module requires all display drivers to provide cursor support. A display driver must provide the following functions. Note that the DIB engine provides cursor support and that minidrivers may forward these calls to the DIB engine.

Function Description
CheckCursor Draws the cursor if drawing is not disabled.
InquireCursor Retrieves information about the cursor.
MoveCursor Moves the cursor to a specified position on the display.
SetCursor Sets the cursor shape.

When Windows first starts, USER calls the InquireCursor function to retrieve information about the cursor. It then sets a system timer to call the CheckCursor function on each timer interrupt and enables the mouse driver, allowing the Windows mouse-event routine to call MoveCursor at each mouse interrupt occurrence. USER and Windows applications subsequently set the shape of the cursor using SetCursor.

Because USER calls MoveCursor on each mouse interrupt, MoveCursor should set a semaphore to prevent the function from being called before it can complete the current call. The function should set the semaphore using a noninterruptable instruction, such as the bts instruction. Once the semaphore is set, MoveCursor should retrieve the x and y coordinates and draw the cursor in the new position. When finished, MoveCursor should clear the flag with a non-interruptable instruction such as and. Whenever MoveCursor is called, it should check this flag before continuing the request.

The CheckCursor function is called on each timer interrupt. The function should determine whether the cursor needs redrawing and whether drawing is enabled. If so, the function should redraw the cursor.

For displays that do not have a hardware cursor, the display driver should exclude the cursor from the screen before carrying out drawing operations in functions such as BitBlt, Output, and ExtTextOut. The driver should check the current x and y coordinates and exclude the cursor if any part of the cursor lies within the drawing region, as specified in the following.

Operation Region
Bit-block transfer Destination rectangle
Ellipse Bounding rectangle
Other line drawing Bounding rectangle
Polygon Clip rectangle
Polyline Clip rectangle
Scan line Whole scan line
Text Bounding rectangle and/or opaquing rectangle