mirror of
https://github.com/glfw/glfw.git
synced 2025-06-06 15:54:56 +00:00
integrate _glfwGetWindowIsFullscreenX11 with platform idiom
This commit is contained in:
parent
618532218e
commit
bb4ba846da
@ -747,7 +747,7 @@ struct _GLFWplatform
|
|||||||
void (*setWindowFloating)(_GLFWwindow*,GLFWbool);
|
void (*setWindowFloating)(_GLFWwindow*,GLFWbool);
|
||||||
void (*setWindowOpacity)(_GLFWwindow*,float);
|
void (*setWindowOpacity)(_GLFWwindow*,float);
|
||||||
void (*setWindowMousePassthrough)(_GLFWwindow*,GLFWbool);
|
void (*setWindowMousePassthrough)(_GLFWwindow*,GLFWbool);
|
||||||
void (*getWindowIsFullscreen) (_GLFWwindow*);
|
GLFWbool (*getWindowIsFullscreen) (_GLFWwindow*);
|
||||||
void (*pollEvents)(void);
|
void (*pollEvents)(void);
|
||||||
void (*waitEvents)(void);
|
void (*waitEvents)(void);
|
||||||
void (*waitEventsTimeout)(double);
|
void (*waitEventsTimeout)(double);
|
||||||
|
@ -173,10 +173,6 @@ void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor)
|
|||||||
window->monitor = monitor;
|
window->monitor = monitor;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWbool _glfwWindowGetIsFullscreen(_GLFWwindow* window) {
|
|
||||||
return _glfwGetIsWindowFullscreenX11(window);
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW public API //////
|
////// GLFW public API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -905,7 +901,7 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
|
|||||||
case GLFW_MOUSE_PASSTHROUGH:
|
case GLFW_MOUSE_PASSTHROUGH:
|
||||||
return window->mousePassthrough;
|
return window->mousePassthrough;
|
||||||
case GLFW_FULLSCREEN:
|
case GLFW_FULLSCREEN:
|
||||||
return _glfwWindowGetIsFullscreen(window);
|
return _glfw.platform.getWindowIsFullscreen(window);
|
||||||
case GLFW_TRANSPARENT_FRAMEBUFFER:
|
case GLFW_TRANSPARENT_FRAMEBUFFER:
|
||||||
return _glfw.platform.framebufferTransparent(window);
|
return _glfw.platform.framebufferTransparent(window);
|
||||||
case GLFW_RESIZABLE:
|
case GLFW_RESIZABLE:
|
||||||
|
@ -1237,6 +1237,7 @@ GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform)
|
|||||||
.setWindowFloating = _glfwSetWindowFloatingX11,
|
.setWindowFloating = _glfwSetWindowFloatingX11,
|
||||||
.setWindowOpacity = _glfwSetWindowOpacityX11,
|
.setWindowOpacity = _glfwSetWindowOpacityX11,
|
||||||
.setWindowMousePassthrough = _glfwSetWindowMousePassthroughX11,
|
.setWindowMousePassthrough = _glfwSetWindowMousePassthroughX11,
|
||||||
|
.getWindowIsFullscreen = _glfwGetWindowIsFullscreenX11,
|
||||||
.pollEvents = _glfwPollEventsX11,
|
.pollEvents = _glfwPollEventsX11,
|
||||||
.waitEvents = _glfwWaitEventsX11,
|
.waitEvents = _glfwWaitEventsX11,
|
||||||
.waitEventsTimeout = _glfwWaitEventsTimeoutX11,
|
.waitEventsTimeout = _glfwWaitEventsTimeoutX11,
|
||||||
|
@ -934,7 +934,7 @@ void _glfwSetWindowFloatingX11(_GLFWwindow* window, GLFWbool enabled);
|
|||||||
float _glfwGetWindowOpacityX11(_GLFWwindow* window);
|
float _glfwGetWindowOpacityX11(_GLFWwindow* window);
|
||||||
void _glfwSetWindowOpacityX11(_GLFWwindow* window, float opacity);
|
void _glfwSetWindowOpacityX11(_GLFWwindow* window, float opacity);
|
||||||
void _glfwSetWindowMousePassthroughX11(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwSetWindowMousePassthroughX11(_GLFWwindow* window, GLFWbool enabled);
|
||||||
GLFWbool _glfwGetIsWindowFullscreenX11(_GLFWwindow* window);
|
GLFWbool _glfwGetWindowIsFullscreenX11(_GLFWwindow* window);
|
||||||
|
|
||||||
void _glfwSetRawMouseMotionX11(_GLFWwindow *window, GLFWbool enabled);
|
void _glfwSetRawMouseMotionX11(_GLFWwindow *window, GLFWbool enabled);
|
||||||
GLFWbool _glfwRawMouseMotionSupportedX11(void);
|
GLFWbool _glfwRawMouseMotionSupportedX11(void);
|
||||||
|
@ -26,7 +26,9 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
#include <X11/X.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
#if defined(_GLFW_X11)
|
#if defined(_GLFW_X11)
|
||||||
|
|
||||||
@ -2730,25 +2732,44 @@ void _glfwSetWindowMousePassthroughX11(_GLFWwindow* window, GLFWbool enabled)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWbool _glfwGetIsWindowFullscreenX11(_GLFWwindow* window)
|
GLFWbool _glfwGetWindowIsFullscreenX11(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
Atom atom = XInternAtom(_glfw.x11.display, "_NET_WM_STATE_FULLSCREEN", 0);
|
Atom wm_state = XInternAtom(_glfw.x11.display, "_NET_WM_STATE", True);
|
||||||
|
Atom wm_state_fullscreen = XInternAtom(_glfw.x11.display, "_NET_WM_STATE_FULLSCREEN", True);
|
||||||
|
|
||||||
unsigned char prop[32] = {};
|
Atom type = XA_ATOM;
|
||||||
XGetWindowProperty(
|
int format;
|
||||||
|
size_t nItems;
|
||||||
|
size_t bytesAfterReturn;
|
||||||
|
Atom* prop;
|
||||||
|
|
||||||
|
int result = XGetWindowProperty(
|
||||||
_glfw.x11.display,
|
_glfw.x11.display,
|
||||||
window->x11.handle,
|
window->x11.handle,
|
||||||
atom,
|
wm_state,
|
||||||
0,
|
0,
|
||||||
1, // 32 bits
|
~0L,
|
||||||
0,
|
False,
|
||||||
NULL,
|
AnyPropertyType,
|
||||||
NULL,
|
&type,
|
||||||
NULL,
|
&format,
|
||||||
NULL,
|
&nItems,
|
||||||
NULL,
|
&bytesAfterReturn,
|
||||||
(unsigned char**)&prop
|
(unsigned char**)&prop
|
||||||
);
|
);
|
||||||
|
|
||||||
|
assert(result == Success);
|
||||||
|
|
||||||
|
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 _glfwGetWindowOpacityX11(_GLFWwindow* window)
|
||||||
|
@ -190,6 +190,15 @@ int main(int argc, char** argv)
|
|||||||
glfwSetWindowAttrib(window, GLFW_MOUSE_PASSTHROUGH, false);
|
glfwSetWindowAttrib(window, GLFW_MOUSE_PASSTHROUGH, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nk_button_label(nk, "Is window fullscreen?")) {
|
||||||
|
int fullscreen = glfwGetWindowAttrib(window, GLFW_FULLSCREEN);
|
||||||
|
if (fullscreen) {
|
||||||
|
nk_label(nk, "Yes", NK_TEXT_CENTERED);
|
||||||
|
} else {
|
||||||
|
nk_label(nk, "No", NK_TEXT_CENTERED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nk_label(nk, "Press Enter in a text field to set value", NK_TEXT_CENTERED);
|
nk_label(nk, "Press Enter in a text field to set value", NK_TEXT_CENTERED);
|
||||||
|
|
||||||
nk_flags events;
|
nk_flags events;
|
||||||
|
Loading…
Reference in New Issue
Block a user