Wayland: Use Wayland to wait for libdecor to init

Much of libdecor is initialized only after certain events have been
received from the compositor and some parts of libdecor 0.1 are unsafe
to use until this delayed initialization has completed.

Since libdecor does not provide an API to query if or be notified when
this has happened, GLFW processed events until its newly created
libdecor frame had created its XDG shell objects.

This commit switches to using a generic Wayland sync point created just
after libdecor (and presumably its plugin) has set up its delayed
initialization, instead of relying on the more specific implementation
detail mentioned above.

It also makes this wait mandatory before the first libdecor frame is
created instead of a pre-condition for certain libdecor frame calls,
hopefully removing even more dependence on implementation details.
This commit is contained in:
Camilla Löwy
2023-11-30 02:43:48 +01:00
parent 23ea072c41
commit 9fdc425931
3 changed files with 35 additions and 9 deletions
+4 -6
View File
@@ -735,6 +735,10 @@ static const struct libdecor_frame_interface libdecorFrameInterface =
static GLFWbool createLibdecorFrame(_GLFWwindow* window)
{
// Allow libdecor to finish initialization of itself and its plugin
while (!_glfw.wl.libdecor.ready)
_glfwWaitEventsWayland();
window->wl.libdecor.frame = libdecor_decorate(_glfw.wl.libdecor.context,
window->wl.surface,
&libdecorFrameInterface,
@@ -776,12 +780,6 @@ static GLFWbool createLibdecorFrame(_GLFWwindow* window)
if (window->monitor)
{
// HACK: Allow libdecor to finish initialization of itself and its
// plugin so it will create the xdg_toplevel for the frame
// This needs to exist when setting the frame to fullscreen
while (!libdecor_frame_get_xdg_toplevel(window->wl.libdecor.frame))
_glfwWaitEventsWayland();
libdecor_frame_set_fullscreen(window->wl.libdecor.frame,
window->monitor->wl.output);
setIdleInhibitor(window, GLFW_TRUE);