summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2020-06-11 16:20:22 +0200
committerCarlos Garnacho <carlosg@gnome.org>2020-09-05 08:03:44 +0000
commit6782bc07dbdf2fc9490193aaf784eb3aa709dd26 (patch)
tree2a669efcc2abc1f1c14f4571f603a4f1820f4252
parentc89f5ca5262bc8bb738fee0de5546471012ebf0f (diff)
downloadgnome-control-center-6782bc07dbdf2fc9490193aaf784eb3aa709dd26.tar.gz
display: Hook to PanelOrientationManaged for accelerometer checks
This property gives means for Mutter to determine who is in charge of display rotation for the built-in panel (us or Mutter). The UI must reflect this change. Fixes: https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/1018
-rw-r--r--panels/display/cc-display-panel.c112
1 files changed, 13 insertions, 99 deletions
diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c
index b30ff3652..dfca98cc6 100644
--- a/panels/display/cc-display-panel.c
+++ b/panels/display/cc-display-panel.c
@@ -82,10 +82,6 @@ struct _CcDisplayPanel
GDBusProxy *shell_proxy;
- guint sensor_watch_id;
- GDBusProxy *iio_sensor_proxy;
- gboolean has_accelerometer;
-
gchar *main_title;
GtkWidget *main_titlebar;
GtkWidget *apply_titlebar;
@@ -405,14 +401,6 @@ cc_display_panel_dispose (GObject *object)
reset_titlebar (CC_DISPLAY_PANEL (object));
- if (self->sensor_watch_id > 0)
- {
- g_bus_unwatch_name (self->sensor_watch_id);
- self->sensor_watch_id = 0;
- }
-
- g_clear_object (&self->iio_sensor_proxy);
-
if (self->focus_id)
{
self->focus_id = 0;
@@ -858,6 +846,13 @@ rebuild_ui (CcDisplayPanel *panel)
}
static void
+update_panel_orientation_managed (CcDisplayPanel *panel,
+ gboolean managed)
+{
+ cc_display_settings_set_has_accelerometer (panel->settings, managed);
+}
+
+static void
reset_current_config (CcDisplayPanel *panel)
{
CcDisplayConfig *current;
@@ -874,6 +869,12 @@ reset_current_config (CcDisplayPanel *panel)
cc_display_config_set_minimum_size (current, MINIMUM_WIDTH, MINIMUM_HEIGHT);
panel->current_config = current;
+ g_signal_connect_object (current, "panel-orientation-managed",
+ G_CALLBACK (update_panel_orientation_managed), panel,
+ G_CONNECT_SWAPPED);
+ update_panel_orientation_managed (panel,
+ cc_display_config_get_panel_orientation_managed (current));
+
g_list_store_remove_all (panel->primary_display_list);
gtk_list_store_clear (panel->output_selection_list);
@@ -1069,85 +1070,6 @@ shell_proxy_ready (GObject *source,
}
static void
-update_has_accel (CcDisplayPanel *self)
-{
- g_autoptr(GVariant) v = NULL;
-
- if (self->iio_sensor_proxy == NULL)
- {
- g_debug ("Has no accelerometer");
- self->has_accelerometer = FALSE;
- cc_display_settings_set_has_accelerometer (self->settings, self->has_accelerometer);
- return;
- }
-
- v = g_dbus_proxy_get_cached_property (self->iio_sensor_proxy, "HasAccelerometer");
- if (v)
- {
- self->has_accelerometer = g_variant_get_boolean (v);
- }
- else
- {
- self->has_accelerometer = FALSE;
- }
-
- cc_display_settings_set_has_accelerometer (self->settings, self->has_accelerometer);
-
- g_debug ("Has %saccelerometer", self->has_accelerometer ? "" : "no ");
-}
-
-static void
-sensor_proxy_properties_changed_cb (CcDisplayPanel *self,
- GVariant *changed_properties,
- GStrv invalidated_properties)
-{
- GVariantDict dict;
-
- g_variant_dict_init (&dict, changed_properties);
-
- if (g_variant_dict_contains (&dict, "HasAccelerometer"))
- update_has_accel (self);
-}
-
-static void
-sensor_proxy_appeared_cb (GDBusConnection *connection,
- const gchar *name,
- const gchar *name_owner,
- gpointer user_data)
-{
- CcDisplayPanel *self = user_data;
-
- g_debug ("SensorProxy appeared");
-
- self->iio_sensor_proxy = g_dbus_proxy_new_sync (connection,
- G_DBUS_PROXY_FLAGS_NONE,
- NULL,
- "net.hadess.SensorProxy",
- "/net/hadess/SensorProxy",
- "net.hadess.SensorProxy",
- NULL,
- NULL);
- g_return_if_fail (self->iio_sensor_proxy);
-
- g_signal_connect_object (self->iio_sensor_proxy, "g-properties-changed",
- G_CALLBACK (sensor_proxy_properties_changed_cb), self, G_CONNECT_SWAPPED);
- update_has_accel (self);
-}
-
-static void
-sensor_proxy_vanished_cb (GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
-{
- CcDisplayPanel *self = user_data;
-
- g_debug ("SensorProxy vanished");
-
- g_clear_object (&self->iio_sensor_proxy);
- update_has_accel (self);
-}
-
-static void
session_bus_ready (GObject *source,
GAsyncResult *res,
CcDisplayPanel *self)
@@ -1249,14 +1171,6 @@ cc_display_panel_init (CcDisplayPanel *self)
(GAsyncReadyCallback) session_bus_ready,
self);
- self->sensor_watch_id = g_bus_watch_name (G_BUS_TYPE_SYSTEM,
- "net.hadess.SensorProxy",
- G_BUS_NAME_WATCHER_FLAGS_NONE,
- sensor_proxy_appeared_cb,
- sensor_proxy_vanished_cb,
- self,
- NULL);
-
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_resource (provider, "/org/gnome/control-center/display/display-arrangement.css");
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),