[mutter/wip/up-client-cleanups: 135/136] backend: Move lid-is-closed handling to MetaBackend



commit 951219650f8d8553d08e02210f46965f4ca6542f
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Apr 16 20:07:45 2018 +0200

    backend: Move lid-is-closed handling to MetaBackend
    
    Rather than handle UpClient in both MetaBackend (to reset the idletime
    when the lid is opened), and in MetaMonitorManager and
    MetaMonitorConfigManager (to turn the screen under the lid on/off
    depending on its status), move the ability to get the lid status from
    UPower or mock it in one place, in MetaBackend.

 src/backends/meta-backend-private.h         |  5 ++
 src/backends/meta-backend.c                 | 89 +++++++++++++++++++++++------
 src/backends/meta-monitor-config-manager.c  | 18 ++++--
 src/backends/meta-monitor-manager-private.h |  7 ---
 src/backends/meta-monitor-manager.c         | 53 ++++-------------
 src/tests/meta-backend-test.c               | 18 ++++++
 src/tests/meta-backend-test.h               |  3 +
 src/tests/meta-monitor-manager-test.c       | 17 ------
 src/tests/meta-monitor-manager-test.h       |  3 -
 src/tests/monitor-unit-tests.c              | 41 +++++--------
 10 files changed, 137 insertions(+), 117 deletions(-)
---
diff --git a/src/backends/meta-backend-private.h b/src/backends/meta-backend-private.h
index a25275499..cd532ae48 100644
--- a/src/backends/meta-backend-private.h
+++ b/src/backends/meta-backend-private.h
@@ -29,6 +29,7 @@
 #include <glib-object.h>
 
 #include <xkbcommon/xkbcommon.h>
+#include <libupower-glib/upower.h>
 
 #include <meta/meta-backend.h>
 #include <meta/meta-idle-monitor.h>
@@ -84,6 +85,8 @@ struct _MetaBackendClass
                        const char  *variants,
                        const char  *options);
 
+  gboolean (* is_lid_closed) (MetaBackend *backend);
+
   struct xkb_keymap * (* get_keymap) (MetaBackend *backend);
 
   xkb_layout_index_t (* get_keymap_layout_group) (MetaBackend *backend);
@@ -144,6 +147,8 @@ struct xkb_keymap * meta_backend_get_keymap (MetaBackend *backend);
 
 xkb_layout_index_t meta_backend_get_keymap_layout_group (MetaBackend *backend);
 
+gboolean meta_backend_is_lid_closed (MetaBackend *backend);
+
 void meta_backend_update_last_device (MetaBackend *backend,
                                       int          device_id);
 
diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c
index 9348aa1bb..c61fc5880 100644
--- a/src/backends/meta-backend.c
+++ b/src/backends/meta-backend.c
@@ -58,6 +58,7 @@ enum
   KEYMAP_CHANGED,
   KEYMAP_LAYOUT_GROUP_CHANGED,
   LAST_DEVICE_CHANGED,
+  LID_IS_CLOSED_CHANGED,
 
   N_SIGNALS
 };
@@ -112,6 +113,8 @@ struct _MetaBackendPrivate
   MetaDnd *dnd;
 
   UpClient *up_client;
+  gboolean lid_is_closed;
+
   guint sleep_signal_id;
   GCancellable *cancellable;
   GDBusConnection *system_bus;
@@ -141,7 +144,7 @@ meta_backend_finalize (GObject *object)
   g_clear_object (&priv->dbus_session_watcher);
 #endif
 
-  g_object_unref (priv->up_client);
+  g_clear_object (&priv->up_client);
   if (priv->sleep_signal_id)
     g_dbus_connection_signal_unsubscribe (priv->system_bus, priv->sleep_signal_id);
   g_cancellable_cancel (priv->cancellable);
@@ -503,6 +506,66 @@ meta_backend_real_get_relative_motion_deltas (MetaBackend *backend,
   return FALSE;
 }
 
