summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFurkan Sahin <furkan-dev@proton.me>2019-08-15 19:48:17 -0400
committerFurkan Sahin <furkan-dev@proton.me>2019-08-15 19:48:17 -0400
commit9a8bc3cdb5aa822d964c2f4e33c6f013bd081b0f (patch)
treeb19e1b64f3df07ae28857db8c619308c0183ef3e
parent3c8d496c81db98ddc96a807118f372335d330b4e (diff)
input/seatop_down: add axis handler
This adds an axis handler to seatop_down so that it is possible to manually scroll while having a mouse button down. This is mainly useful for selecting text. Some applications may not automatically scroll when the cursor is near the edge of the application or the user may just prefer manually scrolling for more control over the scrolling speed.
-rw-r--r--sway/input/seatop_down.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/sway/input/seatop_down.c b/sway/input/seatop_down.c
index 95ea7cbb..04de894d 100644
--- a/sway/input/seatop_down.c
+++ b/sway/input/seatop_down.c
@@ -1,4 +1,5 @@
#define _POSIX_C_SOURCE 200809L
+#include <float.h>
#include <wlr/types/wlr_cursor.h>
#include "sway/input/cursor.h"
#include "sway/input/seat.h"
@@ -11,6 +12,20 @@ struct seatop_down_event {
double ref_con_lx, ref_con_ly; // container's x/y at start of op
};
+static void handle_axis(struct sway_seat *seat,
+ struct wlr_event_pointer_axis *event) {
+ struct sway_input_device *input_device =
+ event->device ? event->device->data : NULL;
+ struct input_config *ic =
+ input_device ? input_device_get_config(input_device) : NULL;
+ float scroll_factor =
+ (ic == NULL || ic->scroll_factor == FLT_MIN) ? 1.0f : ic->scroll_factor;
+
+ wlr_seat_pointer_notify_axis(seat->wlr_seat, event->time_msec,
+ event->orientation, scroll_factor * event->delta,
+ round(scroll_factor * event->delta_discrete), event->source);
+}
+
static void handle_button(struct sway_seat *seat, uint32_t time_msec,
struct wlr_input_device *device, uint32_t button,
enum wlr_button_state state) {
@@ -42,6 +57,7 @@ static void handle_unref(struct sway_seat *seat, struct sway_container *con) {
}
static const struct sway_seatop_impl seatop_impl = {
+ .axis = handle_axis,
.button = handle_button,
.motion = handle_motion,
.unref = handle_unref,