[metacity] compositor: check for required extensions



commit aace82d5ebfb31c1009f4cb8e0c32af208717bea
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Fri Mar 10 22:44:12 2017 +0200

    compositor: check for required extensions

 src/compositor/meta-compositor-private.h |    9 ++++++---
 src/compositor/meta-compositor-vulkan.c  |    3 +++
 src/compositor/meta-compositor-xrender.c |   19 +++++++++++++++++++
 src/compositor/meta-compositor.c         |   27 +++++++++++++++++++++++++++
 4 files changed, 55 insertions(+), 3 deletions(-)
---
diff --git a/src/compositor/meta-compositor-private.h b/src/compositor/meta-compositor-private.h
index 73904d5..feef60f 100644
--- a/src/compositor/meta-compositor-private.h
+++ b/src/compositor/meta-compositor-private.h
@@ -77,10 +77,13 @@ struct _MetaCompositorClass
                                                 Window              xwindow);
 };
 
-gboolean     meta_compositor_set_selection (MetaCompositor  *compositor,
-                                            GError         **error);
+gboolean     meta_compositor_check_extensions (MetaCompositor  *compositor,
+                                               GError         **error);
 
-MetaDisplay *meta_compositor_get_display   (MetaCompositor  *compositor);
+gboolean     meta_compositor_set_selection    (MetaCompositor  *compositor,
+                                               GError         **error);
+
+MetaDisplay *meta_compositor_get_display      (MetaCompositor  *compositor);
 
 G_END_DECLS
 
diff --git a/src/compositor/meta-compositor-vulkan.c b/src/compositor/meta-compositor-vulkan.c
index 798aa8f..39e954d 100644
--- a/src/compositor/meta-compositor-vulkan.c
+++ b/src/compositor/meta-compositor-vulkan.c
@@ -499,6 +499,9 @@ meta_compositor_vulkan_manage (MetaCompositor  *compositor,
 
   vulkan = META_COMPOSITOR_VULKAN (compositor);
 
+  if (!meta_compositor_check_extensions (compositor, error))
+    return FALSE;
+
   enumerate_instance_layers (vulkan);
   enumerate_instance_extensions (vulkan);
 
diff --git a/src/compositor/meta-compositor-xrender.c b/src/compositor/meta-compositor-xrender.c
index 14fc845..1a2c4bd 100644
--- a/src/compositor/meta-compositor-xrender.c
+++ b/src/compositor/meta-compositor-xrender.c
@@ -2630,6 +2630,25 @@ meta_compositor_xrender_manage (MetaCompositor  *compositor,
   int screen_number = meta_screen_get_screen_number (screen);
   Window xroot = meta_screen_get_xroot (screen);
 
+  if (!meta_compositor_check_extensions (compositor, error))
+    return FALSE;
+
+  if (!display->have_render)
+    {
+      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+                   "Missing render extension required for compositing");
+
+      return FALSE;
+    }
+
+  if (!display->have_xfixes)
+    {
+      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+                   "Missing xfixes extension required for compositing");
+
+      return FALSE;
+    }
+
   if (!meta_compositor_set_selection (compositor, error))
     return FALSE;
 
diff --git a/src/compositor/meta-compositor.c b/src/compositor/meta-compositor.c
index a9014f8..1c7f5c0 100644
--- a/src/compositor/meta-compositor.c
+++ b/src/compositor/meta-compositor.c
@@ -379,6 +379,33 @@ meta_compositor_is_our_xwindow (MetaCompositor *compositor,
 }
 
 gboolean
+meta_compositor_check_extensions (MetaCompositor  *compositor,
+                                  GError         **error)
+{
+  MetaCompositorPrivate *priv;
+
+  priv = meta_compositor_get_instance_private (compositor);
+
+  if (!priv->display->have_composite)
+    {
+      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+                   "Missing composite extension required for compositing");
+
+      return FALSE;
+    }
+
+  if (!priv->display->have_damage)
+    {
+      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+                   "Missing damage extension required for compositing");
+
+      return FALSE;
+    }
+
+  return TRUE;
+}
+
+gboolean
 meta_compositor_set_selection (MetaCompositor  *compositor,
                                GError         **error)
 {


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