Skip to content

Commit 655b003

Browse files
author
Drew DeVault
committed
Fix pointer scroll thing
1 parent ebead7a commit 655b003

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

sway/handlers.c

+29-24
Original file line numberDiff line numberDiff line change
@@ -647,30 +647,6 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w
647647
case M_SCROLL_DOWN:
648648
break;
649649
}
650-
if (!(modifiers->mods ^ config->floating_mod) &&
651-
(button == M_SCROLL_UP || button == M_SCROLL_DOWN)) {
652-
switch (config->floating_scroll) {
653-
case FSB_GAPS_INNER:
654-
case FSB_GAPS_OUTER:
655-
{
656-
int amount = button == M_SCROLL_UP ? -1 : 1;
657-
int i,j;
658-
for (i = 0; i < root_container.children->length; ++i) {
659-
swayc_t *op = root_container.children->items[i];
660-
for (j = 0; j < op->children->length; ++j) {
661-
swayc_t *ws = op->children->items[j];
662-
if (config->floating_scroll == FSB_GAPS_INNER) {
663-
container_map(ws, add_gaps, &amount);
664-
} else {
665-
ws->gaps += amount;
666-
}
667-
}
668-
}
669-
arrange_windows(&root_container, -1, -1);
670-
break;
671-
}
672-
}
673-
}
674650

675651
// get focused window and check if to change focus on mouse click
676652
swayc_t *focused = get_focused_container(&root_container);
@@ -719,6 +695,34 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w
719695
return EVENT_PASSTHROUGH;
720696
}
721697

698+
bool handle_pointer_scroll(wlc_handle view, uint32_t time, const struct wlc_modifiers* modifiers,
699+
uint8_t axis_bits, double _amount[2]) {
700+
if (!(modifiers->mods ^ config->floating_mod)) {
701+
switch (config->floating_scroll) {
702+
case FSB_GAPS_INNER:
703+
case FSB_GAPS_OUTER:
704+
{
705+
int amount = (int)_amount[0];
706+
int i,j;
707+
for (i = 0; i < root_container.children->length; ++i) {
708+
swayc_t *op = root_container.children->items[i];
709+
for (j = 0; j < op->children->length; ++j) {
710+
swayc_t *ws = op->children->items[j];
711+
if (config->floating_scroll == FSB_GAPS_INNER) {
712+
container_map(ws, add_gaps, &amount);
713+
} else {
714+
ws->gaps += amount;
715+
}
716+
}
717+
}
718+
arrange_windows(&root_container, -1, -1);
719+
break;
720+
}
721+
}
722+
}
723+
return EVENT_PASSTHROUGH;
724+
}
725+
722726
static void handle_wlc_ready(void) {
723727
sway_log(L_DEBUG, "Compositor is ready, executing cmds in queue");
724728
// Execute commands until there are none left
@@ -751,6 +755,7 @@ void register_wlc_handlers() {
751755
wlc_set_keyboard_key_cb(handle_key);
752756
wlc_set_pointer_motion_cb(handle_pointer_motion);
753757
wlc_set_pointer_button_cb(handle_pointer_button);
758+
wlc_set_pointer_scroll_cb(handle_pointer_scroll);
754759
wlc_set_compositor_ready_cb(handle_wlc_ready);
755760
wlc_set_input_created_cb(handle_input_created);
756761
wlc_set_input_destroyed_cb(handle_input_destroyed);

0 commit comments

Comments
 (0)