From 124ae7cc2f37aa7b3eac970120b8f7712e3a70f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Tue, 6 Sep 2022 19:30:49 +0200 Subject: [PATCH] app_server: store the brightness with the current screen config if absent when no screen configuration is found, the preferred mode is then selected, and we now use this as current screen configuration. Otherwise, the user would adjust the brightness, but it would never be stored for the next boot. Change-Id: Ia855f8a29eb5e429747f3e0bc89a46587fa42f59 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5624 Tested-by: Commit checker robot Reviewed-by: waddlesplash --- src/servers/app/Desktop.cpp | 7 +++++++ src/servers/app/VirtualScreen.cpp | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index 98fd48b9fe..0b1ba583b4 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -899,6 +899,13 @@ Desktop::SetBrightness(int32 id, float brightness) status_t result = HWInterface()->SetBrightness(brightness); if (result == B_OK) { + if (fWorkspaces[0].StoredScreenConfiguration().CurrentByID(id) == NULL) { + // store the current configuration if empty + screen_configuration* current + = fWorkspaces[0].CurrentScreenConfiguration().CurrentByID(id); + fWorkspaces[0].StoredScreenConfiguration().Set(id, + current->has_info ? ¤t->info : NULL, current->frame, current->mode); + } fWorkspaces[0].StoredScreenConfiguration().SetBrightness(id, brightness); // Save brightness for next boot diff --git a/src/servers/app/VirtualScreen.cpp b/src/servers/app/VirtualScreen.cpp index 1a9f7e2662..4855fcb3c6 100644 --- a/src/servers/app/VirtualScreen.cpp +++ b/src/servers/app/VirtualScreen.cpp @@ -129,6 +129,12 @@ VirtualScreen::AddScreen(Screen* screen, ScreenConfigurations& configurations) // We found no configuration or it wasn't valid, try to fallback to // sane values status = screen->SetPreferredMode(); + if (status == B_OK) { + monitor_info info; + bool hasInfo = screen->GetMonitorInfo(info) == B_OK; + screen->GetMode(mode); + configurations.Set(screen->ID(), hasInfo ? &info : NULL, screen->Frame(), mode); + } if (status != B_OK) status = screen->SetBestMode(1024, 768, B_RGB32, 60.f); if (status != B_OK)