[PATCH 02/17] ephyr: Expose a single function for detecting extensions.

Eric Anholt eric at anholt.net
Mon Aug 26 13:26:08 PDT 2013


Signed-off-by: Eric Anholt <eric at anholt.net>
---
 hw/kdrive/ephyr/ephyr.c       | 15 ++++++++++++++-
 hw/kdrive/ephyr/ephyrdriext.c |  7 +++++--
 hw/kdrive/ephyr/ephyrglxext.c |  3 ++-
 hw/kdrive/ephyr/hostx.c       | 29 -----------------------------
 hw/kdrive/ephyr/hostx.h       |  3 ++-
 5 files changed, 23 insertions(+), 34 deletions(-)

diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index b34b5cc..cd2cae1 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -26,6 +26,9 @@
 #ifdef HAVE_CONFIG_H
 #include <kdrive-config.h>
 #endif
+
+#include <xcb/xf86dri.h>
+
 #include "ephyr.h"
 
 #include "inputstr.h"
@@ -59,6 +62,16 @@ Bool EphyrWantGrayScale = 0;
 Bool EphyrWantResize = 0;
 
 Bool
+host_has_extension(xcb_extension_t *extension)
+{
+    const xcb_query_extension_reply_t *rep;
+
+    rep = xcb_get_extension_data(hostx_get_xcbconn(), extension);
+
+    return rep && rep->present;
+}
+
+Bool
 ephyrInitialize(KdCardInfo * card, EphyrPriv * priv)
 {
     OsSignal(SIGUSR1, hostx_handle_signal);
@@ -657,7 +670,7 @@ ephyrInitScreen(ScreenPtr pScreen)
     }
 #endif /*XV*/
 #ifdef XF86DRI
-    if (!ephyrNoDRI && !hostx_has_dri()) {
+    if (!ephyrNoDRI && !host_has_extension(&xcb_xf86dri_id)) {
         EPHYR_LOG("host x does not support DRI. Disabling DRI forwarding\n");
         ephyrNoDRI = TRUE;
     }
diff --git a/hw/kdrive/ephyr/ephyrdriext.c b/hw/kdrive/ephyr/ephyrdriext.c
index 617ffb1..13df60a 100644
--- a/hw/kdrive/ephyr/ephyrdriext.c
+++ b/hw/kdrive/ephyr/ephyrdriext.c
@@ -39,6 +39,9 @@
 #define _XF86DRI_SERVER_
 #include <X11/dri/xf86dri.h>
 #include <X11/dri/xf86driproto.h>
+#include <xcb/xcb.h>
+#include <xcb/shape.h>
+#include <xcb/xf86dri.h>
 #include "misc.h"
 #include "privates.h"
 #include "dixstruct.h"
@@ -1319,12 +1322,12 @@ ephyrDRIExtensionInit(ScreenPtr a_screen)
     EphyrDRIScreenPrivPtr screen_priv = NULL;
 
     EPHYR_LOG("enter\n");
-    if (!hostx_has_dri()) {
+    if (!host_has_extension(&xcb_xf86dri_id)) {
         EPHYR_LOG("host does not have DRI extension\n");
         goto out;
     }
     EPHYR_LOG("host X does have DRI extension\n");
-    if (!hostx_has_xshape()) {
+    if (!host_has_extension(&xcb_shape_id)) {
         EPHYR_LOG("host does not have XShape extension\n");
         goto out;
     }
diff --git a/hw/kdrive/ephyr/ephyrglxext.c b/hw/kdrive/ephyr/ephyrglxext.c
index 1231b0d..632a9c4 100644
--- a/hw/kdrive/ephyr/ephyrglxext.c
+++ b/hw/kdrive/ephyr/ephyrglxext.c
@@ -29,6 +29,7 @@
 #include <kdrive-config.h>
 #endif
 
+#include <xcb/glx.h>
 #include "extnsionst.h"
 #include "ephyrglxext.h"
 #include "ephyrhostglx.h"
@@ -83,7 +84,7 @@ ephyrHijackGLXExtension(void)
 {
     const void *(*dispatch_functions)[2];
 
-    if (!hostx_has_glx()) {
+    if (!host_has_extension(&xcb_glx_id)) {
         EPHYR_LOG("host X does not have GLX\n");
         return FALSE;
     }
diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 97b2dc0..3715956 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -1390,15 +1390,6 @@ out:
     return is_ok;
 }
 
-int
-hostx_has_xshape(void)
-{
-    const xcb_query_extension_reply_t *rep;
-
-    rep = xcb_get_extension_data(HostX.conn, &xcb_shape_id);
-    return rep && rep->present;
-}
-
 #ifdef XF86DRI
 typedef struct {
     int is_valid;
@@ -1471,24 +1462,4 @@ hostx_get_resource_id_peer(int a_local_resource_id, int *a_remote_resource_id)
     return FALSE;
 }
 
-int
-hostx_has_dri(void)
-{
-    const xcb_query_extension_reply_t *dri;
-
-    dri = xcb_get_extension_data(HostX.conn, &xcb_xf86dri_id);
-
-    return dri && dri->present;
-}
-
-int
-hostx_has_glx(void)
-{
-    const xcb_query_extension_reply_t *glx;
-
-    glx = xcb_get_extension_data(HostX.conn, &xcb_glx_id);
-
-    return glx && glx->present;
-}
-
 #endif                          /* XF86DRI */
diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h
index 3276eb1..625ca8a 100644
--- a/hw/kdrive/ephyr/hostx.h
+++ b/hw/kdrive/ephyr/hostx.h
@@ -233,7 +233,8 @@ int hostx_set_window_bounding_rectangles(int a_window,
 
 int hostx_set_window_clipping_rectangles(int a_window,
                                          EphyrRect * a_rects, int a_num_rects);
-int hostx_has_xshape(void);
+
+int host_has_extension(xcb_extension_t *extension);
 
 #ifdef XF86DRI
 int hostx_lookup_peer_window(void *a_local_window,
-- 
1.8.4.rc3



More information about the xorg-devel mailing list