2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
|
|
* list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2019-05-24 19:32:46 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/OwnPtr.h>
|
2019-06-21 18:45:35 +02:00
|
|
|
#include <AK/RefPtr.h>
|
2020-02-06 15:04:03 +01:00
|
|
|
#include <LibCore/Object.h>
|
2020-12-28 10:56:22 +01:00
|
|
|
#include <LibGfx/Color.h>
|
2020-02-06 20:03:37 +01:00
|
|
|
#include <LibGfx/DisjointRectSet.h>
|
2020-02-06 11:56:38 +01:00
|
|
|
|
2020-02-06 20:03:37 +01:00
|
|
|
namespace WindowServer {
|
|
|
|
|
2020-04-22 00:07:48 +02:00
|
|
|
class ClientConnection;
|
2020-02-06 20:03:37 +01:00
|
|
|
class Cursor;
|
2020-05-19 19:02:15 +02:00
|
|
|
class Window;
|
2020-12-28 10:56:22 +01:00
|
|
|
class WindowManager;
|
2019-05-24 19:32:46 +02:00
|
|
|
|
2019-06-07 17:13:23 +02:00
|
|
|
enum class WallpaperMode {
|
2019-05-28 11:53:16 +02:00
|
|
|
Simple,
|
|
|
|
Tile,
|
|
|
|
Center,
|
|
|
|
Scaled,
|
|
|
|
Unchecked
|
|
|
|
};
|
2019-05-26 10:14:03 -07:00
|
|
|
|
2020-02-06 20:03:37 +01:00
|
|
|
class Compositor final : public Core::Object {
|
|
|
|
C_OBJECT(Compositor)
|
2019-05-24 19:32:46 +02:00
|
|
|
public:
|
2020-02-06 20:03:37 +01:00
|
|
|
static Compositor& the();
|
2019-05-24 19:32:46 +02:00
|
|
|
|
|
|
|
void compose();
|
2020-08-17 22:45:10 -06:00
|
|
|
void invalidate_window();
|
|
|
|
void invalidate_screen();
|
|
|
|
void invalidate_screen(const Gfx::IntRect&);
|
2019-05-24 19:32:46 +02:00
|
|
|
|
2020-02-27 17:09:41 +02:00
|
|
|
bool set_resolution(int desired_width, int desired_height);
|
2019-05-24 19:32:46 +02:00
|
|
|
|
2020-04-29 20:58:39 +02:00
|
|
|
bool set_background_color(const String& background_color);
|
2020-03-29 13:32:06 +03:00
|
|
|
|
|
|
|
bool set_wallpaper_mode(const String& mode);
|
|
|
|
|
2019-05-24 19:32:46 +02:00
|
|
|
bool set_wallpaper(const String& path, Function<void(bool)>&& callback);
|
|
|
|
String wallpaper_path() const { return m_wallpaper_path; }
|
|
|
|
|
2020-12-16 22:15:14 -07:00
|
|
|
void invalidate_cursor(bool = false);
|
2020-06-10 10:57:59 +02:00
|
|
|
Gfx::IntRect current_cursor_rect() const;
|
2019-05-24 19:32:46 +02:00
|
|
|
|
2020-04-22 00:07:48 +02:00
|
|
|
void increment_display_link_count(Badge<ClientConnection>);
|
|
|
|
void decrement_display_link_count(Badge<ClientConnection>);
|
|
|
|
|
2020-08-17 22:45:10 -06:00
|
|
|
void invalidate_occlusions() { m_occlusions_dirty = true; }
|
2020-05-19 19:02:15 +02:00
|
|
|
|
2020-12-28 10:56:22 +01:00
|
|
|
void did_construct_window_manager(Badge<WindowManager>);
|
|
|
|
|
2019-05-24 19:32:46 +02:00
|
|
|
private:
|
2020-02-06 20:03:37 +01:00
|
|
|
Compositor();
|
2019-08-18 14:32:14 +10:00
|
|
|
void init_bitmaps();
|
2019-05-24 19:32:46 +02:00
|
|
|
void flip_buffers();
|
2020-06-10 10:57:59 +02:00
|
|
|
void flush(const Gfx::IntRect&);
|
2019-05-24 19:32:46 +02:00
|
|
|
void draw_menubar();
|
2020-08-17 22:45:10 -06:00
|
|
|
void run_animations(Gfx::DisjointRectSet&);
|
2020-03-22 21:13:23 +01:00
|
|
|
void notify_display_links();
|
2020-08-17 22:45:10 -06:00
|
|
|
void start_compose_async_timer();
|
|
|
|
void recompute_occlusions();
|
2020-06-10 10:57:59 +02:00
|
|
|
bool any_opaque_window_above_this_one_contains_rect(const Window&, const Gfx::IntRect&);
|
2020-12-16 22:15:14 -07:00
|
|
|
void change_cursor(const Cursor*);
|
2020-08-17 22:45:10 -06:00
|
|
|
void draw_cursor(const Gfx::IntRect&);
|
|
|
|
void restore_cursor_back();
|
|
|
|
bool draw_geometry_label(Gfx::IntRect&);
|
2019-05-24 19:32:46 +02:00
|
|
|
|
2020-02-02 12:34:39 +01:00
|
|
|
RefPtr<Core::Timer> m_compose_timer;
|
|
|
|
RefPtr<Core::Timer> m_immediate_compose_timer;
|
2019-05-24 19:32:46 +02:00
|
|
|
bool m_flash_flush { false };
|
|
|
|
bool m_buffers_are_flipped { false };
|
2019-08-18 14:32:14 +10:00
|
|
|
bool m_screen_can_set_buffer { false };
|
2020-08-17 22:45:10 -06:00
|
|
|
bool m_occlusions_dirty { true };
|
|
|
|
bool m_invalidated_any { true };
|
|
|
|
bool m_invalidated_window { false };
|
|
|
|
bool m_invalidated_cursor { false };
|
2019-05-24 19:32:46 +02:00
|
|
|
|
2020-02-06 11:56:38 +01:00
|
|
|
RefPtr<Gfx::Bitmap> m_front_bitmap;
|
|
|
|
RefPtr<Gfx::Bitmap> m_back_bitmap;
|
2020-08-17 22:45:10 -06:00
|
|
|
RefPtr<Gfx::Bitmap> m_temp_bitmap;
|
2020-02-06 11:56:38 +01:00
|
|
|
OwnPtr<Gfx::Painter> m_back_painter;
|
|
|
|
OwnPtr<Gfx::Painter> m_front_painter;
|
2020-08-17 22:45:10 -06:00
|
|
|
OwnPtr<Gfx::Painter> m_temp_painter;
|
2019-05-24 19:32:46 +02:00
|
|
|
|
2020-08-17 22:45:10 -06:00
|
|
|
Gfx::DisjointRectSet m_dirty_screen_rects;
|
|
|
|
Gfx::DisjointRectSet m_opaque_wallpaper_rects;
|
2019-05-24 19:32:46 +02:00
|
|
|
|
2020-08-17 22:45:10 -06:00
|
|
|
RefPtr<Gfx::Bitmap> m_cursor_back_bitmap;
|
|
|
|
OwnPtr<Gfx::Painter> m_cursor_back_painter;
|
2020-06-10 10:57:59 +02:00
|
|
|
Gfx::IntRect m_last_cursor_rect;
|
|
|
|
Gfx::IntRect m_last_dnd_rect;
|
2020-12-28 01:35:53 +01:00
|
|
|
Gfx::IntRect m_last_geometry_label_damage_rect;
|
2019-05-24 19:32:46 +02:00
|
|
|
|
2020-12-05 17:47:51 +01:00
|
|
|
String m_wallpaper_path { "" };
|
2019-05-26 10:14:03 -07:00
|
|
|
WallpaperMode m_wallpaper_mode { WallpaperMode::Unchecked };
|
2020-02-06 11:56:38 +01:00
|
|
|
RefPtr<Gfx::Bitmap> m_wallpaper;
|
2020-04-22 00:07:48 +02:00
|
|
|
|
2020-12-16 22:15:14 -07:00
|
|
|
const Cursor* m_current_cursor { nullptr };
|
|
|
|
unsigned m_current_cursor_frame { 0 };
|
|
|
|
RefPtr<Core::Timer> m_cursor_timer;
|
|
|
|
|
2020-04-22 00:07:48 +02:00
|
|
|
RefPtr<Core::Timer> m_display_link_notify_timer;
|
|
|
|
size_t m_display_link_count { 0 };
|
2020-12-28 10:56:22 +01:00
|
|
|
|
|
|
|
Optional<Gfx::Color> m_custom_background_color;
|
2019-05-24 19:32:46 +02:00
|
|
|
};
|
2020-02-06 20:03:37 +01:00
|
|
|
|
|
|
|
}
|