aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/input-manager.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/input/input-manager.c')
-rw-r--r--sway/input/input-manager.c56
1 files changed, 34 insertions, 22 deletions
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c
index 29b47a7b..0b7cb766 100644
--- a/sway/input/input-manager.c
+++ b/sway/input/input-manager.c
@@ -61,7 +61,7 @@ static char *get_device_identifier(struct wlr_input_device *device) {
61 int len = snprintf(NULL, 0, fmt, vendor, product, name) + 1; 61 int len = snprintf(NULL, 0, fmt, vendor, product, name) + 1;
62 char *identifier = malloc(len); 62 char *identifier = malloc(len);
63 if (!identifier) { 63 if (!identifier) {
64 wlr_log(L_ERROR, "Unable to allocate unique input device name"); 64 wlr_log(WLR_ERROR, "Unable to allocate unique input device name");
65 return NULL; 65 return NULL;
66 } 66 }
67 67
@@ -104,77 +104,89 @@ static void input_manager_libinput_config_pointer(
104 } 104 }
105 105
106 libinput_device = wlr_libinput_get_device_handle(wlr_device); 106 libinput_device = wlr_libinput_get_device_handle(wlr_device);
107 wlr_log(L_DEBUG, "input_manager_libinput_config_pointer(%s)", 107 wlr_log(WLR_DEBUG, "input_manager_libinput_config_pointer(%s)",
108 ic->identifier); 108 ic->identifier);
109 109
110 if (ic->accel_profile != INT_MIN) { 110 if (ic->accel_profile != INT_MIN) {
111 wlr_log(L_DEBUG, "libinput_config_pointer(%s) accel_set_profile(%d)", 111 wlr_log(WLR_DEBUG, "libinput_config_pointer(%s) accel_set_profile(%d)",
112 ic->identifier, ic->accel_profile); 112 ic->identifier, ic->accel_profile);
113 libinput_device_config_accel_set_profile(libinput_device, 113 libinput_device_config_accel_set_profile(libinput_device,
114 ic->accel_profile); 114 ic->accel_profile);
115 } 115 }
116 if (ic->click_method != INT_MIN) { 116 if (ic->click_method != INT_MIN) {
117 wlr_log(L_DEBUG, "libinput_config_pointer(%s) click_set_method(%d)", 117 wlr_log(WLR_DEBUG, "libinput_config_pointer(%s) click_set_method(%d)",
118 ic->identifier, ic->click_method); 118 ic->identifier, ic->click_method);
119 libinput_device_config_click_set_method(libinput_device, 119 libinput_device_config_click_set_method(libinput_device,
120 ic->click_method); 120 ic->click_method);
121 } 121 }
122 if (ic->drag_lock != INT_MIN) { 122 if (ic->drag_lock != INT_MIN) {
123 wlr_log(L_DEBUG, 123 wlr_log(WLR_DEBUG,
124 "libinput_config_pointer(%s) tap_set_drag_lock_enabled(%d)", 124 "libinput_config_pointer(%s) tap_set_drag_lock_enabled(%d)",
125 ic->identifier, ic->click_method); 125 ic->identifier, ic->click_method);
126 libinput_device_config_tap_set_drag_lock_enabled(libinput_device, 126 libinput_device_config_tap_set_drag_lock_enabled(libinput_device,
127 ic->drag_lock); 127 ic->drag_lock);
128 } 128 }
129 if (ic->dwt != INT_MIN) { 129 if (ic->dwt != INT_MIN) {
130 wlr_log(L_DEBUG, "libinput_config_pointer(%s) dwt_set_enabled(%d)", 130 wlr_log(WLR_DEBUG, "libinput_config_pointer(%s) dwt_set_enabled(%d)",
131 ic->identifier, ic->dwt); 131 ic->identifier, ic->dwt);
132 libinput_device_config_dwt_set_enabled(libinput_device, ic->dwt); 132 libinput_device_config_dwt_set_enabled(libinput_device, ic->dwt);
133 } 133 }
134 if (ic->left_handed != INT_MIN) { 134 if (ic->left_handed != INT_MIN) {
135 wlr_log(L_DEBUG, 135 wlr_log(WLR_DEBUG,
136 "libinput_config_pointer(%s) left_handed_set_enabled(%d)", 136 "libinput_config_pointer(%s) left_handed_set_enabled(%d)",
137 ic->identifier, ic->left_handed); 137 ic->identifier, ic->left_handed);
138 libinput_device_config_left_handed_set(libinput_device, 138 libinput_device_config_left_handed_set(libinput_device,
139 ic->left_handed); 139 ic->left_handed);
140 } 140 }
141 if (ic->middle_emulation != INT_MIN) { 141 if (ic->middle_emulation != INT_MIN) {
142 wlr_log(L_DEBUG, 142 wlr_log(WLR_DEBUG,
143 "libinput_config_pointer(%s) middle_emulation_set_enabled(%d)", 143 "libinput_config_pointer(%s) middle_emulation_set_enabled(%d)",
144 ic->identifier, ic->middle_emulation); 144 ic->identifier, ic->middle_emulation);
145 libinput_device_config_middle_emulation_set_enabled(libinput_device, 145 libinput_device_config_middle_emulation_set_enabled(libinput_device,
146 ic->middle_emulation); 146 ic->middle_emulation);
147 } 147 }
148 if (ic->natural_scroll != INT_MIN) { 148 if (ic->natural_scroll != INT_MIN) {
149 wlr_log(L_DEBUG, 149 wlr_log(WLR_DEBUG,
150 "libinput_config_pointer(%s) natural_scroll_set_enabled(%d)", 150 "libinput_config_pointer(%s) natural_scroll_set_enabled(%d)",
151 ic->identifier, ic->natural_scroll); 151 ic->identifier, ic->natural_scroll);
152 libinput_device_config_scroll_set_natural_scroll_enabled( 152 libinput_device_config_scroll_set_natural_scroll_enabled(
153 libinput_device, ic->natural_scroll); 153 libinput_device, ic->natural_scroll);
154 } 154 }
155 if (ic->pointer_accel != FLT_MIN) { 155 if (ic->pointer_accel != FLT_MIN) {
156 wlr_log(L_DEBUG, "libinput_config_pointer(%s) accel_set_speed(%f)", 156 wlr_log(WLR_DEBUG, "libinput_config_pointer(%s) accel_set_speed(%f)",
157 ic->identifier, ic->pointer_accel); 157 ic->identifier, ic->pointer_accel);
158 libinput_device_config_accel_set_speed(libinput_device, 158 libinput_device_config_accel_set_speed(libinput_device,
159 ic->pointer_accel); 159 ic->pointer_accel);
160 } 160 }
161 if (ic->scroll_button != INT_MIN) {
162 wlr_log(WLR_DEBUG, "libinput_config_pointer(%s) scroll_set_button(%d)",
163 ic->identifier, ic->scroll_button);
164 libinput_device_config_scroll_set_button(libinput_device,
165 ic->scroll_button);
166 }
161 if (ic->scroll_method != INT_MIN) { 167 if (ic->scroll_method != INT_MIN) {
162 wlr_log(L_DEBUG, "libinput_config_pointer(%s) scroll_set_method(%d)", 168 wlr_log(WLR_DEBUG, "libinput_config_pointer(%s) scroll_set_method(%d)",
163 ic->identifier, ic->scroll_method); 169 ic->identifier, ic->scroll_method);
164 libinput_device_config_scroll_set_method(libinput_device, 170 libinput_device_config_scroll_set_method(libinput_device,
165 ic->scroll_method); 171 ic->scroll_method);
166 } 172 }
167 if (ic->send_events != INT_MIN) { 173 if (ic->send_events != INT_MIN) {
168 wlr_log(L_DEBUG, "libinput_config_pointer(%s) send_events_set_mode(%d)", 174 wlr_log(WLR_DEBUG, "libinput_config_pointer(%s) send_events_set_mode(%d)",
169 ic->identifier, ic->send_events); 175 ic->identifier, ic->send_events);
170 libinput_device_config_send_events_set_mode(libinput_device, 176 libinput_device_config_send_events_set_mode(libinput_device,
171 ic->send_events); 177 ic->send_events);
172 } 178 }
173 if (ic->tap != INT_MIN) { 179 if (ic->tap != INT_MIN) {
174 wlr_log(L_DEBUG, "libinput_config_pointer(%s) tap_set_enabled(%d)", 180 wlr_log(WLR_DEBUG, "libinput_config_pointer(%s) tap_set_enabled(%d)",
175 ic->identifier, ic->tap); 181 ic->identifier, ic->tap);
176 libinput_device_config_tap_set_enabled(libinput_device, ic->tap); 182 libinput_device_config_tap_set_enabled(libinput_device, ic->tap);
177 } 183 }
184 if (ic->tap_button_map != INT_MIN) {
185 wlr_log(WLR_DEBUG, "libinput_config_pointer(%s) tap_set_button_map(%d)",
186 ic->identifier, ic->tap);
187 libinput_device_config_tap_set_button_map(libinput_device,
188 ic->tap_button_map);
189 }
178} 190}
179 191
180static void handle_device_destroy(struct wl_listener *listener, void *data) { 192static void handle_device_destroy(struct wl_listener *listener, void *data) {
@@ -187,7 +199,7 @@ static void handle_device_destroy(struct wl_listener *listener, void *data) {
187 return; 199 return;
188 } 200 }
189 201
190 wlr_log(L_DEBUG, "removing device: '%s'", 202 wlr_log(WLR_DEBUG, "removing device: '%s'",
191 input_device->identifier); 203 input_device->identifier);
192 204
193 struct sway_seat *seat = NULL; 205 struct sway_seat *seat = NULL;
@@ -217,16 +229,19 @@ static void handle_new_input(struct wl_listener *listener, void *data) {
217 input_device->identifier = get_device_identifier(device); 229 input_device->identifier = get_device_identifier(device);
218 wl_list_insert(&input->devices, &input_device->link); 230 wl_list_insert(&input->devices, &input_device->link);
219 231
220 wlr_log(L_DEBUG, "adding device: '%s'", 232 wlr_log(WLR_DEBUG, "adding device: '%s'",
221 input_device->identifier); 233 input_device->identifier);
222 234
223 if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) { 235 if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) {
224 input_manager_libinput_config_pointer(input_device); 236 input_manager_libinput_config_pointer(input_device);
225 } 237 }
226 238
239 wl_signal_add(&device->events.destroy, &input_device->device_destroy);
240 input_device->device_destroy.notify = handle_device_destroy;
241
227 struct sway_seat *seat = NULL; 242 struct sway_seat *seat = NULL;
228 if (!input_has_seat_configuration(input)) { 243 if (!input_has_seat_configuration(input)) {
229 wlr_log(L_DEBUG, "no seat configuration, using default seat"); 244 wlr_log(WLR_DEBUG, "no seat configuration, using default seat");
230 seat = input_manager_get_seat(input, default_seat); 245 seat = input_manager_get_seat(input, default_seat);
231 seat_add_device(seat, input_device); 246 seat_add_device(seat, input_device);
232 return; 247 return;
@@ -256,13 +271,10 @@ static void handle_new_input(struct wl_listener *listener, void *data) {
256 } 271 }
257 272
258 if (!added) { 273 if (!added) {
259 wlr_log(L_DEBUG, 274 wlr_log(WLR_DEBUG,
260 "device '%s' is not configured on any seats", 275 "device '%s' is not configured on any seats",
261 input_device->identifier); 276 input_device->identifier);
262 } 277 }
263
264 wl_signal_add(&device->events.destroy, &input_device->device_destroy);
265 input_device->device_destroy.notify = handle_device_destroy;
266} 278}
267 279
268static void handle_inhibit_activate(struct wl_listener *listener, void *data) { 280static void handle_inhibit_activate(struct wl_listener *listener, void *data) {
@@ -282,7 +294,7 @@ static void handle_inhibit_deactivate(struct wl_listener *listener, void *data)
282 seat_set_exclusive_client(seat, NULL); 294 seat_set_exclusive_client(seat, NULL);
283 struct sway_container *previous = seat_get_focus(seat); 295 struct sway_container *previous = seat_get_focus(seat);
284 if (previous) { 296 if (previous) {
285 wlr_log(L_DEBUG, "Returning focus to %p %s '%s'", previous, 297 wlr_log(WLR_DEBUG, "Returning focus to %p %s '%s'", previous,
286 container_type_to_str(previous->type), previous->name); 298 container_type_to_str(previous->type), previous->name);
287 // Hack to get seat to re-focus the return value of get_focus 299 // Hack to get seat to re-focus the return value of get_focus
288 seat_set_focus(seat, previous->parent); 300 seat_set_focus(seat, previous->parent);
@@ -359,7 +371,7 @@ void input_manager_apply_input_config(struct sway_input_manager *input,
359 371
360void input_manager_apply_seat_config(struct sway_input_manager *input, 372void input_manager_apply_seat_config(struct sway_input_manager *input,
361 struct seat_config *seat_config) { 373 struct seat_config *seat_config) {
362 wlr_log(L_DEBUG, "applying new seat config for seat %s", 374 wlr_log(WLR_DEBUG, "applying new seat config for seat %s",
363 seat_config->name); 375 seat_config->name);
364 struct sway_seat *seat = input_manager_get_seat(input, seat_config->name); 376 struct sway_seat *seat = input_manager_get_seat(input, seat_config->name);
365 if (!seat) { 377 if (!seat) {