From 18d836f6dde46bcac8b794d34f76032688c28851 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 18 Aug 2013 14:12:45 +0200 Subject: [PATCH] ephyr: Expose a single function for detecting extensions. v2: Fix trying to include xcb-dri in the non-dri-build case (Noted by Julien) Signed-off-by: Eric Anholt Reviewed-by: Julien Cristau --- hw/kdrive/ephyr/ephyr.c | 14 +++++++++++++- 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, 22 insertions(+), 34 deletions(-) diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index b34b5cc5c..003ef2101 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -26,6 +26,7 @@ #ifdef HAVE_CONFIG_H #include #endif + #include "ephyr.h" #include "inputstr.h" @@ -33,6 +34,7 @@ #include "ephyrlog.h" #ifdef XF86DRI +#include #include "ephyrdri.h" #include "ephyrdriext.h" #include "ephyrglxext.h" @@ -58,6 +60,16 @@ typedef struct _EphyrInputPrivate { 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) { @@ -657,7 +669,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 617ffb158..13df60a5b 100644 --- a/hw/kdrive/ephyr/ephyrdriext.c +++ b/hw/kdrive/ephyr/ephyrdriext.c @@ -39,6 +39,9 @@ #define _XF86DRI_SERVER_ #include #include +#include +#include +#include #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 1231b0d9d..632a9c474 100644 --- a/hw/kdrive/ephyr/ephyrglxext.c +++ b/hw/kdrive/ephyr/ephyrglxext.c @@ -29,6 +29,7 @@ #include #endif +#include #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 97b2dc0c5..3715956bd 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 3276eb11f..625ca8a93 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,