From 6d1e44d3d53b451d466d43197be589d0ecc4b9f6 Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Tue, 4 Sep 2007 18:28:16 +0200 Subject: [PATCH] Xephyr: fix a host X hang. * hw/kdrive/ephyr/ephyrdri.c: (ephyrDRIGetDrawableInfo): quickly hook this into getting the drawable info from the host X server. For the time being, this only gets the drawable info of the Xephyr main window in the host. It should really get the info of a the peer drawable in the host X. So there should be a peer drawable to begin with. * hw/kdrive/ephyr/ephyrdriext.c: (ProcXF86DRIGetDrawableInfo): some cleanups. Properly get the the drawable info otherwise there is a host X hang. * hw/kdrive/ephyr/ephyrhostglx.c: do not (ephyrHostGLXQueryVersion): do not use C bindings of the glx protocol calls. Some of those actually access DRI context directly, resulting in the context having three clients. Instead all XF86DRI proto fowarding request should be coded by hand and only forward the protocol requests --- hw/kdrive/ephyr/ephyrdri.c | 32 +++++++++++++++++++++----------- hw/kdrive/ephyr/ephyrdriext.c | 9 +++++---- hw/kdrive/ephyr/ephyrhostglx.c | 4 ++++ 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/hw/kdrive/ephyr/ephyrdri.c b/hw/kdrive/ephyr/ephyrdri.c index 95ace7c25..3f470f8b0 100644 --- a/hw/kdrive/ephyr/ephyrdri.c +++ b/hw/kdrive/ephyr/ephyrdri.c @@ -216,6 +216,7 @@ ephyrDRIGetDrawableInfo (int a_screen, drm_clip_rect_t **a_back_clip_rects) { Bool is_ok=FALSE; + Display *dpy=hostx_get_display () ; DrawablePtr drawable = a_drawable ; EphyrHostWindowAttributes attrs ; @@ -229,20 +230,29 @@ ephyrDRIGetDrawableInfo (int a_screen, EPHYR_LOG_ERROR ("failed to query host window attributes\n") ; goto out; } - *a_x = drawable->x + attrs.x; - *a_y = drawable->y + attrs.y; - *a_w = drawable->width + attrs.width ; - *a_h = drawable->height + attrs.height ; - *a_num_clip_rects = 0 ; - *a_clip_rects = NULL ; - *a_back_x = 0; - *a_back_y = 0 ; - *a_num_back_clip_rects = 0 ; - *a_back_clip_rects = NULL ; + if (!XF86DRIGetDrawableInfo (dpy, a_screen, hostx_get_window (), + a_index, a_stamp, + a_x, a_y, + a_w, a_h, + a_num_clip_rects, a_clip_rects, + a_back_x, a_back_y, + a_num_back_clip_rects, + a_back_clip_rects)) { + EPHYR_LOG_ERROR ("XF86DRIGetDrawableInfo ()\n") ; + goto out ; + } + EPHYR_LOG ("host x,y,w,h: (%d,%d,%d,%d)\n", *a_x, *a_y, *a_w, *a_h) ; + *a_x += drawable->x ; + *a_y += drawable->y ; + *a_back_x = *a_x ; + *a_back_y = *a_y ; + *a_w = drawable->width; + *a_h = drawable->height; is_ok = TRUE ; out: - EPHYR_LOG ("leave\n") ; + EPHYR_LOG ("leave. index:%d, stamp:%d, x,y:(%d,%d), w,y:(%d,%d)\n", + *a_index, *a_stamp, *a_x, *a_y, *a_w, *a_h) ; return is_ok ; } diff --git a/hw/kdrive/ephyr/ephyrdriext.c b/hw/kdrive/ephyr/ephyrdriext.c index d54da2164..443fe9d57 100644 --- a/hw/kdrive/ephyr/ephyrdriext.c +++ b/hw/kdrive/ephyr/ephyrdriext.c @@ -446,13 +446,14 @@ ProcXF86DRIDestroyDrawable (register ClientPtr client) static int ProcXF86DRIGetDrawableInfo (register ClientPtr client) { - xXF86DRIGetDrawableInfoReply rep; + xXF86DRIGetDrawableInfoReply rep; DrawablePtr drawable; - int X, Y, W, H, backX, backY, rc; - drm_clip_rect_t * pClipRects, *pClippedRects; - drm_clip_rect_t * pBackClipRects; + int X=0, Y=0, W=0, H=0, backX=0, backY=0, rc=0; + drm_clip_rect_t *pClipRects=NULL, *pClippedRects=NULL; + drm_clip_rect_t *pBackClipRects=NULL; EPHYR_LOG ("enter\n") ; + memset (&rep, 0, sizeof (rep)) ; REQUEST(xXF86DRIGetDrawableInfoReq); REQUEST_SIZE_MATCH(xXF86DRIGetDrawableInfoReq); if (stuff->screen >= screenInfo.numScreens) { diff --git a/hw/kdrive/ephyr/ephyrhostglx.c b/hw/kdrive/ephyr/ephyrhostglx.c index 071a58154..21a109e64 100644 --- a/hw/kdrive/ephyr/ephyrhostglx.c +++ b/hw/kdrive/ephyr/ephyrhostglx.c @@ -89,10 +89,14 @@ ephyrHostGLXQueryVersion (int *a_major, int *a_minor) EPHYR_RETURN_VAL_IF_FAIL (a_major && a_minor, FALSE) ; EPHYR_LOG ("enter\n") ; + *a_major = 1 ; + *a_minor = 2 ; + /* if (!glXQueryVersion (dpy, a_major, a_minor)) { EPHYR_LOG_ERROR ("glxQueryVersion() failed\n") ; goto out ; } + */ is_ok = TRUE ; out: