swaybar: fix scrolling behaviour
1. wrap_scroll has been fixed 2. release bindings are checked when returning early
This commit is contained in:
parent
c3fdabb725
commit
c5541763c0
|
@ -152,10 +152,9 @@ static void wl_pointer_axis(void *data, struct wl_pointer *wl_pointer,
|
||||||
|
|
||||||
// If there is a button press binding, execute it, skip default behavior,
|
// If there is a button press binding, execute it, skip default behavior,
|
||||||
// and check button release bindings
|
// and check button release bindings
|
||||||
if (check_bindings(bar, wl_axis_to_x11_button(axis, value),
|
enum x11_button button = wl_axis_to_x11_button(axis, value);
|
||||||
WL_POINTER_BUTTON_STATE_PRESSED)) {
|
if (check_bindings(bar, button, WL_POINTER_BUTTON_STATE_PRESSED)) {
|
||||||
check_bindings(bar, wl_axis_to_x11_button(axis, value),
|
check_bindings(bar, button, WL_POINTER_BUTTON_STATE_RELEASED);
|
||||||
WL_POINTER_BUTTON_STATE_RELEASED);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,68 +167,55 @@ static void wl_pointer_axis(void *data, struct wl_pointer *wl_pointer,
|
||||||
&& x < hotspot->x + hotspot->width
|
&& x < hotspot->x + hotspot->width
|
||||||
&& y < hotspot->y + hotspot->height) {
|
&& y < hotspot->y + hotspot->height) {
|
||||||
if (HOTSPOT_IGNORE == hotspot->callback(
|
if (HOTSPOT_IGNORE == hotspot->callback(
|
||||||
output, pointer->x, pointer->y,
|
output, pointer->x, pointer->y, button, hotspot->data)) {
|
||||||
wl_axis_to_x11_button(axis, value), hotspot->data)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct swaybar_config *config = bar->config;
|
||||||
double amt = wl_fixed_to_double(value);
|
double amt = wl_fixed_to_double(value);
|
||||||
if (amt == 0.0) {
|
if (amt == 0.0 || !config->workspace_buttons) {
|
||||||
|
check_bindings(bar, button, WL_POINTER_BUTTON_STATE_RELEASED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// last doesn't actually need initialization,
|
struct swaybar_workspace *first =
|
||||||
// but gcc (7.3.1) is too dumb to figure it out
|
wl_container_of(output->workspaces.next, first, link);
|
||||||
struct swaybar_workspace *first = NULL;
|
struct swaybar_workspace *last =
|
||||||
struct swaybar_workspace *active = NULL;
|
wl_container_of(output->workspaces.prev, last, link);
|
||||||
struct swaybar_workspace *last = NULL;
|
|
||||||
|
|
||||||
struct swaybar_workspace *iter;
|
struct swaybar_workspace *active;
|
||||||
wl_list_for_each(iter, &output->workspaces, link) {
|
wl_list_for_each(active, &output->workspaces, link) {
|
||||||
if (!first) {
|
if (active->visible) {
|
||||||
first = iter;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iter->visible) {
|
|
||||||
active = iter;
|
|
||||||
}
|
|
||||||
|
|
||||||
last = iter;
|
|
||||||
}
|
}
|
||||||
|
if (!sway_assert(active->visible, "axis with null workspace")) {
|
||||||
if (!sway_assert(active, "axis with null workspace")) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct swaybar_workspace *new;
|
struct swaybar_workspace *new;
|
||||||
|
|
||||||
if (amt < 0.0) {
|
if (amt < 0.0) {
|
||||||
if (active == first) {
|
if (active == first) {
|
||||||
if (!bar->config->wrap_scroll) {
|
new = config->wrap_scroll ? last : NULL;
|
||||||
return;
|
} else {
|
||||||
}
|
new = wl_container_of(active->link.prev, new, link);
|
||||||
new = last;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
new = wl_container_of(active->link.prev, new, link);
|
|
||||||
} else {
|
} else {
|
||||||
if (active == last) {
|
if (active == last) {
|
||||||
if (!bar->config->wrap_scroll) {
|
new = config->wrap_scroll ? first : NULL;
|
||||||
return;
|
} else {
|
||||||
}
|
new = wl_container_of(active->link.next, new, link);
|
||||||
new = first;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
new = wl_container_of(active->link.next, new, link);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ipc_send_workspace_command(bar, new->name);
|
if (new) {
|
||||||
|
ipc_send_workspace_command(bar, new->name);
|
||||||
|
}
|
||||||
|
|
||||||
// Check button release bindings
|
// Check button release bindings
|
||||||
check_bindings(bar, wl_axis_to_x11_button(axis, value),
|
check_bindings(bar, button, WL_POINTER_BUTTON_STATE_RELEASED);
|
||||||
WL_POINTER_BUTTON_STATE_RELEASED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wl_pointer_frame(void *data, struct wl_pointer *wl_pointer) {
|
static void wl_pointer_frame(void *data, struct wl_pointer *wl_pointer) {
|
||||||
|
|
Loading…
Reference in a new issue