Explorar el Código

testmessage: Create a renderer for window display on Wayland

On Wayland -- or at least on some Wayland implementations -- windows
aren't shown until something has been rendered into them. For the
'testmessage' test program, this means that the final messagebox (a
modal one) is blocking an "invisible window", which can then be
difficult to close.

By creating a renderer and presenting once, the window is properly
displayed, and the test behaves as it does under X11 (including
XWayland).
David Gow hace 5 años
padre
commit
1cd97e2695
Se han modificado 1 ficheros con 6 adiciones y 0 borrados
  1. 6 0
      test/testmessage.c

+ 6 - 0
test/testmessage.c

@@ -189,6 +189,12 @@ main(int argc, char *argv[])
         SDL_Event event;
         SDL_Event event;
         SDL_Window *window = SDL_CreateWindow("Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, 0);
         SDL_Window *window = SDL_CreateWindow("Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, 0);
 
 
+        /* On wayland, no window will actually show until something has
+           actually been displayed.
+        */
+        SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, 0);
+        SDL_RenderPresent(renderer);
+
         success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
         success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
                     "Simple MessageBox",
                     "Simple MessageBox",
                     "This is a simple error MessageBox with a parent window",
                     "This is a simple error MessageBox with a parent window",