[PATCH v6 RFC 08/10] ephyr: move host_has_extension() implementation to hostx.c

Laércio de Sousa laerciosousa at sme-mogidascruzes.sp.gov.br
Thu Sep 3 11:00:53 PDT 2015


This is a trivial patch that moves host_has_extension() implementation
from ephyr.c to hostx.c so that it can be called by hostx.c internal
functions. Also rename function to hostx_has_extension() for consistency.

Signed-off-by: Laércio de Sousa <laerciosousa at sme-mogidascruzes.sp.gov.br>
---
 hw/kdrive/ephyr/ephyr.c       | 12 +-----------
 hw/kdrive/ephyr/ephyrdriext.c |  4 ++--
 hw/kdrive/ephyr/ephyrglxext.c |  2 +-
 hw/kdrive/ephyr/hostx.c       | 16 ++++++++++++----
 hw/kdrive/ephyr/hostx.h       |  2 +-
 5 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index e6e72d3..1909a06 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -71,16 +71,6 @@ Bool EphyrWantResize = 0;
 Bool EphyrWantNoHostGrab = 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);
@@ -670,7 +660,7 @@ ephyrInitScreen(ScreenPtr pScreen)
     }
 #endif /*XV*/
 #ifdef XF86DRI
-    if (!ephyrNoDRI && !host_has_extension(&xcb_xf86dri_id)) {
+    if (!ephyrNoDRI && !hostx_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 748b608..3703adf 100644
--- a/hw/kdrive/ephyr/ephyrdriext.c
+++ b/hw/kdrive/ephyr/ephyrdriext.c
@@ -1321,12 +1321,12 @@ ephyrDRIExtensionInit(ScreenPtr a_screen)
     EphyrDRIScreenPrivPtr screen_priv = NULL;
 
     EPHYR_LOG("enter\n");
-    if (!host_has_extension(&xcb_xf86dri_id)) {
+    if (!hostx_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 (!host_has_extension(&xcb_shape_id)) {
+    if (!hostx_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 248689e..c6d1569 100644
--- a/hw/kdrive/ephyr/ephyrglxext.c
+++ b/hw/kdrive/ephyr/ephyrglxext.c
@@ -84,7 +84,7 @@ ephyrHijackGLXExtension(void)
 {
     const void *(*dispatch_functions)[2];
 
-    if (!host_has_extension(&xcb_glx_id)) {
+    if (!hostx_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 dc265d5..5406938 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -99,6 +99,16 @@ int ephyrResNameFromCmd = 0;
 char *ephyrTitle = NULL;
 Bool ephyr_glamor = FALSE;
 
+Bool
+hostx_has_extension(xcb_extension_t *extension)
+{
+    const xcb_query_extension_reply_t *rep;
+
+    rep = xcb_get_extension_data(HostX.conn, extension);
+
+    return rep && rep->present;
+}
+
 static void
  hostx_set_fullscreen_hint(void);
 
@@ -240,7 +250,7 @@ hostx_get_output_geometry(const char *output,
     xcb_randr_get_crtc_info_reply_t *crtc_info_r;
 
     /* First of all, check for extension */
-    if (!xcb_get_extension_data(HostX.conn, &xcb_randr_id)->present)
+    if (!hostx_has_extension(&xcb_randr_id))
     {
         fprintf(stderr, "\nHost X server does not support RANDR extension (or it's disabled).\n");
         exit(1);
@@ -422,7 +432,6 @@ hostx_init(void)
     char *tmpstr;
     char *class_hint;
     size_t class_len;
-    const xcb_query_extension_reply_t *shm_rep;
     xcb_screen_t *xscreen;
     xcb_rectangle_t rect = { 0, 0, 1, 1 };
 
@@ -632,8 +641,7 @@ hostx_init(void)
     }
 
     /* Try to get share memory ximages for a little bit more speed */
-    shm_rep = xcb_get_extension_data(HostX.conn, &xcb_shm_id);
-    if (!shm_rep || !shm_rep->present || getenv("XEPHYR_NO_SHM")) {
+    if (!hostx_has_extension(&xcb_shm_id) || getenv("XEPHYR_NO_SHM")) {
         fprintf(stderr, "\nXephyr unable to use SHM XImages\n");
         HostX.have_shm = FALSE;
     }
diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h
index 93aaa50..9299e8d 100644
--- a/hw/kdrive/ephyr/hostx.h
+++ b/hw/kdrive/ephyr/hostx.h
@@ -182,7 +182,7 @@ int hostx_set_window_geometry(int a_win, EphyrBox * a_geo);
 int hostx_set_window_bounding_rectangles(int a_window,
                                          EphyrRect * a_rects, int a_num_rects);
 
-int host_has_extension(xcb_extension_t *extension);
+int hostx_has_extension(xcb_extension_t *extension);
 
 #ifdef XF86DRI
 int hostx_lookup_peer_window(void *a_local_window,
-- 
2.5.0



More information about the xorg-devel mailing list