Xephyr: check presence of extensions in host X
* hw/kdrive/ephyr/hostx.c,h: (hostx_has_xshape), (hostx_has_glx), (hostx_has_dri): added these new entry points * hw/kdrive/ephyr/ephyrdriext.c: (ephyrDRIExtensionInit): check presence of DRI and XShape extensions before trying to use them. * hw/kdrive/ephyr/ephyrglxext.c: (ephyrHijackGLXExtension): check presence of glx extension before we use it.
This commit is contained in:
parent
2b217fc055
commit
6a435b0000
|
@ -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);
|
||||
|
|
|
@ -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 ;
|
||||
|
|
|
@ -23,6 +23,10 @@
|
|||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <kdrive-config.h>
|
||||
#endif
|
||||
|
||||
#include "hostx.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@ -41,8 +45,17 @@
|
|||
#include <X11/keysym.h>
|
||||
#include <X11/extensions/XShm.h>
|
||||
#include <X11/extensions/shape.h>
|
||||
#ifdef XEPHYR_DRI
|
||||
#include <GL/glx.h>
|
||||
#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; i<RESOURCE_PEERS_SIZE; i++) {
|
||||
if (resource_peers[i].is_valid
|
||||
&& resource_peers[i].local_id == a_local_resource_id) {
|
||||
peer = &resource_peers[i] ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* find one free peer entry, an feed it with
|
||||
*/
|
||||
if (!peer) {
|
||||
for (i=0; i<RESOURCE_PEERS_SIZE; i++) {
|
||||
if (!resource_peers[i].is_valid) {
|
||||
peer = &resource_peers[i] ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
if (peer) {
|
||||
peer->remote_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; i<RESOURCE_PEERS_SIZE; i++) {
|
||||
if (resource_peers[i].is_valid
|
||||
&& resource_peers[i].local_id == a_local_resource_id) {
|
||||
peer = &resource_peers[i] ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
if (peer) {
|
||||
*a_remote_resource_id = peer->remote_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; i<RESOURCE_PEERS_SIZE; i++) {
|
||||
if (resource_peers[i].is_valid
|
||||
&& resource_peers[i].local_id == a_local_resource_id) {
|
||||
peer = &resource_peers[i] ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* find one free peer entry, an feed it with
|
||||
*/
|
||||
if (!peer) {
|
||||
for (i=0; i<RESOURCE_PEERS_SIZE; i++) {
|
||||
if (!resource_peers[i].is_valid) {
|
||||
peer = &resource_peers[i] ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
if (peer) {
|
||||
peer->remote_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; i<RESOURCE_PEERS_SIZE; i++) {
|
||||
if (resource_peers[i].is_valid
|
||||
&& resource_peers[i].local_id == a_local_resource_id) {
|
||||
peer = &resource_peers[i] ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
if (peer) {
|
||||
*a_remote_resource_id = peer->remote_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*/
|
||||
|
||||
|
|
|
@ -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_*/
|
||||
|
|
Loading…
Reference in New Issue
Block a user