diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index b1c0b2b10..d94c2e30c 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -2407,6 +2407,14 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor UNUSED) updateCursorImage(window); } +bool _glfwPlatformIsFullscreen(_GLFWwindow* w, unsigned int flags) { + NSWindow *window = w->ns.object; + bool traditional = !(flags & 1); + if (traditional && @available(macOS 10.16, *)) return w->ns.in_traditional_fullscreen; + NSWindowStyleMask sm = [window styleMask]; + return sm & NSWindowStyleMaskFullScreen; +} + bool _glfwPlatformToggleFullscreen(_GLFWwindow* w, unsigned int flags) { NSWindow *window = w->ns.object; bool made_fullscreen = true; diff --git a/glfw/glfw3.h b/glfw/glfw3.h index 3d1aafc2a..234cbd507 100644 --- a/glfw/glfw3.h +++ b/glfw/glfw3.h @@ -2752,6 +2752,7 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value); */ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share); GLFWAPI bool glfwToggleFullscreen(GLFWwindow *window, unsigned int flags); +GLFWAPI bool glfwIsFullscreen(GLFWwindow *window, unsigned int flags); /*! @brief Destroys the specified window and its context. * diff --git a/glfw/internal.h b/glfw/internal.h index a14d0ffb3..12591cfba 100644 --- a/glfw/internal.h +++ b/glfw/internal.h @@ -717,6 +717,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate); bool _glfwPlatformToggleFullscreen(_GLFWwindow *w, unsigned int flags); +bool _glfwPlatformIsFullscreen(_GLFWwindow *w, unsigned int flags); int _glfwPlatformWindowFocused(_GLFWwindow* window); int _glfwPlatformWindowOccluded(_GLFWwindow* window); int _glfwPlatformWindowIconified(_GLFWwindow* window); diff --git a/glfw/window.c b/glfw/window.c index 9ad3add66..b69300e2b 100644 --- a/glfw/window.c +++ b/glfw/window.c @@ -1058,6 +1058,10 @@ GLFWAPI bool glfwToggleFullscreen(GLFWwindow* wh, unsigned int flags) { return false; } +GLFWAPI bool glfwIsFullscreen(GLFWwindow* wh, unsigned int flags) { + return _glfwPlatformIsFullscreen((_GLFWwindow*)wh, flags); +} + GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* handle, void* pointer) { _GLFWwindow* window = (_GLFWwindow*) handle; diff --git a/glfw/wl_window.c b/glfw/wl_window.c index 528b95458..a3c46d94d 100644 --- a/glfw/wl_window.c +++ b/glfw/wl_window.c @@ -413,9 +413,15 @@ static void setFullscreen(_GLFWwindow* window, _GLFWmonitor* monitor, bool on) setIdleInhibitor(window, on); } + +bool +_glfwPlatformIsFullscreen(_GLFWwindow *window, unsigned int flags UNUSED) { + return window->wl.toplevel_states & TOPLEVEL_STATE_FULLSCREEN; +} + bool _glfwPlatformToggleFullscreen(_GLFWwindow *window, unsigned int flags UNUSED) { - bool already_fullscreen = window->wl.toplevel_states & TOPLEVEL_STATE_FULLSCREEN; + bool already_fullscreen = _glfwPlatformIsFullscreen(window, flags); setFullscreen(window, NULL, !already_fullscreen); return !already_fullscreen; } diff --git a/glfw/x11_window.c b/glfw/x11_window.c index bb46ea63f..b9528add3 100644 --- a/glfw/x11_window.c +++ b/glfw/x11_window.c @@ -343,6 +343,11 @@ set_fullscreen(_GLFWwindow *window, bool on) { } } +bool +_glfwPlatformIsFullscreen(_GLFWwindow *window, unsigned int flags UNUSED) { + return is_window_fullscreen(window); +} + bool _glfwPlatformToggleFullscreen(_GLFWwindow *window, unsigned int flags UNUSED) { bool already_fullscreen = is_window_fullscreen(window); diff --git a/kitty/glfw.c b/kitty/glfw.c index 8bf320da8..1adc5863f 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -592,7 +592,9 @@ static bool toggle_fullscreen_for_os_window(OSWindow *w) { if (w && w->handle) { #ifdef __APPLE__ - if (!OPT(macos_traditional_fullscreen)) return glfwToggleFullscreen(w->handle, 1); + if (!OPT(macos_traditional_fullscreen)) { + return glfwToggleFullscreen(w->handle, 1); + } #endif return do_toggle_fullscreen(w); }