X11: Fix updating GLFW_FLOATING on a hidden window

This commit is contained in:
Camilla Löwy 2019-12-16 16:09:52 +01:00
parent 0b652a44d2
commit 9db156421f
2 changed files with 23 additions and 17 deletions

View File

@ -150,6 +150,7 @@ information on what to include when reporting a bug.
- [X11] Bugfix: Content scale fallback value could be inconsistent (#1578) - [X11] Bugfix: Content scale fallback value could be inconsistent (#1578)
- [X11] Bugfix: `glfwMaximizeWindow` had no effect on hidden windows - [X11] Bugfix: `glfwMaximizeWindow` had no effect on hidden windows
- [X11] Bugfix: Clearing `GLFW_FLOATING` on a hidden window caused invalid read - [X11] Bugfix: Clearing `GLFW_FLOATING` on a hidden window caused invalid read
- [X11] Bugfix: Changing `GLFW_FLOATING` on a hidden window could silently fail
- [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432)
- [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled
- [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled

View File

@ -2628,15 +2628,16 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
} }
else else
{ {
Atom* states; Atom* states = NULL;
unsigned long i, count; unsigned long i, count;
count = _glfwGetWindowPropertyX11(window->x11.handle, count = _glfwGetWindowPropertyX11(window->x11.handle,
_glfw.x11.NET_WM_STATE, _glfw.x11.NET_WM_STATE,
XA_ATOM, XA_ATOM,
(unsigned char**) &states); (unsigned char**) &states);
if (!states)
return; // NOTE: We don't check for failure as this property may not exist yet
// and that's fine (and we'll create it implicitly with append)
if (enabled) if (enabled)
{ {
@ -2646,32 +2647,36 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
break; break;
} }
if (i == count) if (i < count)
{ return;
XChangeProperty(_glfw.x11.display, window->x11.handle,
_glfw.x11.NET_WM_STATE, XA_ATOM, 32, XChangeProperty(_glfw.x11.display, window->x11.handle,
PropModeAppend, _glfw.x11.NET_WM_STATE, XA_ATOM, 32,
(unsigned char*) &_glfw.x11.NET_WM_STATE_ABOVE, PropModeAppend,
1); (unsigned char*) &_glfw.x11.NET_WM_STATE_ABOVE,
} 1);
} }
else else if (states)
{ {
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
if (states[i] == _glfw.x11.NET_WM_STATE_ABOVE) if (states[i] == _glfw.x11.NET_WM_STATE_ABOVE)
{ break;
states[i] = states[count - 1];
count--;
}
} }
if (i == count)
return;
states[i] = states[count - 1];
count--;
XChangeProperty(_glfw.x11.display, window->x11.handle, XChangeProperty(_glfw.x11.display, window->x11.handle,
_glfw.x11.NET_WM_STATE, XA_ATOM, 32, _glfw.x11.NET_WM_STATE, XA_ATOM, 32,
PropModeReplace, (unsigned char*) states, count); PropModeReplace, (unsigned char*) states, count);
} }
XFree(states); if (states)
XFree(states);
} }
XFlush(_glfw.x11.display); XFlush(_glfw.x11.display);