I've never submitted a patch for wine before, but here's one I wrote to get 3D graphics to show in the Aurora Toolset (for Neverwinter Nights). The problem it solves is for GL graphics drawn in subwindows. Without this change they'll draw in the parent drawable, with the child drawable that the program intended clipping it. I suppose the gldrawable changes for x11drv should be #ifdefed out if you don't have opengl support. There are probably cleaner ways to write this, too, but I don't know them yet. ChangeLog: Yann Vernier <yann@algonet.se> * Implement context tracking for GL subwindows
Index: dlls/opengl32/wgl.c =================================================================== RCS file: /home/wine/wine/dlls/opengl32/wgl.c,v retrieving revision 1.33 diff -u -b -r1.33 wgl.c --- dlls/opengl32/wgl.c 7 May 2003 03:18:51 -0000 1.33 +++ dlls/opengl32/wgl.c 2 Jun 2003 16:18:50 -0000 @@ -40,6 +40,7 @@ X11DRV_GET_DISPLAY, /* get X11 display for a DC */ X11DRV_GET_DRAWABLE, /* get current drawable for a DC */ X11DRV_GET_FONT, /* get current X font for a DC */ + X11DRV_GET_GLDRAWABLE, /* get current GL drawable for a DC */ }; void (*wine_tsx11_lock_ptr)(void) = NULL; @@ -107,10 +108,10 @@ /* retrieve the X drawable to use on a given DC */ -inline static Drawable get_drawable( HDC hdc ) +inline static Drawable get_gldrawable( HDC hdc ) { Drawable drawable; - enum x11drv_escape_codes escape = X11DRV_GET_DRAWABLE; + enum x11drv_escape_codes escape = X11DRV_GET_GLDRAWABLE; if (!ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPCSTR)&escape, sizeof(drawable), (LPSTR)&drawable )) drawable = 0; @@ -377,7 +378,7 @@ ret = glXMakeCurrent(default_display, None, NULL); } else { Wine_GLContext *ctx = (Wine_GLContext *) hglrc; - Drawable drawable = get_drawable( hdc ); + Drawable drawable = get_gldrawable( hdc ); if (ctx->ctx == NULL) { ctx->ctx = glXCreateContext(ctx->display, ctx->vis, NULL, True); Index: dlls/x11drv/winpos.c =================================================================== RCS file: /home/wine/wine/dlls/x11drv/winpos.c,v retrieving revision 1.65 diff -u -b -r1.65 winpos.c --- dlls/x11drv/winpos.c 19 May 2003 19:09:40 -0000 1.65 +++ dlls/x11drv/winpos.c 2 Jun 2003 16:18:52 -0000 @@ -426,7 +426,7 @@ WND *win = WIN_GetPtr( hwnd ); HWND top = 0; X11DRV_WND_DATA *data = win->pDriverData; - Drawable drawable; + Drawable drawable, gldrawable; BOOL visible; POINT org, drawable_org; int mode = IncludeInferiors; @@ -461,7 +461,10 @@ if (top) { - HWND parent = GetAncestor( top, GA_PARENT ); + + HWND parent; + gldrawable=X11DRV_get_client_window(top); + parent = GetAncestor( top, GA_PARENT ); org.x = org.y = 0; if (flags & DCX_WINDOW) { @@ -500,10 +503,11 @@ drawable_org = org; if (flags & DCX_CLIPCHILDREN) mode = ClipByChildren; /* can use X11 clipping */ } + gldrawable=drawable; MapWindowPoints( hwnd, 0, &drawable_org, 1 ); } - X11DRV_SetDrawable( hdc, drawable, mode, &org, &drawable_org ); + X11DRV_SetDrawable( hdc, drawable, mode, &org, &drawable_org, gldrawable ); if (flags & (DCX_EXCLUDERGN | DCX_INTERSECTRGN) || SetHookFlags16( HDC_16(hdc), DCHF_VALIDATEVISRGN )) /* DC was dirty */ @@ -538,7 +542,7 @@ POINT org; org.x = org.y = 0; - X11DRV_SetDrawable( hdc, root_window, IncludeInferiors, &org, &org ); + X11DRV_SetDrawable( hdc, root_window, IncludeInferiors, &org, &org, root_window ); } Index: dlls/x11drv/x11drv.h =================================================================== RCS file: /home/wine/wine/dlls/x11drv/x11drv.h,v retrieving revision 1.1 diff -u -b -r1.1 x11drv.h --- dlls/x11drv/x11drv.h 22 Apr 2003 04:05:08 -0000 1.1 +++ dlls/x11drv/x11drv.h 2 Jun 2003 16:18:52 -0000 @@ -85,6 +85,7 @@ DC *dc; /* direct pointer to DC, should go away */ GC gc; /* X Window GC */ Drawable drawable; + Drawable gldrawable; POINT org; /* DC origin relative to drawable */ POINT drawable_org; /* Origin of drawable relative to screen */ X_PHYSFONT font; @@ -199,7 +200,7 @@ extern RGNDATA *X11DRV_GetRegionData( HRGN hrgn, HDC hdc_lptodp ); extern void X11DRV_SetDrawable( HDC hdc, Drawable drawable, int mode, const POINT *org, - const POINT *drawable_org ); + const POINT *drawable_org, Drawable gldrawable ); extern void X11DRV_StartGraphicsExposures( HDC hdc ); extern void X11DRV_EndGraphicsExposures( HDC hdc, HRGN hrgn ); @@ -323,6 +324,7 @@ X11DRV_GET_DISPLAY, /* get X11 display for a DC */ X11DRV_GET_DRAWABLE, /* get current drawable for a DC */ X11DRV_GET_FONT, /* get current X font for a DC */ + X11DRV_GET_GLDRAWABLE, /* get current GL drawable for a DC */ }; /************************************************************************** Index: graphics/x11drv/clipping.c =================================================================== RCS file: /home/wine/wine/graphics/x11drv/clipping.c,v retrieving revision 1.25 diff -u -b -r1.25 clipping.c --- graphics/x11drv/clipping.c 11 May 2003 02:53:09 -0000 1.25 +++ graphics/x11drv/clipping.c 2 Jun 2003 16:18:52 -0000 @@ -129,7 +129,7 @@ * Set the drawable, clipping mode and origin for a DC. */ void X11DRV_SetDrawable( HDC hdc, Drawable drawable, int mode, const POINT *org, - const POINT *drawable_org ) + const POINT *drawable_org, Drawable gldrawable ) { DC *dc = DC_GetDCPtr( hdc ); if (dc) @@ -141,6 +141,7 @@ physDev->org = *org; physDev->drawable = drawable; + physDev->gldrawable = gldrawable; physDev->drawable_org = *drawable_org; TSXSetSubwindowMode( gdi_display, physDev->gc, mode ); GDI_ReleaseObj( hdc ); Index: graphics/x11drv/init.c =================================================================== RCS file: /home/wine/wine/graphics/x11drv/init.c,v retrieving revision 1.56 diff -u -b -r1.56 init.c --- graphics/x11drv/init.c 13 May 2003 23:56:12 -0000 1.56 +++ graphics/x11drv/init.c 2 Jun 2003 16:18:52 -0000 @@ -294,6 +294,13 @@ *(Font *)out_data = pfo->fs->fid; return TRUE; } + break; + case X11DRV_GET_GLDRAWABLE: + if (out_count >= sizeof(Drawable)) + { + *(Drawable *)out_data = physDev->gldrawable; + return TRUE; + } } } break; Index: graphics/x11drv/opengl.c =================================================================== RCS file: /home/wine/wine/graphics/x11drv/opengl.c,v retrieving revision 1.15 diff -u -b -r1.15 opengl.c --- graphics/x11drv/opengl.c 27 Nov 2002 20:21:24 -0000 1.15 +++ graphics/x11drv/opengl.c 2 Jun 2003 16:18:52 -0000 @@ -402,7 +402,7 @@ TRACE("(%p)\n", physDev); wine_tsx11_lock(); - pglXSwapBuffers(gdi_display, physDev->drawable); + pglXSwapBuffers(gdi_display, physDev->gldrawable); wine_tsx11_unlock(); return TRUE;