The SDL_FlashWindow()
function is supported on most major platforms, but its behavior may vary depending on the underlying operating system. Currently, SDL_FlashWindow()
works on Windows, macOS, and some Linux desktop environments that support window manager hints.
On unsupported platforms or window managers, the function is effectively a no-op, meaning it won't cause any harm but also won't produce any noticeable result.
SDL_FlashWindow()
triggers the taskbar icon to flash or the window to draw attention, depending on the flash mode you specify.Here's a program to test flash functionality:
#include <SDL.h>
#include <iostream>
int main() {
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
std::cout << "SDL_Init Error: " <<
SDL_GetError() << '\n';
return 1;
}
SDL_Window* window =
SDL_CreateWindow(
"Flash Test",
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
640, 480,
SDL_WINDOW_SHOWN
);
if (!window) {
std::cout << "SDL_CreateWindow Error: "
<< SDL_GetError() << '\n';
SDL_Quit();
return 1;
}
std::cout << "Flashing window\n";
SDL_FlashWindow(
window, SDL_FLASH_UNTIL_FOCUSED);
SDL_Delay(5000);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}
If you're using an unsupported platform or window manager, you might need to implement custom attention-grabbing techniques.
For example, changing the window's title or using SDL_SetWindowAlwaysOnTop()
as a workaround.
To check if SDL_FlashWindow()
is supported on your platform, test the behavior and consult your system documentation. SDL itself doesn't provide a direct function to query flash support, so experimentation is your best bet.
Answers to questions are automatically generated and may not have been reviewed.
Learn how to control the visibility of SDL2 windows, including showing, hiding, minimizing, and more