Wayland: Fix window hiding

Corrects the protocol violation with attaching an xdg_surface to a
wl_surface that already has a buffer.

Fixes  #1492
This commit is contained in:
Jason Francis 2020-07-12 20:47:50 -04:00
parent 49dbcfcb8c
commit 1a92f92762
No known key found for this signature in database
GPG Key ID: CDF87B819A5ADA13
4 changed files with 20 additions and 11 deletions

View File

@ -119,6 +119,7 @@ information on what to include when reporting a bug.
## Changelog
- [Wayland] Bugfix: Window hiding not working (#1492)
- Added `GLFW_RESIZE_NWSE_CURSOR`, `GLFW_RESIZE_NESW_CURSOR`,
`GLFW_RESIZE_ALL_CURSOR` and `GLFW_NOT_ALLOWED_CURSOR` cursor shapes (#427)
- Added `GLFW_RESIZE_EW_CURSOR` alias for `GLFW_HRESIZE_CURSOR` (#427)
@ -271,6 +272,7 @@ skills.
- Siavash Eliasi
- Felipe Ferreira
- Michael Fogleman
- Jason Francis
- Gerald Franz
- Mário Freitas
- GeO4d

View File

@ -566,7 +566,7 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
// Clearing the front buffer to black to avoid garbage pixels left over from
// previous uses of our bit of VRAM
{
if (_glfwPlatformWindowVisible(window)) {
PFNGLCLEARPROC glClear = (PFNGLCLEARPROC)
window->context.getProcAddress("glClear");
glClear(GL_COLOR_BUFFER_BIT);

View File

@ -221,7 +221,7 @@ static void makeContextCurrentEGL(_GLFWwindow* window)
_glfwPlatformSetTls(&_glfw.contextSlot, window);
}
static void swapBuffersEGL(_GLFWwindow* window)
void swapBuffersEGL(_GLFWwindow* window)
{
if (window != _glfwPlatformGetTls(&_glfw.contextSlot))
{

View File

@ -777,6 +777,14 @@ static void handleEvents(int timeout)
}
}
void swapBuffersEGL(_GLFWwindow* window);
static void swapBuffersWL(_GLFWwindow* window)
{
if (window->wl.visible)
swapBuffersEGL(window);
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
@ -800,6 +808,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
return GLFW_FALSE;
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
return GLFW_FALSE;
window->context.swapBuffers = swapBuffersWL;
}
else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
{
@ -813,11 +822,12 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
if (wndconfig->title)
window->wl.title = _glfw_strdup(wndconfig->title);
if (wndconfig->visible)
{
if (!createXdgSurface(window))
return GLFW_FALSE;
if (wndconfig->visible)
{
window->wl.visible = GLFW_TRUE;
}
else
@ -1019,22 +1029,19 @@ void _glfwPlatformShowWindow(_GLFWwindow* window)
{
if (!window->wl.visible)
{
createXdgSurface(window);
window->wl.visible = GLFW_TRUE;
}
}
void _glfwPlatformHideWindow(_GLFWwindow* window)
{
if (window->wl.xdg.toplevel)
if (window->wl.visible)
{
xdg_toplevel_destroy(window->wl.xdg.toplevel);
xdg_surface_destroy(window->wl.xdg.surface);
window->wl.xdg.toplevel = NULL;
window->wl.xdg.surface = NULL;
}
wl_surface_attach(window->wl.surface, NULL, 0, 0);
wl_surface_commit(window->wl.surface);
window->wl.visible = GLFW_FALSE;
}
}
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
{