Fix auto-brightness with gnome-shell 49.x
Related: https://issues.redhat.com/browse/RHEL-144940
This commit is contained in:
parent
5a4e7411c7
commit
0ae217ea4c
@ -0,0 +1,98 @@
|
||||
From d1507341dab832e78ba4d6961f8cd24ee265023f Mon Sep 17 00:00:00 2001
|
||||
From: Carlos Garnacho <carlosg@gnome.org>
|
||||
Date: Mon, 24 Nov 2025 17:19:45 +0100
|
||||
Subject: [PATCH] power: Trigger re-normalization on out-of-band brightness
|
||||
changes
|
||||
|
||||
When brightness is auto-managed by ALS, we still have two situations
|
||||
where the brightness changes do not come from it:
|
||||
|
||||
- User changes to the display brightness, either through keybindings,
|
||||
or the sliders in the shell menu being changed.
|
||||
- Dimming requests on user inactivity.
|
||||
|
||||
The response to both should be similar, the abrupt brightness change
|
||||
can alter ALS readings, so the brightness resulting of the change must
|
||||
be used as a new baseline for normalization.
|
||||
|
||||
Tracking of user-triggered changes is done through a new BrightnessChanged
|
||||
signal in the org.gnome.Shell.Brightness D-Bus interface. This will do
|
||||
nothing on older versions of GNOME Shell without the signal, so effectively
|
||||
brightness changes would not trigger a re-normalization there, as before.
|
||||
If the signal exists and is emitted, then it will be used.
|
||||
|
||||
(cherry picked from commit 5af04e7742701849e4f1ac04b340a3acf3a3345f)
|
||||
---
|
||||
plugins/power/gsd-power-manager.c | 27 +++++++++++++++++++++------
|
||||
1 file changed, 21 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
|
||||
index b7b5b642..bfbf0071 100644
|
||||
--- a/plugins/power/gsd-power-manager.c
|
||||
+++ b/plugins/power/gsd-power-manager.c
|
||||
@@ -1237,19 +1237,19 @@ shell_brightness_set_dimming_cb (GObject *source_object,
|
||||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
+ GsdPowerManager *manager = user_data;
|
||||
g_autoptr (GVariant) result = NULL;
|
||||
g_autoptr (GError) error = NULL;
|
||||
- gboolean enable = !!GPOINTER_TO_UINT (user_data);
|
||||
|
||||
result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object),
|
||||
res,
|
||||
&error);
|
||||
- if (result)
|
||||
+ if (result) {
|
||||
+ manager->ambient_norm_required = TRUE;
|
||||
return;
|
||||
+ }
|
||||
|
||||
- g_warning ("couldn't %s dimming: %s",
|
||||
- enable ? "enable" : "disable",
|
||||
- error->message);
|
||||
+ g_warning ("couldn't change dimming: %s", error->message);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1265,7 +1265,7 @@ shell_brightness_set_dimming (GsdPowerManager *manager,
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
-1, NULL,
|
||||
shell_brightness_set_dimming_cb,
|
||||
- GUINT_TO_POINTER (enable));
|
||||
+ manager);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2987,6 +2987,16 @@ iio_proxy_vanished_cb (GDBusConnection *connection,
|
||||
g_clear_object (&manager->iio_proxy);
|
||||
}
|
||||
|
||||
+static void
|
||||
+on_brightness_changed_by_user (GsdPowerManager *manager)
|
||||
+{
|
||||
+ /* Brightness was changed by the user, we need a new baseline
|
||||
+ * for the normalization being applied.
|
||||
+ */
|
||||
+ g_debug ("User brightness change detected, re-normalizing");
|
||||
+ manager->ambient_norm_required = TRUE;
|
||||
+}
|
||||
+
|
||||
gboolean
|
||||
gsd_power_manager_start (GsdPowerManager *manager,
|
||||
GError **error)
|
||||
@@ -3132,6 +3142,11 @@ gsd_power_manager_start (GsdPowerManager *manager,
|
||||
g_clear_error (error);
|
||||
}
|
||||
|
||||
+ g_signal_connect_swapped (manager->shell_brightness_proxy,
|
||||
+ "g-signal::BrightnessChanged",
|
||||
+ G_CALLBACK (on_brightness_changed_by_user),
|
||||
+ manager);
|
||||
+
|
||||
manager->devices_array = g_ptr_array_new_with_free_func (g_object_unref);
|
||||
manager->devices_notified_ht = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free, NULL);
|
||||
--
|
||||
2.52.0
|
||||
|
||||
@ -40,6 +40,9 @@ Patch2: subman-delay-startup-notification-by-30min.patch
|
||||
# https://issues.redhat.com/browse/RHEL-124242
|
||||
Patch3: use-shell-brightness.patch
|
||||
|
||||
# https://issues.redhat.com/browse/RHEL-144940
|
||||
Patch4: 0001-power-Trigger-re-normalization-on-out-of-band-bright.patch
|
||||
|
||||
BuildRequires: gcc
|
||||
BuildRequires: gettext
|
||||
BuildRequires: meson >= 0.49.0
|
||||
|
||||
Loading…
Reference in New Issue
Block a user