slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.14k stars 581 forks source link

Wrong mouse-cursor when two `TouchArea`'s are involved #6443

Open Enyium opened 4 days ago

Enyium commented 4 days ago

Demo video, slowed down 4x:

https://github.com/user-attachments/assets/26f1b6ed-3842-44d7-9342-4034496f6cc4

The bug doesn't occur in SlintPad, but in a local build as well as the VS Code preview window.

Rust test project I wrote on Windows 10: mouse-cursor-bug.zip. The code is a simplification of a part of my app; so, the nested TouchAreas are necessary.

Relevant part:

    // The bug happens with both of the variants below:

    /*
    */
    TouchArea {
        Text {
            text: "https://www.example.com/lorem+ipsum+dolor+sit+amet";

            TouchArea {
                mouse-cursor: pointer;
            }
        }
    }

    /*
    TouchArea {
        TouchArea {
            width: self.preferred-width;
            height: self.preferred-height;
            mouse-cursor: pointer;

            Text {
                text: "https://www.example.com/lorem+ipsum+dolor+sit+amet";
            }
        }
    }
    */
Enyium commented 4 days ago

With a TextInput inside a TouchArea:

    TouchArea {
        TextInput {
            text: "https://www.example.com/lorem+ipsum+dolor+sit+amet";
        }
    }

...the situation described in #6444 becomes worse: Now, clicking with any mouse button switches to the default cursor, at least temporarily (while holding the button). This can be reproduced in SlintPad.

ogoffart commented 1 day ago

When two TouchArea have the cursor at the same time, they both will call set_mouse_cursor, resulting in potential blinking cursor as the WM gets both cursor command in a row.

There is also a problem if two TouchArea are next to each other, the exit event might be sent after the inter event of the other, resulting in the default cursor to be shown when the mouse just move over to the second TouchArea