main: Only set window icon on Linux

OSX carries high-resolution icons in its bundles, and windows uses
windres to embed .ico files, so don't interfere with those.
This commit is contained in:
Jonas Kulla 2017-03-04 11:04:02 +01:00
parent c4dd3ffaf6
commit 6349146e01
1 changed files with 25 additions and 15 deletions

View File

@ -166,6 +166,24 @@ static void showInitError(const std::string &msg)
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "mkxp", msg.c_str(), 0);
}
static void setupWindowIcon(const Config &conf, SDL_Window *win)
{
SDL_RWops *iconSrc;
if (conf.iconPath.empty())
iconSrc = SDL_RWFromConstMem(assets_icon_png, assets_icon_png_len);
else
iconSrc = SDL_RWFromFile(conf.iconPath.c_str(), "rb");
SDL_Surface *iconImg = IMG_Load_RW(iconSrc, SDL_TRUE);
if (iconImg)
{
SDL_SetWindowIcon(win, iconImg);
SDL_FreeSurface(iconImg);
}
}
int main(int argc, char *argv[])
{
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
@ -239,16 +257,6 @@ int main(int argc, char *argv[])
return 0;
}
/* Setup application icon */
SDL_RWops *iconSrc;
if (conf.iconPath.empty())
iconSrc = SDL_RWFromConstMem(assets_icon_png, assets_icon_png_len);
else
iconSrc = SDL_RWFromFile(conf.iconPath.c_str(), "rb");
SDL_Surface *iconImg = IMG_Load_RW(iconSrc, SDL_TRUE);
SDL_Window *win;
Uint32 winFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_INPUT_FOCUS;
@ -267,11 +275,13 @@ int main(int argc, char *argv[])
return 0;
}
if (iconImg)
{
SDL_SetWindowIcon(win, iconImg);
SDL_FreeSurface(iconImg);
}
/* OSX and Windows have their own native ways of
* dealing with icons; don't interfere with them */
#ifdef __LINUX__
setupWindowIcon(conf, win);
#else
(void) setupWindowIcon;
#endif
ALCdevice *alcDev = alcOpenDevice(0);