mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
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:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user