Move last bits of window setup to platform code

This avoids glfwCreateWindow emitting GLFW_PLATFORM_ERROR on Wayland
because shared code was calling unimplemented or unavailable platform
functions during final setup.

It also makes it consistent with the final setup of full screen windows.

This is adapted to 3.3-stable from
09653b8c54.
This commit is contained in:
Camilla Löwy 2022-04-06 21:13:48 +02:00
parent c8be8606f0
commit b9ea733ca8
7 changed files with 52 additions and 24 deletions

View File

@ -144,6 +144,7 @@ information on what to include when reporting a bug.
- [Wayland] Bugfix: Drag and drop data was misinterpreted as clipboard string - [Wayland] Bugfix: Drag and drop data was misinterpreted as clipboard string
- [Wayland] Bugfix: MIME type matching was not performed for clipboard string - [Wayland] Bugfix: MIME type matching was not performed for clipboard string
- [Wayland] Bugfix: The OSMesa library was not unloaded on termination - [Wayland] Bugfix: The OSMesa library was not unloaded on termination
- [Wayland] Bugfix: `glfwCreateWindow` could emit `GLFW_PLATFORM_ERROR`
## Contact ## Contact

View File

@ -934,6 +934,9 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig)) if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
return GLFW_FALSE; return GLFW_FALSE;
} }
if (!_glfwRefreshContextAttribs(window, ctxconfig))
return GLFW_FALSE;
} }
if (window->monitor) if (window->monitor)
@ -941,6 +944,18 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
_glfwPlatformShowWindow(window); _glfwPlatformShowWindow(window);
_glfwPlatformFocusWindow(window); _glfwPlatformFocusWindow(window);
acquireMonitor(window); acquireMonitor(window);
if (wndconfig->centerCursor)
_glfwCenterCursorInContentArea(window);
}
else
{
if (wndconfig->visible)
{
_glfwPlatformShowWindow(window);
if (wndconfig->focused)
_glfwPlatformFocusWindow(window);
}
} }
return GLFW_TRUE; return GLFW_TRUE;

View File

@ -67,6 +67,9 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
_glfwInputError(GLFW_API_UNAVAILABLE, "Null: EGL not available"); _glfwInputError(GLFW_API_UNAVAILABLE, "Null: EGL not available");
return GLFW_FALSE; return GLFW_FALSE;
} }
if (!_glfwRefreshContextAttribs(window, ctxconfig))
return GLFW_FALSE;
} }
return GLFW_TRUE; return GLFW_TRUE;

View File

@ -1498,6 +1498,9 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig)) if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
return GLFW_FALSE; return GLFW_FALSE;
} }
if (!_glfwRefreshContextAttribs(window, ctxconfig))
return GLFW_FALSE;
} }
if (window->monitor) if (window->monitor)
@ -1506,6 +1509,18 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
_glfwPlatformFocusWindow(window); _glfwPlatformFocusWindow(window);
acquireMonitor(window); acquireMonitor(window);
fitToMonitor(window); fitToMonitor(window);
if (wndconfig->centerCursor)
_glfwCenterCursorInContentArea(window);
}
else
{
if (wndconfig->visible)
{
_glfwPlatformShowWindow(window);
if (wndconfig->focused)
_glfwPlatformFocusWindow(window);
}
} }
return GLFW_TRUE; return GLFW_TRUE;

View File

@ -221,30 +221,6 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
return NULL; return NULL;
} }
if (ctxconfig.client != GLFW_NO_API)
{
if (!_glfwRefreshContextAttribs(window, &ctxconfig))
{
glfwDestroyWindow((GLFWwindow*) window);
return NULL;
}
}
if (window->monitor)
{
if (wndconfig.centerCursor)
_glfwCenterCursorInContentArea(window);
}
else
{
if (wndconfig.visible)
{
_glfwPlatformShowWindow(window);
if (wndconfig.focused)
_glfwPlatformFocusWindow(window);
}
}
return (GLFWwindow*) window; return (GLFWwindow*) window;
} }

View File

@ -1925,6 +1925,9 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig)) if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
return GLFW_FALSE; return GLFW_FALSE;
} }
if (!_glfwRefreshContextAttribs(window, ctxconfig))
return GLFW_FALSE;
} }
return GLFW_TRUE; return GLFW_TRUE;

View File

@ -2013,6 +2013,9 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig)) if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
return GLFW_FALSE; return GLFW_FALSE;
} }
if (!_glfwRefreshContextAttribs(window, ctxconfig))
return GLFW_FALSE;
} }
if (window->monitor) if (window->monitor)
@ -2020,6 +2023,18 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
_glfwPlatformShowWindow(window); _glfwPlatformShowWindow(window);
updateWindowMode(window); updateWindowMode(window);
acquireMonitor(window); acquireMonitor(window);
if (wndconfig->centerCursor)
_glfwCenterCursorInContentArea(window);
}
else
{
if (wndconfig->visible)
{
_glfwPlatformShowWindow(window);
if (wndconfig->focused)
_glfwPlatformFocusWindow(window);
}
} }
XFlush(_glfw.x11.display); XFlush(_glfw.x11.display);