Fix mouse handling when using client side decorations
The mouse co-ordinates used by glfw were all wrong.
This commit is contained in:
parent
7c7933efa9
commit
fc8e147e4a
@ -146,6 +146,8 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
|
|||||||
|
|
||||||
- Wayland: Add support for the text input protocol (:iss:`3410`)
|
- Wayland: Add support for the text input protocol (:iss:`3410`)
|
||||||
|
|
||||||
|
- Wayland: Fix mouse handling when using client side decorations
|
||||||
|
|
||||||
- Add an option, :opt:`detect_urls` to control whether kitty will detect URLs
|
- Add an option, :opt:`detect_urls` to control whether kitty will detect URLs
|
||||||
when the mouse moves over them (:pull:`3118`)
|
when the mouse moves over them (:pull:`3118`)
|
||||||
|
|
||||||
|
|||||||
24
glfw/wl_init.c
vendored
24
glfw/wl_init.c
vendored
@ -173,6 +173,8 @@ static void setCursor(GLFWCursorShape shape, _GLFWwindow* window)
|
|||||||
_glfw.wl.cursorPreviousShape = shape;
|
_glfw.wl.cursorPreviousShape = shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define x window->wl.allCursorPosX
|
||||||
|
#define y window->wl.allCursorPosY
|
||||||
static void pointerHandleMotion(void* data UNUSED,
|
static void pointerHandleMotion(void* data UNUSED,
|
||||||
struct wl_pointer* pointer UNUSED,
|
struct wl_pointer* pointer UNUSED,
|
||||||
uint32_t time UNUSED,
|
uint32_t time UNUSED,
|
||||||
@ -181,15 +183,14 @@ static void pointerHandleMotion(void* data UNUSED,
|
|||||||
{
|
{
|
||||||
_GLFWwindow* window = _glfw.wl.pointerFocus;
|
_GLFWwindow* window = _glfw.wl.pointerFocus;
|
||||||
GLFWCursorShape cursorShape = GLFW_ARROW_CURSOR;
|
GLFWCursorShape cursorShape = GLFW_ARROW_CURSOR;
|
||||||
double x, y;
|
|
||||||
|
|
||||||
if (!window)
|
if (!window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
return;
|
return;
|
||||||
x = wl_fixed_to_double(sx);
|
window->wl.allCursorPosX = wl_fixed_to_double(sx);
|
||||||
y = wl_fixed_to_double(sy);
|
window->wl.allCursorPosY = wl_fixed_to_double(sy);
|
||||||
|
|
||||||
switch (window->wl.decorations.focus)
|
switch (window->wl.decorations.focus)
|
||||||
{
|
{
|
||||||
@ -252,7 +253,7 @@ static void pointerHandleButton(void* data UNUSED,
|
|||||||
case mainWindow:
|
case mainWindow:
|
||||||
break;
|
break;
|
||||||
case topDecoration:
|
case topDecoration:
|
||||||
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
|
if (y < _GLFW_DECORATION_WIDTH)
|
||||||
edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP;
|
edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -261,21 +262,21 @@ static void pointerHandleButton(void* data UNUSED,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case leftDecoration:
|
case leftDecoration:
|
||||||
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
|
if (y < _GLFW_DECORATION_WIDTH)
|
||||||
edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT;
|
edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT;
|
||||||
else
|
else
|
||||||
edges = XDG_TOPLEVEL_RESIZE_EDGE_LEFT;
|
edges = XDG_TOPLEVEL_RESIZE_EDGE_LEFT;
|
||||||
break;
|
break;
|
||||||
case rightDecoration:
|
case rightDecoration:
|
||||||
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
|
if (y < _GLFW_DECORATION_WIDTH)
|
||||||
edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT;
|
edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT;
|
||||||
else
|
else
|
||||||
edges = XDG_TOPLEVEL_RESIZE_EDGE_RIGHT;
|
edges = XDG_TOPLEVEL_RESIZE_EDGE_RIGHT;
|
||||||
break;
|
break;
|
||||||
case bottomDecoration:
|
case bottomDecoration:
|
||||||
if (window->wl.cursorPosX < _GLFW_DECORATION_WIDTH)
|
if (x < _GLFW_DECORATION_WIDTH)
|
||||||
edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT;
|
edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT;
|
||||||
else if (window->wl.cursorPosX > window->wl.width + _GLFW_DECORATION_WIDTH)
|
else if (x > window->wl.width + _GLFW_DECORATION_WIDTH)
|
||||||
edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT;
|
edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT;
|
||||||
else
|
else
|
||||||
edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM;
|
edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM;
|
||||||
@ -293,10 +294,7 @@ static void pointerHandleButton(void* data UNUSED,
|
|||||||
{
|
{
|
||||||
if (window->wl.decorations.focus != mainWindow && window->wl.xdg.toplevel)
|
if (window->wl.decorations.focus != mainWindow && window->wl.xdg.toplevel)
|
||||||
{
|
{
|
||||||
xdg_toplevel_show_window_menu(window->wl.xdg.toplevel,
|
xdg_toplevel_show_window_menu(window->wl.xdg.toplevel, _glfw.wl.seat, serial, (int32_t)x, (int32_t)y - _GLFW_DECORATION_TOP);
|
||||||
_glfw.wl.seat, serial,
|
|
||||||
(int32_t)window->wl.cursorPosX,
|
|
||||||
(int32_t)window->wl.cursorPosY);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -318,6 +316,8 @@ static void pointerHandleButton(void* data UNUSED,
|
|||||||
: GLFW_RELEASE,
|
: GLFW_RELEASE,
|
||||||
_glfw.wl.xkb.states.modifiers);
|
_glfw.wl.xkb.states.modifiers);
|
||||||
}
|
}
|
||||||
|
#undef x
|
||||||
|
#undef y
|
||||||
|
|
||||||
static void pointerHandleAxis(void* data UNUSED,
|
static void pointerHandleAxis(void* data UNUSED,
|
||||||
struct wl_pointer* pointer UNUSED,
|
struct wl_pointer* pointer UNUSED,
|
||||||
|
|||||||
2
glfw/wl_platform.h
vendored
2
glfw/wl_platform.h
vendored
@ -132,7 +132,7 @@ typedef struct _GLFWwindowWayland
|
|||||||
} xdg;
|
} xdg;
|
||||||
|
|
||||||
_GLFWcursor* currentCursor;
|
_GLFWcursor* currentCursor;
|
||||||
double cursorPosX, cursorPosY;
|
double cursorPosX, cursorPosY, allCursorPosX, allCursorPosY;
|
||||||
|
|
||||||
char* title;
|
char* title;
|
||||||
char appId[256];
|
char appId[256];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user