+static gboolean
+meta_backend_real_is_lid_closed (MetaBackend *backend)
+{
+  MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
+
+  if (!priv->up_client)
+    return FALSE;
+
+  return priv->lid_is_closed;
+}
+
+gboolean
+meta_backend_is_lid_closed (MetaBackend *backend)
+{
+  return META_BACKEND_GET_CLASS (backend)->is_lid_closed (backend);
+}
+
+static void
+lid_is_closed_changed_cb (UpClient   *client,
+                          GParamSpec *pspec,
+                          gpointer    user_data)
+{
+  MetaBackend *backend = user_data;
+  MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
+  gboolean lid_is_closed;
+
+  lid_is_closed = up_client_get_lid_is_closed (priv->up_client);
+  if (lid_is_closed == priv->lid_is_closed)
+    return;
+
+  priv->lid_is_closed = lid_is_closed;
+  g_signal_emit (backend, signals[LID_IS_CLOSED_CHANGED], 0,
+                 priv->lid_is_closed);
+
+  if (lid_is_closed)
+    return;
+
+  meta_idle_monitor_reset_idletime (meta_idle_monitor_get_core ());
+}
+
+static void
+meta_backend_constructed (GObject *object)
+{
+  MetaBackend *backend = META_BACKEND (object);
+  MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
+  MetaBackendClass *backend_class =
+   META_BACKEND_GET_CLASS (backend);
+
+  if (backend_class->is_lid_closed != meta_backend_real_is_lid_closed)
+    return;
+
+  priv->up_client = up_client_new ();
+  if (priv->up_client)
+    {
+      g_signal_connect (priv->up_client, "notify::lid-is-closed",
+                        G_CALLBACK (lid_is_closed_changed_cb), NULL);
+      priv->lid_is_closed = up_client_get_lid_is_closed (priv->up_client);
+    }
+}
+
 static void
 meta_backend_class_init (MetaBackendClass *klass)
 {
@@ -510,6 +573,7 @@ meta_backend_class_init (MetaBackendClass *klass)
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
   object_class->finalize = meta_backend_finalize;
+  object_class->constructed = meta_backend_constructed;
 
   klass->post_init = meta_backend_real_post_init;
   klass->create_cursor_renderer = meta_backend_real_create_cursor_renderer;
@@ -517,6 +581,7 @@ meta_backend_class_init (MetaBackendClass *klass)
   klass->ungrab_device = meta_backend_real_ungrab_device;
   klass->select_stage_events = meta_backend_real_select_stage_events;
   klass->get_relative_motion_deltas = meta_backend_real_get_relative_motion_deltas;
+  klass->is_lid_closed = meta_backend_real_is_lid_closed;
 
   signals[KEYMAP_CHANGED] =
     g_signal_new ("keymap-changed",
@@ -539,6 +604,13 @@ meta_backend_class_init (MetaBackendClass *klass)
                   0,
                   NULL, NULL, NULL,
                   G_TYPE_NONE, 1, G_TYPE_INT);
+  signals[LID_IS_CLOSED_CHANGED] =
+    g_signal_new ("lid-is-closed-changed",
+                  G_TYPE_FROM_CLASS (object_class),
+                  G_SIGNAL_RUN_LAST,
+                  0,
+                  NULL, NULL, NULL,
+                  G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
 
   mutter_stage_views = g_getenv ("MUTTER_STAGE_VIEWS");
   stage_views_disabled = g_strcmp0 (mutter_stage_views, "0") == 0;
@@ -562,17 +634,6 @@ meta_backend_create_renderer (MetaBackend *backend,
   return META_BACKEND_GET_CLASS (backend)->create_renderer (backend, error);
 }
 
-static void
-lid_is_closed_changed_cb (UpClient   *client,
-                          GParamSpec *pspec,
-                          gpointer    user_data)
-{
-  if (up_client_get_lid_is_closed (client))
-    return;
-
-  meta_idle_monitor_reset_idletime (meta_idle_monitor_get_core ());
-}
-
 static void
 prepare_for_sleep_cb (GDBusConnection *connection,
                       const gchar     *sender_name,
@@ -643,10 +704,6 @@ meta_backend_initable_init (GInitable     *initable,
 
   priv->dnd = g_object_new (META_TYPE_DND, NULL);
 
-  priv->up_client = up_client_new ();
-  g_signal_connect (priv->up_client, "notify::lid-is-closed",
-                    G_CALLBACK (lid_is_closed_changed_cb), NULL);
-
   priv->cancellable = g_cancellable_new ();
   g_bus_get (G_BUS_TYPE_SYSTEM,
              priv->cancellable,
diff --git a/src/backends/meta-monitor-config-manager.c b/src/backends/meta-monitor-config-manager.c
index 197892bf2..67e7791f0 100644
--- a/src/backends/meta-monitor-config-manager.c
+++ b/src/backends/meta-monitor-config-manager.c
@@ -23,6 +23,7 @@
 
 #include "backends/meta-monitor-config-manager.h"
 
+#include "backends/meta-backend-private.h"
 #include "backends/meta-monitor-config-migration.h"
 #include "backends/meta-monitor-config-store.h"
 #include "backends/meta-monitor-manager-private.h"
@@ -326,6 +327,15 @@ meta_monitor_config_manager_assign (MetaMonitorManager *manager,
   return TRUE;
 }
 
+static gboolean
+is_lid_closed (MetaMonitorManager *monitor_manager)
+{
+    MetaBackend *backend;
+
+    backend = meta_monitor_manager_get_backend (monitor_manager);
+    return meta_backend_is_lid_closed (backend);
+}
+
 MetaMonitorsConfigKey *
 meta_create_monitors_config_key_for_current_state (MetaMonitorManager *monitor_manager)
 {
@@ -340,7 +350,7 @@ meta_create_monitors_config_key_for_current_state (MetaMonitorManager *monitor_m
       MetaMonitorSpec *monitor_spec;
 
       if (meta_monitor_is_laptop_panel (monitor) &&
-          meta_monitor_manager_is_lid_closed (monitor_manager))
+          is_lid_closed (monitor_manager))
         continue;
 
       monitor_spec = meta_monitor_spec_clone (meta_monitor_get_spec (monitor));
@@ -455,7 +465,7 @@ find_primary_monitor (MetaMonitorManager *monitor_manager)
 {
   MetaMonitor *monitor;
 
-  if (meta_monitor_manager_is_lid_closed (monitor_manager))
+  if (is_lid_closed (monitor_manager))
     {
       monitor = meta_monitor_manager_get_primary_monitor (monitor_manager);
       if (monitor && !meta_monitor_is_laptop_panel (monitor))
@@ -598,7 +608,7 @@ meta_monitor_config_manager_create_linear (MetaMonitorConfigManager *config_mana
         continue;
 
       if (meta_monitor_is_laptop_panel (monitor) &&
-          meta_monitor_manager_is_lid_closed (monitor_manager))
+          is_lid_closed (monitor_manager))
         continue;
 
       logical_monitor_config =
@@ -1252,7 +1262,7 @@ meta_monitors_config_new (MetaMonitorManager           *monitor_manager,
       MetaMonitor *monitor = l->data;
       MetaMonitorSpec *monitor_spec;
 
-      if (meta_monitor_manager_is_lid_closed (monitor_manager) &&
+      if (is_lid_closed (monitor_manager) &&
           meta_monitor_is_laptop_panel (monitor))
         continue;
 
diff --git a/src/backends/meta-monitor-manager-private.h b/src/backends/meta-monitor-manager-private.h
index 80802c477..811200ab8 100644
--- a/src/backends/meta-monitor-manager-private.h
+++ b/src/backends/meta-monitor-manager-private.h
@@ -37,7 +37,6 @@
 
 #include <cogl/cogl.h>
 #include <libgnome-desktop/gnome-pnp-ids.h>
-#include <libupower-glib/upower.h>
 
 #include "display-private.h"
 #include "stack-tracker.h"
@@ -179,8 +178,6 @@ struct _MetaMonitorManager
   MetaMonitorConfigManager *config_manager;
 
   GnomePnpIds *pnp_ids;
-  UpClient *up_client;
-  gboolean lid_is_closed;
 
   gulong experimental_features_changed_handler_id;
 
@@ -196,8 +193,6 @@ struct _MetaMonitorManagerClass
   GBytes* (*read_edid) (MetaMonitorManager *,
                         MetaOutput         *);
 
-  gboolean (*is_lid_closed) (MetaMonitorManager *);
-
   void (*ensure_initial_config) (MetaMonitorManager *);
 
   gboolean (*apply_monitors_config) (MetaMonitorManager      *,
@@ -336,8 +331,6 @@ void               meta_monitor_manager_update_logical_state (MetaMonitorManager
 void               meta_monitor_manager_update_logical_state_derived (MetaMonitorManager *manager,
                                                                       MetaMonitorsConfig *config);
 
-gboolean           meta_monitor_manager_is_lid_closed (MetaMonitorManager *manager);
-
 void               meta_monitor_manager_lid_is_closed_changed (MetaMonitorManager *manager);
 
 gboolean           meta_monitor_manager_is_headless (MetaMonitorManager *manager);
diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c
index a6c7f9a0d..610499f1c 100644
--- a/src/backends/meta-monitor-manager.c
+++ b/src/backends/meta-monitor-manager.c
@@ -36,6 +36,7 @@
 #include "util-private.h"
 #include <meta/meta-x11-errors.h>
 #include "edid.h"
+#include "backends/meta-backend-private.h"
 #include "backends/meta-crtc.h"
 #include "backends/meta-logical-monitor.h"
 #include "backends/meta-monitor.h"
@@ -346,36 +347,14 @@ meta_monitor_manager_lid_is_closed_changed (MetaMonitorManager *manager)
 }
 
 static void
-lid_is_closed_changed (UpClient   *client,
-                       GParamSpec *pspec,
-                       gpointer    user_data)
+lid_is_closed_changed (MetaBackend *backend,
+                       gboolean     lid_is_closed,
+                       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);
 }
 
-static gboolean
-meta_monitor_manager_real_is_lid_closed (MetaMonitorManager *manager)
-{
-  if (!manager->up_client)
-    return FALSE;
-
-  return manager->lid_is_closed;
-}
-
-gboolean
-meta_monitor_manager_is_lid_closed (MetaMonitorManager *manager)
-{
-  return META_MONITOR_MANAGER_GET_CLASS (manager)->is_lid_closed (manager);
-}
-
 gboolean
 meta_monitor_manager_is_headless (MetaMonitorManager *manager)
 {
@@ -725,8 +704,6 @@ static void
 meta_monitor_manager_constructed (GObject *object)
 {
   MetaMonitorManager *manager = META_MONITOR_MANAGER (object);
-  MetaMonitorManagerClass *manager_class =
-    META_MONITOR_MANAGER_GET_CLASS (manager);
   MetaBackend *backend = manager->backend;
   MetaSettings *settings = meta_backend_get_settings (backend);
 
@@ -736,17 +713,6 @@ meta_monitor_manager_constructed (GObject *object)
                       G_CALLBACK (experimental_features_changed),
                       manager);
 
-  if (manager_class->is_lid_closed == meta_monitor_manager_real_is_lid_closed)
-    {
-      manager->up_client = up_client_new ();
-      if (manager->up_client)
-        {
-          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);
-        }
-    }
-
   g_signal_connect_object (manager, "notify::power-save-mode",
                            G_CALLBACK (power_save_mode_changed), manager, 0);
 
@@ -755,6 +721,11 @@ meta_monitor_manager_constructed (GObject *object)
                            G_CALLBACK (orientation_changed),
                            manager, 0);
 
+  g_signal_connect_object (backend,
+                           "lid-is-closed-changed",
+                           G_CALLBACK (lid_is_closed_changed),
+                           manager, 0);
+
   manager->current_switch_config = META_MONITOR_SWITCH_CONFIG_UNKNOWN;
 
   initialize_dbus_interface (manager);
@@ -786,7 +757,6 @@ meta_monitor_manager_dispose (GObject *object)
     }
 
   g_clear_object (&manager->config_manager);
-  g_clear_object (&manager->up_client);
 
   G_OBJECT_CLASS (meta_monitor_manager_parent_class)->dispose (object);
 }
@@ -854,7 +824,6 @@ meta_monitor_manager_class_init (MetaMonitorManagerClass *klass)
 
   klass->get_edid_file = meta_monitor_manager_real_get_edid_file;
   klass->read_edid = meta_monitor_manager_real_read_edid;
-  klass->is_lid_closed = meta_monitor_manager_real_is_lid_closed;
 
   signals[MONITORS_CHANGED_INTERNAL] =
     g_signal_new ("monitors-changed-internal",
@@ -1592,7 +1561,7 @@ meta_monitor_manager_is_config_applicable (MetaMonitorManager *manager,
             }
 
           if (meta_monitor_is_laptop_panel (monitor) &&
-              meta_monitor_manager_is_lid_closed (manager))
+              meta_backend_is_lid_closed (manager->backend))
             {
               g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
                            "Refusing to activate a closed laptop panel");
@@ -2994,7 +2963,7 @@ meta_monitor_manager_switch_config (MetaMonitorManager          *manager,
 gboolean
 meta_monitor_manager_can_switch_config (MetaMonitorManager *manager)
 {
-  return (!meta_monitor_manager_is_lid_closed (manager) &&
+  return (!meta_backend_is_lid_closed (manager->backend) &&
           g_list_length (manager->monitors) > 1);
 }
 
diff --git a/src/tests/meta-backend-test.c b/src/tests/meta-backend-test.c
index 57a946739..5da9da07f 100644
--- a/src/tests/meta-backend-test.c
+++ b/src/tests/meta-backend-test.c
@@ -26,10 +26,27 @@
 struct _MetaBackendTest
 {
   MetaBackendX11Nested parent;
+
+  gboolean is_lid_closed;
 };
 
 G_DEFINE_TYPE (MetaBackendTest, meta_backend_test, META_TYPE_BACKEND_X11_NESTED)
 
+void
+meta_backend_test_set_is_lid_closed (MetaBackendTest *backend_test,
+                                     gboolean         is_lid_closed)
+{
+  backend_test->is_lid_closed = is_lid_closed;
+}
+
+static gboolean
+meta_backend_test_is_lid_closed (MetaBackend *backend)
+{
+  MetaBackendTest *backend_test = META_BACKEND_TEST (backend);
+
+  return backend_test->is_lid_closed;
+}
+
 static void
 meta_backend_test_init (MetaBackendTest *backend_test)
 {
@@ -50,4 +67,5 @@ meta_backend_test_class_init (MetaBackendTestClass *klass)
   MetaBackendClass *backend_class = META_BACKEND_CLASS (klass);
 
   backend_class->create_monitor_manager = meta_backend_test_create_monitor_manager;
+  backend_class->is_lid_closed = meta_backend_test_is_lid_closed;
 }
diff --git a/src/tests/meta-backend-test.h b/src/tests/meta-backend-test.h
index 4ac04e0f4..25cb8e6ee 100644
--- a/src/tests/meta-backend-test.h
+++ b/src/tests/meta-backend-test.h
@@ -26,4 +26,7 @@
 G_DECLARE_FINAL_TYPE (MetaBackendTest, meta_backend_test,
                       META, BACKEND_TEST, MetaBackendX11Nested)
 
+void meta_backend_test_set_is_lid_closed (MetaBackendTest *backend_test,
+                                          gboolean         is_lid_closed);
+
 #endif /* META_BACKEND_TEST_H */
diff --git a/src/tests/meta-monitor-manager-test.c b/src/tests/meta-monitor-manager-test.c
index 953d87192..d1b729c8a 100644
--- a/src/tests/meta-monitor-manager-test.c
+++ b/src/tests/meta-monitor-manager-test.c
@@ -33,7 +33,6 @@ struct _MetaMonitorManagerTest
 
   MetaGpu *gpu;
 
-  gboolean is_lid_closed;
   gboolean handles_transforms;
 
   int tiled_monitor_count;
@@ -81,13 +80,6 @@ meta_monitor_manager_test_emulate_hotplug (MetaMonitorManagerTest *manager_test,
   g_free (old_test_setup);
 }
 
-void
-meta_monitor_manager_test_set_is_lid_closed (MetaMonitorManagerTest *manager_test,
-                                             gboolean                is_lid_closed)
-{
-  manager_test->is_lid_closed = is_lid_closed;
-}
-
 void
 meta_monitor_manager_test_set_handles_transforms (MetaMonitorManagerTest *manager_test,
                                                   gboolean                handles_transforms)
@@ -127,14 +119,6 @@ meta_monitor_manager_test_read_current (MetaMonitorManager *manager)
                          manager_test->test_setup->outputs);
 }
 
-static gboolean
-meta_monitor_manager_test_is_lid_closed (MetaMonitorManager *manager)
-{
-  MetaMonitorManagerTest *manager_test = META_MONITOR_MANAGER_TEST (manager);
-
-  return manager_test->is_lid_closed;
-}
-
 static void
 meta_monitor_manager_test_ensure_initial_config (MetaMonitorManager *manager)
 {
@@ -496,7 +480,6 @@ meta_monitor_manager_test_class_init (MetaMonitorManagerTestClass *klass)
 
   object_class->dispose = meta_monitor_manager_test_dispose;
 
-  manager_class->is_lid_closed = meta_monitor_manager_test_is_lid_closed;
   manager_class->ensure_initial_config = meta_monitor_manager_test_ensure_initial_config;
   manager_class->apply_monitors_config = meta_monitor_manager_test_apply_monitors_config;
   manager_class->tiled_monitor_added = meta_monitor_manager_test_tiled_monitor_added;
diff --git a/src/tests/meta-monitor-manager-test.h b/src/tests/meta-monitor-manager-test.h
index 29dfa82a2..a38c7f198 100644
--- a/src/tests/meta-monitor-manager-test.h
+++ b/src/tests/meta-monitor-manager-test.h
@@ -49,9 +49,6 @@ MetaGpu * meta_monitor_manager_test_get_gpu (MetaMonitorManagerTest *manager_tes
 void meta_monitor_manager_test_emulate_hotplug (MetaMonitorManagerTest *manager_test,
                                                 MetaMonitorTestSetup   *test_setup);
 
-void meta_monitor_manager_test_set_is_lid_closed (MetaMonitorManagerTest *manager_test,
-                                                  gboolean                is_lid_closed);
-
 void meta_monitor_manager_test_set_handles_transforms (MetaMonitorManagerTest *manager_test,
                                                        gboolean                handles_transforms);
 
diff --git a/src/tests/monitor-unit-tests.c b/src/tests/monitor-unit-tests.c
index a9cb2e24f..9c1285858 100644
--- a/src/tests/monitor-unit-tests.c
+++ b/src/tests/monitor-unit-tests.c
@@ -28,6 +28,7 @@
 #include "backends/meta-monitor-config-migration.h"
 #include "backends/meta-monitor-config-store.h"
 #include "backends/meta-output.h"
+#include "meta-backend-test.h"
 #include "tests/meta-monitor-manager-test.h"
 #include "tests/monitor-test-utils.h"
 #include "tests/test-utils.h"
@@ -2351,15 +2352,13 @@ meta_test_monitor_lid_switch_config (void)
   MetaBackend *backend = meta_get_backend ();
   MetaMonitorManager *monitor_manager =
     meta_backend_get_monitor_manager (backend);
-  MetaMonitorManagerTest *monitor_manager_test =
-    META_MONITOR_MANAGER_TEST (monitor_manager);
 
   test_setup = create_monitor_test_setup (&test_case,
                                           MONITOR_TEST_FLAG_NO_STORED);
   emulate_hotplug (test_setup);
   check_monitor_configuration (&test_case);
 
-  meta_monitor_manager_test_set_is_lid_closed (monitor_manager_test, TRUE);
+  meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), TRUE);
   meta_monitor_manager_lid_is_closed_changed (monitor_manager);
 
   test_case.expect.logical_monitors[0] = (MonitorTestCaseLogicalMonitor) {
@@ -2375,7 +2374,7 @@ meta_test_monitor_lid_switch_config (void)
 
   check_monitor_configuration (&test_case);
 
-  meta_monitor_manager_test_set_is_lid_closed (monitor_manager_test, FALSE);
+  meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), FALSE);
   meta_monitor_manager_lid_is_closed_changed (monitor_manager);
 
   test_case.expect.logical_monitors[0] = (MonitorTestCaseLogicalMonitor) {
@@ -2524,17 +2523,15 @@ meta_test_monitor_lid_opened_config (void)
   MetaBackend *backend = meta_get_backend ();
   MetaMonitorManager *monitor_manager =
     meta_backend_get_monitor_manager (backend);
-  MetaMonitorManagerTest *monitor_manager_test =
-    META_MONITOR_MANAGER_TEST (monitor_manager);
 
   test_setup = create_monitor_test_setup (&test_case,
                                           MONITOR_TEST_FLAG_NO_STORED);
-  meta_monitor_manager_test_set_is_lid_closed (monitor_manager_test, TRUE);
+  meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), TRUE);
 
   emulate_hotplug (test_setup);
   check_monitor_configuration (&test_case);
 
-  meta_monitor_manager_test_set_is_lid_closed (monitor_manager_test, FALSE);
+  meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), FALSE);
   meta_monitor_manager_lid_is_closed_changed (monitor_manager);
 
   test_case.expect.n_logical_monitors = 2;
@@ -2630,14 +2627,10 @@ meta_test_monitor_lid_closed_no_external (void)
   };
   MetaMonitorTestSetup *test_setup;
   MetaBackend *backend = meta_get_backend ();
-  MetaMonitorManager *monitor_manager =
-    meta_backend_get_monitor_manager (backend);
-  MetaMonitorManagerTest *monitor_manager_test =
-    META_MONITOR_MANAGER_TEST (monitor_manager);
 
   test_setup = create_monitor_test_setup (&test_case,
                                           MONITOR_TEST_FLAG_NO_STORED);
-  meta_monitor_manager_test_set_is_lid_closed (monitor_manager_test, TRUE);
+  meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), TRUE);
 
   emulate_hotplug (test_setup);
   check_monitor_configuration (&test_case);
