Alexandre Julliard : Revert "winex11: Refuse to set the pixel format for HWND_MESSAGE windows."
Alexandre Julliard
julliard at winehq.org
Tue Oct 23 13:37:18 CDT 2012
Module: wine
Branch: master
Commit: f950f41bfe821879b9974f204c1f0e7ad26ebf89
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f950f41bfe821879b9974f204c1f0e7ad26ebf89
Author: Alexandre Julliard <julliard at winehq.org>
Date: Tue Oct 23 16:34:57 2012 +0200
Revert "winex11: Refuse to set the pixel format for HWND_MESSAGE windows."
This reverts commit 53806917a3fc32460201a40a9edd6d8d24983c25.
Tests show that this is allowed.
---
dlls/opengl32/tests/opengl.c | 79 ++++++++++++++++++++++++++++++++++++++++++
dlls/winex11.drv/opengl.c | 12 ++----
2 files changed, 83 insertions(+), 8 deletions(-)
diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c
index 4f799d2..02a72c8 100644
--- a/dlls/opengl32/tests/opengl.c
+++ b/dlls/opengl32/tests/opengl.c
@@ -1110,6 +1110,84 @@ static void test_window_dc(void)
DestroyWindow(window);
}
+static void test_message_window(void)
+{
+ PIXELFORMATDESCRIPTOR pf_desc =
+ {
+ sizeof(PIXELFORMATDESCRIPTOR),
+ 1, /* version */
+ PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
+ PFD_TYPE_RGBA,
+ 24, /* 24-bit color depth */
+ 0, 0, 0, 0, 0, 0, /* color bits */
+ 0, /* alpha buffer */
+ 0, /* shift bit */
+ 0, /* accumulation buffer */
+ 0, 0, 0, 0, /* accum bits */
+ 32, /* z-buffer */
+ 0, /* stencil buffer */
+ 0, /* auxiliary buffer */
+ PFD_MAIN_PLANE, /* main layer */
+ 0, /* reserved */
+ 0, 0, 0 /* layer masks */
+ };
+ int pixel_format;
+ HWND window;
+ RECT vp, r;
+ HGLRC ctx;
+ BOOL ret;
+ HDC dc;
+ GLenum glerr;
+
+ window = CreateWindowA("static", "opengl32_test",
+ WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, HWND_MESSAGE, 0, 0, 0);
+ if (!window)
+ {
+ win_skip( "HWND_MESSAGE not supported\n" );
+ return;
+ }
+ dc = GetDC(window);
+ ok(!!dc, "Failed to get DC.\n");
+
+ pixel_format = ChoosePixelFormat(dc, &pf_desc);
+ if (!pixel_format)
+ {
+ win_skip("Failed to find pixel format.\n");
+ ReleaseDC(window, dc);
+ DestroyWindow(window);
+ return;
+ }
+
+ ret = SetPixelFormat(dc, pixel_format, &pf_desc);
+ ok(ret, "Failed to set pixel format, last error %#x.\n", GetLastError());
+
+ ctx = wglCreateContext(dc);
+ ok(!!ctx, "Failed to create GL context, last error %#x.\n", GetLastError());
+
+ ret = wglMakeCurrent(dc, ctx);
+ ok(ret, "Failed to make context current, last error %#x.\n", GetLastError());
+
+ GetClientRect(window, &r);
+ glGetIntegerv(GL_VIEWPORT, (GLint *)&vp);
+ ok(EqualRect(&r, &vp), "Viewport not equal to client rect.\n");
+
+ glClear(GL_COLOR_BUFFER_BIT);
+ glFinish();
+ glerr = glGetError();
+ ok(glerr == GL_NO_ERROR, "Failed glClear, error %#x.\n", glerr);
+ ret = SwapBuffers(dc);
+ ok(ret, "Failed SwapBuffers, error %#x.\n", GetLastError());
+
+ ret = wglMakeCurrent(NULL, NULL);
+ ok(ret, "Failed to clear current context, last error %#x.\n", GetLastError());
+
+ ret = wglDeleteContext(ctx);
+ ok(ret, "Failed to delete GL context, last error %#x.\n", GetLastError());
+
+ ReleaseDC(window, dc);
+ DestroyWindow(window);
+}
+
static void test_destroy(HDC oldhdc)
{
PIXELFORMATDESCRIPTOR pf_desc =
@@ -1458,6 +1536,7 @@ START_TEST(opengl)
test_bitmap_rendering( FALSE );
test_minimized();
test_window_dc();
+ test_message_window();
test_dc(hwnd, hdc);
hglrc = wglCreateContext(hdc);
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c
index 7c30ce0..61aff532 100644
--- a/dlls/winex11.drv/opengl.c
+++ b/dlls/winex11.drv/opengl.c
@@ -1170,9 +1170,9 @@ static BOOL create_gl_drawable( HWND hwnd, HWND parent, struct gl_drawable *gl )
gl->drawable = 0;
- if (parent == GetDesktopWindow()) /* top-level window */
+ if (GetAncestor( hwnd, GA_PARENT ) == GetDesktopWindow()) /* top-level window */
{
- Window xparent = X11DRV_get_whole_window( hwnd );
+ Window parent = X11DRV_get_whole_window( hwnd );
gl->type = DC_GL_WINDOW;
gl->colormap = XCreateColormap( gdi_display, root_window, gl->visual->visual,
@@ -1185,8 +1185,8 @@ static BOOL create_gl_drawable( HWND hwnd, HWND parent, struct gl_drawable *gl )
attrib.backing_store = NotUseful;
/* put the initial rect outside of the window, it will be moved into place by SetWindowPos */
OffsetRect( &gl->rect, gl->rect.right, gl->rect.bottom );
- if (xparent)
- gl->drawable = XCreateWindow( gdi_display, xparent, gl->rect.left, gl->rect.top,
+ if (parent)
+ gl->drawable = XCreateWindow( gdi_display, parent, gl->rect.left, gl->rect.top,
gl->rect.right - gl->rect.left, gl->rect.bottom - gl->rect.top,
0, default_visual.depth, InputOutput, gl->visual->visual,
CWBitGravity | CWWinGravity | CWBackingStore | CWColormap,
@@ -1196,10 +1196,6 @@ static BOOL create_gl_drawable( HWND hwnd, HWND parent, struct gl_drawable *gl )
else
XFreeColormap( gdi_display, gl->colormap );
}
- else if (!GetAncestor( parent, GA_PARENT ))
- {
- FIXME( "can't set format of HWND_MESSAGE window %p\n", hwnd );
- }
#ifdef SONAME_LIBXCOMPOSITE
else if(usexcomposite)
{
More information about the wine-cvs
mailing list