1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 21:08:12 +00:00
serenity/Userland/Services/WindowServer/ScreenLayout.h
kleines Filmröllchen be98ce0f9f WindowServer: Add the screen mode property in the screen configuration
This will allow us to change between a couple of properties, for now
it's only Device and Virtual. (How about Remote :^) ) These get handled
by a different screen backend in the Screen.
2022-04-21 13:41:55 +02:00

81 lines
2 KiB
C++

/*
* Copyright (c) 2020, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/String.h>
#include <AK/Vector.h>
#include <LibCore/ConfigFile.h>
#include <LibGfx/Rect.h>
#include <LibGfx/Size.h>
#include <LibIPC/Forward.h>
namespace WindowServer {
class ScreenLayout {
public:
struct Screen {
enum class Mode {
Invalid,
Device,
Virtual,
} mode;
Optional<String> device;
Gfx::IntPoint location;
Gfx::IntSize resolution;
int scale_factor;
Gfx::IntRect virtual_rect() const
{
return { location, { resolution.width() / scale_factor, resolution.height() / scale_factor } };
}
static StringView mode_to_string(Mode mode)
{
#define __ENUMERATE_MODE_ENUM(val) \
case Mode::val: \
return #val;
switch (mode) {
__ENUMERATE_MODE_ENUM(Invalid)
__ENUMERATE_MODE_ENUM(Device)
__ENUMERATE_MODE_ENUM(Virtual)
}
VERIFY_NOT_REACHED();
#undef __ENUMERATE_MODE_ENUM
}
bool operator==(Screen const&) const = default;
};
Vector<Screen> screens;
unsigned main_screen_index { 0 };
bool is_valid(String* error_msg = nullptr) const;
bool normalize();
bool load_config(Core::ConfigFile const& config_file, String* error_msg = nullptr);
bool save_config(Core::ConfigFile& config_file, bool sync = true) const;
bool try_auto_add_framebuffer(String const&);
// TODO: spaceship operator
bool operator!=(ScreenLayout const& other) const;
bool operator==(ScreenLayout const& other) const
{
return !(*this != other);
}
};
}
namespace IPC {
bool encode(Encoder&, WindowServer::ScreenLayout::Screen const&);
ErrorOr<void> decode(Decoder&, WindowServer::ScreenLayout::Screen&);
bool encode(Encoder&, WindowServer::ScreenLayout const&);
ErrorOr<void> decode(Decoder&, WindowServer::ScreenLayout&);
}