input/libinput: only reset supported options

This adds checks to the input_manager_libinput_reset_* functions to
only attempt resetting supported options on reload. This should have no
functional difference to the user, but will remove several `Failed to
apply libinput config: Unsupported configuration option` lines from the
log that can be noisy and potential red herrings.
master
Brian Ashworth 6 years ago committed by Drew DeVault
parent 152e30c374
commit 32265d9136

@ -304,15 +304,19 @@ static void input_manager_libinput_reset_touch(
uint32_t send_events = uint32_t send_events =
libinput_device_config_send_events_get_default_mode(libinput_device); libinput_device_config_send_events_get_default_mode(libinput_device);
sway_log(SWAY_DEBUG, "libinput_reset_touch(%s) send_events_set_mode(%d)", sway_log(SWAY_DEBUG, "libinput_reset_touch(%s) send_events_set_mode(%d)",
input_device->identifier, send_events); input_device->identifier, send_events);
log_libinput_config_status(libinput_device_config_send_events_set_mode( log_libinput_config_status(libinput_device_config_send_events_set_mode(
libinput_device, send_events)); libinput_device, send_events));
float m[6];
libinput_device_config_calibration_get_default_matrix(libinput_device, m); if (libinput_device_config_calibration_has_matrix(libinput_device)) {
sway_log(SWAY_DEBUG, "libinput_reset_touch(%s) calibration_set_matrix(%f %f %f %f %f %f)", float m[6];
input_device->identifier, m[0], m[1], m[2], m[3], m[4], m[5]); libinput_device_config_calibration_get_default_matrix(libinput_device, m);
log_libinput_config_status(libinput_device_config_calibration_set_matrix( sway_log(SWAY_DEBUG, "libinput_reset_touch(%s) calibration_set_matrix("
"%f %f %f %f %f %f)", input_device->identifier, m[0], m[1],
m[2], m[3], m[4], m[5]);
log_libinput_config_status(libinput_device_config_calibration_set_matrix(
libinput_device, m)); libinput_device, m));
}
} }
static void input_manager_libinput_config_pointer( static void input_manager_libinput_config_pointer(
@ -434,113 +438,133 @@ static void input_manager_libinput_reset_pointer(
struct libinput_device *libinput_device = struct libinput_device *libinput_device =
wlr_libinput_get_device_handle(wlr_device); wlr_libinput_get_device_handle(wlr_device);
enum libinput_config_accel_profile accel_profile = uint32_t send_events =
libinput_device_config_accel_get_default_profile(libinput_device); libinput_device_config_send_events_get_default_mode(libinput_device);
sway_log(SWAY_DEBUG, "libinput_reset_pointer(%s) accel_set_profile(%d)", sway_log(SWAY_DEBUG, "libinput_reset_pointer(%s) send_events_set_mode(%d)",
input_device->identifier, accel_profile); input_device->identifier, send_events);
log_libinput_config_status(libinput_device_config_accel_set_profile( log_libinput_config_status(libinput_device_config_send_events_set_mode(
libinput_device, accel_profile)); libinput_device, send_events));
enum libinput_config_click_method click_method = if (libinput_device_config_tap_get_finger_count(libinput_device) > 0) {
libinput_device_config_click_get_default_method(libinput_device); enum libinput_config_tap_state tap =
sway_log(SWAY_DEBUG, "libinput_reset_pointer(%s) click_set_method(%d)", libinput_device_config_tap_get_default_enabled(libinput_device);
input_device->identifier, click_method); sway_log(SWAY_DEBUG, "libinput_reset_pointer(%s) tap_set_enabled(%d)",
log_libinput_config_status(libinput_device_config_click_set_method( input_device->identifier, tap);
libinput_device, click_method)); log_libinput_config_status(libinput_device_config_tap_set_enabled(
libinput_device, tap));
enum libinput_config_drag_state drag = enum libinput_config_tap_button_map tap_button_map =
libinput_device_config_tap_get_default_drag_enabled(libinput_device); libinput_device_config_tap_get_button_map(libinput_device);
sway_log(SWAY_DEBUG, "libinput_reset_pointer(%s) tap_set_drag_enabled(%d)", sway_log(SWAY_DEBUG,
input_device->identifier, drag); "libinput_reset_pointer(%s) tap_set_button_map(%d)",
log_libinput_config_status(libinput_device_config_tap_set_drag_enabled( input_device->identifier, tap_button_map);
libinput_device, drag)); log_libinput_config_status(libinput_device_config_tap_set_button_map(
libinput_device, tap_button_map));
enum libinput_config_drag_lock_state drag_lock = enum libinput_config_drag_state drag =
libinput_device_config_tap_get_default_drag_lock_enabled( libinput_device_config_tap_get_default_drag_enabled(libinput_device);
libinput_device); sway_log(SWAY_DEBUG,
sway_log(SWAY_DEBUG, "libinput_reset_pointer(%s) tap_set_drag_enabled(%d)",
"libinput_reset_pointer(%s) tap_set_drag_lock_enabled(%d)", input_device->identifier, drag);
input_device->identifier, drag_lock); log_libinput_config_status(libinput_device_config_tap_set_drag_enabled(
log_libinput_config_status( libinput_device, drag));
libinput_device_config_tap_set_drag_lock_enabled(
libinput_device, drag_lock));
enum libinput_config_dwt_state dwt =
libinput_device_config_dwt_get_default_enabled(libinput_device);
sway_log(SWAY_DEBUG, "libinput_reset_pointer(%s) dwt_set_enabled(%d)",
input_device->identifier, dwt);
log_libinput_config_status(libinput_device_config_dwt_set_enabled(
libinput_device, dwt));
int left_handed = enum libinput_config_drag_lock_state drag_lock =
libinput_device_config_left_handed_get_default(libinput_device); libinput_device_config_tap_get_default_drag_lock_enabled(
sway_log(SWAY_DEBUG, libinput_device);
"libinput_reset_pointer(%s) left_handed_set_enabled(%d)", sway_log(SWAY_DEBUG,
input_device->identifier, left_handed); "libinput_reset_pointer(%s) tap_set_drag_lock_enabled(%d)",
log_libinput_config_status(libinput_device_config_left_handed_set( input_device->identifier, drag_lock);
libinput_device, left_handed)); log_libinput_config_status(
libinput_device_config_tap_set_drag_lock_enabled(
libinput_device, drag_lock));
}
enum libinput_config_middle_emulation_state middle_emulation = if (libinput_device_config_accel_is_available(libinput_device)) {
libinput_device_config_middle_emulation_get_default_enabled( double pointer_accel =
libinput_device); libinput_device_config_accel_get_default_speed(libinput_device);
sway_log(SWAY_DEBUG, sway_log(SWAY_DEBUG, "libinput_reset_pointer(%s) accel_set_speed(%f)",
"libinput_reset_pointer(%s) middle_emulation_set_enabled(%d)", input_device->identifier, pointer_accel);
input_device->identifier, middle_emulation); log_libinput_config_status(libinput_device_config_accel_set_speed(
log_libinput_config_status(
libinput_device_config_middle_emulation_set_enabled(
libinput_device, middle_emulation));
int natural_scroll =
libinput_device_config_scroll_get_default_natural_scroll_enabled(
libinput_device);
sway_log(SWAY_DEBUG,
"libinput_reset_pointer(%s) natural_scroll_set_enabled(%d)",
input_device->identifier, natural_scroll);
log_libinput_config_status(
libinput_device_config_scroll_set_natural_scroll_enabled(
libinput_device, natural_scroll));
double pointer_accel =
libinput_device_config_accel_get_default_speed(libinput_device);
sway_log(SWAY_DEBUG, "libinput_reset_pointer(%s) accel_set_speed(%f)",
input_device->identifier, pointer_accel);
log_libinput_config_status(libinput_device_config_accel_set_speed(
libinput_device, pointer_accel)); libinput_device, pointer_accel));
uint32_t scroll_button = enum libinput_config_accel_profile accel_profile =
libinput_device_config_scroll_get_default_button(libinput_device); libinput_device_config_accel_get_default_profile(libinput_device);
sway_log(SWAY_DEBUG, "libinput_reset_pointer(%s) scroll_set_button(%d)", sway_log(SWAY_DEBUG, "libinput_reset_pointer(%s) accel_set_profile(%d)",
input_device->identifier, scroll_button); input_device->identifier, accel_profile);
log_libinput_config_status(libinput_device_config_scroll_set_button( log_libinput_config_status(libinput_device_config_accel_set_profile(
libinput_device, scroll_button)); libinput_device, accel_profile));
}
enum libinput_config_scroll_method scroll_method = if (libinput_device_config_scroll_has_natural_scroll(libinput_device)) {
libinput_device_config_scroll_get_default_method(libinput_device); int natural_scroll =
sway_log(SWAY_DEBUG, "libinput_reset_pointer(%s) scroll_set_method(%d)", libinput_device_config_scroll_get_default_natural_scroll_enabled(
input_device->identifier, scroll_method); libinput_device);
log_libinput_config_status(libinput_device_config_scroll_set_method( sway_log(SWAY_DEBUG,
libinput_device, scroll_method)); "libinput_reset_pointer(%s) natural_scroll_set_enabled(%d)",
input_device->identifier, natural_scroll);
log_libinput_config_status(
libinput_device_config_scroll_set_natural_scroll_enabled(
libinput_device, natural_scroll));
}
uint32_t send_events = if (libinput_device_config_left_handed_is_available(libinput_device)) {
libinput_device_config_send_events_get_default_mode(libinput_device); int left_handed =
sway_log(SWAY_DEBUG, "libinput_reset_pointer(%s) send_events_set_mode(%d)", libinput_device_config_left_handed_get_default(libinput_device);
input_device->identifier, send_events); sway_log(SWAY_DEBUG,
log_libinput_config_status(libinput_device_config_send_events_set_mode( "libinput_reset_pointer(%s) left_handed_set_enabled(%d)",
libinput_device, send_events)); input_device->identifier, left_handed);
log_libinput_config_status(libinput_device_config_left_handed_set(
libinput_device, left_handed));
}
enum libinput_config_tap_state tap = uint32_t click = libinput_device_config_click_get_methods(libinput_device);
libinput_device_config_tap_get_default_enabled(libinput_device); if ((click & ~LIBINPUT_CONFIG_CLICK_METHOD_NONE) != 0) {
sway_log(SWAY_DEBUG, "libinput_reset_pointer(%s) tap_set_enabled(%d)", enum libinput_config_click_method click_method =
input_device->identifier, tap); libinput_device_config_click_get_default_method(libinput_device);
log_libinput_config_status(libinput_device_config_tap_set_enabled( sway_log(SWAY_DEBUG, "libinput_reset_pointer(%s) click_set_method(%d)",
libinput_device, tap)); input_device->identifier, click_method);
log_libinput_config_status(libinput_device_config_click_set_method(
libinput_device, click_method));
}
enum libinput_config_tap_button_map tap_button_map = if (libinput_device_config_middle_emulation_is_available(libinput_device)) {
libinput_device_config_tap_get_button_map(libinput_device); enum libinput_config_middle_emulation_state middle_emulation =
sway_log(SWAY_DEBUG, "libinput_reset_pointer(%s) tap_set_button_map(%d)", libinput_device_config_middle_emulation_get_default_enabled(
input_device->identifier, tap_button_map); libinput_device);
log_libinput_config_status(libinput_device_config_tap_set_button_map( sway_log(SWAY_DEBUG,
libinput_device, tap_button_map)); "libinput_reset_pointer(%s) middle_emulation_set_enabled(%d)",
input_device->identifier, middle_emulation);
log_libinput_config_status(
libinput_device_config_middle_emulation_set_enabled(
libinput_device, middle_emulation));
}
uint32_t scroll = libinput_device_config_scroll_get_methods(libinput_device);
if ((scroll & ~LIBINPUT_CONFIG_SCROLL_NO_SCROLL) != 0) {
enum libinput_config_scroll_method scroll_method =
libinput_device_config_scroll_get_default_method(libinput_device);
sway_log(SWAY_DEBUG, "libinput_reset_pointer(%s) scroll_set_method(%d)",
input_device->identifier, scroll_method);
log_libinput_config_status(libinput_device_config_scroll_set_method(
libinput_device, scroll_method));
uint32_t scroll_button =
libinput_device_config_scroll_get_default_button(libinput_device);
sway_log(SWAY_DEBUG, "libinput_reset_pointer(%s) scroll_set_button(%d)",
input_device->identifier, scroll_button);
log_libinput_config_status(libinput_device_config_scroll_set_button(
libinput_device, scroll_button));
}
if (libinput_device_config_dwt_is_available(libinput_device)) {
enum libinput_config_dwt_state dwt =
libinput_device_config_dwt_get_default_enabled(libinput_device);
sway_log(SWAY_DEBUG, "libinput_reset_pointer(%s) dwt_set_enabled(%d)",
input_device->identifier, dwt);
log_libinput_config_status(libinput_device_config_dwt_set_enabled(
libinput_device, dwt));
}
} }
static void handle_device_destroy(struct wl_listener *listener, void *data) { static void handle_device_destroy(struct wl_listener *listener, void *data) {

Loading…
Cancel
Save