-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Milestone
Description
The following example tries to create a window and then a child message box (i.e. a message box with that window as the window
attribute in the SDL_MessageBoxData
structure).
#include <SDL3/SDL.h>
int main() {
SDL_Init(SDL_INIT_VIDEO);
SDL_Window* window;
SDL_Renderer* renderer;
SDL_CreateWindowAndRenderer("A window", 400, 400, 0, &window, &renderer);
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
SDL_Delay(1000);
SDL_MessageBoxButtonData buttons[] = {
{.flags = 0, .buttonID = 0, .text = "Close"},
};
SDL_MessageBoxData data = {
.flags = 0,
.window = window,
.title = "A message box",
.message = "This only works if window is nullptr.",
.numbuttons = 1,
.buttons = buttons,
.colorScheme = nullptr,
};
int result = -1;
SDL_ShowMessageBox(&data, &result);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}
However, this does not work on Wayland. I have built the program above with g++ $(pkg-config --libs sdl3) main.cpp -fsanitize=address -o example
. Its behavior depends on the SDL_VIDEODRIVER
environment variable:
- With
./example
(no environment variable), no message box appears and the address sanitizer complains about a SEGV somewhere insidelibSDL3.so
. The result ofSDL_GetCurrentVideoDriver
iswayland
.- If the
window
field ofdata
is replaced bynullptr
, the message box appears (far from the window) and there is no SEGV. - If
-fsanitize=address
is not used, there is no visible complain for the SEGV, but the message box still does not appear.
- If the
- With
SDL_VIDEODRIVER=wayland ./example
, no message box appears, but there is apparently no SEGV. This is quite surprising, becausewayland
seems to be the default driver. - With
SDL_VIDEODRIVER=x11 ./example
, the message box is shown and everything works as expected.
I am using SDL 3.2.24 on ArchLinux.
Metadata
Metadata
Assignees
Labels
No labels