|
|
a11c41 |
From 22c43422f83a69d7654953db368585f168952aab Mon Sep 17 00:00:00 2001
|
|
|
a11c41 |
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
|
|
|
a11c41 |
Date: Fri, 4 Feb 2022 11:45:53 +0100
|
|
|
a11c41 |
Subject: [PATCH] display: Only display configuration options if apply is
|
|
|
a11c41 |
allowed
|
|
|
a11c41 |
|
|
|
a11c41 |
org.gnome.Mutter.DisplayConfig contains a new property that tells
|
|
|
a11c41 |
whether apply will be allowed to be called or not. Whether it is true or
|
|
|
a11c41 |
not depends on policy stored in any of its monitors.xml configuration
|
|
|
a11c41 |
files.
|
|
|
a11c41 |
|
|
|
a11c41 |
In order to make it clearer that configuration is not possible, except
|
|
|
a11c41 |
for night light, make sure to hide the unconfigurable parts, leaving
|
|
|
a11c41 |
only night light.
|
|
|
a11c41 |
---
|
|
|
a11c41 |
.../display/cc-display-config-manager-dbus.c | 36 +++++++++++++++++++
|
|
|
a11c41 |
panels/display/cc-display-config-manager.c | 6 ++++
|
|
|
a11c41 |
panels/display/cc-display-config-manager.h | 3 ++
|
|
|
a11c41 |
panels/display/cc-display-panel.c | 23 ++++++++++++
|
|
|
a11c41 |
4 files changed, 68 insertions(+)
|
|
|
a11c41 |
|
|
|
a11c41 |
diff --git a/panels/display/cc-display-config-manager-dbus.c b/panels/display/cc-display-config-manager-dbus.c
|
|
|
a11c41 |
index 8912faaa8..7f85c3a01 100644
|
|
|
a11c41 |
--- a/panels/display/cc-display-config-manager-dbus.c
|
|
|
a11c41 |
+++ b/panels/display/cc-display-config-manager-dbus.c
|
|
|
a11c41 |
@@ -31,6 +31,8 @@ struct _CcDisplayConfigManagerDBus
|
|
|
a11c41 |
guint monitors_changed_id;
|
|
|
a11c41 |
|
|
|
a11c41 |
GVariant *current_state;
|
|
|
a11c41 |
+
|
|
|
a11c41 |
+ gboolean apply_allowed;
|
|
|
a11c41 |
};
|
|
|
a11c41 |
|
|
|
a11c41 |
G_DEFINE_TYPE (CcDisplayConfigManagerDBus,
|
|
|
a11c41 |
@@ -119,6 +121,8 @@ bus_gotten (GObject *object,
|
|
|
a11c41 |
CcDisplayConfigManagerDBus *self;
|
|
|
a11c41 |
GDBusConnection *connection;
|
|
|
a11c41 |
GError *error = NULL;
|
|
|
a11c41 |
+ g_autoptr(GDBusProxy) proxy = NULL;
|
|
|
a11c41 |
+ g_autoptr(GVariant) variant = NULL;
|
|
|
a11c41 |
|
|
|
a11c41 |
connection = g_bus_get_finish (result, &error);
|
|
|
a11c41 |
if (!connection)
|
|
|
a11c41 |
@@ -145,12 +149,35 @@ bus_gotten (GObject *object,
|
|
|
a11c41 |
monitors_changed,
|
|
|
a11c41 |
self,
|
|
|
a11c41 |
NULL);
|
|
|
a11c41 |
+
|
|
|
a11c41 |
+ proxy = g_dbus_proxy_new_sync (self->connection,
|
|
|
a11c41 |
+ G_DBUS_PROXY_FLAGS_NONE,
|
|
|
a11c41 |
+ NULL,
|
|
|
a11c41 |
+ "org.gnome.Mutter.DisplayConfig",
|
|
|
a11c41 |
+ "/org/gnome/Mutter/DisplayConfig",
|
|
|
a11c41 |
+ "org.gnome.Mutter.DisplayConfig",
|
|
|
a11c41 |
+ NULL,
|
|
|
a11c41 |
+ &error);
|
|
|
a11c41 |
+ if (!proxy)
|
|
|
a11c41 |
+ {
|
|
|
a11c41 |
+ g_warning ("Failed to create D-Bus proxy to \"org.gnome.Mutter.DisplayConfig\": %s",
|
|
|
a11c41 |
+ error->message);
|
|
|
a11c41 |
+ return;
|
|
|
a11c41 |
+ }
|
|
|
a11c41 |
+
|
|
|
a11c41 |
+ variant = g_dbus_proxy_get_cached_property (proxy, "ApplyMonitorsConfigAllowed");
|
|
|
a11c41 |
+ if (variant)
|
|
|
a11c41 |
+ self->apply_allowed = g_variant_get_boolean (variant);
|
|
|
a11c41 |
+ else
|
|
|
a11c41 |
+ g_warning ("Missing property 'ApplyMonitorsConfigAllowed' on DisplayConfig API");
|
|
|
a11c41 |
+
|
|
|
a11c41 |
get_current_state (self);
|
|
|
a11c41 |
}
|
|
|
a11c41 |
|
|
|
a11c41 |
static void
|
|
|
a11c41 |
cc_display_config_manager_dbus_init (CcDisplayConfigManagerDBus *self)
|
|
|
a11c41 |
{
|
|
|
a11c41 |
+ self->apply_allowed = TRUE;
|
|
|
a11c41 |
self->cancellable = g_cancellable_new ();
|
|
|
a11c41 |
g_bus_get (G_BUS_TYPE_SESSION, self->cancellable, bus_gotten, self);
|
|
|
a11c41 |
}
|
|
|
a11c41 |
@@ -172,6 +199,14 @@ cc_display_config_manager_dbus_finalize (GObject *object)
|
|
|
a11c41 |
G_OBJECT_CLASS (cc_display_config_manager_dbus_parent_class)->finalize (object);
|
|
|
a11c41 |
}
|
|
|
a11c41 |
|
|
|
a11c41 |
+static gboolean
|
|
|
a11c41 |
+cc_display_config_manager_dbus_get_apply_allowed (CcDisplayConfigManager *pself)
|
|
|
a11c41 |
+{
|
|
|
a11c41 |
+ CcDisplayConfigManagerDBus *self = CC_DISPLAY_CONFIG_MANAGER_DBUS (pself);
|
|
|
a11c41 |
+
|
|
|
a11c41 |
+ return self->apply_allowed;
|
|
|
a11c41 |
+}
|
|
|
a11c41 |
+
|
|
|
a11c41 |
static void
|
|
|
a11c41 |
cc_display_config_manager_dbus_class_init (CcDisplayConfigManagerDBusClass *klass)
|
|
|
a11c41 |
{
|
|
|
a11c41 |
@@ -181,6 +216,7 @@ cc_display_config_manager_dbus_class_init (CcDisplayConfigManagerDBusClass *klas
|
|
|
a11c41 |
gobject_class->finalize = cc_display_config_manager_dbus_finalize;
|
|
|
a11c41 |
|
|
|
a11c41 |
parent_class->get_current = cc_display_config_manager_dbus_get_current;
|
|
|
a11c41 |
+ parent_class->get_apply_allowed = cc_display_config_manager_dbus_get_apply_allowed;
|
|
|
a11c41 |
}
|
|
|
a11c41 |
|
|
|
a11c41 |
CcDisplayConfigManager *
|
|
|
a11c41 |
diff --git a/panels/display/cc-display-config-manager.c b/panels/display/cc-display-config-manager.c
|
|
|
a11c41 |
index 0da298a29..3d683c53d 100644
|
|
|
a11c41 |
--- a/panels/display/cc-display-config-manager.c
|
|
|
a11c41 |
+++ b/panels/display/cc-display-config-manager.c
|
|
|
a11c41 |
@@ -59,3 +59,9 @@ cc_display_config_manager_get_current (CcDisplayConfigManager *self)
|
|
|
a11c41 |
{
|
|
|
a11c41 |
return CC_DISPLAY_CONFIG_MANAGER_GET_CLASS (self)->get_current (self);
|
|
|
a11c41 |
}
|
|
|
a11c41 |
+
|
|
|
a11c41 |
+gboolean
|
|
|
a11c41 |
+cc_display_config_manager_get_apply_allowed (CcDisplayConfigManager *self)
|
|
|
a11c41 |
+{
|
|
|
a11c41 |
+ return CC_DISPLAY_CONFIG_MANAGER_GET_CLASS (self)->get_apply_allowed (self);
|
|
|
a11c41 |
+}
|
|
|
a11c41 |
diff --git a/panels/display/cc-display-config-manager.h b/panels/display/cc-display-config-manager.h
|
|
|
a11c41 |
index 134cea0a1..22c16758c 100644
|
|
|
a11c41 |
--- a/panels/display/cc-display-config-manager.h
|
|
|
a11c41 |
+++ b/panels/display/cc-display-config-manager.h
|
|
|
a11c41 |
@@ -35,10 +35,13 @@ struct _CcDisplayConfigManagerClass
|
|
|
a11c41 |
GObjectClass parent_class;
|
|
|
a11c41 |
|
|
|
a11c41 |
CcDisplayConfig * (*get_current) (CcDisplayConfigManager *self);
|
|
|
a11c41 |
+ gboolean (* get_apply_allowed) (CcDisplayConfigManager *self);
|
|
|
a11c41 |
};
|
|
|
a11c41 |
|
|
|
a11c41 |
CcDisplayConfig * cc_display_config_manager_get_current (CcDisplayConfigManager *self);
|
|
|
a11c41 |
|
|
|
a11c41 |
+gboolean cc_display_config_manager_get_apply_allowed (CcDisplayConfigManager *self);
|
|
|
a11c41 |
+
|
|
|
a11c41 |
void _cc_display_config_manager_emit_changed (CcDisplayConfigManager *self);
|
|
|
a11c41 |
|
|
|
a11c41 |
G_END_DECLS
|
|
|
a11c41 |
diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c
|
|
|
a11c41 |
index 0b4fa193d..1b0db8321 100644
|
|
|
a11c41 |
--- a/panels/display/cc-display-panel.c
|
|
|
a11c41 |
+++ b/panels/display/cc-display-panel.c
|
|
|
a11c41 |
@@ -1245,6 +1245,22 @@ make_output_ui (CcDisplayPanel *panel)
|
|
|
a11c41 |
return listbox;
|
|
|
a11c41 |
}
|
|
|
a11c41 |
|
|
|
a11c41 |
+static GtkWidget *
|
|
|
a11c41 |
+make_night_light_only_ui (CcDisplayPanel *panel)
|
|
|
a11c41 |
+{
|
|
|
a11c41 |
+ CcDisplayPanelPrivate *priv = panel->priv;
|
|
|
a11c41 |
+ GtkWidget *vbox;
|
|
|
a11c41 |
+
|
|
|
a11c41 |
+ priv->rows_size_group = gtk_size_group_new (GTK_SIZE_GROUP_BOTH);
|
|
|
a11c41 |
+
|
|
|
a11c41 |
+ vbox = make_main_vbox (priv->main_size_group);
|
|
|
a11c41 |
+
|
|
|
a11c41 |
+ gtk_container_add (GTK_CONTAINER (vbox), make_night_light_widget (panel));
|
|
|
a11c41 |
+
|
|
|
a11c41 |
+ g_clear_object (&priv->rows_size_group);
|
|
|
a11c41 |
+ return make_scrollable (vbox);
|
|
|
a11c41 |
+}
|
|
|
a11c41 |
+
|
|
|
a11c41 |
static GtkWidget *
|
|
|
a11c41 |
make_single_output_ui (CcDisplayPanel *panel)
|
|
|
a11c41 |
{
|
|
|
a11c41 |
@@ -2097,6 +2113,12 @@ on_screen_changed (CcDisplayPanel *panel)
|
|
|
a11c41 |
if (!priv->current_config)
|
|
|
a11c41 |
goto show_error;
|
|
|
a11c41 |
|
|
|
a11c41 |
+ if (!cc_display_config_manager_get_apply_allowed (priv->manager))
|
|
|
a11c41 |
+ {
|
|
|
a11c41 |
+ main_widget = make_night_light_only_ui (panel);
|
|
|
a11c41 |
+ goto show_main_widget;
|
|
|
a11c41 |
+ }
|
|
|
a11c41 |
+
|
|
|
a11c41 |
ensure_monitor_labels (panel);
|
|
|
a11c41 |
|
|
|
a11c41 |
if (!priv->current_output)
|
|
|
a11c41 |
@@ -2121,6 +2143,7 @@ on_screen_changed (CcDisplayPanel *panel)
|
|
|
a11c41 |
main_widget = make_multi_output_ui (panel);
|
|
|
a11c41 |
}
|
|
|
a11c41 |
|
|
|
a11c41 |
+ show_main_widget:
|
|
|
a11c41 |
gtk_widget_show_all (main_widget);
|
|
|
a11c41 |
gtk_stack_add_named (GTK_STACK (priv->stack), main_widget, "main");
|
|
|
a11c41 |
gtk_stack_set_visible_child (GTK_STACK (priv->stack), main_widget);
|
|
|
a11c41 |
--
|
|
|
a11c41 |
2.33.1
|
|
|
a11c41 |
|