winex11: Use the HDC from the gdi_physdev structure.
diff --git a/dlls/winex11.drv/bitblt.c b/dlls/winex11.drv/bitblt.c
index 9209227..a73d551 100644
--- a/dlls/winex11.drv/bitblt.c
+++ b/dlls/winex11.drv/bitblt.c
@@ -542,7 +542,7 @@
     *fg = physDevDst->textPixel;
     *bg = physDevDst->backgroundPixel;
     if(physDevSrc->depth == 1) {
-        if(GetDIBColorTable(physDevSrc->hdc, 0, 2, rgb) == 2) {
+        if(GetDIBColorTable(physDevSrc->dev.hdc, 0, 2, rgb) == 2) {
             DWORD logcolor;
             logcolor = RGB(rgb[0].rgbRed, rgb[0].rgbGreen, rgb[0].rgbBlue);
             *fg = X11DRV_PALETTE_ToPhysical( physDevDst, logcolor );
@@ -918,7 +918,7 @@
     BITBLT_StretchImage( imageSrc, imageDst, src->width, src->height,
                          dst->width, dst->height, &rectSrc, &rectDst,
                          fg, physDevDst->depth != 1 ? bg : physDevSrc->backgroundPixel,
-                         image_pixel_mask( physDevSrc ), GetStretchBltMode(physDevDst->hdc) );
+                         image_pixel_mask( physDevSrc ), GetStretchBltMode(physDevDst->dev.hdc) );
     wine_tsx11_lock();
     XPutImage( gdi_display, pixmap, gc, imageDst, 0, 0, 0, 0,
                rectDst.right - rectDst.left, rectDst.bottom - rectDst.top );
@@ -944,7 +944,7 @@
     INT width  = visRectSrc->right - visRectSrc->left;
     INT height = visRectSrc->bottom - visRectSrc->top;
     int fg, bg;
-    BOOL memdc = (GetObjectType(physDevSrc->hdc) == OBJ_MEMDC);
+    BOOL memdc = (GetObjectType(physDevSrc->dev.hdc) == OBJ_MEMDC);
 
     if (physDevSrc->depth == physDevDst->depth)
     {
@@ -1074,7 +1074,7 @@
     int exposures = 0;
     INT width  = visRectDst->right - visRectDst->left;
     INT height = visRectDst->bottom - visRectDst->top;
-    BOOL memdc = (GetObjectType( physDev->hdc ) == OBJ_MEMDC);
+    BOOL memdc = (GetObjectType( physDev->dev.hdc ) == OBJ_MEMDC);
 
     wine_tsx11_lock();
 
@@ -1182,7 +1182,7 @@
     rect.top    = dst->y;
     rect.right  = dst->x + dst->width;
     rect.bottom = dst->y + dst->height;
-    LPtoDP( physDevDst->hdc, (POINT *)&rect, 2 );
+    LPtoDP( physDevDst->dev.hdc, (POINT *)&rect, 2 );
     dst->x      = rect.left;
     dst->y      = rect.top;
     dst->width  = rect.right - rect.left;
@@ -1207,7 +1207,7 @@
     rect.top    = src->y;
     rect.right  = src->x + src->width;
     rect.bottom = src->y + src->height;
-    LPtoDP( physDevSrc->hdc, (POINT *)&rect, 2 );
+    LPtoDP( physDevSrc->dev.hdc, (POINT *)&rect, 2 );
     src->x      = rect.left;
     src->y      = rect.top;
     src->width  = rect.right - rect.left;
@@ -1419,7 +1419,7 @@
     dst.y      = y;
     dst.width  = width;
     dst.height = height;
-    dst.layout = GetLayout( physDev->hdc );
+    dst.layout = GetLayout( dev->hdc );
 
     if (rop & NOMIRRORBITMAP)
     {
@@ -1507,12 +1507,12 @@
     src.y      = ySrc;
     src.width  = widthSrc;
     src.height = heightSrc;
-    src.layout = GetLayout( physDevSrc->hdc );
+    src.layout = GetLayout( src_dev->hdc );
     dst.x      = xDst;
     dst.y      = yDst;
     dst.width  = widthDst;
     dst.height = heightDst;
-    dst.layout = GetLayout( physDevDst->hdc );
+    dst.layout = GetLayout( dst_dev->hdc );
 
     if (rop & NOMIRRORBITMAP)
     {
@@ -1699,12 +1699,12 @@
     src.y      = ySrc;
     src.width  = widthSrc;
     src.height = heightSrc;
-    src.layout = GetLayout( physDevSrc->hdc );
+    src.layout = GetLayout( src_dev->hdc );
     dst.x      = xDst;
     dst.y      = yDst;
     dst.width  = widthDst;
     dst.height = heightDst;
-    dst.layout = GetLayout( physDevDst->hdc );
+    dst.layout = GetLayout( dst_dev->hdc );
 
     if (!BITBLT_GetVisRectangles( physDevDst, physDevSrc, &dst, &src )) return TRUE;
 
diff --git a/dlls/winex11.drv/brush.c b/dlls/winex11.drv/brush.c
index ca8c5b7..1a25658 100644
--- a/dlls/winex11.drv/brush.c
+++ b/dlls/winex11.drv/brush.c
@@ -259,7 +259,7 @@
 
     if (!GetObjectA( hbrush, sizeof(logbrush), &logbrush )) return 0;
 
-    TRACE("hdc=%p hbrush=%p\n", physDev->hdc,hbrush);
+    TRACE("hdc=%p hbrush=%p\n", dev->hdc, hbrush);
 
     if (physDev->brush.pixmap)
     {
@@ -270,7 +270,7 @@
     }
     physDev->brush.style = logbrush.lbStyle;
     if (hbrush == GetStockObject( DC_BRUSH ))
-        logbrush.lbColor = GetDCBrushColor( physDev->hdc );
+        logbrush.lbColor = GetDCBrushColor( dev->hdc );
 
     switch(logbrush.lbStyle)
     {
@@ -303,7 +303,7 @@
         if ((bmpInfo = GlobalLock( (HGLOBAL)logbrush.lbHatch )))
 	{
 	    int size = bitmap_info_size( bmpInfo, logbrush.lbColor );
-	    hBitmap = CreateDIBitmap( physDev->hdc, &bmpInfo->bmiHeader,
+	    hBitmap = CreateDIBitmap( dev->hdc, &bmpInfo->bmiHeader,
                                         CBM_INIT, ((char *)bmpInfo) + size,
                                         bmpInfo,
                                         (WORD)logbrush.lbColor );
@@ -325,7 +325,7 @@
 {
     X11DRV_PDEVICE *physDev = get_x11drv_dev( dev );
 
-    if (GetCurrentObject(physDev->hdc, OBJ_BRUSH) == GetStockObject( DC_BRUSH ))
+    if (GetCurrentObject(dev->hdc, OBJ_BRUSH) == GetStockObject( DC_BRUSH ))
         BRUSH_SelectSolidBrush( physDev, crColor );
 
     return crColor;
diff --git a/dlls/winex11.drv/dib.c b/dlls/winex11.drv/dib.c
index eb716fc..40501ae 100644
--- a/dlls/winex11.drv/dib.c
+++ b/dlls/winex11.drv/dib.c
@@ -361,7 +361,7 @@
                 BOOL invert = FALSE;
                 RGBQUAD table[2];
 
-                if (GetDIBColorTable( physDev->hdc, 0, 2, table ) == 2)
+                if (GetDIBColorTable( physDev->dev.hdc, 0, 2, table ) == 2)
                     invert = !colour_is_brighter(table[1], table[0]);
 
                 for (i = start; i < end; i++, rgb++) 
@@ -385,7 +385,7 @@
                 BOOL invert = FALSE;
                 RGBQUAD table[2];
 
-                if (GetDIBColorTable( physDev->hdc, 0, 2, table ) == 2)
+                if (GetDIBColorTable( physDev->dev.hdc, 0, 2, table ) == 2)
                     invert = !colour_is_brighter(table[1], table[0]);
 
                 for (i = start; i < end; i++, rgb++)
@@ -3853,7 +3853,7 @@
     LONG width, height;
     BOOL top_down;
     POINT pt;
-    int rop = X11DRV_XROPfunction[GetROP2(physDev->hdc) - 1];
+    int rop = X11DRV_XROPfunction[GetROP2(dev->hdc) - 1];
 
     if (DIB_GetBitmapInfo( &info->bmiHeader, &width, &height,
 			   &descr.infoBpp, &descr.compression ) == -1)
@@ -3864,7 +3864,7 @@
 
     pt.x = xDest;
     pt.y = yDest;
-    LPtoDP(physDev->hdc, &pt, 1);
+    LPtoDP(dev->hdc, &pt, 1);
 
     if (!lines || (startscan >= height)) return 0;
     if (!top_down && startscan + lines > height) lines = height - startscan;
@@ -4117,7 +4117,7 @@
 
   if (physBitmap->pixmap_depth > 1)
   {
-    GetPaletteEntries( GetCurrentObject( physDev->hdc, OBJ_PAL ), 0, 256, palette );
+    GetPaletteEntries( GetCurrentObject( dev->hdc, OBJ_PAL ), 0, 256, palette );
   }
   else
   {
@@ -4342,7 +4342,7 @@
   int* x11ColorMap;
   int freeColorMap;
 
-  TRACE("(%p,%p,%d,%d,%d,%d,%d,%d)\n", physDevSrc->hdc, physDevDst->hdc,
+  TRACE("(%p,%p,%d,%d,%d,%d,%d,%d)\n", physDevSrc->dev.hdc, physDevDst->dev.hdc,
     xSrc, ySrc, xDest, yDest, width, height);
   /* this function is meant as an optimization for BitBlt,
    * not to be called otherwise */
@@ -4363,7 +4363,7 @@
     /* if the source bitmap is 8bpp or less, we're supposed to use the
      * DC's palette for color conversion (not the DIB color table) */
     if (dib.dsBm.bmBitsPixel <= 8) {
-      HPALETTE hPalette = GetCurrentObject( physDevSrc->hdc, OBJ_PAL );
+      HPALETTE hPalette = GetCurrentObject( physDevSrc->dev.hdc, OBJ_PAL );
       if (!hPalette || (hPalette == GetStockObject(DEFAULT_PALETTE))) {
 	/* HACK: no palette has been set in the source DC,
 	 * use the DIB colormap instead - this is necessary in some
diff --git a/dlls/winex11.drv/graphics.c b/dlls/winex11.drv/graphics.c
index 459be9b..301d84d 100644
--- a/dlls/winex11.drv/graphics.c
+++ b/dlls/winex11.drv/graphics.c
@@ -242,7 +242,7 @@
         val.background = X11DRV_PALETTE_XPixelToPalette[val.background];
     }
 
-    val.function = X11DRV_XROPfunction[GetROP2(physDev->hdc)-1];
+    val.function = X11DRV_XROPfunction[GetROP2(physDev->dev.hdc)-1];
     /*
     ** Let's replace GXinvert by GXxor with (black xor white)
     ** This solves the selection color and leak problems in excel
@@ -259,7 +259,7 @@
     {
     case FillStippled:
     case FillOpaqueStippled:
-	if (GetBkMode(physDev->hdc)==OPAQUE) val.fill_style = FillOpaqueStippled;
+	if (GetBkMode(physDev->dev.hdc)==OPAQUE) val.fill_style = FillOpaqueStippled;
 	val.stipple = physDev->brush.pixmap;
 	mask = GCStipple;
         break;
@@ -290,10 +290,10 @@
         mask = 0;
         break;
     }
-    GetBrushOrgEx( physDev->hdc, &pt );
+    GetBrushOrgEx( physDev->dev.hdc, &pt );
     val.ts_x_origin = physDev->dc_rect.left + pt.x;
     val.ts_y_origin = physDev->dc_rect.top + pt.y;
-    val.fill_rule = (GetPolyFillMode(physDev->hdc) == WINDING) ? WindingRule : EvenOddRule;
+    val.fill_rule = (GetPolyFillMode(physDev->dev.hdc) == WINDING) ? WindingRule : EvenOddRule;
     wine_tsx11_lock();
     XChangeGC( gdi_display, gc,
 	       GCFunction | GCForeground | GCBackground | GCFillStyle |
@@ -326,7 +326,7 @@
 static BOOL X11DRV_SetupGCForPen( X11DRV_PDEVICE *physDev )
 {
     XGCValues val;
-    UINT rop2 = GetROP2(physDev->hdc);
+    UINT rop2 = GetROP2(physDev->dev.hdc);
 
     if (physDev->pen.style == PS_NULL) return FALSE;
 
@@ -386,7 +386,7 @@
     }
 
     if (physDev->pen.dash_len)
-        val.line_style = ((GetBkMode(physDev->hdc) == OPAQUE) && (!physDev->pen.ext))
+        val.line_style = ((GetBkMode(physDev->dev.hdc) == OPAQUE) && (!physDev->pen.ext))
                          ? LineDoubleDash : LineOnOffDash;
     else
         val.line_style = LineSolid;
@@ -446,7 +446,7 @@
     pt[0].y = 0;
     pt[1].x = width;
     pt[1].y = 0;
-    LPtoDP( physDev->hdc, pt, 2 );
+    LPtoDP( physDev->dev.hdc, pt, 2 );
     return pt[1].x - pt[0].x;
 }
 
@@ -463,7 +463,7 @@
     pt[0].y = 0;
     pt[1].x = 0;
     pt[1].y = height;
-    LPtoDP( physDev->hdc, pt, 2 );
+    LPtoDP( physDev->dev.hdc, pt, 2 );
     return pt[1].y - pt[0].y;
 }
 
@@ -479,10 +479,10 @@
 	/* Update the pixmap from the DIB section */
 	X11DRV_LockDIBSection(physDev, DIB_Status_GdiMod);
 
-        GetCurrentPositionEx( physDev->hdc, &pt[0] );
+        GetCurrentPositionEx( dev->hdc, &pt[0] );
         pt[1].x = x;
         pt[1].y = y;
-        LPtoDP( physDev->hdc, pt, 2 );
+        LPtoDP( dev->hdc, pt, 2 );
 
         wine_tsx11_lock();
         XDrawLine(gdi_display, physDev->drawable, physDev->gc,
@@ -515,19 +515,19 @@
     XPoint points[4];
     BOOL update = FALSE;
     POINT start, end;
-    RECT rc = get_device_rect( physDev->hdc, left, top, right, bottom );
+    RECT rc = get_device_rect( dev->hdc, left, top, right, bottom );
 
     start.x = xstart;
     start.y = ystart;
     end.x = xend;
     end.y = yend;
-    LPtoDP(physDev->hdc, &start, 1);
-    LPtoDP(physDev->hdc, &end, 1);
+    LPtoDP(dev->hdc, &start, 1);
+    LPtoDP(dev->hdc, &end, 1);
 
     if ((rc.left == rc.right) || (rc.top == rc.bottom)
             ||(lines && ((rc.right-rc.left==1)||(rc.bottom-rc.top==1)))) return TRUE;
 
-    if (GetArcDirection( physDev->hdc ) == AD_CLOCKWISE)
+    if (GetArcDirection( dev->hdc ) == AD_CLOCKWISE)
       { POINT tmp = start; start = end; end = tmp; }
 
     oldwidth = width = physDev->pen.width;
@@ -695,7 +695,7 @@
     X11DRV_PDEVICE *physDev = get_x11drv_dev( dev );
     INT width, oldwidth;
     BOOL update = FALSE;
-    RECT rc = get_device_rect( physDev->hdc, left, top, right, bottom );
+    RECT rc = get_device_rect( dev->hdc, left, top, right, bottom );
 
     if ((rc.left == rc.right) || (rc.top == rc.bottom)) return TRUE;
 
@@ -753,7 +753,7 @@
     X11DRV_PDEVICE *physDev = get_x11drv_dev( dev );
     INT width, oldwidth, oldjoinstyle;
     BOOL update = FALSE;
-    RECT rc = get_device_rect( physDev->hdc, left, top, right, bottom );
+    RECT rc = get_device_rect( dev->hdc, left, top, right, bottom );
 
     TRACE("(%d %d %d %d)\n", left, top, right, bottom);
 
@@ -822,7 +822,7 @@
     INT width, oldwidth, oldendcap;
     BOOL update = FALSE;
     POINT pts[2];
-    RECT rc = get_device_rect( physDev->hdc, left, top, right, bottom );
+    RECT rc = get_device_rect( dev->hdc, left, top, right, bottom );
 
     TRACE("(%d %d %d %d  %d %d\n",
     	left, top, right, bottom, ell_width, ell_height);
@@ -835,7 +835,7 @@
     pts[0].x = pts[0].y = 0;
     pts[1].x = ell_width;
     pts[1].y = ell_height;
-    LPtoDP(physDev->hdc, pts, 2);
+    LPtoDP(dev->hdc, pts, 2);
     ell_width  = max(abs( pts[1].x - pts[0].x ), 1);
     ell_height = max(abs( pts[1].y - pts[0].y ), 1);
 
@@ -1025,7 +1025,7 @@
 
     pt.x = x;
     pt.y = y;
-    LPtoDP( physDev->hdc, &pt, 1 );
+    LPtoDP( dev->hdc, &pt, 1 );
     pixel = X11DRV_PALETTE_ToPhysical( physDev, color );
 
     /* Update the pixmap from the DIB section */
@@ -1056,11 +1056,11 @@
     XImage * image;
     int pixel;
     POINT pt;
-    BOOL memdc = (GetObjectType(physDev->hdc) == OBJ_MEMDC);
+    BOOL memdc = (GetObjectType(dev->hdc) == OBJ_MEMDC);
 
     pt.x = x;
     pt.y = y;
-    LPtoDP( physDev->hdc, &pt, 1 );
+    LPtoDP( dev->hdc, &pt, 1 );
 
     /* Update the pixmap from the DIB section */
     X11DRV_LockDIBSection(physDev, DIB_Status_GdiMod);
@@ -1109,7 +1109,7 @@
     {
         unsigned int i;
         XRectangle *rect;
-        RGNDATA *data = X11DRV_GetRegionData( hrgn, physDev->hdc );
+        RGNDATA *data = X11DRV_GetRegionData( hrgn, dev->hdc );
 
         if (!data) return FALSE;
         rect = (XRectangle *)data->Buffer;
@@ -1146,7 +1146,7 @@
     for (i = 0; i < count; i++)
     {
         POINT tmp = pt[i];
-        LPtoDP(physDev->hdc, &tmp, 1);
+        LPtoDP(dev->hdc, &tmp, 1);
         points[i].x = physDev->dc_rect.left + tmp.x;
         points[i].y = physDev->dc_rect.top + tmp.y;
     }
@@ -1184,7 +1184,7 @@
     for (i = 0; i < count; i++)
     {
         POINT tmp = pt[i];
-        LPtoDP(physDev->hdc, &tmp, 1);
+        LPtoDP(dev->hdc, &tmp, 1);
         points[i].x = physDev->dc_rect.left + tmp.x;
         points[i].y = physDev->dc_rect.top + tmp.y;
     }
@@ -1229,7 +1229,7 @@
     /* FIXME: The points should be converted to device coords before */
     /* creating the region. */
 
-    hrgn = CreatePolyPolygonRgn( pt, counts, polygons, GetPolyFillMode( physDev->hdc ) );
+    hrgn = CreatePolyPolygonRgn( pt, counts, polygons, GetPolyFillMode( dev->hdc ) );
     X11DRV_PaintRgn( dev, hrgn );
     DeleteObject( hrgn );
 
@@ -1255,7 +1255,7 @@
 	    for (j = 0; j < counts[i]; j++)
 	    {
                 POINT tmp = *pt;
-                LPtoDP(physDev->hdc, &tmp, 1);
+                LPtoDP(dev->hdc, &tmp, 1);
                 points[j].x = physDev->dc_rect.left + tmp.x;
                 points[j].y = physDev->dc_rect.top + tmp.y;
 		pt++;
@@ -1302,7 +1302,7 @@
             for (j = 0; j < counts[i]; j++)
             {
                 POINT tmp = *pt;
-                LPtoDP(physDev->hdc, &tmp, 1);
+                LPtoDP(dev->hdc, &tmp, 1);
                 points[j].x = physDev->dc_rect.left + tmp.x;
                 points[j].y = physDev->dc_rect.top + tmp.y;
                 pt++;
@@ -1410,7 +1410,7 @@
 
     pt.x = x;
     pt.y = y;
-    LPtoDP( physDev->hdc, &pt, 1 );
+    LPtoDP( dev->hdc, &pt, 1 );
     if (!PtInRegion( physDev->region, pt.x, pt.y )) return FALSE;
     GetRgnBox( physDev->region, &rect );
 
diff --git a/dlls/winex11.drv/init.c b/dlls/winex11.drv/init.c
index 00d1edd..a36ba10 100644
--- a/dlls/winex11.drv/init.c
+++ b/dlls/winex11.drv/init.c
@@ -129,7 +129,6 @@
     if (!physDev) return FALSE;
 
     *pdev = physDev;
-    physDev->hdc = hdc;
 
     if (GetObjectType( hdc ) == OBJ_MEMDC)
     {
@@ -187,8 +186,6 @@
  */
 INT CDECL X11DRV_GetDeviceCaps( PHYSDEV dev, INT cap )
 {
-    X11DRV_PDEVICE *physDev = get_x11drv_dev( dev );
-
     switch(cap)
     {
     case DRIVERVERSION:
@@ -262,7 +259,7 @@
     case LOGPIXELSY:
         return log_pixels_y;
     case CAPS1:
-        FIXME("(%p): CAPS1 is unimplemented, will return 0\n", physDev->hdc );
+        FIXME("(%p): CAPS1 is unimplemented, will return 0\n", dev->hdc );
         /* please see wingdi.h for the possible bit-flag values that need
            to be returned. */
         return 0;
@@ -279,7 +276,7 @@
     case BLTALIGNMENT:
         return 0;
     default:
-        FIXME("(%p): unsupported capability %d, will return 0\n", physDev->hdc, cap );
+        FIXME("(%p): unsupported capability %d, will return 0\n", dev->hdc, cap );
         return 0;
     }
 }
@@ -352,7 +349,7 @@
                     XSetSubwindowMode( gdi_display, physDev->gc, data->mode );
                     wine_tsx11_unlock();
                     TRACE( "SET_DRAWABLE hdc %p drawable %lx gl_drawable %lx pf %u dc_rect %s drawable_rect %s\n",
-                           physDev->hdc, physDev->drawable, physDev->gl_drawable, physDev->current_pf,
+                           dev->hdc, physDev->drawable, physDev->gl_drawable, physDev->current_pf,
                            wine_dbgstr_rect(&physDev->dc_rect), wine_dbgstr_rect(&physDev->drawable_rect) );
                     return TRUE;
                 }
@@ -389,7 +386,7 @@
                                 rect.top    = event.xgraphicsexpose.y - physDev->dc_rect.top;
                                 rect.right  = rect.left + event.xgraphicsexpose.width;
                                 rect.bottom = rect.top + event.xgraphicsexpose.height;
-                                if (GetLayout( physDev->hdc ) & LAYOUT_RTL)
+                                if (GetLayout( dev->hdc ) & LAYOUT_RTL)
                                     mirror_rect( &physDev->dc_rect, &rect );
 
                                 TRACE( "got %s count %d\n", wine_dbgstr_rect(&rect),
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c
index 4e9d14a..0059660 100644
--- a/dlls/winex11.drv/opengl.c
+++ b/dlls/winex11.drv/opengl.c
@@ -658,7 +658,7 @@
     fmt = ConvertPixelFormatWGLtoGLX(gdi_display, physDev->current_pf, TRUE /* Offscreen */, &fmt_count);
     if(!fmt) return FALSE;
 
-    TRACE(" HDC %p has:\n", physDev->hdc);
+    TRACE(" HDC %p has:\n", physDev->dev.hdc);
     TRACE(" - iPixelFormat %d\n", fmt->iPixelFormat);
     TRACE(" - Drawable %p\n", (void*) get_glxdrawable(physDev));
     TRACE(" - FBCONFIG_ID 0x%x\n", fmt->fmt_id);
@@ -1648,7 +1648,7 @@
     pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DRAWABLE_TYPE, &value);
     wine_tsx11_unlock();
 
-    hwnd = WindowFromDC(physDev->hdc);
+    hwnd = WindowFromDC(physDev->dev.hdc);
     if(hwnd) {
         if(!(value&GLX_WINDOW_BIT)) {
             WARN("Pixel format %d is not compatible for window rendering\n", iPixelFormat);
@@ -1749,7 +1749,7 @@
     WineGLPixelFormat *fmt;
     int hdcPF = physDev->current_pf;
     int fmt_count = 0;
-    HDC hdc = physDev->hdc;
+    HDC hdc = dev->hdc;
 
     TRACE("(%p)->(PF:%d)\n", hdc, hdcPF);
 
@@ -1886,7 +1886,7 @@
 {
     X11DRV_PDEVICE *physDev = get_x11drv_dev( dev );
     BOOL ret;
-    HDC hdc = physDev->hdc;
+    HDC hdc = dev->hdc;
     DWORD type = GetObjectType(hdc);
     Wine_GLContext *ctx = (Wine_GLContext *) hglrc;
 
@@ -2004,8 +2004,8 @@
 
                 ctx->has_been_current = TRUE;
                 ctx->tid = GetCurrentThreadId();
-                ctx->hdc = pDrawDev->hdc;
-                ctx->read_hdc = pReadDev->hdc;
+                ctx->hdc = draw_dev->hdc;
+                ctx->read_hdc = read_dev->hdc;
                 ctx->drawables[0] = d_draw;
                 ctx->drawables[1] = d_read;
                 ctx->refresh_drawables = FALSE;
@@ -2199,12 +2199,12 @@
     X11DRV_PDEVICE *physDev = get_x11drv_dev( dev );
      Font fid = physDev->font;
 
-     TRACE("(%p, %d, %d, %d) using font %ld\n", physDev->hdc, first, count, listBase, fid);
+     TRACE("(%p, %d, %d, %d) using font %ld\n", dev->hdc, first, count, listBase, fid);
 
      if (!has_opengl()) return FALSE;
 
      if (fid == 0) {
-         return internal_wglUseFontBitmaps(physDev->hdc, first, count, listBase, GetGlyphOutlineA);
+         return internal_wglUseFontBitmaps(dev->hdc, first, count, listBase, GetGlyphOutlineA);
      }
 
      wine_tsx11_lock();
@@ -2224,12 +2224,12 @@
     X11DRV_PDEVICE *physDev = get_x11drv_dev( dev );
      Font fid = physDev->font;
 
-     TRACE("(%p, %d, %d, %d) using font %ld\n", physDev->hdc, first, count, listBase, fid);
+     TRACE("(%p, %d, %d, %d) using font %ld\n", dev->hdc, first, count, listBase, fid);
 
      if (!has_opengl()) return FALSE;
 
      if (fid == 0) {
-         return internal_wglUseFontBitmaps(physDev->hdc, first, count, listBase, GetGlyphOutlineW);
+         return internal_wglUseFontBitmaps(dev->hdc, first, count, listBase, GetGlyphOutlineW);
      }
 
      WARN("Using the glX API for the WCHAR variant - some characters may come out incorrectly !\n");
@@ -2358,7 +2358,7 @@
     wine_tsx11_lock();
     ret = alloc_context();
     wine_tsx11_unlock();
-    ret->hdc = physDev->hdc;
+    ret->hdc = dev->hdc;
     ret->fmt = fmt;
     ret->vis = NULL; /* glXCreateContextAttribsARB requires a fbconfig instead of a visual */
     ret->gl3_context = TRUE;
@@ -2701,8 +2701,8 @@
     SetRect( &physDev->drawable_rect, 0, 0, object->width, object->height );
     physDev->dc_rect = physDev->drawable_rect;
 
-    TRACE("(%p)->(%p)\n", hPbuffer, physDev->hdc);
-    return physDev->hdc;
+    TRACE("(%p)->(%p)\n", hPbuffer, dev->hdc);
+    return dev->hdc;
 }
 
 /**
diff --git a/dlls/winex11.drv/palette.c b/dlls/winex11.drv/palette.c
index 3b0097f..27f6f0b 100644
--- a/dlls/winex11.drv/palette.c
+++ b/dlls/winex11.drv/palette.c
@@ -880,7 +880,7 @@
  */
 COLORREF X11DRV_PALETTE_GetColor( X11DRV_PDEVICE *physDev, COLORREF color )
 {
-    HPALETTE             hPal = GetCurrentObject(physDev->hdc, OBJ_PAL );
+    HPALETTE             hPal = GetCurrentObject(physDev->dev.hdc, OBJ_PAL );
     unsigned char        spec_type = color >> 24;
     unsigned             idx = color & 0xffff;
     PALETTEENTRY         entry;
@@ -901,7 +901,7 @@
         return RGB( entry.peRed, entry.peGreen, entry.peBlue );
 
       case 0x10: /* DIBINDEX */
-        if( GetDIBColorTable( physDev->hdc, idx, 1, &quad ) != 1 ) {
+        if( GetDIBColorTable( physDev->dev.hdc, idx, 1, &quad ) != 1 ) {
             WARN("DIBINDEX(%x) : idx %d is out of bounds, assuming black\n", color , idx);
             return 0;
         }
@@ -924,7 +924,7 @@
 int X11DRV_PALETTE_ToPhysical( X11DRV_PDEVICE *physDev, COLORREF color )
 {
     WORD 		 index = 0;
-    HPALETTE 		 hPal = GetCurrentObject(physDev->hdc, OBJ_PAL );
+    HPALETTE 		 hPal = GetCurrentObject(physDev->dev.hdc, OBJ_PAL );
     unsigned char	 spec_type = color >> 24;
     int *mapping = palette_get_mapping( hPal );
     PALETTEENTRY entry;
@@ -968,7 +968,7 @@
                 int white = 1;
                 RGBQUAD table[2];
 
-                if (GetDIBColorTable( physDev->hdc, 0, 2, table ) == 2)
+                if (GetDIBColorTable( physDev->dev.hdc, 0, 2, table ) == 2)
                 {
                     if(!colour_is_brighter(table[1], table[0])) white = 0;
                 }
@@ -1024,7 +1024,7 @@
                     int white = 1;
                     RGBQUAD table[2];
 
-                    if (GetDIBColorTable( physDev->hdc, 0, 2, table ) == 2)
+                    if (GetDIBColorTable( physDev->dev.hdc, 0, 2, table ) == 2)
                     {
                         if(!colour_is_brighter(table[1], table[0]))
                             white = 0;
@@ -1377,7 +1377,6 @@
  */
 COLORREF CDECL X11DRV_GetNearestColor( PHYSDEV dev, COLORREF color )
 {
-    X11DRV_PDEVICE *physDev = get_x11drv_dev( dev );
     unsigned char spec_type = color >> 24;
     COLORREF nearest;
 
@@ -1389,7 +1388,7 @@
 
         UINT index;
         PALETTEENTRY entry;
-        HPALETTE hpal = GetCurrentObject( physDev->hdc, OBJ_PAL );
+        HPALETTE hpal = GetCurrentObject( dev->hdc, OBJ_PAL );
 
         if (!hpal) hpal = GetStockObject( DEFAULT_PALETTE );
 
@@ -1420,10 +1419,9 @@
  */
 UINT CDECL X11DRV_RealizeDefaultPalette( PHYSDEV dev )
 {
-    X11DRV_PDEVICE *physDev = get_x11drv_dev( dev );
     UINT ret = 0;
 
-    if (palette_size && GetObjectType(physDev->hdc) != OBJ_MEMDC)
+    if (palette_size && GetObjectType(dev->hdc) != OBJ_MEMDC)
     {
         /* lookup is needed to account for SetSystemPaletteUse() stuff */
         int i, index, *mapping = palette_get_mapping( GetStockObject(DEFAULT_PALETTE) );
diff --git a/dlls/winex11.drv/pen.c b/dlls/winex11.drv/pen.c
index 188a406..fb35578 100644
--- a/dlls/winex11.drv/pen.c
+++ b/dlls/winex11.drv/pen.c
@@ -80,7 +80,7 @@
 
     if (physDev->pen.width == 1) physDev->pen.width = 0;  /* Faster */
     if (hpen == GetStockObject( DC_PEN ))
-        logpen.lopnColor = GetDCPenColor( physDev->hdc );
+        logpen.lopnColor = GetDCPenColor( dev->hdc );
     physDev->pen.pixel = X11DRV_PALETTE_ToPhysical( physDev, logpen.lopnColor );
     switch(logpen.lopnStyle & PS_STYLE_MASK)
     {
@@ -131,7 +131,7 @@
 {
     X11DRV_PDEVICE *physDev = get_x11drv_dev( dev );
 
-    if (GetCurrentObject(physDev->hdc, OBJ_PEN) == GetStockObject( DC_PEN ))
+    if (GetCurrentObject(dev->hdc, OBJ_PEN) == GetStockObject( DC_PEN ))
         physDev->pen.pixel = X11DRV_PALETTE_ToPhysical( physDev, crColor );
 
     return crColor;
diff --git a/dlls/winex11.drv/text.c b/dlls/winex11.drv/text.c
index a468879..e3a556e 100644
--- a/dlls/winex11.drv/text.c
+++ b/dlls/winex11.drv/text.c
@@ -62,7 +62,7 @@
         rotated = TRUE;
 
     TRACE("hdc=%p df=%04x %d,%d rc %s %s, %d  flags=%d lpDx=%p\n",
-          physDev->hdc, (UINT16)physDev->font, x, y, wine_dbgstr_rect(lprect),
+          dev->hdc, (UINT16)physDev->font, x, y, wine_dbgstr_rect(lprect),
 	  debugstr_wn (wstr, count), count, flags, lpDx);
 
       /* Draw the rectangle */
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index 8c28fd3..617504f 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -146,7 +146,6 @@
 typedef struct
 {
     struct gdi_physdev dev;
-    HDC           hdc;
     GC            gc;          /* X Window GC */
     Drawable      drawable;
     RECT          dc_rect;       /* DC rectangle relative to drawable */
diff --git a/dlls/winex11.drv/xfont.c b/dlls/winex11.drv/xfont.c
index 342acb9..a11717d 100644
--- a/dlls/winex11.drv/xfont.c
+++ b/dlls/winex11.drv/xfont.c
@@ -3232,7 +3232,7 @@
     LOGFONTW logfont;
     LOGFONT16 lf;
 
-    TRACE("hdc=%p, hfont=%p\n", physDev->hdc, hfont);
+    TRACE("hdc=%p, hfont=%p\n", dev->hdc, hfont);
 
     if (!GetObjectW( hfont, sizeof(logfont), &logfont )) return HGDI_ERROR;
 
@@ -3275,7 +3275,7 @@
     }
 
     if (!lf.lfHeight)
-        lf.lfHeight = -(DEF_POINT_SIZE * GetDeviceCaps(physDev->hdc,LOGPIXELSY) + (72>>1)) / 72;
+        lf.lfHeight = -(DEF_POINT_SIZE * GetDeviceCaps(dev->hdc,LOGPIXELSY) + (72>>1)) / 72;
 
     {
 	/* Fixup aliases before passing to RealizeFont */
diff --git a/dlls/winex11.drv/xrender.c b/dlls/winex11.drv/xrender.c
index f21492f..17e646a 100644
--- a/dlls/winex11.drv/xrender.c
+++ b/dlls/winex11.drv/xrender.c
@@ -577,7 +577,7 @@
                                               physDev->dc_rect.left, physDev->dc_rect.top,
                                               (XRectangle *)clip->Buffer, clip->rdh.nCount );
         wine_tsx11_unlock();
-        TRACE("Allocing pict=%lx dc=%p drawable=%08lx\n", info->pict, physDev->hdc, physDev->drawable);
+        TRACE("Allocing pict=%lx dc=%p drawable=%08lx\n", info->pict, physDev->dev.hdc, physDev->drawable);
         HeapFree( GetProcessHeap(), 0, clip );
     }
 
@@ -601,7 +601,7 @@
         wine_tsx11_unlock();
 
         TRACE("Allocing pict_src=%lx dc=%p drawable=%08lx repeat=%u\n",
-              info->pict_src, physDev->hdc, physDev->drawable, pa.repeat);
+              info->pict_src, physDev->dev.hdc, physDev->drawable, pa.repeat);
     }
 
     return info->pict_src;
@@ -792,14 +792,14 @@
 
     *flags = 0;
 
-    size = GetFontData(physDev->hdc, MS_GASP_TAG,  0, NULL, 0);
+    size = GetFontData(physDev->dev.hdc, MS_GASP_TAG,  0, NULL, 0);
     if(size == GDI_ERROR)
         return FALSE;
 
     gasp = buffer = HeapAlloc(GetProcessHeap(), 0, size);
-    GetFontData(physDev->hdc, MS_GASP_TAG,  0, gasp, size);
+    GetFontData(physDev->dev.hdc, MS_GASP_TAG,  0, gasp, size);
 
-    GetTextMetricsW(physDev->hdc, &tm);
+    GetTextMetricsW(physDev->dev.hdc, &tm);
     ppem = abs(X11DRV_YWStoDS(physDev, tm.tmAscent + tm.tmDescent - tm.tmInternalLeading));
 
     gasp++;
@@ -1062,7 +1062,7 @@
     lfsz.devsize.cx = X11DRV_XWStoDS( physDev, lfsz.lf.lfWidth );
     lfsz.devsize.cy = X11DRV_YWStoDS( physDev, lfsz.lf.lfHeight );
 
-    GetTransform( physDev->hdc, 0x204, &lfsz.xform );
+    GetTransform( physDev->dev.hdc, 0x204, &lfsz.xform );
     TRACE("font transform %f %f %f %f\n", lfsz.xform.eM11, lfsz.xform.eM12,
           lfsz.xform.eM21, lfsz.xform.eM22);
 
@@ -1202,13 +1202,13 @@
         XFlush( gdi_display );
         if (info->pict)
         {
-            TRACE("freeing pict = %lx dc = %p\n", info->pict, physDev->hdc);
+            TRACE("freeing pict = %lx dc = %p\n", info->pict, physDev->dev.hdc);
             pXRenderFreePicture(gdi_display, info->pict);
             info->pict = 0;
         }
         if(info->pict_src)
         {
-            TRACE("freeing pict = %lx dc = %p\n", info->pict_src, physDev->hdc);
+            TRACE("freeing pict = %lx dc = %p\n", info->pict_src, physDev->dev.hdc);
             pXRenderFreePicture(gdi_display, info->pict_src);
             info->pict_src = 0;
         }
@@ -1261,20 +1261,20 @@
 	break;
     }
 
-    buflen = GetGlyphOutlineW(physDev->hdc, glyph, ggo_format, &gm, 0, NULL, &identity);
+    buflen = GetGlyphOutlineW(physDev->dev.hdc, glyph, ggo_format, &gm, 0, NULL, &identity);
     if(buflen == GDI_ERROR) {
         if(format != AA_None) {
             format = AA_None;
             entry->aa_default = AA_None;
             ggo_format = GGO_GLYPH_INDEX | GGO_BITMAP;
-            buflen = GetGlyphOutlineW(physDev->hdc, glyph, ggo_format, &gm, 0, NULL, &identity);
+            buflen = GetGlyphOutlineW(physDev->dev.hdc, glyph, ggo_format, &gm, 0, NULL, &identity);
         }
         if(buflen == GDI_ERROR) {
             WARN("GetGlyphOutlineW failed using default glyph\n");
-            buflen = GetGlyphOutlineW(physDev->hdc, 0, ggo_format, &gm, 0, NULL, &identity);
+            buflen = GetGlyphOutlineW(physDev->dev.hdc, 0, ggo_format, &gm, 0, NULL, &identity);
             if(buflen == GDI_ERROR) {
                 WARN("GetGlyphOutlineW failed for default glyph trying for space\n");
-                buflen = GetGlyphOutlineW(physDev->hdc, 0x20, ggo_format, &gm, 0, NULL, &identity);
+                buflen = GetGlyphOutlineW(physDev->dev.hdc, 0x20, ggo_format, &gm, 0, NULL, &identity);
                 if(buflen == GDI_ERROR) {
                     ERR("GetGlyphOutlineW for all attempts unable to upload a glyph\n");
                     return;
@@ -1356,7 +1356,7 @@
 
 
     buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, buflen);
-    GetGlyphOutlineW(physDev->hdc, glyph, ggo_format, &gm, buflen, buf, &identity);
+    GetGlyphOutlineW(physDev->dev.hdc, glyph, ggo_format, &gm, buflen, buf, &identity);
     formatEntry->realized[glyph] = TRUE;
 
     TRACE("buflen = %d. Got metrics: %dx%d adv=%d,%d origin=%d,%d\n",