monitor-manager: Cache the last known value of "lid-is-closed"

Restarting UPower will make every property of UpClient emit a "notify"
signal (as a GDBusProxy would). Avoid mutter reconfiguring the displays
when upower restarts by caching the last known value of "lid-is-closed"
and only reconfiguring the displays if it actually changed.

This fixes a black out of the screen when UPower restarts.
This commit is contained in:
Bastien Nocera 2018-04-16 10:57:02 +02:00 committed by Jonas Ådahl
parent 644a618fb1
commit 49b23c7490
2 changed files with 9 additions and 1 deletions

View File

@ -180,6 +180,7 @@ struct _MetaMonitorManager
GnomePnpIds *pnp_ids;
UpClient *up_client;
gboolean lid_is_closed;
gulong experimental_features_changed_handler_id;

View File

@ -351,7 +351,13 @@ lid_is_closed_changed (UpClient *client,
gpointer user_data)
{
MetaMonitorManager *manager = user_data;
gboolean lid_is_closed;
lid_is_closed = up_client_get_lid_is_closed (manager->up_client);
if (lid_is_closed == manager->lid_is_closed)
return;
manager->lid_is_closed = lid_is_closed;
meta_monitor_manager_lid_is_closed_changed (manager);
}
@ -361,7 +367,7 @@ meta_monitor_manager_real_is_lid_closed (MetaMonitorManager *manager)
if (!manager->up_client)
return FALSE;
return up_client_get_lid_is_closed (manager->up_client);
return manager->lid_is_closed;
}
gboolean
@ -737,6 +743,7 @@ meta_monitor_manager_constructed (GObject *object)
{
g_signal_connect_object (manager->up_client, "notify::lid-is-closed",
G_CALLBACK (lid_is_closed_changed), manager, 0);
manager->lid_is_closed = up_client_get_lid_is_closed (manager->up_client);
}
}