slint icon indicating copy to clipboard operation
slint copied to clipboard

LinuxKMS: Add support for mouse cursor rendering with the software renderer

Open tronical opened this issue 1 year ago • 3 comments

As a follow-up to #4334 , this issue exists to remind about the missing support for rendering the mouse cursor when using renderer-software with backend-linuxkms.

The approach discussed in #4334 to implement this cleanly is briefly outlined in https://github.com/slint-ui/slint/pull/4334#discussion_r1451556820 : Add support for this type of mouse cursor rendering in the core library by synthesizing an Image that's rendered on top of the scene.

tronical avatar Jun 10 '24 13:06 tronical

We probably need a public API in the software renderer as this would also be in used for the uefi example.

Just wondering at which level to do. The API could look like

impl SoftwareRenderer { // Or should it be in slint::Window?
   pub fn set_draw_mouse_cursor(cursor: Option<slint::Image>);

ogoffart avatar Jun 11 '24 07:06 ogoffart

Maybe fn set_cursor_image(&self, image: Option<slint::Image>). I think Wayland also supports specifying an image for use a cursor, so this could indeed be on the Window.

tronical avatar Jun 11 '24 08:06 tronical

No, no. The API i have in mind would be that Slint draws the cursor with its own renderer.

So an implementation of a backend would look like

impl WindowAdapter for MyBackendWindow {
 // ...
 
 // this is currently in WindowAdapterInternal, but we should make it public at some point)
 fn set_mouse_cursor(&self, cursor: MouseCursor) {
    let cursor_image: Option<slint::Image> = load_png_for_cursor(cursor);
    self.renderer.set_draw_mouse_cursor(cursor_image);
 }
}

I think Wayland also supports specifying an image for use a cursor, so this could indeed be on the Window.

That is something else, and should be somehow in the MouseCursor enum, we could pass an image to TouchArea::mouse-cursor or an extra property.

ogoffart avatar Jun 11 '24 09:06 ogoffart