diff options
author | Tom <tomut@yahoo.com> | 2021-06-25 12:08:23 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-25 20:38:13 +0200 |
commit | 8cfb4c82f0d1e487d2316163b5e424300e1f4e1e (patch) | |
tree | 13f2bef5c996f371fc892b2b022096bda32ac3a7 /Userland/Services/WindowServer/Overlays.h | |
parent | 84cab29c59259fc2fdbcc7003ecfcd5880c95898 (diff) | |
download | serenity-8cfb4c82f0d1e487d2316163b5e424300e1f4e1e.zip |
WindowServer: Change rendering drag&drop to use the Overlay class
This enables flicker-free rendering.
Diffstat (limited to 'Userland/Services/WindowServer/Overlays.h')
-rw-r--r-- | Userland/Services/WindowServer/Overlays.h | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/Userland/Services/WindowServer/Overlays.h b/Userland/Services/WindowServer/Overlays.h index a97d797075..f2d45b9ec2 100644 --- a/Userland/Services/WindowServer/Overlays.h +++ b/Userland/Services/WindowServer/Overlays.h @@ -26,6 +26,7 @@ public: enum class ZOrder { WindowGeometry, + Dnd, ScreenNumber, }; [[nodiscard]] virtual ZOrder zorder() const = 0; @@ -39,7 +40,7 @@ public: virtual void theme_changed() { - rect_changed(); + rect_changed(m_rect); } bool invalidate(); @@ -49,7 +50,7 @@ protected: void set_rect(Gfx::IntRect const&); - virtual void rect_changed() {}; + virtual void rect_changed(Gfx::IntRect const&) {}; private: void clear_invalidated() { m_invalidated = false; } @@ -76,7 +77,7 @@ protected: BitmapOverlay(); void clear_bitmaps(); - virtual void rect_changed() override; + virtual void rect_changed(Gfx::IntRect const&) override; private: RefPtr<MultiScaleBitmaps> m_bitmaps; @@ -97,10 +98,16 @@ protected: void set_content_rect(Gfx::IntRect const&); void clear_bitmaps(); - virtual void rect_changed() override; + virtual void rect_changed(Gfx::IntRect const&) override; + + void rerender_on_location_change(bool value) + { + m_rerender_on_location_change = value; + } private: RefPtr<MultiScaleBitmaps> m_rendered_bitmaps; + bool m_rerender_on_location_change { false }; }; class ScreenNumberOverlay : public RectangularOverlay { @@ -143,4 +150,25 @@ private: Gfx::IntRect m_label_rect; }; +class DndOverlay : public BitmapOverlay { +public: + DndOverlay(String const&, Gfx::Bitmap const*); + + void cursor_moved() + { + update_rect(); + } + + virtual ZOrder zorder() const override { return ZOrder::Dnd; } + virtual RefPtr<Gfx::Bitmap> create_bitmap(int) override; + +private: + Gfx::Font const& font(); + void update_rect(); + + RefPtr<Gfx::Bitmap> m_bitmap; + String m_text; + Gfx::IntRect m_label_rect; +}; + } |