[mutter] color-device: Maybe update brightness from profile when updating



commit b7d3c9e3c53717ac8365d7ad879b68df42071c54
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Mon Dec 6 11:51:22 2021 +0100

    color-device: Maybe update brightness from profile when updating
    
    Some profiles have brightness metadata that also needs to be applied.
    Make sure this happens.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>

 src/backends/meta-color-device.c  | 20 ++++++++++++++++++--
 src/backends/meta-color-device.h  |  4 ++--
 src/backends/meta-color-manager.c |  6 +++---
 3 files changed, 23 insertions(+), 7 deletions(-)
---
diff --git a/src/backends/meta-color-device.c b/src/backends/meta-color-device.c
index 5192a7b1fd..3bfe776a27 100644
--- a/src/backends/meta-color-device.c
+++ b/src/backends/meta-color-device.c
@@ -1087,8 +1087,8 @@ meta_color_device_get_assigned_profile (MetaColorDevice *color_device)
 }
 
 void
-meta_color_device_update_gamma (MetaColorDevice *color_device,
-                                unsigned int     temperature)
+meta_color_device_update (MetaColorDevice *color_device,
+                          unsigned int     temperature)
 {
   MetaColorProfile *color_profile;
   MetaMonitor *monitor;
@@ -1111,6 +1111,22 @@ meta_color_device_update_gamma (MetaColorDevice *color_device,
               meta_color_profile_get_id (color_profile),
               temperature);
 
+  if (meta_monitor_is_laptop_panel (monitor))
+    {
+      const char *brightness_profile;
+
+      brightness_profile =
+        meta_color_profile_get_brightness_profile (color_profile);
+      if (brightness_profile)
+        {
+          meta_topic (META_DEBUG_COLOR,
+                      "Setting brightness to %s%% from brightness profile",
+                      brightness_profile);
+          meta_color_manager_set_brightness (color_device->color_manager,
+                                             atoi (brightness_profile));
+        }
+    }
+
   lut_size = meta_monitor_get_gamma_lut_size (monitor);
   lut = meta_color_profile_generate_gamma_lut (color_profile,
                                                temperature,
diff --git a/src/backends/meta-color-device.h b/src/backends/meta-color-device.h
index 450513e51d..bbf2cea6d7 100644
--- a/src/backends/meta-color-device.h
+++ b/src/backends/meta-color-device.h
@@ -62,7 +62,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_gamma (MetaColorDevice *color_device,
-                                     unsigned int     temperature);
+void meta_color_device_update (MetaColorDevice *color_device,
+                               unsigned int     temperature);
 
 #endif /* META_COLOR_DEVICE_H */
diff --git a/src/backends/meta-color-manager.c b/src/backends/meta-color-manager.c
index 94d06b3eda..6702e34ffe 100644
--- a/src/backends/meta-color-manager.c
+++ b/src/backends/meta-color-manager.c
@@ -109,7 +109,7 @@ on_device_ready (MetaColorDevice  *color_device,
       return;
     }
 
-  meta_color_device_update_gamma (color_device, priv->temperature);
+  meta_color_device_update (color_device, priv->temperature);
 }
 
 static void
@@ -119,7 +119,7 @@ on_device_changed (MetaColorDevice  *color_device,
   MetaColorManagerPrivate *priv =
     meta_color_manager_get_instance_private (color_manager);
 
-  meta_color_device_update_gamma (color_device, priv->temperature);
+  meta_color_device_update (color_device, priv->temperature);
 }
 
 static char *
@@ -282,7 +282,7 @@ update_all_gamma (MetaColorManager *color_manager)
       if (!meta_color_device_is_ready (color_device))
           continue;
 
-      meta_color_device_update_gamma (color_device, priv->temperature);
+      meta_color_device_update (color_device, priv->temperature);
     }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]