Fix setting color space of all os::Windows

This commit is contained in:
David Capello 2021-05-21 21:44:30 -03:00
parent fd7d31ddc2
commit e7f0832ff3
3 changed files with 21 additions and 6 deletions

2
laf

@ -1 +1 @@
Subproject commit 2d4fe8dfc0184405c22e0dec9d1f5a8e6e7f0f14
Subproject commit a9caf030323b64673f5440103841c09e5e9c5c5a

View File

@ -646,7 +646,6 @@ public:
if (j == winCs) {
name = gfxCs->name();
os::instance()->setWindowsColorSpace(cs);
break;
}
++j;

View File

@ -47,6 +47,7 @@
#include "os/surface.h"
#include "os/system.h"
#include "os/window.h"
#include "os/window.h"
#include "ui/intern.h"
#include "ui/ui.h"
@ -257,13 +258,14 @@ void update_windows_color_profile_from_preferences()
else
windowProfile = gen::WindowColorProfile::SRGB;
os::ColorSpaceRef osCS = nullptr;
switch (windowProfile) {
case gen::WindowColorProfile::MONITOR:
system->setWindowsColorSpace(nullptr);
osCS = nullptr;
break;
case gen::WindowColorProfile::SRGB:
system->setWindowsColorSpace(
system->makeColorSpace(gfx::ColorSpace::MakeSRGB()));
osCS = system->makeColorSpace(gfx::ColorSpace::MakeSRGB());
break;
case gen::WindowColorProfile::SPECIFIC: {
std::string name =
@ -276,13 +278,27 @@ void update_windows_color_profile_from_preferences()
auto gfxCs = cs->gfxColorSpace();
if (gfxCs->type() == gfx::ColorSpace::ICC &&
gfxCs->name() == name) {
system->setWindowsColorSpace(cs);
osCS = cs;
break;
}
}
break;
}
}
// Set the default color space for all windows (osCS can be nullptr
// which means that each window should use its monitor color space)
system->setWindowsColorSpace(osCS);
// Set the color space of all windows
for (ui::Widget* widget : manager->children()) {
ASSERT(widget->type() == ui::kWindowWidget);
auto window = static_cast<ui::Window*>(widget);
if (window->ownDisplay()) {
if (auto display = window->display())
display->nativeWindow()->setColorSpace(osCS);
}
}
}
static void load_gui_config(os::WindowSpec& spec, bool& maximized)