SDL_FlashWindow() platform support

What platforms support the SDL_FlashWindow() function?

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.

Platform-Specific Details

  • Windows: SDL_FlashWindow() triggers the taskbar icon to flash or the window to draw attention, depending on the flash mode you specify.
  • macOS: The function typically causes the dock icon to bounce, which is a common way to attract user attention on macOS.
  • Linux: Support depends on the window manager. Popular environments like GNOME and KDE are likely to support it, but minimal window managers may not respond to flash requests.

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.

Verifying Support

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.

Window Visibility

Learn how to control the visibility of SDL2 windows, including showing, hiding, minimizing, and more

Questions & Answers

Answers are generated by AI models and may not have been reviewed. Be mindful when running any code on your device.

Why hide a window?
Why would I want to hide a window in my program?
Check multiple SDL window flags
Can I check multiple window flags simultaneously?
Do hidden windows process events?
Can a hidden window still process events or render content?
Toggle always-on-top with a key
How can I toggle the always-on-top behavior with a key press?
Window flags after restart
Are window flags like SDL_WINDOW_HIDDEN preserved after restarting the program?
Or Ask your Own Question
Purchase the course to ask your own questions