[Piglit] [PATCH] utils: Write event loop for Waffle+WGL

Emil Velikov emil.l.velikov at gmail.com
Mon Feb 23 13:00:09 PST 2015


On 20 February 2015 at 23:38, Jose Fonseca <jfonseca at vmware.com> wrote:
> Without this it is not really possible to see test rendering
> interactively.
I'm a bit low on experience wrt Windows input code, but this looks great afaict.

Fwiw
Reviewed-by: Emil Velikov <emil.l.velikov at gmail.com>
> ---
>  .../piglit-framework-gl/piglit_wgl_framework.c     | 72 +++++++++++++++++++---
>  1 file changed, 64 insertions(+), 8 deletions(-)
>
> diff --git a/tests/util/piglit-framework-gl/piglit_wgl_framework.c b/tests/util/piglit-framework-gl/piglit_wgl_framework.c
> index 4df2eb6..1cce4b2 100644
> --- a/tests/util/piglit-framework-gl/piglit_wgl_framework.c
> +++ b/tests/util/piglit-framework-gl/piglit_wgl_framework.c
> @@ -29,16 +29,72 @@
>  #include "piglit_wl_framework.h"
>
>  static void
> -enter_event_loop(struct piglit_winsys_framework *winsys_fw)
> +process_next_event(struct piglit_winsys_framework *winsys_fw)
>  {
> +       const struct piglit_gl_test_config *test_config = winsys_fw->wfl_fw.gl_fw.test_config;
> +
> +       BOOL bRet;
> +       MSG msg;
> +
> +       bRet = GetMessage(&msg, NULL, 0, 0 );
> +       if (bRet <= 0) {
> +               return;
> +       }
> +
> +       switch (msg.message) {
> +       case WM_PAINT:
> +               winsys_fw->need_redisplay = true;
> +               break;
> +       case WM_SIZE:
> +               if (winsys_fw->user_reshape_func) {
> +                       RECT rect;
> +                       if (GetClientRect(msg.hwnd, &rect)) {
> +                               int width  = rect.right  - rect.left;
> +                               int height = rect.bottom - rect.top;
> +                               winsys_fw->user_reshape_func(width, height);
> +                       }
> +               }
> +               winsys_fw->need_redisplay = true;
> +               break;
> +       case WM_KEYDOWN:
> +               switch (msg.wParam) {
> +               case VK_ESCAPE:
> +                       PostMessage(msg.hwnd, WM_CLOSE, 0, 0);
> +                       break;
> +               }
> +               break;
> +       case WM_CHAR:
> +               if (winsys_fw->user_keyboard_func) {
> +                       winsys_fw->user_keyboard_func(msg.wParam, 0, 0);
Just a question - some tests actually set the keyboard_func. Do those
work under Windows ?

> +               }
> +               winsys_fw->need_redisplay = true;
> +               break;
> +       case WM_CLOSE:
> +               exit(0);
> +       case WM_QUIT:
> +               exit(0);
As a future work we might want to clean/teardown things here (also in
piglit_x11_framework), but until then this will do just fine.
Feel free to add a comment if you have a second.

Thanks Jose!

-Emil


More information about the Piglit mailing list