diff --git a/hw/kdrive/ephyr/ephyrdriext.c b/hw/kdrive/ephyr/ephyrdriext.c index 41a1f4b85..26c792d52 100644 --- a/hw/kdrive/ephyr/ephyrdriext.c +++ b/hw/kdrive/ephyr/ephyrdriext.c @@ -136,6 +136,16 @@ ephyrDRIExtensionInit (ScreenPtr a_screen) EphyrDRIScreenPrivPtr screen_priv=NULL ; EPHYR_LOG ("enter\n") ; + if (!hostx_has_dri ()) { + EPHYR_LOG ("host does not have DRI extension\n") ; + goto out ; + } + EPHYR_LOG ("host X does have DRI extension\n") ; + if (!hostx_has_xshape ()) { + EPHYR_LOG ("host does not have XShape extension\n") ; + goto out ; + } + EPHYR_LOG ("host X does have XShape extension\n") ; #ifdef XF86DRI_EVENTS EventType = CreateNewResourceType (XF86DRIFreeEvents); diff --git a/hw/kdrive/ephyr/ephyrglxext.c b/hw/kdrive/ephyr/ephyrglxext.c index 27b2a2dc3..47c4fb1c8 100644 --- a/hw/kdrive/ephyr/ephyrglxext.c +++ b/hw/kdrive/ephyr/ephyrglxext.c @@ -81,7 +81,12 @@ ephyrHijackGLXExtension (void) { const void *(*dispatch_functions)[2]; - EPHYR_LOG ("going to hijack some glx entry points ...\n") ; + if (!hostx_has_glx ()) { + EPHYR_LOG ("host X does not have GLX\n") ; + return FALSE ; + } + EPHYR_LOG ("host X does have GLX\n") ; + if (!Single_dispatch_info.dispatch_functions) { EPHYR_LOG_ERROR ("could not get dispatch functions table\n") ; return FALSE ; diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index dd988dc69..0ef1a6283 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -23,6 +23,10 @@ * PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include +#endif + #include "hostx.h" #include @@ -41,8 +45,17 @@ #include #include #include +#ifdef XEPHYR_DRI +#include +#endif /*XEPHYR_DRI*/ #include "ephyrlog.h" +#ifdef XEPHYR_DRI +extern Bool XF86DRIQueryExtension (Display *dpy, + int *event_basep, + int *error_basep); +#endif + /* * All xlib calls go here, which gets built as its own .a . * Mixing kdrive and xlib headers causes all sorts of types @@ -1070,68 +1083,6 @@ typedef struct { #define RESOURCE_PEERS_SIZE 1024*10 static ResourcePair resource_peers[RESOURCE_PEERS_SIZE] ; -int -hostx_allocate_resource_id_peer (int a_local_resource_id, - int *a_remote_resource_id) -{ - int i=0 ; - ResourcePair *peer=NULL ; - Display *dpy=hostx_get_display (); - - /* - * first make sure a resource peer - * does not exist already for - * a_local_resource_id - */ - for (i=0; iremote_id = XAllocID (dpy); - peer->local_id = a_local_resource_id ; - peer->is_valid = TRUE ; - } - } - if (peer) { - *a_remote_resource_id = peer->remote_id ; - return TRUE ; - } - return FALSE ; -} - -int -hostx_get_resource_id_peer (int a_local_resource_id, - int *a_remote_resource_id) -{ - int i=0 ; - ResourcePair *peer=NULL ; - for (i=0; iremote_id ; - return TRUE ; - } - return FALSE ; -} int hostx_create_window (EphyrBox *a_geometry, @@ -1289,3 +1240,108 @@ hostx_set_window_clipping_rectangles (int a_window, return is_ok; } +int +hostx_has_xshape (void) +{ + int event_base=0, error_base=0 ; + Display *dpy=hostx_get_display () ; + if (!XShapeQueryExtension (dpy, + &event_base, + &error_base)) { + return FALSE ; + } + return TRUE; +} + +#ifdef XEPHYR_DRI +int +hostx_allocate_resource_id_peer (int a_local_resource_id, + int *a_remote_resource_id) +{ + int i=0 ; + ResourcePair *peer=NULL ; + Display *dpy=hostx_get_display (); + + /* + * first make sure a resource peer + * does not exist already for + * a_local_resource_id + */ + for (i=0; iremote_id = XAllocID (dpy); + peer->local_id = a_local_resource_id ; + peer->is_valid = TRUE ; + } + } + if (peer) { + *a_remote_resource_id = peer->remote_id ; + return TRUE ; + } + return FALSE ; +} + +int +hostx_get_resource_id_peer (int a_local_resource_id, + int *a_remote_resource_id) +{ + int i=0 ; + ResourcePair *peer=NULL ; + for (i=0; iremote_id ; + return TRUE ; + } + return FALSE ; +} + +int +hostx_has_dri (void) +{ + int event_base=0, error_base=0 ; + Display *dpy=hostx_get_display () ; + + if (!XF86DRIQueryExtension (dpy, + &event_base, + &error_base)) { + return FALSE ; + } + return TRUE ; +} + +int +hostx_has_glx (void) +{ + Display *dpy=hostx_get_display () ; + int event_base=0, error_base=0 ; + + if (!glXQueryExtension (dpy, &event_base, &error_base)) { + return FALSE ; + } + return TRUE ; +} + +#endif /*XEPHYR_DRI*/ + diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h index 70255a1b7..941eeceb5 100644 --- a/hw/kdrive/ephyr/hostx.h +++ b/hw/kdrive/ephyr/hostx.h @@ -215,12 +215,6 @@ hostx_get_extension_info (const char *a_ext_name, int hostx_get_visuals_info (EphyrHostVisualInfo **a_visuals, int *a_num_entries) ; -int -hostx_allocate_resource_id_peer (int a_local_resource_id, - int *a_remote_resource_id) ; -int -hostx_get_resource_id_peer (int a_local_resource_id, - int *a_remote_resource_id) ; int hostx_create_window (EphyrBox *a_geometry, int a_visual_id, @@ -230,8 +224,6 @@ int hostx_destroy_window (int a_win) ; int hostx_set_window_geometry (int a_win, EphyrBox *a_geo) ; -int hostx_lookup_peer_window (void *a_local_window, - int *a_host_peer /*out parameter*/) ; int hostx_set_window_bounding_rectangles (int a_window, EphyrRect *a_rects, @@ -239,4 +231,20 @@ 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) ; -#endif +int hostx_has_xshape (void) ; + +#ifdef XEPHYR_DRI +int hostx_lookup_peer_window (void *a_local_window, + int *a_host_peer /*out parameter*/) ; +int +hostx_allocate_resource_id_peer (int a_local_resource_id, + int *a_remote_resource_id) ; +int +hostx_get_resource_id_peer (int a_local_resource_id, + int *a_remote_resource_id) ; +int hostx_has_dri (void) ; + +int hostx_has_glx (void) ; +#endif /*XEPHYR_DRI*/ + +#endif /*_XLIBS_STUFF_H_*/