diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 79b06288..5fbaf1b4 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1102,6 +1102,7 @@ extern "C" { * [window hint](@ref GLFW_SCALE_FRAMEBUFFER_hint). */ #define GLFW_SCALE_FRAMEBUFFER 0x0002200D +#define GLFW_FULLSCREEN 0x0002200E /*! @brief Legacy name for compatibility. * * This is an alias for the diff --git a/src/cocoa_init.m b/src/cocoa_init.m index 15dc4ec4..f1e0bad4 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -555,6 +555,7 @@ GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform) .setWindowFloating = _glfwSetWindowFloatingCocoa, .setWindowOpacity = _glfwSetWindowOpacityCocoa, .setWindowMousePassthrough = _glfwSetWindowMousePassthroughCocoa, + .getWindowIsFullscreen = _glfwGetWindowIsFullscreenNull, .pollEvents = _glfwPollEventsCocoa, .waitEvents = _glfwWaitEventsCocoa, .waitEventsTimeout = _glfwWaitEventsTimeoutCocoa, diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 4d1d66ae..46d81607 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -247,6 +247,7 @@ void _glfwSetWindowFloatingCocoa(_GLFWwindow* window, GLFWbool enabled); float _glfwGetWindowOpacityCocoa(_GLFWwindow* window); void _glfwSetWindowOpacityCocoa(_GLFWwindow* window, float opacity); void _glfwSetWindowMousePassthroughCocoa(_GLFWwindow* window, GLFWbool enabled); +GLFWbool _glfwGetWindowIsFullscreenCocoa(_GLFWwindow* window); void _glfwSetRawMouseMotionCocoa(_GLFWwindow *window, GLFWbool enabled); GLFWbool _glfwRawMouseMotionSupportedCocoa(void); diff --git a/src/internal.h b/src/internal.h index 4f097aa8..d9c555db 100644 --- a/src/internal.h +++ b/src/internal.h @@ -747,6 +747,7 @@ struct _GLFWplatform void (*setWindowFloating)(_GLFWwindow*,GLFWbool); void (*setWindowOpacity)(_GLFWwindow*,float); void (*setWindowMousePassthrough)(_GLFWwindow*,GLFWbool); + GLFWbool (*getWindowIsFullscreen) (_GLFWwindow*); void (*pollEvents)(void); void (*waitEvents)(void); void (*waitEventsTimeout)(double); diff --git a/src/null_platform.h b/src/null_platform.h index dbcb835b..88460942 100644 --- a/src/null_platform.h +++ b/src/null_platform.h @@ -243,6 +243,8 @@ void _glfwSetWindowResizableNull(_GLFWwindow* window, GLFWbool enabled); void _glfwSetWindowDecoratedNull(_GLFWwindow* window, GLFWbool enabled); void _glfwSetWindowFloatingNull(_GLFWwindow* window, GLFWbool enabled); void _glfwSetWindowMousePassthroughNull(_GLFWwindow* window, GLFWbool enabled); +GLFWbool _glfwGetWindowIsFullscreenNull(_GLFWwindow* window); + float _glfwGetWindowOpacityNull(_GLFWwindow* window); void _glfwSetWindowOpacityNull(_GLFWwindow* window, float opacity); void _glfwSetRawMouseMotionNull(_GLFWwindow *window, GLFWbool enabled); diff --git a/src/null_window.c b/src/null_window.c index f0e1dcc9..ff3cdce3 100644 --- a/src/null_window.c +++ b/src/null_window.c @@ -408,6 +408,11 @@ void _glfwSetWindowMousePassthroughNull(_GLFWwindow* window, GLFWbool enabled) { } +GLFWbool _glfwGetWindowIsFullscreenNull(_GLFWwindow* window) +{ + return 0; +} + float _glfwGetWindowOpacityNull(_GLFWwindow* window) { return window->null.opacity; diff --git a/src/win32_init.c b/src/win32_init.c index 77ab56ba..a30ebb18 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -664,6 +664,7 @@ GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform) .setWindowFloating = _glfwSetWindowFloatingWin32, .setWindowOpacity = _glfwSetWindowOpacityWin32, .setWindowMousePassthrough = _glfwSetWindowMousePassthroughWin32, + .getWindowIsFullscreen = _glfwGetWindowIsFullscreenNull, .pollEvents = _glfwPollEventsWin32, .waitEvents = _glfwWaitEventsWin32, .waitEventsTimeout = _glfwWaitEventsTimeoutWin32, diff --git a/src/win32_platform.h b/src/win32_platform.h index a2f86852..f2381a81 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -573,6 +573,7 @@ void _glfwSetWindowResizableWin32(_GLFWwindow* window, GLFWbool enabled); void _glfwSetWindowDecoratedWin32(_GLFWwindow* window, GLFWbool enabled); void _glfwSetWindowFloatingWin32(_GLFWwindow* window, GLFWbool enabled); void _glfwSetWindowMousePassthroughWin32(_GLFWwindow* window, GLFWbool enabled); +GLFWbool _glfwGetWindowIsFullscreenWin32(_GLFWwindow* window); float _glfwGetWindowOpacityWin32(_GLFWwindow* window); void _glfwSetWindowOpacityWin32(_GLFWwindow* window, float opacity); diff --git a/src/window.c b/src/window.c index e03121a4..52536d9f 100644 --- a/src/window.c +++ b/src/window.c @@ -900,6 +900,8 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib) return window->focusOnShow; case GLFW_MOUSE_PASSTHROUGH: return window->mousePassthrough; + case GLFW_FULLSCREEN: + return _glfw.platform.getWindowIsFullscreen(window); case GLFW_TRANSPARENT_FRAMEBUFFER: return _glfw.platform.framebufferTransparent(window); case GLFW_RESIZABLE: diff --git a/src/wl_init.c b/src/wl_init.c index ef9e4503..859cf29f 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -506,6 +506,7 @@ GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform) .setWindowFloating = _glfwSetWindowFloatingWayland, .setWindowOpacity = _glfwSetWindowOpacityWayland, .setWindowMousePassthrough = _glfwSetWindowMousePassthroughWayland, + .getWindowIsFullscreen = _glfwGetWindowIsFullscreenNull, .pollEvents = _glfwPollEventsWayland, .waitEvents = _glfwWaitEventsWayland, .waitEventsTimeout = _glfwWaitEventsTimeoutWayland, diff --git a/src/wl_platform.h b/src/wl_platform.h index afa6f50a..3202e8ff 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -648,6 +648,7 @@ void _glfwSetWindowFloatingWayland(_GLFWwindow* window, GLFWbool enabled); float _glfwGetWindowOpacityWayland(_GLFWwindow* window); void _glfwSetWindowOpacityWayland(_GLFWwindow* window, float opacity); void _glfwSetWindowMousePassthroughWayland(_GLFWwindow* window, GLFWbool enabled); +GLFWbool _glfwGetWindowIsFullscreenWayland(_GLFWwindow* window); void _glfwSetRawMouseMotionWayland(_GLFWwindow* window, GLFWbool enabled); GLFWbool _glfwRawMouseMotionSupportedWayland(void); diff --git a/src/x11_init.c b/src/x11_init.c index 6b34c263..1f7c4776 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -1237,6 +1237,7 @@ GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform) .setWindowFloating = _glfwSetWindowFloatingX11, .setWindowOpacity = _glfwSetWindowOpacityX11, .setWindowMousePassthrough = _glfwSetWindowMousePassthroughX11, + .getWindowIsFullscreen = _glfwGetWindowIsFullscreenX11, .pollEvents = _glfwPollEventsX11, .waitEvents = _glfwWaitEventsX11, .waitEventsTimeout = _glfwWaitEventsTimeoutX11, diff --git a/src/x11_platform.h b/src/x11_platform.h index 30326c5b..1a918794 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -934,6 +934,7 @@ void _glfwSetWindowFloatingX11(_GLFWwindow* window, GLFWbool enabled); float _glfwGetWindowOpacityX11(_GLFWwindow* window); void _glfwSetWindowOpacityX11(_GLFWwindow* window, float opacity); void _glfwSetWindowMousePassthroughX11(_GLFWwindow* window, GLFWbool enabled); +GLFWbool _glfwGetWindowIsFullscreenX11(_GLFWwindow* window); void _glfwSetRawMouseMotionX11(_GLFWwindow *window, GLFWbool enabled); GLFWbool _glfwRawMouseMotionSupportedX11(void); diff --git a/src/x11_window.c b/src/x11_window.c index 322349f0..22aa8548 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2729,6 +2729,51 @@ void _glfwSetWindowMousePassthroughX11(_GLFWwindow* window, GLFWbool enabled) } } +GLFWbool _glfwGetWindowIsFullscreenX11(_GLFWwindow* window) +{ + Atom wm_state = XInternAtom(_glfw.x11.display, "_NET_WM_STATE", True); + Atom wm_state_fullscreen = XInternAtom(_glfw.x11.display, "_NET_WM_STATE_FULLSCREEN", True); + + Atom type = XA_ATOM; + int format; + size_t nItems; + size_t bytesAfterReturn; + Atom* prop; + + int result = XGetWindowProperty( + _glfw.x11.display, + window->x11.handle, + wm_state, + 0, + ~0L, + False, + AnyPropertyType, + &type, + &format, + &nItems, + &bytesAfterReturn, + (unsigned char**)&prop + ); + + assert(result == Success); + assert(nItems > 0); + + if (!prop) { + return 0; + } + + GLFWbool isFullscreen = 0; + for (int i = 0; i < nItems; i++) { + if (prop[i] == wm_state_fullscreen) { + isFullscreen = 1; + } + } + + XFree(prop); + + return isFullscreen; +} + float _glfwGetWindowOpacityX11(_GLFWwindow* window) { float opacity = 1.f; diff --git a/tests/window.c b/tests/window.c index ffea5dbf..d67e10fc 100644 --- a/tests/window.c +++ b/tests/window.c @@ -441,6 +441,7 @@ int main(int argc, char** argv) nk_value_bool(nk, "Visible", glfwGetWindowAttrib(window, GLFW_VISIBLE)); nk_value_bool(nk, "Iconified", glfwGetWindowAttrib(window, GLFW_ICONIFIED)); nk_value_bool(nk, "Maximized", glfwGetWindowAttrib(window, GLFW_MAXIMIZED)); + nk_value_bool(nk, "Fullscreen", glfwGetWindowAttrib(window, GLFW_FULLSCREEN)); } nk_end(nk);