mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:17:45 +00:00
LibGUI: Retain the active input tracking widget's cursor
Until the tracking stops, we want to keep displaying the same cursor.
This commit is contained in:
parent
1885445a79
commit
6548ae8afd
2 changed files with 12 additions and 5 deletions
|
@ -345,7 +345,7 @@ public:
|
||||||
|
|
||||||
virtual Gfx::IntRect children_clip_rect() const;
|
virtual Gfx::IntRect children_clip_rect() const;
|
||||||
|
|
||||||
AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> override_cursor() const { return m_override_cursor; }
|
AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> const& override_cursor() const { return m_override_cursor; }
|
||||||
void set_override_cursor(AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>>);
|
void set_override_cursor(AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>>);
|
||||||
|
|
||||||
bool load_from_gml(StringView);
|
bool load_from_gml(StringView);
|
||||||
|
|
|
@ -1177,10 +1177,17 @@ void Window::update_cursor()
|
||||||
{
|
{
|
||||||
auto new_cursor = m_cursor;
|
auto new_cursor = m_cursor;
|
||||||
|
|
||||||
if (m_hovered_widget) {
|
auto is_usable_cursor = [](auto& cursor) {
|
||||||
auto override_cursor = m_hovered_widget->override_cursor();
|
return cursor.template has<NonnullRefPtr<Gfx::Bitmap>>() || cursor.template get<Gfx::StandardCursor>() != Gfx::StandardCursor::None;
|
||||||
if (override_cursor.has<NonnullRefPtr<Gfx::Bitmap>>() || override_cursor.get<Gfx::StandardCursor>() != Gfx::StandardCursor::None)
|
};
|
||||||
new_cursor = move(override_cursor);
|
|
||||||
|
// NOTE: If there's an automatic cursor tracking widget, we retain its cursor until tracking stops.
|
||||||
|
if (auto widget = m_automatic_cursor_tracking_widget) {
|
||||||
|
if (is_usable_cursor(widget->override_cursor()))
|
||||||
|
new_cursor = widget->override_cursor();
|
||||||
|
} else if (auto widget = m_hovered_widget) {
|
||||||
|
if (is_usable_cursor(widget->override_cursor()))
|
||||||
|
new_cursor = widget->override_cursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (are_cursors_the_same(m_effective_cursor, new_cursor))
|
if (are_cursors_the_same(m_effective_cursor, new_cursor))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue