diff options
author | Tom <tomut@yahoo.com> | 2021-02-14 16:42:37 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-02-15 23:07:49 +0100 |
commit | d590e0c946c0c54b30b280987c18a20d60d4195c (patch) | |
tree | e83bddec5c8feb4a42fca99713dca02b2c5afc0b /Userland/Libraries/LibGUI | |
parent | b3f0a5c917a69eaf8a405653ae882f45a03ad467 (diff) | |
download | serenity-d590e0c946c0c54b30b280987c18a20d60d4195c.zip |
WindowServer: Add support for alpha channel based hit testing
This enables implementing non-rectangular window shapes, including
non-rectangular window frames.
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r-- | Userland/Libraries/LibGUI/Window.cpp | 15 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Window.h | 4 |
2 files changed, 19 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/Window.cpp b/Userland/Libraries/LibGUI/Window.cpp index 1dc2d8ce7a..0cdb8b9c43 100644 --- a/Userland/Libraries/LibGUI/Window.cpp +++ b/Userland/Libraries/LibGUI/Window.cpp @@ -147,6 +147,7 @@ void Window::show() m_frameless, m_accessory, m_opacity_when_windowless, + m_alpha_hit_threshold, m_base_size, m_size_increment, m_resize_aspect_ratio, @@ -673,6 +674,20 @@ void Window::set_opacity(float opacity) WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowOpacity>(m_window_id, opacity); } +void Window::set_alpha_hit_threshold(float threshold) +{ + if (threshold < 0.0f) + threshold = 0.0f; + else if (threshold > 1.0f) + threshold = 1.0f; + if (m_alpha_hit_threshold == threshold) + return; + m_alpha_hit_threshold = threshold; + if (!is_visible()) + return; + WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowAlphaHitThreshold>(m_window_id, threshold); +} + void Window::set_hovered_widget(Widget* widget) { if (widget == m_hovered_widget) diff --git a/Userland/Libraries/LibGUI/Window.h b/Userland/Libraries/LibGUI/Window.h index 1c1e96dbd4..aca7e0842e 100644 --- a/Userland/Libraries/LibGUI/Window.h +++ b/Userland/Libraries/LibGUI/Window.h @@ -72,6 +72,9 @@ public: void set_opacity(float); float opacity() const { return m_opacity_when_windowless; } + void set_alpha_hit_threshold(float); + float alpha_hit_threshold() const { return m_alpha_hit_threshold; } + WindowType window_type() const { return m_window_type; } void set_window_type(WindowType); @@ -238,6 +241,7 @@ private: RefPtr<Gfx::Bitmap> m_custom_cursor; int m_window_id { 0 }; float m_opacity_when_windowless { 1.0f }; + float m_alpha_hit_threshold { 0.0f }; RefPtr<Widget> m_main_widget; WeakPtr<Widget> m_focused_widget; WeakPtr<Widget> m_global_cursor_tracking_widget; |