Mouse reporting: Fix incorrect position reported for windows with padding

Fixes #6950
This commit is contained in:
Kovid Goyal 2023-12-26 22:27:20 +05:30
parent 858f0c1073
commit 0a2fcf1805
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 3 additions and 1 deletions

View file

@ -73,6 +73,8 @@ Detailed list of changes
- GNOME Wayland: Fix remembered window size smaller than actual size (:iss:`6946`)
- Mouse reporting: Fix incorrect position reported for windows with padding (:iss:`6950`)
0.31.0 [2023-11-08]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View file

@ -236,7 +236,7 @@ cell_for_pos(Window *w, unsigned int *x, unsigned int *y, bool *in_left_half_of_
bool in_left_half = true;
double mouse_x = global_state.callback_os_window->mouse_x;
double mouse_y = global_state.callback_os_window->mouse_y;
double left = window_left(w), top = window_top(w), right = window_right(w), bottom = window_bottom(w);
double left = g->left, top = g->top, right = g->right, bottom = g->bottom;
w->mouse_pos.global_x = mouse_x - left; w->mouse_pos.global_y = mouse_y - top;
if (clamp_to_window) {
mouse_x = MIN(MAX(mouse_x, left), right);