mirror of
https://github.com/swaywm/sway.git
synced 2024-12-01 02:49:26 +00:00
Touchpad scroll on titlebar
This commit is contained in:
parent
e0a94bee8d
commit
51ff13826b
|
@ -142,3 +142,16 @@ bool sway_set_cloexec(int fd, bool cloexec) {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
float _distance_scrolled = 0;
|
||||
void scroll_distance_add(float delta) {
|
||||
_distance_scrolled += delta;
|
||||
}
|
||||
|
||||
void scroll_distance_reset() {
|
||||
_distance_scrolled = 0;
|
||||
}
|
||||
|
||||
float scroll_distance_get() {
|
||||
return _distance_scrolled;
|
||||
}
|
||||
|
|
|
@ -67,4 +67,8 @@ const char *sway_wl_output_subpixel_to_string(enum wl_output_subpixel subpixel);
|
|||
|
||||
bool sway_set_cloexec(int fd, bool cloexec);
|
||||
|
||||
void scroll_distance_add(float delta);
|
||||
void scroll_distance_reset();
|
||||
float scroll_distance_get();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "sway/tree/view.h"
|
||||
#include "sway/tree/workspace.h"
|
||||
#include "log.h"
|
||||
#include "util.h"
|
||||
#if HAVE_XWAYLAND
|
||||
#include "sway/xwayland.h"
|
||||
#endif
|
||||
|
@ -709,8 +710,17 @@ static void handle_pointer_axis(struct sway_seat *seat,
|
|||
struct sway_node *active =
|
||||
seat_get_active_tiling_child(seat, tabcontainer);
|
||||
list_t *siblings = container_get_siblings(cont);
|
||||
int delta_discrete = event->delta_discrete;
|
||||
if (delta_discrete == 0) {
|
||||
scroll_distance_add(event->delta);
|
||||
float dist = scroll_distance_get();
|
||||
delta_discrete = round(dist / 10.);
|
||||
if (abs(delta_discrete) > 0) {
|
||||
scroll_distance_reset();
|
||||
}
|
||||
}
|
||||
int desired = list_find(siblings, active->sway_container) +
|
||||
round(scroll_factor * event->delta_discrete);
|
||||
round(scroll_factor * delta_discrete);
|
||||
if (desired < 0) {
|
||||
desired = 0;
|
||||
} else if (desired >= siblings->length) {
|
||||
|
|
Loading…
Reference in a new issue