Repository navigation
feat(graphics): added gfxfb's calls to set and move a hardware cursor - #461
Merged
Merged
Conversation
A pointer drawn into each frame costs a present for every mouse move. gfxfb_output_info grew to 40 bytes to report each output's cursor maximum, and the two cursor calls take control as presents do.
FlareCoding
force-pushed
the
pr/gfxfb-cursor
branch
from
October 25, 2026 22:03
5fff2cc to
11164de
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
gfxfb lets a program set the picture and position of an output's hardware cursor, which the display draws over what the output shows, so a mouse moves the pointer without drawing and presenting a new frame.
Changes
GFXFB_SET_CURSORgives an output's cursor a picture with straight alpha (colors not multiplied by alpha) and its hotspot (the pixel that sits at the cursor's position), or hides the cursor at a width of 0, andGFXFB_MOVE_CURSORplaces the hotspot anywhere, even off the output.GFXFB_GET_OUTPUTreports each output's largest cursor picture, 0 by 0 without a hardware cursor, sogfxfb_output_infogrows from 32 to 40 bytes.gfxfb_noderefuses an unknown output, a set reserved field, a hotspot outside the picture or a picture past the output's largest with EINVAL, then copies the pixels onto the unprivileged heap, failing with ENOMEM or, for pixels it cannot read, EINVAL, so a refused request fails alike whoever controls the buffers. A largest picture a display reports pastCURSOR_DIMENSION_MAX(256) is held to it, inGFXFB_GET_OUTPUT's reply as in the check, so a copy never passes 256 KiB.ERR_DEVICEalso marks. The controlling file's close, ingive_outputs_back(), hides each output's cursor before its control ends, unless the display has failed or refuses the hide.gfxfb::displaygainsset_cursor()andmove_cursor(), which gfxfb calls one at a time for each output under a mutex of their own, so a mouse's moves never wait for a present's display call. The boot display and virtio-gpu report no hardware cursor, so a picture there fails with EINVAL against a maximum of 0 by 0, and a hide or a move with ENOTTY.ERR_DEVICEfails every later flush, present and cursor call (another file's cursor calls with EBUSY while the controller holds control, and with EIO once it closes), cursor calls take and keep control as creations do, a closing controller hides every output's cursor before its control ends, and a move waits for a hide's display call on its output (output 1 as well as output 0) but not for a present there. On the boot display a picture fails with EINVAL and a hide or a move with ENOTTY, none taking control. Two GET_OUTPUT tests and the boot display'sread_output()test check the largest picture, one reporting a fake's maximum past 256 held toCURSOR_DIMENSION_MAX.Note
Medium Risk
Touches kernel user-copy paths, device control lifecycle, and the gfxfb display contract; virtio-gpu and boot paths are stubs only until a driver implements hardware cursors.
Overview
Adds hardware cursor support to
/dev/gfxfbso userland can set a cursor image and move it without presenting frames.User API: New ioctls
GFXFB_SET_CURSOR(ARGB picture + hotspot, or width 0 to hide) andGFXFB_MOVE_CURSOR(hotspot position, including off-screen).GFXFB_GET_OUTPUTnow returnscursor_max_width/cursor_max_height(gfxfb_output_infogrows to 40 bytes). Reported maxima are capped atCURSOR_DIMENSION_MAX(256) so kernel copies stay bounded (up to 256 KiB).Kernel path:
gfxfb_nodevalidates arguments, copies pixel data from userland before taking buffer control, and forwards to newdisplay::set_cursor()/move_cursor()under per-output cursor mutexes (serialized with each other, not with presents). Successful cursor calls participate in the same single-controller model as buffer create/present; device failure andERR_DEVICEfrom cursor calls block later flush/present/cursor ioctls. On close, the controller hides cursors on all outputs viagive_outputs_back().Drivers:
boot_displayand virtio-gpu stub cursor support (ERR_UNSUPPORTED, 0×0 max); real hardware drivers must implement the newdisplaymethods.Reviewed by Cursor Bugbot for commit 5fff2cc. Bugbot is set up for automated code reviews on this repo. Configure here.