mirror of
https://github.com/swaywm/sway.git
synced 2024-11-19 14:39:15 +00:00
Merge branch 'master' into rename-surface-subsurfaces
This commit is contained in:
commit
e4965f7dac
|
@ -156,31 +156,56 @@ static void wl_pointer_axis(void *data, struct wl_pointer *wl_pointer,
|
||||||
if (!sway_assert(output, "axis with no active output")) {
|
if (!sway_assert(output, "axis with no active output")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double amt = wl_fixed_to_double(value);
|
double amt = wl_fixed_to_double(value);
|
||||||
if (!bar->config->wrap_scroll) {
|
if (amt == 0.0) {
|
||||||
int i = 0;
|
|
||||||
struct swaybar_workspace *ws = NULL;
|
|
||||||
wl_list_for_each(ws, &output->workspaces, link) {
|
|
||||||
if (ws->focused) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
int len = wl_list_length(&output->workspaces);
|
|
||||||
if (!sway_assert(i != len, "axis with null workspace")) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (i == 0 && amt > 0) {
|
|
||||||
return; // Do not wrap
|
struct swaybar_workspace *first = NULL;
|
||||||
}
|
struct swaybar_workspace *active = NULL;
|
||||||
if (i == len - 1 && amt < 0) {
|
struct swaybar_workspace *last;
|
||||||
return; // Do not wrap
|
|
||||||
}
|
struct swaybar_workspace *iter;
|
||||||
|
wl_list_for_each(iter, &output->workspaces, link) {
|
||||||
|
if (!first) {
|
||||||
|
first = iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *workspace_name =
|
if (iter->visible) {
|
||||||
amt < 0 ? "prev_on_output" : "next_on_output";
|
active = iter;
|
||||||
ipc_send_workspace_command(bar, workspace_name);
|
}
|
||||||
|
|
||||||
|
last = iter;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sway_assert(active, "axis with null workspace")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct swaybar_workspace *new;
|
||||||
|
|
||||||
|
if (amt > 0.0) {
|
||||||
|
if (active == first) {
|
||||||
|
if (!bar->config->wrap_scroll) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
new = last;
|
||||||
|
}
|
||||||
|
|
||||||
|
new = wl_container_of(active->link.prev, new, link);
|
||||||
|
} else {
|
||||||
|
if (active == last) {
|
||||||
|
if (!bar->config->wrap_scroll) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
new = first;
|
||||||
|
}
|
||||||
|
|
||||||
|
new = wl_container_of(active->link.next, new, link);
|
||||||
|
}
|
||||||
|
|
||||||
|
ipc_send_workspace_command(bar, new->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
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