Added love.window.requestAttention. Bounces the dock icon in OS X and flashes the taskbar icon in Windows when called, if the program isn't in focus.

This commit is contained in:
Alex Szpakowski
2015-06-07 19:40:46 -03:00
parent 6ef6f85d0c
commit cf73aa0107
7 changed files with 67 additions and 2 deletions
+36 -1
View File
@@ -31,8 +31,13 @@
// C
#include <cstdio>
#ifdef LOVE_WINDOWS
// SDL
#include <SDL_syswm.h>
#if defined(LOVE_WINDOWS)
#include <windows.h>
#elif defined(LOVE_MACOSX)
#include "common/OSX.h"
#endif
#ifndef APIENTRY
@@ -965,6 +970,36 @@ int Window::showMessageBox(const MessageBoxData &data)
return pressedbutton;
}
void Window::requestAttention(bool continuous)
{
#if defined(LOVE_WINDOWS)
SDL_SysWMinfo wminfo = {};
SDL_VERSION(&wminfo.version);
if (SDL_GetWindowWMInfo(window, &wminfo))
{
FLASHWINFO flashinfo = {};
flashinfo.cbSize = sizeof(FLASHWINFO);
flashinfo.hwnd = wminfo.info.win.window;
flashinfo.uCount = 1;
flashinfo.dwFlags = FLASHW_ALL;
if (continuous)
flashinfo.dwFlags |= FLASHW_TIMERNOFG;
FlashWindowEx(&flashinfo);
}
#elif defined(LOVE_MACOSX)
love::osx::requestAttention(continuous);
#endif
// TODO: Linux?
}
love::window::Window *Window::createSingleton()
{
if (!singleton)
+2
View File
@@ -100,6 +100,8 @@ public:
bool showMessageBox(const std::string &title, const std::string &message, MessageBoxType type, bool attachtowindow);
int showMessageBox(const MessageBoxData &data);
void requestAttention(bool continuous) override;
static love::window::Window *createSingleton();
const char *getName() const;