Commit bde51568 authored by Alexandre Julliard's avatar Alexandre Julliard

winex11: Get the current pixel format from the drawable structure in wglMakeContextCurrentARB.

parent 11013af0
...@@ -1718,8 +1718,9 @@ done: ...@@ -1718,8 +1718,9 @@ done:
*/ */
static BOOL X11DRV_wglMakeContextCurrentARB( HDC draw_hdc, HDC read_hdc, struct wgl_context *ctx ) static BOOL X11DRV_wglMakeContextCurrentARB( HDC draw_hdc, HDC read_hdc, struct wgl_context *ctx )
{ {
struct x11drv_escape_get_drawable escape_draw, escape_read; BOOL ret = FALSE;
BOOL ret; HWND draw_hwnd, read_hwnd;
struct gl_drawable *draw_gl, *read_gl;
TRACE("(%p,%p,%p)\n", draw_hdc, read_hdc, ctx); TRACE("(%p,%p,%p)\n", draw_hdc, read_hdc, ctx);
...@@ -1730,43 +1731,36 @@ static BOOL X11DRV_wglMakeContextCurrentARB( HDC draw_hdc, HDC read_hdc, struct ...@@ -1730,43 +1731,36 @@ static BOOL X11DRV_wglMakeContextCurrentARB( HDC draw_hdc, HDC read_hdc, struct
return TRUE; return TRUE;
} }
escape_draw.code = X11DRV_GET_DRAWABLE; if (!pglXMakeContextCurrent) return FALSE;
if (!ExtEscape( draw_hdc, X11DRV_ESCAPE, sizeof(escape_draw.code), (LPCSTR)&escape_draw.code,
sizeof(escape_draw), (LPSTR)&escape_draw ))
return FALSE;
escape_read.code = X11DRV_GET_DRAWABLE; draw_hwnd = WindowFromDC( draw_hdc );
if (!ExtEscape( read_hdc, X11DRV_ESCAPE, sizeof(escape_read.code), (LPCSTR)&escape_read.code, read_hwnd = WindowFromDC( read_hdc );
sizeof(escape_read), (LPSTR)&escape_read )) EnterCriticalSection( &context_section );
return FALSE;
if (!escape_draw.pixel_format) if (!XFindContext( gdi_display, (XID)draw_hwnd, gl_hwnd_context, (char **)&draw_gl ) ||
{ !XFindContext( gdi_display, (XID)draw_hdc, gl_pbuffer_context, (char **)&draw_gl ))
WARN("Trying to use an invalid drawable\n");
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
else
{ {
if (!pglXMakeContextCurrent) return FALSE; if (XFindContext( gdi_display, (XID)read_hwnd, gl_hwnd_context, (char **)&read_gl ) &&
XFindContext( gdi_display, (XID)read_hdc, gl_pbuffer_context, (char **)&read_gl ))
read_gl = NULL;
ret = pglXMakeContextCurrent(gdi_display, escape_draw.gl_drawable, escape_read.gl_drawable, ctx->ctx); ret = pglXMakeContextCurrent(gdi_display, draw_gl->drawable,
read_gl ? read_gl->drawable : 0, ctx->ctx);
if (ret) if (ret)
{ {
EnterCriticalSection( &context_section );
ctx->has_been_current = TRUE; ctx->has_been_current = TRUE;
ctx->hdc = draw_hdc; ctx->hdc = draw_hdc;
ctx->drawables[0] = escape_draw.gl_drawable; ctx->drawables[0] = draw_gl->drawable;
ctx->drawables[1] = escape_read.gl_drawable; ctx->drawables[1] = read_gl ? read_gl->drawable : 0;
ctx->refresh_drawables = FALSE; ctx->refresh_drawables = FALSE;
LeaveCriticalSection( &context_section );
NtCurrentTeb()->glContext = ctx; NtCurrentTeb()->glContext = ctx;
goto done;
} }
else
SetLastError(ERROR_INVALID_HANDLE);
} }
SetLastError( ERROR_INVALID_HANDLE );
TRACE(" returning %s\n", (ret ? "True" : "False")); done:
LeaveCriticalSection( &context_section );
TRACE( "%p,%p,%p returning %d\n", draw_hdc, read_hdc, ctx, ret );
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment