Skip to content

Commit 6d5d3ae

Browse files
committed
improve reliability of mouse.scrolled event
1 parent bfbfdfc commit 6d5d3ae

File tree

1 file changed

+34
-33
lines changed

1 file changed

+34
-33
lines changed

src/event.c

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -255,39 +255,6 @@ static void event_mouse_scrolled(void* context) {
255255
= clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW_APPROX);
256256
}
257257

258-
259-
struct bar* bar = bar_manager_get_bar_by_wid(&g_bar_manager, wid);
260-
if (bar) {
261-
// Handle global mouse scrolled event
262-
if (bar->mouse_over
263-
&& !bar_manager_mouse_over_any_popup(&g_bar_manager)) {
264-
bar_manager_handle_mouse_scrolled_global(&g_bar_manager,
265-
scroll_delta
266-
+ g_scroll_info.delta_y,
267-
bar->adid,
268-
modifier_keys );
269-
}
270-
271-
g_scroll_info.delta_y = 0;
272-
return;
273-
}
274-
275-
struct popup* popup = bar_manager_get_popup_by_wid(&g_bar_manager, wid);
276-
if (popup) {
277-
// Handle global mouse scrolled event
278-
if (popup->mouse_over
279-
&& !bar_manager_mouse_over_any_bar(&g_bar_manager)) {
280-
bar_manager_handle_mouse_scrolled_global(&g_bar_manager,
281-
scroll_delta
282-
+ g_scroll_info.delta_y,
283-
popup->adid,
284-
modifier_keys );
285-
}
286-
287-
g_scroll_info.delta_y = 0;
288-
return;
289-
}
290-
291258
struct bar_item* bar_item = bar_manager_get_item_by_wid(&g_bar_manager,
292259
wid,
293260
NULL );
@@ -296,6 +263,40 @@ static void event_mouse_scrolled(void* context) {
296263
bar_item = bar_manager_get_item_by_point(&g_bar_manager, point, NULL);
297264
}
298265

266+
if (!bar_item) {
267+
struct bar* bar = bar_manager_get_bar_by_wid(&g_bar_manager, wid);
268+
if (bar) {
269+
// Handle global mouse scrolled event
270+
if (bar->mouse_over
271+
&& !bar_manager_mouse_over_any_popup(&g_bar_manager)) {
272+
bar_manager_handle_mouse_scrolled_global(&g_bar_manager,
273+
scroll_delta
274+
+ g_scroll_info.delta_y,
275+
bar->adid,
276+
modifier_keys );
277+
}
278+
279+
g_scroll_info.delta_y = 0;
280+
return;
281+
}
282+
283+
struct popup* popup = bar_manager_get_popup_by_wid(&g_bar_manager, wid);
284+
if (popup) {
285+
// Handle global mouse scrolled event
286+
if (popup->mouse_over
287+
&& !bar_manager_mouse_over_any_bar(&g_bar_manager)) {
288+
bar_manager_handle_mouse_scrolled_global(&g_bar_manager,
289+
scroll_delta
290+
+ g_scroll_info.delta_y,
291+
popup->adid,
292+
modifier_keys );
293+
}
294+
295+
g_scroll_info.delta_y = 0;
296+
return;
297+
}
298+
}
299+
299300
bar_item_on_scroll(bar_item,
300301
scroll_delta + g_scroll_info.delta_y,
301302
modifier_keys );

0 commit comments

Comments
 (0)