aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/input-manager.c
diff options
context:
space:
mode:
authorLibravatar Dominique Martinet <asmadeus@codewreck.org>2017-12-24 14:53:00 +0100
committerLibravatar Dominique Martinet <asmadeus@codewreck.org>2017-12-24 20:54:48 +0100
commitf3d8df45fc3b4bca0076bc564bd179d87e307b7c (patch)
tree60601ab8a249f8c957d40a98a2b6199ab4ec9ded /sway/input/input-manager.c
parentMerge pull request #1505 from acrisci/feature/input (diff)
downloadsway-f3d8df45fc3b4bca0076bc564bd179d87e307b7c.tar.gz
sway-f3d8df45fc3b4bca0076bc564bd179d87e307b7c.tar.zst
sway-f3d8df45fc3b4bca0076bc564bd179d87e307b7c.zip
seat_configure_pointer: apply libinput config
Restore the code that used to be in config.c:apply_input_config() pre-wlroots
Diffstat (limited to 'sway/input/input-manager.c')
-rw-r--r--sway/input/input-manager.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c
index 4459c43b..128a818a 100644
--- a/sway/input/input-manager.c
+++ b/sway/input/input-manager.c
@@ -6,6 +6,7 @@
6#include <string.h> 6#include <string.h>
7#include <libinput.h> 7#include <libinput.h>
8#include <math.h> 8#include <math.h>
9#include <wlr/backend/libinput.h>
9#include "sway/config.h" 10#include "sway/config.h"
10#include "sway/input/input-manager.h" 11#include "sway/input/input-manager.h"
11#include "sway/input/seat.h" 12#include "sway/input/seat.h"
@@ -82,6 +83,75 @@ static bool input_has_seat_configuration(struct sway_input_manager *input) {
82 return false; 83 return false;
83} 84}
84 85
86static void sway_input_manager_libinput_config_pointer(struct sway_input_device *input_device) {
87 struct wlr_input_device *wlr_device = input_device->wlr_device;
88 struct input_config *ic = input_device->config;
89 struct libinput_device *libinput_device;
90
91 if (!ic || !wlr_input_device_is_libinput(wlr_device)) {
92 return;
93 }
94
95 libinput_device = wlr_libinput_get_device_handle(wlr_device);
96 sway_log(L_DEBUG, "sway_input_manager_libinput_config_pointer(%s)", ic->identifier);
97
98 if (ic->accel_profile != INT_MIN) {
99 sway_log(L_DEBUG, "libinput_config_pointer(%s) accel_set_profile(%d)",
100 ic->identifier, ic->accel_profile);
101 libinput_device_config_accel_set_profile(libinput_device, ic->accel_profile);
102 }
103 if (ic->click_method != INT_MIN) {
104 sway_log(L_DEBUG, "libinput_config_pointer(%s) click_set_method(%d)",
105 ic->identifier, ic->click_method);
106 libinput_device_config_click_set_method(libinput_device, ic->click_method);
107 }
108 if (ic->drag_lock != INT_MIN) {
109 sway_log(L_DEBUG, "libinput_config_pointer(%s) tap_set_drag_lock_enabled(%d)",
110 ic->identifier, ic->click_method);
111 libinput_device_config_tap_set_drag_lock_enabled(libinput_device, ic->drag_lock);
112 }
113 if (ic->dwt != INT_MIN) {
114 sway_log(L_DEBUG, "libinput_config_pointer(%s) dwt_set_enabled(%d)",
115 ic->identifier, ic->dwt);
116 libinput_device_config_dwt_set_enabled(libinput_device, ic->dwt);
117 }
118 if (ic->left_handed != INT_MIN) {
119 sway_log(L_DEBUG, "libinput_config_pointer(%s) left_handed_set_enabled(%d)",
120 ic->identifier, ic->left_handed);
121 libinput_device_config_left_handed_set(libinput_device, ic->left_handed);
122 }
123 if (ic->middle_emulation != INT_MIN) {
124 sway_log(L_DEBUG, "libinput_config_pointer(%s) middle_emulation_set_enabled(%d)",
125 ic->identifier, ic->middle_emulation);
126 libinput_device_config_middle_emulation_set_enabled(libinput_device, ic->middle_emulation);
127 }
128 if (ic->natural_scroll != INT_MIN) {
129 sway_log(L_DEBUG, "libinput_config_pointer(%s) natural_scroll_set_enabled(%d)",
130 ic->identifier, ic->natural_scroll);
131 libinput_device_config_scroll_set_natural_scroll_enabled(libinput_device, ic->natural_scroll);
132 }
133 if (ic->pointer_accel != FLT_MIN) {
134 sway_log(L_DEBUG, "libinput_config_pointer(%s) accel_set_speed(%f)",
135 ic->identifier, ic->pointer_accel);
136 libinput_device_config_accel_set_speed(libinput_device, ic->pointer_accel);
137 }
138 if (ic->scroll_method != INT_MIN) {
139 sway_log(L_DEBUG, "libinput_config_pointer(%s) scroll_set_method(%d)",
140 ic->identifier, ic->scroll_method);
141 libinput_device_config_scroll_set_method(libinput_device, ic->scroll_method);
142 }
143 if (ic->send_events != INT_MIN) {
144 sway_log(L_DEBUG, "libinput_config_pointer(%s) send_events_set_mode(%d)",
145 ic->identifier, ic->send_events);
146 libinput_device_config_send_events_set_mode(libinput_device, ic->send_events);
147 }
148 if (ic->tap != INT_MIN) {
149 sway_log(L_DEBUG, "libinput_config_pointer(%s) tap_set_enabled(%d)",
150 ic->identifier, ic->tap);
151 libinput_device_config_tap_set_enabled(libinput_device, ic->tap);
152 }
153}
154
85static void input_add_notify(struct wl_listener *listener, void *data) { 155static void input_add_notify(struct wl_listener *listener, void *data) {
86 struct sway_input_manager *input = 156 struct sway_input_manager *input =
87 wl_container_of(listener, input, input_add); 157 wl_container_of(listener, input, input_add);
@@ -109,6 +179,10 @@ static void input_add_notify(struct wl_listener *listener, void *data) {
109 } 179 }
110 } 180 }
111 181
182 if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) {
183 sway_input_manager_libinput_config_pointer(input_device);
184 }
185
112 struct sway_seat *seat = NULL; 186 struct sway_seat *seat = NULL;
113 if (!input_has_seat_configuration(input)) { 187 if (!input_has_seat_configuration(input)) {
114 sway_log(L_DEBUG, "no seat configuration, using default seat"); 188 sway_log(L_DEBUG, "no seat configuration, using default seat");
@@ -221,6 +295,10 @@ void sway_input_manager_apply_input_config(struct sway_input_manager *input,
221 if (strcmp(input_device->identifier, input_config->identifier) == 0) { 295 if (strcmp(input_device->identifier, input_config->identifier) == 0) {
222 input_device->config = input_config; 296 input_device->config = input_config;
223 297
298 if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) {
299 sway_input_manager_libinput_config_pointer(input_device);
300 }
301
224 struct sway_seat *seat = NULL; 302 struct sway_seat *seat = NULL;
225 wl_list_for_each(seat, &input->seats, link) { 303 wl_list_for_each(seat, &input->seats, link) {
226 sway_seat_configure_device(seat, input_device); 304 sway_seat_configure_device(seat, input_device);