summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Fonseca <jfonseca@vmware.com>2015-02-26 10:35:28 +0000
committerJose Fonseca <jfonseca@vmware.com>2015-02-27 14:28:02 +0000
commit6320cba15d83cb4d657737a66d14c14e73a75ecd (patch)
treeb12622f4e5e0aa27665816f832c9db4845dccb5b
parent8f5bace8c5d3753c5d922cbda70f623af1f7478c (diff)
utils: Handle WM_QUIT properly.
We were never processing the WM_QUIT message, as GetMessage returns 0 in that case, and we were falling in an infinite loop. We also never see WM_CLOSE messages when pressing Alt-F4 or closing the window via the taskbar. We do however see WM_SYSCOMMAND::SC_CLOSE mesage. So handle that instead. With this change we always quit properly, regardless of the method (Escape/Alt-F4/Close window). Reviewed-by: Brian Paul <brianp@vmware.com>
-rw-r--r--tests/util/piglit-framework-gl/piglit_wgl_framework.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/tests/util/piglit-framework-gl/piglit_wgl_framework.c b/tests/util/piglit-framework-gl/piglit_wgl_framework.c
index 51fdf1f69..b583df777 100644
--- a/tests/util/piglit-framework-gl/piglit_wgl_framework.c
+++ b/tests/util/piglit-framework-gl/piglit_wgl_framework.c
@@ -36,9 +36,14 @@ process_next_event(struct piglit_winsys_framework *winsys_fw)
BOOL bRet;
MSG msg;
- bRet = GetMessage(&msg, NULL, 0, 0 );
- if (bRet <= 0) {
- return;
+ bRet = GetMessage(&msg, NULL, 0, 0);
+ /* bRet will be negative on error, zero on WM_QUIT, positive for other messages */
+ if (bRet < 0) {
+ exit(EXIT_FAILURE);
+ }
+
+ if (0) {
+ fprintf(stderr, "message = 0x%04x, wParam = 0x%04x\n", msg.message, msg.wParam);
}
switch (msg.message) {
@@ -62,10 +67,18 @@ process_next_event(struct piglit_winsys_framework *winsys_fw)
}
winsys_fw->need_redisplay = true;
break;
+ case WM_SYSCOMMAND:
+ if (msg.wParam == SC_CLOSE) {
+ PostQuitMessage(EXIT_SUCCESS);
+ }
+ break;
case WM_CLOSE:
+ /* XXX: we never see this message here in practice, only WM_SYSCOMMAND::SC_CLOSE above */
+ PostQuitMessage(EXIT_SUCCESS);
+ break;
case WM_QUIT:
/* TODO: cleanup/teardown things */
- exit(0);
+ exit(msg.wParam);
default:
break;
}