Fix resizing and moving under xdg-shell

master
Emmanuel Gil Peyrot ago%!(EXTRA string=7 years) committed by linkmauve
parent a0dbffb8f2
commit a8e551cffa
  1. 99
      src/wl_init.c

@ -224,50 +224,77 @@ 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);
else }
wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat, break;
serial, WL_SHELL_SURFACE_RESIZE_LEFT); case leftDecoration:
return; if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
case rightDecoration: edges = WL_SHELL_SURFACE_RESIZE_TOP_LEFT;
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH) else
wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat, edges = WL_SHELL_SURFACE_RESIZE_LEFT;
serial, WL_SHELL_SURFACE_RESIZE_TOP_RIGHT); break;
else case rightDecoration:
wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat, if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
serial, WL_SHELL_SURFACE_RESIZE_RIGHT); edges = WL_SHELL_SURFACE_RESIZE_TOP_RIGHT;
return; else
case bottomDecoration: edges = WL_SHELL_SURFACE_RESIZE_RIGHT;
if (window->wl.cursorPosX < _GLFW_DECORATION_WIDTH) break;
wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat, case bottomDecoration:
serial, WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT); if (window->wl.cursorPosX < _GLFW_DECORATION_WIDTH)
else if (window->wl.cursorPosX > window->wl.width + _GLFW_DECORATION_WIDTH) edges = WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT;
wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat, else if (window->wl.cursorPosX > window->wl.width + _GLFW_DECORATION_WIDTH)
serial, WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT); 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_BOTTOM); 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; return;
default: }
assert(0);
} }
// 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;
/* Makes left, right and middle 0, 1 and 2. Overall order follows evdev /* Makes left, right and middle 0, 1 and 2. Overall order follows evdev

Loading…
Cancel
Save