Added support for testing window manager icons
This commit is contained in:
parent
43503a8b99
commit
c1eb1e8f25
2 changed files with 43 additions and 1 deletions
|
@ -6,7 +6,7 @@
|
|||
#include "common.h"
|
||||
|
||||
#define VIDEO_USAGE \
|
||||
"[--video driver] [--renderer driver] [--info all|video|modes|render|event] [--display N] [--fullscreen | --windows N] [--title title] [--center | --position X,Y] [--geometry WxH] [--depth N] [--refresh R] [--vsync] [--noframe] [--resize] [--minimize] [--maximize] [--grab] [--double] [--triple]"
|
||||
"[--video driver] [--renderer driver] [--info all|video|modes|render|event] [--display N] [--fullscreen | --windows N] [--title title] [--icon icon.bmp] [--center | --position X,Y] [--geometry WxH] [--depth N] [--refresh R] [--vsync] [--noframe] [--resize] [--minimize] [--maximize] [--grab] [--double] [--triple]"
|
||||
|
||||
#define AUDIO_USAGE \
|
||||
"[--rate N] [--format U8|S8|U16|U16LE|U16BE|S16|S16LE|S16BE] [--channels N] [--samples N]"
|
||||
|
@ -192,6 +192,14 @@ CommonArg(CommonState * state, int index)
|
|||
state->window_title = argv[index];
|
||||
return 2;
|
||||
}
|
||||
if (SDL_strcasecmp(argv[index], "--icon") == 0) {
|
||||
++index;
|
||||
if (!argv[index]) {
|
||||
return -1;
|
||||
}
|
||||
state->window_icon = argv[index];
|
||||
return 2;
|
||||
}
|
||||
if (SDL_strcasecmp(argv[index], "--center") == 0) {
|
||||
state->window_x = SDL_WINDOWPOS_CENTERED;
|
||||
state->window_y = SDL_WINDOWPOS_CENTERED;
|
||||
|
@ -611,6 +619,30 @@ PrintRenderer(SDL_RendererInfo * info)
|
|||
}
|
||||
}
|
||||
|
||||
static SDL_Surface *
|
||||
LoadIcon(const char *file)
|
||||
{
|
||||
SDL_Surface *icon;
|
||||
|
||||
/* Load the icon surface */
|
||||
icon = SDL_LoadBMP(file);
|
||||
if (icon == NULL) {
|
||||
fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError());
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (icon->format->palette == NULL) {
|
||||
fprintf(stderr, "Icon must have a palette!\n");
|
||||
SDL_FreeSurface(icon);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* Set the colorkey */
|
||||
SDL_SetColorKey(icon, 1, *((Uint8 *) icon->pixels));
|
||||
|
||||
return (icon);
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
CommonInit(CommonState * state)
|
||||
{
|
||||
|
@ -791,6 +823,15 @@ CommonInit(CommonState * state)
|
|||
SDL_GetError());
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (state->window_icon) {
|
||||
SDL_Surface *icon = LoadIcon(state->window_icon);
|
||||
if (icon) {
|
||||
SDL_SetWindowIcon(state->windows[i], icon);
|
||||
SDL_FreeSurface(icon);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_ShowWindow(state->windows[i]);
|
||||
|
||||
if (!state->skip_renderer
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue