mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 21:14:35 +00:00
Fix resizing and moving under xdg-shell
This commit is contained in:
parent
a0dbffb8f2
commit
a8e551cffa
@ -224,49 +224,76 @@ static void pointerHandleButton(void* data,
|
|||||||
_GLFWwindow* window = _glfw.wl.pointerFocus;
|
_GLFWwindow* window = _glfw.wl.pointerFocus;
|
||||||
int glfwButton;
|
int glfwButton;
|
||||||
|
|
||||||
|
// Both xdg-shell and wl_shell use the same values.
|
||||||
|
uint32_t edges = WL_SHELL_SURFACE_RESIZE_NONE;
|
||||||
|
|
||||||
if (!window)
|
if (!window)
|
||||||
return;
|
return;
|
||||||
|
if (button == BTN_LEFT)
|
||||||
|
{
|
||||||
switch (window->wl.decorations.focus)
|
switch (window->wl.decorations.focus)
|
||||||
{
|
{
|
||||||
case mainWindow:
|
case mainWindow:
|
||||||
break;
|
break;
|
||||||
case topDecoration:
|
case topDecoration:
|
||||||
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
|
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
|
||||||
wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat,
|
edges = WL_SHELL_SURFACE_RESIZE_TOP;
|
||||||
serial, WL_SHELL_SURFACE_RESIZE_TOP);
|
else
|
||||||
|
{
|
||||||
|
if (window->wl.xdg.toplevel)
|
||||||
|
xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, serial);
|
||||||
else
|
else
|
||||||
wl_shell_surface_move(window->wl.shellSurface, _glfw.wl.seat, serial);
|
wl_shell_surface_move(window->wl.shellSurface, _glfw.wl.seat, serial);
|
||||||
return;
|
}
|
||||||
|
break;
|
||||||
case leftDecoration:
|
case leftDecoration:
|
||||||
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
|
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
|
||||||
wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat,
|
edges = WL_SHELL_SURFACE_RESIZE_TOP_LEFT;
|
||||||
serial, WL_SHELL_SURFACE_RESIZE_TOP_LEFT);
|
|
||||||
else
|
else
|
||||||
wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat,
|
edges = WL_SHELL_SURFACE_RESIZE_LEFT;
|
||||||
serial, WL_SHELL_SURFACE_RESIZE_LEFT);
|
break;
|
||||||
return;
|
|
||||||
case rightDecoration:
|
case rightDecoration:
|
||||||
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
|
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
|
||||||
wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat,
|
edges = WL_SHELL_SURFACE_RESIZE_TOP_RIGHT;
|
||||||
serial, WL_SHELL_SURFACE_RESIZE_TOP_RIGHT);
|
|
||||||
else
|
else
|
||||||
wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat,
|
edges = WL_SHELL_SURFACE_RESIZE_RIGHT;
|
||||||
serial, WL_SHELL_SURFACE_RESIZE_RIGHT);
|
break;
|
||||||
return;
|
|
||||||
case bottomDecoration:
|
case bottomDecoration:
|
||||||
if (window->wl.cursorPosX < _GLFW_DECORATION_WIDTH)
|
if (window->wl.cursorPosX < _GLFW_DECORATION_WIDTH)
|
||||||
wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat,
|
edges = WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT;
|
||||||
serial, WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT);
|
|
||||||
else if (window->wl.cursorPosX > window->wl.width + _GLFW_DECORATION_WIDTH)
|
else if (window->wl.cursorPosX > window->wl.width + _GLFW_DECORATION_WIDTH)
|
||||||
wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat,
|
edges = WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT;
|
||||||
serial, WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT);
|
|
||||||
else
|
else
|
||||||
wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat,
|
edges = WL_SHELL_SURFACE_RESIZE_BOTTOM;
|
||||||
serial, WL_SHELL_SURFACE_RESIZE_BOTTOM);
|
break;
|
||||||
return;
|
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
if (edges != WL_SHELL_SURFACE_RESIZE_NONE)
|
||||||
|
{
|
||||||
|
if (window->wl.xdg.toplevel)
|
||||||
|
xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat,
|
||||||
|
serial, edges);
|
||||||
|
else
|
||||||
|
wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat,
|
||||||
|
serial, edges);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (button == BTN_RIGHT)
|
||||||
|
{
|
||||||
|
if (window->wl.decorations.focus != mainWindow && window->wl.xdg.toplevel)
|
||||||
|
{
|
||||||
|
xdg_toplevel_show_window_menu(window->wl.xdg.toplevel,
|
||||||
|
_glfw.wl.seat, serial,
|
||||||
|
window->wl.cursorPosX,
|
||||||
|
window->wl.cursorPosY);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don’t pass the button to the user if it was related to a decoration.
|
||||||
|
if (window->wl.decorations.focus != mainWindow)
|
||||||
|
return;
|
||||||
|
|
||||||
_glfw.wl.pointerSerial = serial;
|
_glfw.wl.pointerSerial = serial;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user