@@ -2770,10 +2763,6 @@ meta_test_monitor_lid_closed_with_hotplugged_external (void)
   };
   MetaMonitorTestSetup *test_setup;
   MetaBackend *backend = meta_get_backend ();
-  MetaMonitorManager *monitor_manager =
-    meta_backend_get_monitor_manager (backend);
-  MetaMonitorManagerTest *monitor_manager_test =
-    META_MONITOR_MANAGER_TEST (monitor_manager);
 
   /*
    * The first part of this test emulate the following:
@@ -2784,7 +2773,7 @@ meta_test_monitor_lid_closed_with_hotplugged_external (void)
 
   test_setup = create_monitor_test_setup (&test_case,
                                           MONITOR_TEST_FLAG_NO_STORED);
-  meta_monitor_manager_test_set_is_lid_closed (monitor_manager_test, FALSE);
+  meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), FALSE);
 
   emulate_hotplug (test_setup);
   check_monitor_configuration (&test_case);
@@ -2813,7 +2802,7 @@ meta_test_monitor_lid_closed_with_hotplugged_external (void)
 
   test_setup = create_monitor_test_setup (&test_case,
                                           MONITOR_TEST_FLAG_NO_STORED);
-  meta_monitor_manager_test_set_is_lid_closed (monitor_manager_test, TRUE);
+  meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), TRUE);
   emulate_hotplug (test_setup);
   check_monitor_configuration (&test_case);
 
@@ -2836,7 +2825,7 @@ meta_test_monitor_lid_closed_with_hotplugged_external (void)
 
   test_setup = create_monitor_test_setup (&test_case,
                                           MONITOR_TEST_FLAG_NO_STORED);
-  meta_monitor_manager_test_set_is_lid_closed (monitor_manager_test, FALSE);
+  meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), FALSE);
   emulate_hotplug (test_setup);
   check_monitor_configuration (&test_case);
 
@@ -2862,7 +2851,7 @@ meta_test_monitor_lid_closed_with_hotplugged_external (void)
 
   test_setup = create_monitor_test_setup (&test_case,
                                           MONITOR_TEST_FLAG_NO_STORED);
-  meta_monitor_manager_test_set_is_lid_closed (monitor_manager_test, TRUE);
+  meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), TRUE);
   emulate_hotplug (test_setup);
   check_monitor_configuration (&test_case);
 
@@ -2870,7 +2859,7 @@ meta_test_monitor_lid_closed_with_hotplugged_external (void)
 
   test_setup = create_monitor_test_setup (&test_case,
                                           MONITOR_TEST_FLAG_NO_STORED);
-  meta_monitor_manager_test_set_is_lid_closed (monitor_manager_test, FALSE);
+  meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), FALSE);
   emulate_hotplug (test_setup);
   check_monitor_configuration (&test_case);
 }
@@ -5357,10 +5346,6 @@ meta_test_monitor_custom_lid_switch_config (void)
   };
   MetaMonitorTestSetup *test_setup;
   MetaBackend *backend = meta_get_backend ();
-  MetaMonitorManager *monitor_manager =
-    meta_backend_get_monitor_manager (backend);
-  MetaMonitorManagerTest *monitor_manager_test =
-    META_MONITOR_MANAGER_TEST (monitor_manager);
 
   test_setup = create_monitor_test_setup (&test_case,
                                           MONITOR_TEST_FLAG_NONE);
@@ -5399,7 +5384,7 @@ meta_test_monitor_custom_lid_switch_config (void)
   test_case.expect.logical_monitors[0].transform = META_MONITOR_TRANSFORM_90;
   test_case.expect.n_logical_monitors = 1;
   test_case.expect.screen_width = 768;
-  meta_monitor_manager_test_set_is_lid_closed (monitor_manager_test, TRUE);
+  meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), TRUE);
 
   test_setup = create_monitor_test_setup (&test_case,
                                           MONITOR_TEST_FLAG_NONE);
@@ -5420,7 +5405,7 @@ meta_test_monitor_custom_lid_switch_config (void)
   test_case.expect.logical_monitors[1].transform = META_MONITOR_TRANSFORM_270;
   test_case.expect.n_logical_monitors = 2;
   test_case.expect.screen_width = 1024 + 768;
-  meta_monitor_manager_test_set_is_lid_closed (monitor_manager_test, FALSE);
+  meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), FALSE);
 
   test_setup = create_monitor_test_setup (&test_case,
                                           MONITOR_TEST_FLAG_NONE);


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