Skip to content
Myr

wayland: always update selected entry on mouse click and motion events

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Before this patch, we tracked the last hovered entry in the seat struct. Then, when clicking, we checked if we clicked the same entry, then execute the selected entry. The problem is the *selected* entry may be another entry, if the selection was moved with the keyboard, after hovering it.

authored by Daniel Eklöf · committed by Daniel Eklöf · parent a16822a · Browse files · 3 files+8 added−11 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+8 added−11 removed

  • other:+8 added−11 removed

3 files+8 added−11 removed

modified:CHANGELOG.md+2 added-1 removed
57 unmodified lines
58* `image-size-ratio=0` causing a crash due to a zero-size allocation59 ([#739][739]).60* First entry not being hover-able until other entries have been61 hovered ([#765][765]).62* Clicking an entry did not select it, causing wrong entry to be63 executed.646365[739]: https://codeberg.org/dnkl/fuzzel/issues/73966[765]: https://codeberg.org/dnkl/fuzzel/issues/7656768### Security
1151 unmodified lines
modified:wayland.c+6 added-9 removed
1134 unmodified lines
11351136 if (hovered_row < 0)1137 return;11381139 if (hovered_row != seat->pointer.hovered_row_idx) {1140 seat->pointer.hovered_row_idx = hovered_row;1141 refresh = matches_idx_select(wayl->matches,hovered_row);1139 refresh = matches_idx_select(wayl->matches, hovered_row);1142 }11401144 if (refresh_always || refresh) {1141 if (refresh_always || refresh)1142 wayl_refresh(wayl);1146 }1143}11441145static void1146wl_pointer_enter(void *data, struct wl_pointer *wl_pointer,
3 unmodified lines
1150 struct seat *seat = data;1151 if (!seat->wayl->enable_mouse)1152 return;1153 seat->pointer.serial = serial;1158 seat->pointer.hovered_row_idx = -1;11541155 /*1156 * Note: do *not* set seat->pointer.{x,y} here!1157 *
56 unmodified lines
1214 if (!wayl->enable_mouse)1215 return;12161217 if (state == WL_POINTER_BUTTON_STATE_RELEASED) {1223 if (button == BTN_LEFT && seat->pointer.hovered_row_idx != -1) {1218 if (button == BTN_LEFT) {1219 ssize_t clicked_row = render_get_row_num(1220 wayl->render, wayl->width, seat->pointer.x, seat->pointer.y,1221 wayl->matches);12221228 if (clicked_row == seat->pointer.hovered_row_idx)1223 if (clicked_row >= 0) {1224 matches_idx_select(wayl->matches, clicked_row);1225 execute_selected(seat, false, -1);1226 }1227 }12281229 else if (button == BTN_RIGHT) {1230 // Same as pressing ESC
1971 unmodified lines
modified:wayland.h-1 removed
47 unmodified lines
48 uint32_t serial;4950 int x;51 int y;52 size_t hovered_row_idx;5253 struct wl_surface *surface;54 struct wp_viewport *viewport;55 struct wl_cursor_theme *theme;
57 unmodified lines