Serenity Operating System
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
8#pragma once
9
10#include <AK/DeprecatedString.h>
11#include <AK/Function.h>
12#include <LibGUI/Forward.h>
13#include <LibGUI/SystemEffects.h>
14#include <LibGfx/Rect.h>
15#include <Services/Taskbar/TaskbarWindow.h>
16#include <Services/WindowServer/ScreenLayout.h>
17
18namespace GUI {
19
20using ScreenLayout = WindowServer::ScreenLayout;
21
22class Desktop {
23public:
24 // Most people will probably have 4 screens or less
25 static constexpr size_t default_screen_rect_count = 4;
26
27 static Desktop& the();
28 Desktop() = default;
29
30 void set_background_color(StringView background_color);
31
32 void set_wallpaper_mode(StringView mode);
33
34 DeprecatedString wallpaper_path() const;
35 RefPtr<Gfx::Bitmap> wallpaper_bitmap() const;
36 bool set_wallpaper(RefPtr<Gfx::Bitmap const> wallpaper_bitmap, Optional<DeprecatedString> path);
37
38 void set_system_effects(Vector<bool> effects) { m_system_effects = { effects }; };
39 SystemEffects const& system_effects() const { return m_system_effects; }
40
41 Gfx::IntRect rect() const { return m_bounding_rect; }
42 Vector<Gfx::IntRect, 4> const& rects() const { return m_rects; }
43 size_t main_screen_index() const { return m_main_screen_index; }
44
45 unsigned workspace_rows() const { return m_workspace_rows; }
46 unsigned workspace_columns() const { return m_workspace_columns; }
47
48 int taskbar_height() const { return TaskbarWindow::taskbar_height(); }
49
50 void did_receive_screen_rects(Badge<ConnectionToWindowServer>, Vector<Gfx::IntRect, 4> const&, size_t, unsigned, unsigned);
51
52 template<typename F>
53 void on_receive_screen_rects(F&& callback)
54 {
55 m_receive_rects_callbacks.append(forward<F>(callback));
56 }
57
58private:
59 Vector<Gfx::IntRect, default_screen_rect_count> m_rects;
60 size_t m_main_screen_index { 0 };
61 Gfx::IntRect m_bounding_rect;
62 unsigned m_workspace_rows { 1 };
63 unsigned m_workspace_columns { 1 };
64 Vector<Function<void(Desktop&)>> m_receive_rects_callbacks;
65 bool m_is_setting_desktop_wallpaper { false };
66 SystemEffects m_system_effects;
67};
68
69}