Add love.window.getIcon, and reset it after setMode, so it doesn't get reset (issue #667 and issue #513)

This commit is contained in:
Bart van Strien
2013-07-09 15:19:49 +02:00
parent aaa301ead2
commit 25d0d87247
5 changed files with 30 additions and 0 deletions
+15
View File
@@ -52,6 +52,7 @@ Window::_currentMode::_currentMode()
: width(800)
, height(600)
, flags()
, icon(0)
{
}
@@ -111,6 +112,7 @@ bool Window::setWindow(int width, int height, graphics::Graphics *graphics, Wind
// Set caption.
setWindowTitle(windowTitle);
setMouseVisible(mouseVisible);
setIcon(currentMode.icon);
SDL_EnableKeyRepeat(keyrepeatDelay, keyrepeatInterval);
// Set GL attributes
@@ -302,9 +304,22 @@ bool Window::setIcon(love::image::ImageData *imgd)
SDL_WM_SetIcon(icon, NULL);
SDL_FreeSurface(icon);
imgd->retain();
if (currentMode.icon)
currentMode.icon->release();
currentMode.icon = imgd;
return true;
}
love::image::ImageData *Window::getIcon()
{
if (currentMode.icon)
currentMode.icon->retain();
return currentMode.icon;
}
void Window::swapBuffers()
{
SDL_GL_SwapBuffers();
+2
View File
@@ -53,6 +53,7 @@ public:
std::string getWindowTitle() const;
bool setIcon(love::image::ImageData *imgd);
love::image::ImageData *getIcon();
void swapBuffers();
@@ -79,6 +80,7 @@ private:
int width;
int height;
WindowFlags flags;
love::image::ImageData *icon;
} currentMode;