Turning on/off window decorations while in full screen won't work properly

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, &currentMonitor); break;
  }
}

What window manager and display server (X11 or Wayland) are you using?

I wonder if this is related to the following issue:

Sorry, I should provide that information already. I am using X11 and XFCE. I also tried the code on another computer with Openbox instead of XFCE. Same results.
I doubt the problem is related to that other issue you linked because glfwSetWindowAttrib does work as expected normally. The only case it doesn’t work is when I try to toggle decorations on/off in full screen. In that case only, GLFW_DECORATED is changed but when I switch back to windowed mode the change is not visible.

I’m not that familiar with the fullscreen switching code on X11, but it does look like the state of GLFW_DECORATED might not be getting checked on return to windowed mode.

So this is likely a bug, and should be posted as an issue to: Issues · glfw/glfw · GitHub

If you don’t have an account or are unsure how to proceed I can file it for you, but it might take me a while to get around to it.

I opened an issue about that in Github. Thank you Doug.

This was a bug in GLFW, affecting GLFW_DECORATED and GLFW_FLOATING. Thank you for reporting this! It should be fixed now with X11: Fix attribs not applied on leaving fullscreen · glfw/glfw@4afa227 · GitHub.