When I am switching on/off window decorations in full screen mode, then return back to windowed mode, the change is not visible, although glfwGetWindowAttrib()
reports the change has been registered. For example, assume the window has decorations on, I switch to full screen and turn decorations off; then I switch back to windowed mode, and I still see the decorations (GLFW thinks decorations are off but I still see them).
Not sure if I am doing something wrong here. Documentation says some attributes are ignored for full screen windows but the new value will take effect if the window is later made windowed; I assume that includes GLFW_DECORATED
, but what I see when switching back to windowed mode is not what GLFW thinks it is happening.
I am using GLFW 3.3.3 on GNU/Linux 64-bit. The code used is as follows.
void toggleFullScreen(GLFWwindow* window, GLFWmonitor **monitor) {
static int xpos,ypos,width,height;
const GLFWvidmode* mode;
if (*monitor==NULL) {
glfwGetWindowPos(window, &xpos, &ypos);
glfwGetFramebufferSize(window, &width, &height);
*monitor=glfwGetPrimaryMonitor();
mode=glfwGetVideoMode(*monitor);
glfwSetWindowMonitor(window, *monitor, 0, 0, mode->width, mode->height,
mode->refreshRate);
} else {
*monitor=NULL;
glfwSetWindowMonitor(window, *monitor, xpos, ypos, width, height, 0);
}
}
void toggleWindowDecorations(GLFWwindow* window) {
glfwSetWindowAttrib(window, GLFW_DECORATED, !glfwGetWindowAttrib(window, GLFW_DECORATED));
}
void keyCallback(GLFWwindow* window, int key, int scancode, int action,
int mods) {
switch (key) {
case GLFW_KEY_ESCAPE:
running=0; break;
case GLFW_KEY_D:
if (action==GLFW_RELEASE) toggleWindowDecorations(window); break;
case GLFW_KEY_ENTER:
if (action==GLFW_RELEASE) toggleFullScreen(window, ¤tMonitor); break;
}
}