mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 13:04:35 +00:00
Fix resizing and moving under xdg-shell
This commit is contained in:
parent
a0dbffb8f2
commit
a8e551cffa
101
src/wl_init.c
101
src/wl_init.c
@ -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;
|
||||||
switch (window->wl.decorations.focus)
|
if (button == BTN_LEFT)
|
||||||
{
|
{
|
||||||
case mainWindow:
|
switch (window->wl.decorations.focus)
|
||||||
break;
|
{
|
||||||
case topDecoration:
|
case mainWindow:
|
||||||
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
|
break;
|
||||||
wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat,
|
case topDecoration:
|
||||||
serial, WL_SHELL_SURFACE_RESIZE_TOP);
|
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
|
||||||
else
|
edges = WL_SHELL_SURFACE_RESIZE_TOP;
|
||||||
wl_shell_surface_move(window->wl.shellSurface, _glfw.wl.seat, serial);
|
else
|
||||||
return;
|
{
|
||||||
case leftDecoration:
|
if (window->wl.xdg.toplevel)
|
||||||
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
|
xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, serial);
|
||||||
wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat,
|
else
|
||||||
serial, WL_SHELL_SURFACE_RESIZE_TOP_LEFT);
|
wl_shell_surface_move(window->wl.shellSurface, _glfw.wl.seat, serial);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case leftDecoration:
|
||||||
|
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
|
||||||
|
edges = WL_SHELL_SURFACE_RESIZE_TOP_LEFT;
|
||||||
|
else
|
||||||
|
edges = WL_SHELL_SURFACE_RESIZE_LEFT;
|
||||||
|
break;
|
||||||
|
case rightDecoration:
|
||||||
|
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
|
||||||
|
edges = WL_SHELL_SURFACE_RESIZE_TOP_RIGHT;
|
||||||
|
else
|
||||||
|
edges = WL_SHELL_SURFACE_RESIZE_RIGHT;
|
||||||
|
break;
|
||||||
|
case bottomDecoration:
|
||||||
|
if (window->wl.cursorPosX < _GLFW_DECORATION_WIDTH)
|
||||||
|
edges = WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT;
|
||||||
|
else if (window->wl.cursorPosX > window->wl.width + _GLFW_DECORATION_WIDTH)
|
||||||
|
edges = WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT;
|
||||||
|
else
|
||||||
|
edges = WL_SHELL_SURFACE_RESIZE_BOTTOM;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
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
|
else
|
||||||
wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat,
|
wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat,
|
||||||
serial, WL_SHELL_SURFACE_RESIZE_LEFT);
|
serial, edges);
|
||||||
return;
|
}
|
||||||
case rightDecoration:
|
|
||||||
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
|
|
||||||
wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat,
|
|
||||||
serial, WL_SHELL_SURFACE_RESIZE_TOP_RIGHT);
|
|
||||||
else
|
|
||||||
wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat,
|
|
||||||
serial, WL_SHELL_SURFACE_RESIZE_RIGHT);
|
|
||||||
return;
|
|
||||||
case bottomDecoration:
|
|
||||||
if (window->wl.cursorPosX < _GLFW_DECORATION_WIDTH)
|
|
||||||
wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat,
|
|
||||||
serial, WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT);
|
|
||||||
else if (window->wl.cursorPosX > window->wl.width + _GLFW_DECORATION_WIDTH)
|
|
||||||
wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat,
|
|
||||||
serial, WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT);
|
|
||||||
else
|
|
||||||
wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat,
|
|
||||||
serial, WL_SHELL_SURFACE_RESIZE_BOTTOM);
|
|
||||||
return;
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
}
|
}
|
||||||
|
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