diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-12-27 08:04:06 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-27 08:04:06 -0800 |
commit | e1c5adc918a95209b432b89a75114e2cd20412a4 (patch) | |
tree | eee1613d0919ac69d0cd7048fa7ba70846a212ec | |
parent | Merge pull request #1538 from acrisci/desktop-shell-surface-commit (diff) | |
parent | seat_configure_pointer: apply libinput config (diff) | |
download | sway-e1c5adc918a95209b432b89a75114e2cd20412a4.tar.gz sway-e1c5adc918a95209b432b89a75114e2cd20412a4.tar.zst sway-e1c5adc918a95209b432b89a75114e2cd20412a4.zip |
Merge pull request #1535 from martinetd/libinput
Libinput config
-rw-r--r-- | sway/input/input-manager.c | 78 | ||||
-rw-r--r-- | sway/input/seat.c | 1 |
2 files changed, 78 insertions, 1 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 | ||
86 | static 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 | |||
85 | static void input_add_notify(struct wl_listener *listener, void *data) { | 155 | static 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); |
diff --git a/sway/input/seat.c b/sway/input/seat.c index fe90565a..9a6a667b 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -58,7 +58,6 @@ struct sway_seat *sway_seat_create(struct sway_input_manager *input, | |||
58 | 58 | ||
59 | static void seat_configure_pointer(struct sway_seat *seat, | 59 | static void seat_configure_pointer(struct sway_seat *seat, |
60 | struct sway_seat_device *sway_device) { | 60 | struct sway_seat_device *sway_device) { |
61 | // TODO pointer configuration | ||
62 | wlr_cursor_attach_input_device(seat->cursor->cursor, | 61 | wlr_cursor_attach_input_device(seat->cursor->cursor, |
63 | sway_device->input_device->wlr_device); | 62 | sway_device->input_device->wlr_device); |
64 | } | 63 | } |