1
0
Fork 0

color-device: Get temperature from the manager

Instead of passing it to the update function. This decouples the
updating from being specifically about the temperature/white point.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3904>
This commit is contained in:
Sebastian Wick 2024-07-16 19:44:45 +02:00
parent 682ce3222c
commit 8eeec32c90
4 changed files with 21 additions and 14 deletions

View file

@ -1226,12 +1226,13 @@ meta_color_device_get_assigned_profile (MetaColorDevice *color_device)
}
void
meta_color_device_update (MetaColorDevice *color_device,
unsigned int temperature)
meta_color_device_update (MetaColorDevice *color_device)
{
MetaColorManager *color_manager = color_device->color_manager;
MetaColorProfile *color_profile;
MetaMonitor *monitor;
size_t lut_size;
unsigned int temperature;
color_profile = meta_color_device_get_assigned_profile (color_device);
if (!color_profile)
@ -1241,6 +1242,8 @@ meta_color_device_update (MetaColorDevice *color_device,
if (!meta_monitor_is_active (monitor))
return;
temperature = meta_color_manager_get_temperature (color_manager);
meta_topic (META_DEBUG_COLOR,
"Updating device '%s' (%s) using color profile '%s' "
"and temperature %uK",
@ -1260,7 +1263,7 @@ meta_color_device_update (MetaColorDevice *color_device,
meta_topic (META_DEBUG_COLOR,
"Setting brightness to %s%% from brightness profile",
brightness_profile);
meta_color_manager_set_brightness (color_device->color_manager,
meta_color_manager_set_brightness (color_manager,
atoi (brightness_profile));
}
}

View file

@ -61,8 +61,7 @@ MetaColorProfile * meta_color_device_generate_profile_finish (MetaColorDevice *
META_EXPORT_TEST
gboolean meta_color_device_is_ready (MetaColorDevice *color_device);
void meta_color_device_update (MetaColorDevice *color_device,
unsigned int temperature);
void meta_color_device_update (MetaColorDevice *color_device);
META_EXPORT_TEST
void meta_set_color_efivar_test_path (const char *path);

View file

@ -40,3 +40,5 @@ META_EXPORT_TEST
int meta_color_manager_get_num_color_devices (MetaColorManager *color_manager);
cmsContext meta_color_manager_get_lcms_context (MetaColorManager *color_manager);
unsigned int meta_color_manager_get_temperature (MetaColorManager *color_manager);

View file

@ -108,9 +108,6 @@ on_device_ready (MetaColorDevice *color_device,
gboolean success,
MetaColorManager *color_manager)
{
MetaColorManagerPrivate *priv =
meta_color_manager_get_instance_private (color_manager);
if (!success)
{
meta_topic (META_DEBUG_COLOR, "Color device '%s' failed to become ready",
@ -118,17 +115,14 @@ on_device_ready (MetaColorDevice *color_device,
return;
}
meta_color_device_update (color_device, priv->temperature);
meta_color_device_update (color_device);
}
static void
on_device_changed (MetaColorDevice *color_device,
MetaColorManager *color_manager)
{
MetaColorManagerPrivate *priv =
meta_color_manager_get_instance_private (color_manager);
meta_color_device_update (color_device, priv->temperature);
meta_color_device_update (color_device);
}
static void
@ -261,7 +255,7 @@ update_device_properties (MetaColorManager *color_manager)
if (!meta_color_device_is_ready (color_device))
continue;
meta_color_device_update (color_device, priv->temperature);
meta_color_device_update (color_device);
}
}
@ -598,6 +592,15 @@ meta_color_manager_get_lcms_context (MetaColorManager *color_manager)
return priv->lcms_context;
}
unsigned int
meta_color_manager_get_temperature (MetaColorManager *color_manager)
{
MetaColorManagerPrivate *priv =
meta_color_manager_get_instance_private (color_manager);
return priv->temperature;
}
void
meta_color_manager_set_brightness (MetaColorManager *color_manager,
int brightness)