From 03c38185f63e0296af7c4072a02d9f26e96ef287 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Mon, 10 Oct 2016 09:14:57 -0300 Subject: [PATCH 1/3] Fix love.window.maximize to immediately update the window dimensions instead of waiting for the next love.event.pump. Fixes issue #1221. --- src/modules/window/sdl/Window.cpp | 26 ++++++++++++++++---------- src/modules/window/sdl/Window.h | 2 +- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/modules/window/sdl/Window.cpp b/src/modules/window/sdl/Window.cpp index dca71fd18..90cccd7bd 100644 --- a/src/modules/window/sdl/Window.cpp +++ b/src/modules/window/sdl/Window.cpp @@ -485,14 +485,14 @@ bool Window::setWindow(int width, int height, WindowSettings *settings) SDL_GL_SetSwapInterval(f.vsync ? 1 : 0); - updateSettings(f); + updateSettings(f, false); auto gfx = Module::getInstance(Module::M_GRAPHICS); if (gfx != nullptr) gfx->setMode(pixelWidth, pixelHeight); #ifdef LOVE_ANDROID - love::android::setImmersive(f.fullscreen); + love::android::setImmersive(f.fullscreen); #endif return true; @@ -515,7 +515,7 @@ bool Window::onSizeChanged(int width, int height) return true; } -void Window::updateSettings(const WindowSettings &newsettings) +void Window::updateSettings(const WindowSettings &newsettings, bool updateGraphicsViewport) { Uint32 wflags = SDL_GetWindowFlags(window); @@ -575,13 +575,21 @@ void Window::updateSettings(const WindowSettings &newsettings) // May be 0 if the refresh rate can't be determined. settings.refreshrate = (double) dmode.refresh_rate; + + if (updateGraphicsViewport) + { + // Update the viewport size now instead of waiting for event polling. + auto gfx = Module::getInstance(Module::M_GRAPHICS); + if (gfx != nullptr) + gfx->setViewportSize(pixelWidth, pixelHeight); + } } void Window::getWindow(int &width, int &height, WindowSettings &newsettings) { // The window might have been modified (moved, resized, etc.) by the user. if (window) - updateSettings(settings); + updateSettings(settings, true); width = windowWidth; height = windowHeight; @@ -648,17 +656,12 @@ bool Window::setFullscreen(bool fullscreen, Window::FullscreenType fstype) if (SDL_SetWindowFullscreen(window, sdlflags) == 0) { SDL_GL_MakeCurrent(window, context); - updateSettings(newsettings); + updateSettings(newsettings, true); // Apparently this gets un-set when we exit fullscreen (at least in OS X). if (!fullscreen) SDL_SetWindowMinimumSize(window, settings.minwidth, settings.minheight); - // Update the viewport size now instead of waiting for event polling. - auto gfx = Module::getInstance(Module::M_GRAPHICS); - if (gfx != nullptr) - gfx->setViewportSize(pixelWidth, pixelHeight); - return true; } @@ -857,7 +860,10 @@ void Window::minimize() void Window::maximize() { if (window != nullptr) + { SDL_MaximizeWindow(window); + updateSettings(settings, true); + } } void Window::swapBuffers() diff --git a/src/modules/window/sdl/Window.h b/src/modules/window/sdl/Window.h index b459a2173..167aa8450 100644 --- a/src/modules/window/sdl/Window.h +++ b/src/modules/window/sdl/Window.h @@ -125,7 +125,7 @@ private: bool createWindowAndContext(int x, int y, int w, int h, Uint32 windowflags, int msaa); // Update the saved window settings based on the window's actual state. - void updateSettings(const WindowSettings &newsettings); + void updateSettings(const WindowSettings &newsettings, bool updateGraphicsViewport); SDL_MessageBoxFlags convertMessageBoxType(MessageBoxType type) const; From 42be56858b1f37b50e3ed774a4bde10ede9648a9 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Mon, 10 Oct 2016 09:33:10 -0300 Subject: [PATCH 2/3] Remove duplicate unused code. --- src/modules/window/Window.h | 3 --- src/modules/window/sdl/Window.cpp | 10 ---------- src/modules/window/sdl/Window.h | 3 --- 3 files changed, 16 deletions(-) diff --git a/src/modules/window/Window.h b/src/modules/window/Window.h index 54e5b9244..6b66adcf8 100644 --- a/src/modules/window/Window.h +++ b/src/modules/window/Window.h @@ -151,9 +151,6 @@ public: virtual bool isVisible() const = 0; - virtual void setMouseVisible(bool visible) = 0; - virtual bool getMouseVisible() const = 0; - virtual void setMouseGrab(bool grab) = 0; virtual bool isMouseGrabbed() const = 0; diff --git a/src/modules/window/sdl/Window.cpp b/src/modules/window/sdl/Window.cpp index 90cccd7bd..bdc3e2ce7 100644 --- a/src/modules/window/sdl/Window.cpp +++ b/src/modules/window/sdl/Window.cpp @@ -886,16 +886,6 @@ bool Window::isVisible() const return window && (SDL_GetWindowFlags(window) & SDL_WINDOW_SHOWN) != 0; } -void Window::setMouseVisible(bool visible) -{ - SDL_ShowCursor(visible ? SDL_ENABLE : SDL_DISABLE); -} - -bool Window::getMouseVisible() const -{ - return (SDL_ShowCursor(SDL_QUERY) == SDL_ENABLE); -} - void Window::setMouseGrab(bool grab) { mouseGrabbed = grab; diff --git a/src/modules/window/sdl/Window.h b/src/modules/window/sdl/Window.h index 167aa8450..fcabb0cc5 100644 --- a/src/modules/window/sdl/Window.h +++ b/src/modules/window/sdl/Window.h @@ -83,9 +83,6 @@ public: bool isVisible() const; - void setMouseVisible(bool visible); - bool getMouseVisible() const; - void setMouseGrab(bool grab); bool isMouseGrabbed() const; From a9593d926e516cca60d1e9265be04a6096ceb63a Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Thu, 20 Oct 2016 22:57:12 -0300 Subject: [PATCH 3/3] Fix love.math.noise(nil) to error instead of returning nil. --- src/modules/math/wrap_Math.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/math/wrap_Math.lua b/src/modules/math/wrap_Math.lua index 77ed4ce0e..d45c5a76b 100644 --- a/src/modules/math/wrap_Math.lua +++ b/src/modules/math/wrap_Math.lua @@ -88,7 +88,7 @@ function love_math.noise(x, y, z, w) return tonumber(ffifuncs.noise3(x, y, z)) elseif y ~= nil then return tonumber(ffifuncs.noise2(x, y)) - elseif x ~= nil then + else return tonumber(ffifuncs.noise1(x)) end end