💾 Archived View for lofi.haiku-os.org › docs › develop › servers › app_server › CursorManager.gmi captured on 2024-08-25 at 00:21:31. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-09-28)
-=-=-=-=-=-=-
The CursorManager class handles token creation, calling the cursor-related graphics driver functions, and freeing heap memory for all ServerCursor instances.
1. Create the cursor list empty
2. Set the token index to 0
3. Allocate the default system cursor and pass it to AddCursor
4. Initialize the member pointer for the graphics driver
5. Create the cursorlock semaphore
6. Call SetDefaultCursor
1. Empty and delete the cursor list
2. Delete the cursorlock semaphore
AddCursor() is used to register the cursor in question with the manager, allowing for the user application to have the identifying token, if necessary. The cursor becomes the property of the manager. If a user application deletes a BCursor, its ServerApp will call DeleteCursor().
1. Acquire cursor lock
2. Add *sc to the cursor list
3. Set sc->token to the current token index value
4. Increment the token index
5. Assign sc->token to temporary variable
6. Release cursor lock
7. Return the saved token value
1. Acquire cursor lock
2. Iterate through the cursor list, looking for ctoken
3. If any ServerCursor->token equals ctoken, remove and delete it
4. Release cursor lock
1. Acquire cursor lock
2. Iterate through the cursor list, checking each cursor’s ServerApp pointer
3. If any have a ServerApp pointer which matches the passed pointer, remove and delete them
4. Release cursor lock
Simple pass-through functions which call the graphics driver’s functions. Note that acquiring the cursor lock will be necessary for all three calls.
These set the current cursor for the graphics driver to the passed cursor, either one previously added via AddCursor or a system cursor.
1. Acquire cursor lock
Token version:
2. Find the cursor in the cursor list and call the graphics driver if non-NULL
3. Iterate through list of system cursor tokens and see if there’s a match. If so, set the internal cursor_which to the match.
cursor_which version:
2. determine which cursor to use via a switch statement and call the graphics driver with the internal pointer for the appropriate cursor
3. set the internal cursor_which to the one passed to the function
4. Release cursor lock
GetCursor is intended for use in figuring out what cursor is in use for a particular system cursor.
1. Acquire cursor lock
2. use a switch statement to figure which cursor to return and assign a temporary pointer its value
3. Release cursor lock
4. Return the temporary pointer
Calling ChangeCursor will allow a user to change a system cursor’s appearance. Note that in calling this, the cursor changes ownership and belongs to the system. Thus, the BCursor destructor will not ultimately cause the cursor to be deleted.
1. Acquire cursor lock
2. Call FindCursor and, if NULL, release the cursor lock and return
3. Look up the pointer for the system cursor in question and check to see if it is active. If active, then set the local active flag to true. Set the system cursor pointer to the one looked up.
4. If active flag is true, call SetCursor()
5. Release cursor lock
Returns the current cursor_which attribute which describes the currently active cursor. If the active cursor is not a system cursor, it will return CURSOR_OTHER.
1. Acquire cursor lock
2. Create a local cursor_which and assign it the value of the CursorManager’s cursor_which
3. Release cursor lock
4. Return the local copy