From 88cb6bb481811d330c1dc6b1670ec28712418c31 Mon Sep 17 00:00:00 2001 From: Denis Sova <58488405+mks14stdio@users.noreply.github.com> Date: Sat, 9 Dec 2023 15:19:38 +0300 Subject: [PATCH] Fix window on fullscreen --- src/window/Window.cpp | 14 +++++++++++--- src/window/Window.h | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/window/Window.cpp b/src/window/Window.cpp index 8093f93d3..6a4f72c66 100644 --- a/src/window/Window.cpp +++ b/src/window/Window.cpp @@ -71,10 +71,18 @@ bool Window::isMaximized() { return glfwGetWindowAttrib(window, GLFW_MAXIMIZED); } +bool Window::isFocused() +{ + return glfwGetWindowAttrib(window, GLFW_FOCUSED); +} + void window_size_callback(GLFWwindow*, int width, int height) { - glViewport(0, 0, width, height); - Window::width = width; - Window::height = height; + if (Window::isFocused()) { + glViewport(0, 0, width, height); + Window::width = width; + Window::height = height; + } + if (!Window::isFullscreen() && !Window::isMaximized()) { Window::getSettings()->width = width; Window::getSettings()->height = height; diff --git a/src/window/Window.h b/src/window/Window.h index f5a382d3a..05e0fb31c 100644 --- a/src/window/Window.h +++ b/src/window/Window.h @@ -38,6 +38,7 @@ class Window { static void toggleFullscreen(); static bool isFullscreen(); static bool isMaximized(); + static bool isFocused(); static void pushScissor(glm::vec4 area); static void popScissor();