1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:37:45 +00:00

DisplaySettings+WindowServer: Add support for display connector devices

This commit is contained in:
Liav A 2022-04-29 17:56:24 +03:00 committed by Andreas Kling
parent e6ebf9e5c1
commit d9a2706079
12 changed files with 308 additions and 38 deletions

View file

@ -68,7 +68,8 @@ ErrorOr<int> serenity_main(Main::Arguments)
WindowServer::ScreenLayout screen_layout;
String error_msg;
auto add_unconfigured_devices = [&]() {
// FIXME: Remove this once framebuffer devices are removed.
auto add_unconfigured_framebuffer_devices = [&]() {
// Enumerate the /dev/fbX devices and try to set up any ones we find that we haven't already used
Core::DirIterator di("/dev", Core::DirIterator::SkipParentAndBaseDir);
while (di.has_next()) {
@ -76,6 +77,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
if (!path.starts_with("fb"))
continue;
auto full_path = String::formatted("/dev/{}", path);
dbgln("{} :", full_path);
if (!Core::File::is_device(full_path))
continue;
if (fb_devices_configured.find(full_path) != fb_devices_configured.end())
@ -85,10 +87,31 @@ ErrorOr<int> serenity_main(Main::Arguments)
}
};
auto add_unconfigured_display_connector_devices = [&]() {
// Enumerate the /dev/fbX devices and try to set up any ones we find that we haven't already used
Core::DirIterator di("/dev/gpu", Core::DirIterator::SkipParentAndBaseDir);
while (di.has_next()) {
auto path = di.next_path();
if (!path.starts_with("connector"))
continue;
auto full_path = String::formatted("/dev/gpu/{}", path);
if (!Core::File::is_device(full_path))
continue;
if (fb_devices_configured.find(full_path) != fb_devices_configured.end())
continue;
if (!screen_layout.try_auto_add_display_connector(full_path))
dbgln("Could not auto-add framebuffer device {} to screen layout", full_path);
}
};
auto apply_and_generate_generic_screen_layout = [&]() {
screen_layout = {};
fb_devices_configured = {};
add_unconfigured_devices();
// FIXME: Remove this once framebuffer devices are removed.
add_unconfigured_framebuffer_devices();
add_unconfigured_display_connector_devices();
if (!WindowServer::Screen::apply_layout(move(screen_layout), error_msg)) {
dbgln("Failed to apply generated fallback screen layout: {}", error_msg);
return false;
@ -100,10 +123,13 @@ ErrorOr<int> serenity_main(Main::Arguments)
if (screen_layout.load_config(*wm_config, &error_msg)) {
for (auto& screen_info : screen_layout.screens)
if (screen_info.mode == WindowServer::ScreenLayout::Screen::Mode::Device)
if (screen_info.mode == WindowServer::ScreenLayout::Screen::Mode::Device || screen_info.mode == WindowServer::ScreenLayout::Screen::Mode::DisplayConnectorDevice)
fb_devices_configured.set(screen_info.device.value());
add_unconfigured_devices();
// FIXME: Remove this once framebuffer devices are removed.
add_unconfigured_framebuffer_devices();
add_unconfigured_display_connector_devices();
if (!WindowServer::Screen::apply_layout(move(screen_layout), error_msg)) {
dbgln("Error applying screen layout: {}", error_msg);