mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 07:38:10 +00:00
WindowServer: Add API to set/get screen layouts
This sets the stage so that DisplaySettings can configure the screen layout and set various screen resolutions in one go. It also allows for an easy "atomic" revert of the previous settings.
This commit is contained in:
parent
34394044b3
commit
aa15bf81e4
23 changed files with 558 additions and 228 deletions
59
Userland/Services/WindowServer/ScreenLayout.h
Normal file
59
Userland/Services/WindowServer/ScreenLayout.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* 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 {
|
||||
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 } };
|
||||
}
|
||||
|
||||
auto operator<=>(const Screen&) const = default;
|
||||
};
|
||||
|
||||
Vector<Screen> screens;
|
||||
unsigned main_screen_index { 0 };
|
||||
|
||||
bool is_valid(String* error_msg = nullptr) const;
|
||||
void normalize();
|
||||
bool load_config(const Core::ConfigFile& config_file, String* error_msg = nullptr);
|
||||
bool save_config(Core::ConfigFile& config_file, bool sync = true) const;
|
||||
|
||||
// TODO: spaceship operator
|
||||
bool operator!=(const ScreenLayout& other) const;
|
||||
bool operator==(const ScreenLayout& other) const
|
||||
{
|
||||
return !(*this != other);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace IPC {
|
||||
|
||||
bool encode(Encoder&, const WindowServer::ScreenLayout::Screen&);
|
||||
bool decode(Decoder&, WindowServer::ScreenLayout::Screen&);
|
||||
bool encode(Encoder&, const WindowServer::ScreenLayout&);
|
||||
bool decode(Decoder&, WindowServer::ScreenLayout&);
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue