mirror of
https://github.com/glfw/glfw.git
synced 2025-12-15 11:43:13 +00:00
Wayland: Fix drag-window segfault by using xdg_toplevel from libdecor
glfwDragWindow() previously assumed window->wl.xdg.toplevel was always valid, which is not the case when libdecor provides server-side decorations. This caused window dragging to fail and segfault on native Wayland. The fix retrieves the xdg_toplevel from the libdecor frame when available and adds validation checks for missing seat or serial to prevent additional edge cases.
This commit is contained in:
parent
2444e5b29b
commit
1940dbccfd
@ -2565,7 +2565,33 @@ void _glfwFocusWindowWayland(_GLFWwindow* window)
|
||||
|
||||
void _glfwDragWindowWayland(_GLFWwindow* window)
|
||||
{
|
||||
xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, _glfw.wl.serial);
|
||||
struct xdg_toplevel* toplevel =
|
||||
window->wl.libdecor.frame ?
|
||||
libdecor_frame_get_xdg_toplevel(window->wl.libdecor.frame) :
|
||||
window->wl.xdg.toplevel;
|
||||
|
||||
if (!toplevel)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Wayland: Cannot drag window: xdg_toplevel not created yet");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_glfw.wl.seat)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Wayland: Cannot drag window: no valid seat");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_glfw.wl.serial == 0)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Wayland: Cannot drag window: no valid serial");
|
||||
return;
|
||||
}
|
||||
|
||||
xdg_toplevel_move(toplevel, _glfw.wl.seat, _glfw.wl.serial);
|
||||
}
|
||||
|
||||
void _glfwSetWindowMonitorWayland(_GLFWwindow* window,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user