checkkeys: 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
'checkkeys' test program, this means that keyboard input isn't
registered, making the program rather useless.

By creating a renderer and presenting once, the window is properly
displayed, and the test behaves as it does under X11 (including
XWayland).

The exact same thing was done with testmessge in 1cd97e2695 (PR #4252)
This commit is contained in:
David Gow 2021-08-13 21:25:35 +08:00 committed by Sam Lantinga
parent 907943a236
commit 105f120615
1 changed files with 7 additions and 0 deletions

View File

@ -201,6 +201,7 @@ int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
SDL_Window *window; SDL_Window *window;
SDL_Renderer *renderer;
/* Enable standard application logging */ /* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
@ -221,6 +222,12 @@ main(int argc, char *argv[])
quit(2); quit(2);
} }
/* On wayland, no window will actually show until something has
actually been displayed.
*/
renderer = SDL_CreateRenderer(window, -1, 0);
SDL_RenderPresent(renderer);
#if __IPHONEOS__ #if __IPHONEOS__
/* Creating the context creates the view, which we need to show keyboard */ /* Creating the context creates the view, which we need to show keyboard */
SDL_GL_CreateContext(window); SDL_GL_CreateContext(window);