From abb559dd7a23788f55c82f6df13ecf089cbcda27 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 8 Nov 2010 15:46:07 +0100 Subject: [PATCH] winex11: Add support for having a drawable associated to non-toplevel windows. --- dlls/winex11.drv/window.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index 1005ad2c89c..2a0f53f1492 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -2110,6 +2110,7 @@ void CDECL X11DRV_GetDC( HDC hdc, HWND hwnd, HWND top, const RECT *win_rect, { struct x11drv_escape_set_drawable escape; struct x11drv_win_data *data = X11DRV_get_win_data( hwnd ); + HWND parent; escape.code = X11DRV_SET_DRAWABLE; escape.mode = IncludeInferiors; @@ -2118,6 +2119,15 @@ void CDECL X11DRV_GetDC( HDC hdc, HWND hwnd, HWND top, const RECT *win_rect, escape.pixmap = 0; escape.gl_copy = FALSE; + escape.dc_rect.left = win_rect->left - top_rect->left; + escape.dc_rect.top = win_rect->top - top_rect->top; + escape.dc_rect.right = win_rect->right - top_rect->left; + escape.dc_rect.bottom = win_rect->bottom - top_rect->top; + escape.drawable_rect.left = top_rect->left; + escape.drawable_rect.top = top_rect->top; + escape.drawable_rect.right = top_rect->right; + escape.drawable_rect.bottom = top_rect->bottom; + if (top == hwnd) { escape.fbconfig_id = data ? data->fbconfig_id : (XID)GetPropA( hwnd, fbconfig_id_prop ); @@ -2134,7 +2144,19 @@ void CDECL X11DRV_GetDC( HDC hdc, HWND hwnd, HWND top, const RECT *win_rect, } else { - escape.drawable = X11DRV_get_client_window( top ); + /* find the first ancestor that has a drawable */ + for (parent = hwnd; parent && parent != top; parent = GetAncestor( parent, GA_PARENT )) + if ((escape.drawable = X11DRV_get_client_window( parent ))) break; + + if (escape.drawable) + { + POINT pt = { 0, 0 }; + MapWindowPoints( top, parent, &pt, 1 ); + OffsetRect( &escape.dc_rect, pt.x, pt.y ); + OffsetRect( &escape.drawable_rect, -pt.x, -pt.y ); + } + else escape.drawable = X11DRV_get_client_window( top ); + escape.fbconfig_id = data ? data->fbconfig_id : (XID)GetPropA( hwnd, fbconfig_id_prop ); escape.gl_drawable = data ? data->gl_drawable : (Drawable)GetPropA( hwnd, gl_drawable_prop ); escape.pixmap = data ? data->pixmap : (Pixmap)GetPropA( hwnd, pixmap_prop ); @@ -2142,15 +2164,6 @@ void CDECL X11DRV_GetDC( HDC hdc, HWND hwnd, HWND top, const RECT *win_rect, if (flags & DCX_CLIPCHILDREN) escape.mode = ClipByChildren; } - escape.dc_rect.left = win_rect->left - top_rect->left; - escape.dc_rect.top = win_rect->top - top_rect->top; - escape.dc_rect.right = win_rect->right - top_rect->left; - escape.dc_rect.bottom = win_rect->bottom - top_rect->top; - escape.drawable_rect.left = top_rect->left; - escape.drawable_rect.top = top_rect->top; - escape.drawable_rect.right = top_rect->right; - escape.drawable_rect.bottom = top_rect->bottom; - ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPSTR)&escape, 0, NULL ); }