1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:37:37 +00:00

LibGUI+WindowServer: Allow applications to set custom cursor bitmaps

This will allow e.g PaintBrush to use custom cursors for each tool.
This commit is contained in:
Shannon Booth 2020-05-16 13:04:09 +12:00 committed by Andreas Kling
parent 8c1b01e79b
commit df43e09433
5 changed files with 36 additions and 2 deletions

View file

@ -209,10 +209,21 @@ void Window::set_override_cursor(StandardCursor cursor)
{
if (!is_visible())
return;
if (m_override_cursor == cursor)
if (!m_custom_cursor && m_override_cursor == cursor)
return;
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowOverrideCursor>(m_window_id, (u32)cursor);
m_override_cursor = cursor;
m_custom_cursor = nullptr;
}
void Window::set_override_cursor(const Gfx::Bitmap& cursor)
{
if (!is_visible())
return;
if (&cursor == m_custom_cursor.ptr())
return;
m_custom_cursor = &cursor;
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowCustomOverrideCursor>(m_window_id, m_custom_cursor->to_shareable_bitmap(WindowServerConnection::the().server_pid()));
}
void Window::event(Core::Event& event)

View file

@ -163,6 +163,7 @@ public:
void set_base_size(const Gfx::Size&);
void set_override_cursor(StandardCursor);
void set_override_cursor(const Gfx::Bitmap&);
void set_icon(const Gfx::Bitmap*);
void apply_icon();
@ -204,6 +205,7 @@ private:
RefPtr<Gfx::Bitmap> m_front_bitmap;
RefPtr<Gfx::Bitmap> m_back_bitmap;
RefPtr<Gfx::Bitmap> m_icon;
RefPtr<Gfx::Bitmap> m_custom_cursor;
int m_window_id { 0 };
float m_opacity_when_windowless { 1.0f };
RefPtr<Widget> m_main_widget;