SDL_video.h

Enumerado SDL_WindowEventID

Un enumerado de eventos de ventana.

typedef enum
{
    SDL_WINDOWEVENT_NONE,           /**< Never used */
    SDL_WINDOWEVENT_SHOWN,          /**< Window has been shown */
    SDL_WINDOWEVENT_HIDDEN,         /**< Window has been hidden */
    SDL_WINDOWEVENT_EXPOSED,        /**< Window has been exposed and should be
                                         redrawn */
    SDL_WINDOWEVENT_MOVED,          /**< Window has been moved to data1, data2
                                     */
    SDL_WINDOWEVENT_RESIZED,        /**< Window has been resized to data1xdata2 */
    SDL_WINDOWEVENT_SIZE_CHANGED,   /**< The window size has changed, either as
                                         a result of an API call or through the
                                         system or user changing the window size. */
    SDL_WINDOWEVENT_MINIMIZED,      /**< Window has been minimized */
    SDL_WINDOWEVENT_MAXIMIZED,      /**< Window has been maximized */
    SDL_WINDOWEVENT_RESTORED,       /**< Window has been restored to normal size
                                         and position */
    SDL_WINDOWEVENT_ENTER,          /**< Window has gained mouse focus */
    SDL_WINDOWEVENT_LEAVE,          /**< Window has lost mouse focus */
    SDL_WINDOWEVENT_FOCUS_GAINED,   /**< Window has gained keyboard focus */
    SDL_WINDOWEVENT_FOCUS_LOST,     /**< Window has lost keyboard focus */
    SDL_WINDOWEVENT_CLOSE,          /**< The window manager requests that the window be closed */
    SDL_WINDOWEVENT_TAKE_FOCUS,     /**< Window is being offered a focus (should SetWindowInputFocus() on itself or a subwindow, or ignore) */
    SDL_WINDOWEVENT_HIT_TEST,       /**< Window had a hit test that wasn't SDL_HITTEST_NORMAL. */
    SDL_WINDOWEVENT_ICCPROF_CHANGED,/**< The ICC profile of the window's display has changed. */
    SDL_WINDOWEVENT_DISPLAY_CHANGED /**< Window has been moved to display data1. */
} SDL_WindowEventID;

Valores

BanderaSignificado
SDL_WINDOWEVENT_NONE No usado.
SDL_WINDOWEVENT_SHOWN Se ha mostrado la ventana.
SDL_WINDOWEVENT_HIDDEN La ventana se ha ocultado.
SDL_WINDOWEVENT_EXPOSED la ventana ha sido expuesta y debe ser redibujada.
SDL_WINDOWEVENT_MOVED La ventana se ha movido a data1, data2.
SDL_WINDOWEVENT_RESIZED La ventana ha sido redimensionada a data1xdata2; este evento siempre es precedido por SDL_WINDOWEVENT_SIZE_CHANGED.
SDL_WINDOWEVENT_SIZE_CHANGED El tamaño de la ventana ha cambiado, ya sea como resultado de una llamada a la API o a través del sistema o el usuario cambiando el tamaño de la ventana; este evento es seguido por SDL_WINDOWEVENT_RESIZED si el tamaño fue cambiado por un evento externo, es decir, el usuario o el gestor de ventanas.
SDL_WINDOWEVENT_MINIMIZED La ventana ha sido minimizada.
SDL_WINDOWEVENT_MAXIMIZED La ventana se ha maximizado.
SDL_WINDOWEVENT_RESTORED La ventana ha sido restaurada a su tamaño y posición normales.
SDL_WINDOWEVENT_ENTER La ventana ha obtenido el foco del ratón.
SDL_WINDOWEVENT_LEAVE La ventana ha perdido el foco del ratón.
SDL_WINDOWEVENT_FOCUS_GAINED La ventana ha obtenido el foco del teclado.
SDL_WINDOWEVENT_FOCUS_LOST La ventana ha perdido el foco del teclado.
SDL_WINDOWEVENT_CLOSE El gestor de ventanas solicita que se cierre la ventana.
SDL_WINDOWEVENT_TAKE_FOCUS A la ventana se le ofrece un foco (debe SDL_SetWindowInputFocus() sobre sí misma o una subventana, o ignorar) (>= SDL 2.0.5).
SDL_WINDOWEVENT_HIT_TEST La ventana tuvo una prueba de impacto que no fue SDL_HITTEST_NORMAL (>= SDL 2.0.5).
SDL_WINDOWEVENT_ICCPROF_CHANGED El perfil ICC de la pantalla de la ventana ha cambiado (>= SDL 2.0.18).
SDL_WINDOWEVENT_DISPLAY_CHANGED La ventana se ha movido a la visualización data1 (>= SDL 2.0.18).

Ejemplo

#include <stdlib.h>
#include "SDL.h"

int main(int argc, char *argv[])  {
  int width = 640;
  int height = 480;

  if (SDL_Init(SDL_INIT_VIDEO) != 0)  {
    return 1;
  }
  atexit(SDL_Quit);

  SDL_Window* window = SDL_CreateWindow(
    "Example", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
    width, height, SDL_WINDOW_RESIZABLE
  );
  Uint32 windowID = SDL_GetWindowID(window);

  while (1)  {
    SDL_Event event;
    while (SDL_PollEvent(&event))  {
      switch (event.type)  {

        case SDL_WINDOWEVENT:  {
          if (event.window.windowID == windowID)  {
            switch (event.window.event)  {

              case SDL_WINDOWEVENT_SIZE_CHANGED:  {
                width = event.window.data1;
                height = event.window.data2;
                break;
              }

              case SDL_WINDOWEVENT_CLOSE:  {
                event.type = SDL_QUIT;
                SDL_PushEvent(&event);
                break;
              }

            }
          }
          break;
        }

        case SDL_QUIT:  {
          return 0;
        }

        /* ... */

      }
    }

    /* ... */

    SDL_Delay(1);
  }
}