Window Visibility

SDL_FlashWindow() platform support

What platforms support the SDL_FlashWindow() function?

Abstract art representing computer programming

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.

Answers to questions are automatically generated and may not have been reviewed.

sdl2-promo.jpg
Part of the course:

Game Dev with SDL2

Learn C++ and SDL development by creating hands on, practical projects inspired by classic retro games

Free, unlimited access

This course includes:

  • 62 Lessons
  • 100+ Code Samples
  • 91% Positive Reviews
  • Regularly Updated
  • Help and FAQ
Free, Unlimited Access

Professional C++

Comprehensive course covering advanced concepts, and how to use them on large-scale projects.

Screenshot from Warhammer: Total War
Screenshot from Tomb Raider
Screenshot from Jedi: Fallen Order
Contact|Privacy Policy|Terms of Use
Copyright © 2024 - All Rights Reserved