[waffle] [PATCH 3/3] wgl: Verify the client area size matches the required size on window creation too.
Jose Fonseca
jfonseca at vmware.com
Mon Dec 29 08:22:45 PST 2014
From: José Fonseca <jfonseca at vmware.com>
By default, Windows will limit windows too large to theu desktop size,
and windows too small to be big enough for the titlebar. Waffle's
windows don't get affected as their style is WS_POPUPWINDOW, which
doesn't include the WS_CAPTION style.
This change adds more assertion, just in case this ever changes, as many
piglit tests rely on large/tiny windows to have the requested size.
Also replace `#ifdef DEBUG` with `#ifndef NDEBUG`, as NDEBUG is the
define that controls assert macro.
That said, I wonder if we should call
`waffle_errorf(WAFFLE_ERROR_INTERNAL, ...)` and verify this on release
builds too.
---
src/waffle/wgl/wgl_window.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/waffle/wgl/wgl_window.c b/src/waffle/wgl/wgl_window.c
index a557c2f..7c3932f 100644
--- a/src/waffle/wgl/wgl_window.c
+++ b/src/waffle/wgl/wgl_window.c
@@ -127,6 +127,16 @@ wgl_window_priv_create(struct wcore_platform *wc_plat,
if (!self->hWnd)
goto error;
+#ifndef NDEBUG
+ // Verify the client area size matches the required size.
+
+ GetClientRect(self->hWnd, &rect);
+ assert(rect.left == 0);
+ assert(rect.top == 0);
+ assert(rect.right - rect.left == width);
+ assert(rect.bottom - rect.top == height);
+#endif
+
self->hDC = GetDC(self->hWnd);
if (!self->hDC)
goto error;
@@ -178,7 +188,7 @@ wgl_window_resize(struct wcore_window *wc_self,
rect.bottom - rect.top,
SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
-#ifdef DEBUG
+#ifndef NDEBUG
// Verify the client area size matches the required size.
GetClientRect(self->hWnd, &rect);
--
2.1.0
More information about the waffle
mailing list