[mutter] Add method to show if in headless mode



commit 754c8345903a0d40fb9a0dacb3239a2207cff392
Author: Joan Torres <joan torres suse com>
Date:   Tue Dec 7 16:12:07 2021 +0100

    Add method to show if in headless mode
    
    MetaBackend can now show whether it is in headless mode or not
    using a vfunc is_headless.
    
    Fallback of is_headless returns FALSE.
    
    MetaBackendNative implements is_headless returning its
    is_headless property.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2130>

 src/backends/meta-backend-private.h       |  2 ++
 src/backends/meta-backend.c               | 13 +++++++++++++
 src/backends/native/meta-backend-native.c | 10 ++++++----
 src/backends/native/meta-backend-native.h |  2 --
 src/meta/meta-backend.h                   |  3 +++
 5 files changed, 24 insertions(+), 6 deletions(-)
---
diff --git a/src/backends/meta-backend-private.h b/src/backends/meta-backend-private.h
index 9c9df2cdd3..1930a1a331 100644
--- a/src/backends/meta-backend-private.h
+++ b/src/backends/meta-backend-private.h
@@ -106,6 +106,8 @@ struct _MetaBackendClass
 
   void (* set_pointer_constraint) (MetaBackend           *backend,
                                    MetaPointerConstraint *constraint);
+
+  gboolean (* is_headless) (MetaBackend *backend);
 };
 
 void meta_backend_destroy (MetaBackend *backend);
diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c
index c0b3e4b78b..77b99293e1 100644
--- a/src/backends/meta-backend.c
+++ b/src/backends/meta-backend.c
@@ -633,12 +633,24 @@ meta_backend_real_create_cursor_tracker (MetaBackend *backend)
                        NULL);
 }
 
+static gboolean
+meta_backend_real_is_headless (MetaBackend *backend)
+{
+  return FALSE;
+}
+
 gboolean
 meta_backend_is_lid_closed (MetaBackend *backend)
 {
   return META_BACKEND_GET_CLASS (backend)->is_lid_closed (backend);
 }
 
+gboolean
+meta_backend_is_headless (MetaBackend *backend)
+{
+  return META_BACKEND_GET_CLASS (backend)->is_headless (backend);
+}
+
 static void
 upower_properties_changed (GDBusProxy *proxy,
                            GVariant   *changed_properties,
@@ -859,6 +871,7 @@ meta_backend_class_init (MetaBackendClass *klass)
   klass->select_stage_events = meta_backend_real_select_stage_events;
   klass->is_lid_closed = meta_backend_real_is_lid_closed;
   klass->create_cursor_tracker = meta_backend_real_create_cursor_tracker;
+  klass->is_headless = meta_backend_real_is_headless;
 
   obj_props[PROP_CONTEXT] =
     g_param_spec_object ("context",
diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c
index fcb6b021aa..0cbe40d87d 100644
--- a/src/backends/native/meta-backend-native.c
+++ b/src/backends/native/meta-backend-native.c
@@ -130,7 +130,7 @@ meta_backend_native_create_default_seat (MetaBackend  *backend,
 
   seat_id = meta_backend_native_get_seat_id (backend_native);
 
-  if (meta_backend_native_is_headless (backend_native))
+  if (meta_backend_is_headless (backend))
     flags = META_SEAT_NATIVE_FLAG_NO_LIBINPUT;
   else
     flags = META_SEAT_NATIVE_FLAG_NONE;
@@ -378,10 +378,10 @@ meta_backend_native_get_seat_id (MetaBackendNative *backend_native)
     return meta_launcher_get_seat_id (backend_native->launcher);
 }
 
-gboolean
-meta_backend_native_is_headless (MetaBackendNative *backend_native)
+static gboolean
+meta_backend_native_is_headless (MetaBackend *backend)
 {
-  return backend_native->is_headless;
+  return META_BACKEND_NATIVE (backend)->is_headless;
 }
 
 static void
@@ -647,6 +647,8 @@ meta_backend_native_class_init (MetaBackendNativeClass *klass)
 
   backend_class->set_pointer_constraint = meta_backend_native_set_pointer_constraint;
 
+  backend_class->is_headless = meta_backend_native_is_headless;
+
   obj_props[PROP_HEADLESS] =
     g_param_spec_boolean ("headless",
                           "headless",
diff --git a/src/backends/native/meta-backend-native.h b/src/backends/native/meta-backend-native.h
index aad4c8413f..eac81acb0c 100644
--- a/src/backends/native/meta-backend-native.h
+++ b/src/backends/native/meta-backend-native.h
@@ -50,6 +50,4 @@ MetaKms * meta_backend_native_get_kms (MetaBackendNative *native);
 
 const char * meta_backend_native_get_seat_id (MetaBackendNative *backend_native);
 
-gboolean meta_backend_native_is_headless (MetaBackendNative *backend_native);
-
 #endif /* META_BACKEND_NATIVE_H */
diff --git a/src/meta/meta-backend.h b/src/meta/meta-backend.h
index 5b5a8c3511..cfb042a726 100644
--- a/src/meta/meta-backend.h
+++ b/src/meta/meta-backend.h
@@ -74,6 +74,9 @@ MetaRemoteAccessController * meta_backend_get_remote_access_controller (MetaBack
 META_EXPORT
 gboolean meta_backend_is_rendering_hardware_accelerated (MetaBackend *backend);
 
+META_EXPORT
+gboolean meta_backend_is_headless (MetaBackend *backend);
+
 META_EXPORT
 void meta_clutter_init (void);
 


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