Desktop.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2022, the SerenityOS developers.
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <AK/Function.h>
  9. #include <AK/String.h>
  10. #include <LibGUI/Forward.h>
  11. #include <LibGUI/SystemEffects.h>
  12. #include <LibGfx/Rect.h>
  13. #include <Services/Taskbar/TaskbarWindow.h>
  14. #include <Services/WindowServer/ScreenLayout.h>
  15. namespace GUI {
  16. using ScreenLayout = WindowServer::ScreenLayout;
  17. class Desktop {
  18. public:
  19. // Most people will probably have 4 screens or less
  20. static constexpr size_t default_screen_rect_count = 4;
  21. static Desktop& the();
  22. Desktop() = default;
  23. void set_background_color(StringView background_color);
  24. void set_wallpaper_mode(StringView mode);
  25. String wallpaper_path() const;
  26. RefPtr<Gfx::Bitmap> wallpaper_bitmap() const;
  27. bool set_wallpaper(RefPtr<Gfx::Bitmap> wallpaper_bitmap, Optional<String> path);
  28. void set_system_effects(Vector<bool> effects) { m_system_effects = { effects }; };
  29. SystemEffects const& system_effects() const { return m_system_effects; }
  30. Gfx::IntRect rect() const { return m_bounding_rect; }
  31. Vector<Gfx::IntRect, 4> const& rects() const { return m_rects; }
  32. size_t main_screen_index() const { return m_main_screen_index; }
  33. unsigned workspace_rows() const { return m_workspace_rows; }
  34. unsigned workspace_columns() const { return m_workspace_columns; }
  35. int taskbar_height() const { return TaskbarWindow::taskbar_height(); }
  36. void did_receive_screen_rects(Badge<ConnectionToWindowServer>, Vector<Gfx::IntRect, 4> const&, size_t, unsigned, unsigned);
  37. template<typename F>
  38. void on_receive_screen_rects(F&& callback)
  39. {
  40. m_receive_rects_callbacks.append(forward<F>(callback));
  41. }
  42. private:
  43. Vector<Gfx::IntRect, default_screen_rect_count> m_rects;
  44. size_t m_main_screen_index { 0 };
  45. Gfx::IntRect m_bounding_rect;
  46. unsigned m_workspace_rows { 1 };
  47. unsigned m_workspace_columns { 1 };
  48. Vector<Function<void(Desktop&)>> m_receive_rects_callbacks;
  49. bool m_is_setting_desktop_wallpaper { false };
  50. SystemEffects m_system_effects;
  51. };
  52. }