Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> --- src/evdev-middle-button.c | 8 ++-- src/evdev-mt-touchpad-buttons.c | 10 ++--- src/evdev-mt-touchpad-tap.c | 60 +++++++++---------------- src/evdev-mt-touchpad.c | 24 +++++----- src/evdev-tablet-pad.c | 4 +- src/evdev.c | 98 ++++++++++++++++++++--------------------- src/evdev.h | 8 ++++ src/libinput.c | 38 ++++++---------- src/path-seat.c | 6 +-- src/udev-seat.c | 4 +- 10 files changed, 119 insertions(+), 141 deletions(-)
diff --git a/src/evdev-middle-button.c b/src/evdev-middle-button.c index 09f77de..d9330ba 100644 --- a/src/evdev-middle-button.c +++ b/src/evdev-middle-button.c @@ -638,7 +638,7 @@ evdev_middlebutton_filter_button(struct evdev_device *device, static void evdev_middlebutton_handle_timeout(uint64_t now, void *data) { - struct evdev_device *device = (struct evdev_device*)data; + struct evdev_device *device = evdev_device(data); evdev_middlebutton_handle_event(device, now, MIDDLEBUTTON_EVENT_TIMEOUT); } @@ -653,7 +653,7 @@ static enum libinput_config_status evdev_middlebutton_set(struct libinput_device *device, enum libinput_config_middle_emulation_state enable) { - struct evdev_device *evdev = (struct evdev_device*)device; + struct evdev_device *evdev = evdev_device(device); switch (enable) { case LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED: @@ -674,7 +674,7 @@ evdev_middlebutton_set(struct libinput_device *device, enum libinput_config_middle_emulation_state evdev_middlebutton_get(struct libinput_device *device) { - struct evdev_device *evdev = (struct evdev_device*)device; + struct evdev_device *evdev = evdev_device(device); return evdev->middlebutton.want_enabled ? LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED : @@ -684,7 +684,7 @@ evdev_middlebutton_get(struct libinput_device *device) enum libinput_config_middle_emulation_state evdev_middlebutton_get_default(struct libinput_device *device) { - struct evdev_device *evdev = (struct evdev_device*)device; + struct evdev_device *evdev = evdev_device(device); return evdev->middlebutton.enabled_default ? LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED : diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c index f4fe6b7..4a68470 100644 --- a/src/evdev-mt-touchpad-buttons.c +++ b/src/evdev-mt-touchpad-buttons.c @@ -627,7 +627,7 @@ tp_init_top_softbuttons(struct tp_dispatch *tp, static inline uint32_t tp_button_config_click_get_methods(struct libinput_device *device) { - struct evdev_device *evdev = (struct evdev_device*)device; + struct evdev_device *evdev = evdev_device(device); struct tp_dispatch *tp = (struct tp_dispatch*)evdev->dispatch; uint32_t methods = LIBINPUT_CONFIG_CLICK_METHOD_NONE; @@ -669,7 +669,7 @@ static enum libinput_config_status tp_button_config_click_set_method(struct libinput_device *device, enum libinput_config_click_method method) { - struct evdev_device *evdev = (struct evdev_device*)device; + struct evdev_device *evdev = evdev_device(device); struct tp_dispatch *tp = (struct tp_dispatch*)evdev->dispatch; tp->buttons.click_method = method; @@ -681,7 +681,7 @@ tp_button_config_click_set_method(struct libinput_device *device, static enum libinput_config_click_method tp_button_config_click_get_method(struct libinput_device *device) { - struct evdev_device *evdev = (struct evdev_device*)device; + struct evdev_device *evdev = evdev_device(device); struct tp_dispatch *tp = (struct tp_dispatch*)evdev->dispatch; return tp->buttons.click_method; @@ -711,7 +711,7 @@ tp_click_get_default_method(struct tp_dispatch *tp) static enum libinput_config_click_method tp_button_config_click_get_default_method(struct libinput_device *device) { - struct evdev_device *evdev = (struct evdev_device*)device; + struct evdev_device *evdev = evdev_device(device); struct tp_dispatch *tp = (struct tp_dispatch*)evdev->dispatch; return tp_click_get_default_method(tp); @@ -746,7 +746,7 @@ static enum libinput_config_status tp_clickpad_middlebutton_set(struct libinput_device *device, enum libinput_config_middle_emulation_state enable) { - struct evdev_device *evdev = (struct evdev_device*)device; + struct evdev_device *evdev = evdev_device(device); switch (enable) { case LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED: diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c index 5fccbc2..1829732 100644 --- a/src/evdev-mt-touchpad-tap.c +++ b/src/evdev-mt-touchpad-tap.c @@ -897,11 +897,8 @@ tp_tap_enabled_update(struct tp_dispatch *tp, bool suspended, bool enabled, uint static int tp_tap_config_count(struct libinput_device *device) { - struct evdev_dispatch *dispatch; - struct tp_dispatch *tp = NULL; - - dispatch = ((struct evdev_device *) device)->dispatch; - tp = tp_dispatch(dispatch); + struct evdev_dispatch *dispatch = evdev_device(device)->dispatch; + struct tp_dispatch *tp = tp_dispatch(dispatch); return min(tp->ntouches, 3U); /* we only do up to 3 finger tap */ } @@ -910,11 +907,8 @@ static enum libinput_config_status tp_tap_config_set_enabled(struct libinput_device *device, enum libinput_config_tap_state enabled) { - struct evdev_dispatch *dispatch; - struct tp_dispatch *tp = NULL; - - dispatch = ((struct evdev_device *) device)->dispatch; - tp = tp_dispatch(dispatch); + struct evdev_dispatch *dispatch = evdev_device(device)->dispatch; + struct tp_dispatch *tp = tp_dispatch(dispatch); tp_tap_enabled_update(tp, tp->tap.suspended, (enabled == LIBINPUT_CONFIG_TAP_ENABLED), @@ -926,11 +920,8 @@ tp_tap_config_set_enabled(struct libinput_device *device, static enum libinput_config_tap_state tp_tap_config_is_enabled(struct libinput_device *device) { - struct evdev_dispatch *dispatch; - struct tp_dispatch *tp = NULL; - - dispatch = ((struct evdev_device *) device)->dispatch; - tp = tp_dispatch(dispatch); + struct evdev_dispatch *dispatch = evdev_device(device)->dispatch; + struct tp_dispatch *tp = tp_dispatch(dispatch); return tp->tap.enabled ? LIBINPUT_CONFIG_TAP_ENABLED : LIBINPUT_CONFIG_TAP_DISABLED; @@ -961,7 +952,7 @@ tp_tap_default(struct evdev_device *evdev) static enum libinput_config_tap_state tp_tap_config_get_default(struct libinput_device *device) { - struct evdev_device *evdev = (struct evdev_device *)device; + struct evdev_device *evdev = evdev_device(device); return tp_tap_default(evdev); } @@ -970,10 +961,9 @@ static enum libinput_config_status tp_tap_config_set_map(struct libinput_device *device, enum libinput_config_tap_button_map map) { - struct evdev_dispatch *dispatch = ((struct evdev_device *) device)->dispatch; - struct tp_dispatch *tp = NULL; + struct evdev_dispatch *dispatch = evdev_device(device)->dispatch; + struct tp_dispatch *tp = tp_dispatch(dispatch); - tp = tp_dispatch(dispatch); tp->tap.want_map = map; tp_tap_update_map(tp); @@ -984,10 +974,8 @@ tp_tap_config_set_map(struct libinput_device *device, static enum libinput_config_tap_button_map tp_tap_config_get_map(struct libinput_device *device) { - struct evdev_dispatch *dispatch = ((struct evdev_device *) device)->dispatch; - struct tp_dispatch *tp = NULL; - - tp = tp_dispatch(dispatch); + struct evdev_dispatch *dispatch = evdev_device(device)->dispatch; + struct tp_dispatch *tp = tp_dispatch(dispatch); return tp->tap.want_map; } @@ -1002,10 +990,9 @@ static enum libinput_config_status tp_tap_config_set_drag_enabled(struct libinput_device *device, enum libinput_config_drag_state enabled) { - struct evdev_dispatch *dispatch = ((struct evdev_device *) device)->dispatch; - struct tp_dispatch *tp = NULL; + struct evdev_dispatch *dispatch = evdev_device(device)->dispatch; + struct tp_dispatch *tp = tp_dispatch(dispatch); - tp = tp_dispatch(dispatch); tp->tap.drag_enabled = enabled; return LIBINPUT_CONFIG_STATUS_SUCCESS; @@ -1014,10 +1001,8 @@ tp_tap_config_set_drag_enabled(struct libinput_device *device, static enum libinput_config_drag_state tp_tap_config_get_drag_enabled(struct libinput_device *device) { - struct evdev_device *evdev = (struct evdev_device *)device; - struct tp_dispatch *tp = NULL; - - tp = tp_dispatch(evdev->dispatch); + struct evdev_dispatch *dispatch = evdev_device(device)->dispatch; + struct tp_dispatch *tp = tp_dispatch(dispatch); return tp->tap.drag_enabled; } @@ -1031,7 +1016,7 @@ tp_drag_default(struct evdev_device *device) static enum libinput_config_drag_state tp_tap_config_get_default_drag_enabled(struct libinput_device *device) { - struct evdev_device *evdev = (struct evdev_device *)device; + struct evdev_device *evdev = evdev_device(device); return tp_drag_default(evdev); } @@ -1040,10 +1025,9 @@ static enum libinput_config_status tp_tap_config_set_draglock_enabled(struct libinput_device *device, enum libinput_config_drag_lock_state enabled) { - struct evdev_dispatch *dispatch = ((struct evdev_device *) device)->dispatch; - struct tp_dispatch *tp = NULL; + struct evdev_dispatch *dispatch = evdev_device(device)->dispatch; + struct tp_dispatch *tp = tp_dispatch(dispatch); - tp = tp_dispatch(dispatch); tp->tap.drag_lock_enabled = enabled; return LIBINPUT_CONFIG_STATUS_SUCCESS; @@ -1052,10 +1036,8 @@ tp_tap_config_set_draglock_enabled(struct libinput_device *device, static enum libinput_config_drag_lock_state tp_tap_config_get_draglock_enabled(struct libinput_device *device) { - struct evdev_device *evdev = (struct evdev_device *)device; - struct tp_dispatch *tp = NULL; - - tp = tp_dispatch(evdev->dispatch); + struct evdev_dispatch *dispatch = evdev_device(device)->dispatch; + struct tp_dispatch *tp = tp_dispatch(dispatch); return tp->tap.drag_lock_enabled; } @@ -1069,7 +1051,7 @@ tp_drag_lock_default(struct evdev_device *device) static enum libinput_config_drag_lock_state tp_tap_config_get_default_draglock_enabled(struct libinput_device *device) { - struct evdev_device *evdev = (struct evdev_device *)device; + struct evdev_device *evdev = evdev_device(device); return tp_drag_lock_default(evdev); } diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index d232634..9614f8e 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -1645,7 +1645,7 @@ tp_interface_device_removed(struct evdev_device *device, return; list_for_each(dev, &device->base.seat->devices_list, link) { - struct evdev_device *d = (struct evdev_device*)dev; + struct evdev_device *d = evdev_device(dev); if (d != removed_device && (d->tags & EVDEV_TAG_EXTERNAL_MOUSE)) { return; @@ -1982,7 +1982,7 @@ tp_scroll_get_methods(struct tp_dispatch *tp) static uint32_t tp_scroll_config_scroll_method_get_methods(struct libinput_device *device) { - struct evdev_device *evdev = (struct evdev_device*)device; + struct evdev_device *evdev = evdev_device(device); struct tp_dispatch *tp = (struct tp_dispatch*)evdev->dispatch; return tp_scroll_get_methods(tp); @@ -1992,7 +1992,7 @@ static enum libinput_config_status tp_scroll_config_scroll_method_set_method(struct libinput_device *device, enum libinput_config_scroll_method method) { - struct evdev_device *evdev = (struct evdev_device*)device; + struct evdev_device *evdev = evdev_device(device); struct tp_dispatch *tp = (struct tp_dispatch*)evdev->dispatch; uint64_t time = libinput_now(tp_libinput_context(tp)); @@ -2010,7 +2010,7 @@ tp_scroll_config_scroll_method_set_method(struct libinput_device *device, static enum libinput_config_scroll_method tp_scroll_config_scroll_method_get_method(struct libinput_device *device) { - struct evdev_device *evdev = (struct evdev_device*)device; + struct evdev_device *evdev = evdev_device(device); struct tp_dispatch *tp = (struct tp_dispatch*)evdev->dispatch; return tp->scroll.method; @@ -2039,7 +2039,7 @@ tp_scroll_get_default_method(struct tp_dispatch *tp) static enum libinput_config_scroll_method tp_scroll_config_scroll_method_get_default_method(struct libinput_device *device) { - struct evdev_device *evdev = (struct evdev_device*)device; + struct evdev_device *evdev = evdev_device(device); struct tp_dispatch *tp = (struct tp_dispatch*)evdev->dispatch; return tp_scroll_get_default_method(tp); @@ -2074,7 +2074,7 @@ static enum libinput_config_status tp_dwt_config_set(struct libinput_device *device, enum libinput_config_dwt_state enable) { - struct evdev_device *evdev = (struct evdev_device*)device; + struct evdev_device *evdev = evdev_device(device); struct tp_dispatch *tp = (struct tp_dispatch*)evdev->dispatch; switch(enable) { @@ -2093,7 +2093,7 @@ tp_dwt_config_set(struct libinput_device *device, static enum libinput_config_dwt_state tp_dwt_config_get(struct libinput_device *device) { - struct evdev_device *evdev = (struct evdev_device*)device; + struct evdev_device *evdev = evdev_device(device); struct tp_dispatch *tp = (struct tp_dispatch*)evdev->dispatch; return tp->dwt.dwt_enabled ? @@ -2110,7 +2110,7 @@ tp_dwt_default_enabled(struct tp_dispatch *tp) static enum libinput_config_dwt_state tp_dwt_config_get_default(struct libinput_device *device) { - struct evdev_device *evdev = (struct evdev_device*)device; + struct evdev_device *evdev = evdev_device(device); struct tp_dispatch *tp = (struct tp_dispatch*)evdev->dispatch; return tp_dwt_default_enabled(tp) ? @@ -2365,7 +2365,7 @@ tp_init(struct tp_dispatch *tp, static uint32_t tp_sendevents_get_modes(struct libinput_device *device) { - struct evdev_device *evdev = (struct evdev_device*)device; + struct evdev_device *evdev = evdev_device(device); uint32_t modes = LIBINPUT_CONFIG_SEND_EVENTS_DISABLED; if (evdev->tags & EVDEV_TAG_INTERNAL_TOUCHPAD) @@ -2381,7 +2381,7 @@ tp_suspend_conditional(struct tp_dispatch *tp, struct libinput_device *dev; list_for_each(dev, &device->base.seat->devices_list, link) { - struct evdev_device *d = (struct evdev_device*)dev; + struct evdev_device *d = evdev_device(dev); if (d->tags & EVDEV_TAG_EXTERNAL_MOUSE) { tp_suspend(tp, device); return; @@ -2393,7 +2393,7 @@ static enum libinput_config_status tp_sendevents_set_mode(struct libinput_device *device, enum libinput_config_send_events_mode mode) { - struct evdev_device *evdev = (struct evdev_device*)device; + struct evdev_device *evdev = evdev_device(device); struct tp_dispatch *tp = (struct tp_dispatch*)evdev->dispatch; /* DISABLED overrides any DISABLED_ON_ */ @@ -2426,7 +2426,7 @@ tp_sendevents_set_mode(struct libinput_device *device, static enum libinput_config_send_events_mode tp_sendevents_get_mode(struct libinput_device *device) { - struct evdev_device *evdev = (struct evdev_device*)device; + struct evdev_device *evdev = evdev_device(device); struct tp_dispatch *dispatch = (struct tp_dispatch*)evdev->dispatch; return dispatch->sendevents.current_mode; diff --git a/src/evdev-tablet-pad.c b/src/evdev-tablet-pad.c index cc7553f..bed43b6 100644 --- a/src/evdev-tablet-pad.c +++ b/src/evdev-tablet-pad.c @@ -580,7 +580,7 @@ static enum libinput_config_status pad_sendevents_set_mode(struct libinput_device *device, enum libinput_config_send_events_mode mode) { - struct evdev_device *evdev = (struct evdev_device*)device; + struct evdev_device *evdev = evdev_device(device); struct pad_dispatch *pad = (struct pad_dispatch*)evdev->dispatch; if (mode == pad->sendevents.current_mode) @@ -604,7 +604,7 @@ pad_sendevents_set_mode(struct libinput_device *device, static enum libinput_config_send_events_mode pad_sendevents_get_mode(struct libinput_device *device) { - struct evdev_device *evdev = (struct evdev_device*)device; + struct evdev_device *evdev = evdev_device(device); struct pad_dispatch *dispatch = (struct pad_dispatch*)evdev->dispatch; return dispatch->sendevents.current_mode; diff --git a/src/evdev.c b/src/evdev.c index e040583..afee590 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -1260,7 +1260,7 @@ fallback_destroy(struct evdev_dispatch *evdev_dispatch) static int evdev_calibration_has_matrix(struct libinput_device *libinput_device) { - struct evdev_device *device = (struct evdev_device*)libinput_device; + struct evdev_device *device = evdev_device(libinput_device); return device->abs.absinfo_x && device->abs.absinfo_y; } @@ -1269,7 +1269,7 @@ static enum libinput_config_status evdev_calibration_set_matrix(struct libinput_device *libinput_device, const float matrix[6]) { - struct evdev_device *device = (struct evdev_device*)libinput_device; + struct evdev_device *device = evdev_device(libinput_device); evdev_device_calibrate(device, matrix); @@ -1280,7 +1280,7 @@ static int evdev_calibration_get_matrix(struct libinput_device *libinput_device, float matrix[6]) { - struct evdev_device *device = (struct evdev_device*)libinput_device; + struct evdev_device *device = evdev_device(libinput_device); matrix_to_farray6(&device->abs.usermatrix, matrix); @@ -1291,7 +1291,7 @@ static int evdev_calibration_get_default_matrix(struct libinput_device *libinput_device, float matrix[6]) { - struct evdev_device *device = (struct evdev_device*)libinput_device; + struct evdev_device *device = evdev_device(libinput_device); matrix_to_farray6(&device->abs.default_calibration, matrix); @@ -1321,7 +1321,7 @@ static enum libinput_config_status evdev_sendevents_set_mode(struct libinput_device *device, enum libinput_config_send_events_mode mode) { - struct evdev_device *evdev = (struct evdev_device*)device; + struct evdev_device *evdev = evdev_device(device); struct evdev_dispatch *dispatch = evdev->dispatch; if (mode == dispatch->sendevents.current_mode) @@ -1346,7 +1346,7 @@ evdev_sendevents_set_mode(struct libinput_device *device, static enum libinput_config_send_events_mode evdev_sendevents_get_mode(struct libinput_device *device) { - struct evdev_device *evdev = (struct evdev_device*)device; + struct evdev_device *evdev = evdev_device(device); struct evdev_dispatch *dispatch = evdev->dispatch; return dispatch->sendevents.current_mode; @@ -1383,11 +1383,11 @@ evdev_change_to_left_handed(struct evdev_device *device) static enum libinput_config_status evdev_left_handed_set(struct libinput_device *device, int left_handed) { - struct evdev_device *evdev_device = (struct evdev_device *)device; + struct evdev_device *evdev = evdev_device(device); - evdev_device->left_handed.want_enabled = left_handed ? true : false; + evdev->left_handed.want_enabled = left_handed ? true : false; - evdev_device->left_handed.change_to_enabled(evdev_device); + evdev->left_handed.change_to_enabled(evdev); return LIBINPUT_CONFIG_STATUS_SUCCESS; } @@ -1395,11 +1395,11 @@ evdev_left_handed_set(struct libinput_device *device, int left_handed) static int evdev_left_handed_get(struct libinput_device *device) { - struct evdev_device *evdev_device = (struct evdev_device *)device; + struct evdev_device *evdev = evdev_device(device); /* return the wanted configuration, even if it hasn't taken * effect yet! */ - return evdev_device->left_handed.want_enabled; + return evdev->left_handed.want_enabled; } static int @@ -1448,7 +1448,7 @@ static enum libinput_config_status evdev_scroll_set_method(struct libinput_device *device, enum libinput_config_scroll_method method) { - struct evdev_device *evdev = (struct evdev_device*)device; + struct evdev_device *evdev = evdev_device(device); evdev->scroll.want_method = method; evdev->scroll.change_scroll_method(evdev); @@ -1459,7 +1459,7 @@ evdev_scroll_set_method(struct libinput_device *device, static enum libinput_config_scroll_method evdev_scroll_get_method(struct libinput_device *device) { - struct evdev_device *evdev = (struct evdev_device *)device; + struct evdev_device *evdev = evdev_device(device); /* return the wanted configuration, even if it hasn't taken * effect yet! */ @@ -1469,7 +1469,7 @@ evdev_scroll_get_method(struct libinput_device *device) static enum libinput_config_scroll_method evdev_scroll_get_default_method(struct libinput_device *device) { - struct evdev_device *evdev = (struct evdev_device *)device; + struct evdev_device *evdev = evdev_device(device); if (evdev->tags & EVDEV_TAG_TRACKPOINT) return LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN; @@ -1488,7 +1488,7 @@ static enum libinput_config_status evdev_scroll_set_button(struct libinput_device *device, uint32_t button) { - struct evdev_device *evdev = (struct evdev_device*)device; + struct evdev_device *evdev = evdev_device(device); evdev->scroll.want_button = button; evdev->scroll.change_scroll_method(evdev); @@ -1499,7 +1499,7 @@ evdev_scroll_set_button(struct libinput_device *device, static uint32_t evdev_scroll_get_button(struct libinput_device *device) { - struct evdev_device *evdev = (struct evdev_device *)device; + struct evdev_device *evdev = evdev_device(device); /* return the wanted configuration, even if it hasn't taken * effect yet! */ @@ -1509,7 +1509,7 @@ evdev_scroll_get_button(struct libinput_device *device) static uint32_t evdev_scroll_get_default_button(struct libinput_device *device) { - struct evdev_device *evdev = (struct evdev_device *)device; + struct evdev_device *evdev = evdev_device(device); if (libevdev_has_event_code(evdev->evdev, EV_KEY, BTN_MIDDLE)) return BTN_MIDDLE; @@ -1574,7 +1574,7 @@ static enum libinput_config_status evdev_scroll_config_natural_set(struct libinput_device *device, int enabled) { - struct evdev_device *dev = (struct evdev_device *)device; + struct evdev_device *dev = evdev_device(device); dev->scroll.natural_scrolling_enabled = enabled ? true : false; @@ -1584,7 +1584,7 @@ evdev_scroll_config_natural_set(struct libinput_device *device, static int evdev_scroll_config_natural_get(struct libinput_device *device) { - struct evdev_device *dev = (struct evdev_device *)device; + struct evdev_device *dev = evdev_device(device); return dev->scroll.natural_scrolling_enabled ? 1 : 0; } @@ -1619,7 +1619,7 @@ static enum libinput_config_status evdev_rotation_config_set_angle(struct libinput_device *libinput_device, unsigned int degrees_cw) { - struct evdev_device *device = (struct evdev_device*)libinput_device; + struct evdev_device *device = evdev_device(libinput_device); struct fallback_dispatch *dispatch = fallback_dispatch(device->dispatch); dispatch->rotation.angle = degrees_cw; @@ -1631,7 +1631,7 @@ evdev_rotation_config_set_angle(struct libinput_device *libinput_device, static unsigned int evdev_rotation_config_get_angle(struct libinput_device *libinput_device) { - struct evdev_device *device = (struct evdev_device*)libinput_device; + struct evdev_device *device = evdev_device(libinput_device); struct fallback_dispatch *dispatch = fallback_dispatch(device->dispatch); return dispatch->rotation.angle; @@ -1766,10 +1766,10 @@ fallback_dispatch_init_abs(struct fallback_dispatch *dispatch, } static struct evdev_dispatch * -fallback_dispatch_create(struct libinput_device *device) +fallback_dispatch_create(struct libinput_device *libinput_device) { struct fallback_dispatch *dispatch = zalloc(sizeof *dispatch); - struct evdev_device *evdev_device = (struct evdev_device *)device; + struct evdev_device *device = evdev_device(libinput_device); if (dispatch == NULL) return NULL; @@ -1778,42 +1778,42 @@ fallback_dispatch_create(struct libinput_device *device) dispatch->base.interface = &fallback_interface; dispatch->pending_event = EVDEV_NONE; - fallback_dispatch_init_rel(dispatch, evdev_device); - fallback_dispatch_init_abs(dispatch, evdev_device); - if (fallback_dispatch_init_slots(dispatch, evdev_device) == -1) { + fallback_dispatch_init_rel(dispatch, device); + fallback_dispatch_init_abs(dispatch, device); + if (fallback_dispatch_init_slots(dispatch, device) == -1) { free(dispatch); return NULL; } - if (evdev_device->left_handed.want_enabled) - evdev_init_left_handed(evdev_device, + if (device->left_handed.want_enabled) + evdev_init_left_handed(device, evdev_change_to_left_handed); - if (evdev_device->scroll.want_button) - evdev_init_button_scroll(evdev_device, + if (device->scroll.want_button) + evdev_init_button_scroll(device, evdev_change_scroll_method); - if (evdev_device->scroll.natural_scrolling_enabled) - evdev_init_natural_scroll(evdev_device); + if (device->scroll.natural_scrolling_enabled) + evdev_init_natural_scroll(device); - evdev_init_calibration(evdev_device, &dispatch->calibration); - evdev_init_sendevents(evdev_device, &dispatch->base); - evdev_init_rotation(evdev_device, dispatch); + evdev_init_calibration(device, &dispatch->calibration); + evdev_init_sendevents(device, &dispatch->base); + evdev_init_rotation(device, dispatch); /* BTN_MIDDLE is set on mice even when it's not present. So * we can only use the absence of BTN_MIDDLE to mean something, i.e. * we enable it by default on anything that only has L&R. * If we have L&R and no middle, we don't expose it as config * option */ - if (libevdev_has_event_code(evdev_device->evdev, EV_KEY, BTN_LEFT) && - libevdev_has_event_code(evdev_device->evdev, EV_KEY, BTN_RIGHT)) { - bool has_middle = libevdev_has_event_code(evdev_device->evdev, + if (libevdev_has_event_code(device->evdev, EV_KEY, BTN_LEFT) && + libevdev_has_event_code(device->evdev, EV_KEY, BTN_RIGHT)) { + bool has_middle = libevdev_has_event_code(device->evdev, EV_KEY, BTN_MIDDLE); bool want_config = has_middle; bool enable_by_default = !has_middle; - evdev_init_middlebutton(evdev_device, + evdev_init_middlebutton(device, enable_by_default, want_config); } @@ -1952,7 +1952,7 @@ evdev_accel_config_available(struct libinput_device *device) static enum libinput_config_status evdev_accel_config_set_speed(struct libinput_device *device, double speed) { - struct evdev_device *dev = (struct evdev_device *)device; + struct evdev_device *dev = evdev_device(device); if (!filter_set_speed(dev->pointer.filter, speed)) return LIBINPUT_CONFIG_STATUS_INVALID; @@ -1963,7 +1963,7 @@ evdev_accel_config_set_speed(struct libinput_device *device, double speed) static double evdev_accel_config_get_speed(struct libinput_device *device) { - struct evdev_device *dev = (struct evdev_device *)device; + struct evdev_device *dev = evdev_device(device); return filter_get_speed(dev->pointer.filter); } @@ -1977,7 +1977,7 @@ evdev_accel_config_get_default_speed(struct libinput_device *device) static uint32_t evdev_accel_config_get_profiles(struct libinput_device *libinput_device) { - struct evdev_device *device = (struct evdev_device*)libinput_device; + struct evdev_device *device = evdev_device(libinput_device); if (!device->pointer.filter) return LIBINPUT_CONFIG_ACCEL_PROFILE_NONE; @@ -1990,7 +1990,7 @@ static enum libinput_config_status evdev_accel_config_set_profile(struct libinput_device *libinput_device, enum libinput_config_accel_profile profile) { - struct evdev_device *device = (struct evdev_device*)libinput_device; + struct evdev_device *device = evdev_device(libinput_device); struct motion_filter *filter; double speed; @@ -2014,7 +2014,7 @@ evdev_accel_config_set_profile(struct libinput_device *libinput_device, static enum libinput_config_accel_profile evdev_accel_config_get_profile(struct libinput_device *libinput_device) { - struct evdev_device *device = (struct evdev_device*)libinput_device; + struct evdev_device *device = evdev_device(libinput_device); return filter_get_type(device->pointer.filter); } @@ -2022,7 +2022,7 @@ evdev_accel_config_get_profile(struct libinput_device *libinput_device) static enum libinput_config_accel_profile evdev_accel_config_get_default_profile(struct libinput_device *libinput_device) { - struct evdev_device *device = (struct evdev_device*)libinput_device; + struct evdev_device *device = evdev_device(libinput_device); if (!device->pointer.filter) return LIBINPUT_CONFIG_ACCEL_PROFILE_NONE; @@ -2698,7 +2698,7 @@ evdev_notify_added_device(struct evdev_device *device) struct libinput_device *dev; list_for_each(dev, &device->base.seat->devices_list, link) { - struct evdev_device *d = (struct evdev_device*)dev; + struct evdev_device *d = evdev_device(dev); if (dev == &device->base) continue; @@ -3282,7 +3282,7 @@ evdev_notify_suspended_device(struct evdev_device *device) return; list_for_each(it, &device->base.seat->devices_list, link) { - struct evdev_device *d = (struct evdev_device*)it; + struct evdev_device *d = evdev_device(it); if (it == &device->base) continue; @@ -3302,7 +3302,7 @@ evdev_notify_resumed_device(struct evdev_device *device) return; list_for_each(it, &device->base.seat->devices_list, link) { - struct evdev_device *d = (struct evdev_device*)it; + struct evdev_device *d = evdev_device(it); if (it == &device->base) continue; @@ -3409,7 +3409,7 @@ evdev_device_remove(struct evdev_device *device) struct libinput_device *dev; list_for_each(dev, &device->base.seat->devices_list, link) { - struct evdev_device *d = (struct evdev_device*)dev; + struct evdev_device *d = evdev_device(dev); if (dev == &device->base) continue; diff --git a/src/evdev.h b/src/evdev.h index 924a4a1..462776d 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -237,6 +237,14 @@ struct evdev_device { } middlebutton; }; +static inline struct evdev_device * +evdev_device(struct libinput_device *device) +{ + struct evdev_device *d; + + return container_of(device, d, base); +} + #define EVDEV_UNHANDLED_DEVICE ((struct evdev_device *) 1) struct evdev_dispatch; diff --git a/src/libinput.c b/src/libinput.c index ebfedec..84e329d 100644 --- a/src/libinput.c +++ b/src/libinput.c @@ -516,8 +516,7 @@ libinput_event_pointer_get_dy_unaccelerated( LIBINPUT_EXPORT double libinput_event_pointer_get_absolute_x(struct libinput_event_pointer *event) { - struct evdev_device *device = - (struct evdev_device *) event->base.device; + struct evdev_device *device = evdev_device(event->base.device); require_event_type(libinput_event_get_context(&event->base), event->base.type, @@ -530,8 +529,7 @@ libinput_event_pointer_get_absolute_x(struct libinput_event_pointer *event) LIBINPUT_EXPORT double libinput_event_pointer_get_absolute_y(struct libinput_event_pointer *event) { - struct evdev_device *device = - (struct evdev_device *) event->base.device; + struct evdev_device *device = evdev_device(event->base.device); require_event_type(libinput_event_get_context(&event->base), event->base.type, @@ -546,8 +544,7 @@ libinput_event_pointer_get_absolute_x_transformed( struct libinput_event_pointer *event, uint32_t width) { - struct evdev_device *device = - (struct evdev_device *) event->base.device; + struct evdev_device *device = evdev_device(event->base.device); require_event_type(libinput_event_get_context(&event->base), event->base.type, @@ -562,8 +559,7 @@ libinput_event_pointer_get_absolute_y_transformed( struct libinput_event_pointer *event, uint32_t height) { - struct evdev_device *device = - (struct evdev_device *) event->base.device; + struct evdev_device *device = evdev_device(event->base.device); require_event_type(libinput_event_get_context(&event->base), event->base.type, @@ -752,8 +748,7 @@ libinput_event_touch_get_seat_slot(struct libinput_event_touch *event) LIBINPUT_EXPORT double libinput_event_touch_get_x(struct libinput_event_touch *event) { - struct evdev_device *device = - (struct evdev_device *) event->base.device; + struct evdev_device *device = evdev_device(event->base.device); require_event_type(libinput_event_get_context(&event->base), event->base.type, @@ -768,8 +763,7 @@ LIBINPUT_EXPORT double libinput_event_touch_get_x_transformed(struct libinput_event_touch *event, uint32_t width) { - struct evdev_device *device = - (struct evdev_device *) event->base.device; + struct evdev_device *device = evdev_device(event->base.device); require_event_type(libinput_event_get_context(&event->base), event->base.type, @@ -784,8 +778,7 @@ LIBINPUT_EXPORT double libinput_event_touch_get_y_transformed(struct libinput_event_touch *event, uint32_t height) { - struct evdev_device *device = - (struct evdev_device *) event->base.device; + struct evdev_device *device = evdev_device(event->base.device); require_event_type(libinput_event_get_context(&event->base), event->base.type, @@ -799,8 +792,7 @@ libinput_event_touch_get_y_transformed(struct libinput_event_touch *event, LIBINPUT_EXPORT double libinput_event_touch_get_y(struct libinput_event_touch *event) { - struct evdev_device *device = - (struct evdev_device *) event->base.device; + struct evdev_device *device = evdev_device(event->base.device); require_event_type(libinput_event_get_context(&event->base), event->base.type, @@ -1110,8 +1102,7 @@ libinput_event_tablet_tool_wheel_has_changed( LIBINPUT_EXPORT double libinput_event_tablet_tool_get_x(struct libinput_event_tablet_tool *event) { - struct evdev_device *device = - (struct evdev_device *) event->base.device; + struct evdev_device *device = evdev_device(event->base.device); require_event_type(libinput_event_get_context(&event->base), event->base.type, @@ -1128,8 +1119,7 @@ libinput_event_tablet_tool_get_x(struct libinput_event_tablet_tool *event) LIBINPUT_EXPORT double libinput_event_tablet_tool_get_y(struct libinput_event_tablet_tool *event) { - struct evdev_device *device = - (struct evdev_device *) event->base.device; + struct evdev_device *device = evdev_device(event->base.device); require_event_type(libinput_event_get_context(&event->base), event->base.type, @@ -1277,8 +1267,7 @@ LIBINPUT_EXPORT double libinput_event_tablet_tool_get_x_transformed(struct libinput_event_tablet_tool *event, uint32_t width) { - struct evdev_device *device = - (struct evdev_device *) event->base.device; + struct evdev_device *device = evdev_device(event->base.device); require_event_type(libinput_event_get_context(&event->base), event->base.type, @@ -1297,8 +1286,7 @@ LIBINPUT_EXPORT double libinput_event_tablet_tool_get_y_transformed(struct libinput_event_tablet_tool *event, uint32_t height) { - struct evdev_device *device = - (struct evdev_device *) event->base.device; + struct evdev_device *device = evdev_device(event->base.device); require_event_type(libinput_event_get_context(&event->base), event->base.type, @@ -1898,7 +1886,7 @@ static void libinput_device_destroy(struct libinput_device *device) { assert(list_empty(&device->event_listeners)); - evdev_device_destroy((struct evdev_device *) device); + evdev_device_destroy(evdev_device(device)); } LIBINPUT_EXPORT struct libinput_device * diff --git a/src/path-seat.c b/src/path-seat.c index d806bfb..e6289a2 100644 --- a/src/path-seat.c +++ b/src/path-seat.c @@ -244,11 +244,11 @@ path_device_change_seat(struct libinput_device *device, const char *seat_name) { struct libinput *libinput = device->seat->libinput; - struct evdev_device *evdev_device = (struct evdev_device *)device; + struct evdev_device *evdev = evdev_device(device); struct udev_device *udev_device = NULL; int rc = -1; - udev_device = evdev_device->udev_device; + udev_device = evdev->udev_device; udev_device_ref(udev_device); libinput_path_remove_device(device); @@ -361,7 +361,7 @@ libinput_path_remove_device(struct libinput_device *device) struct libinput *libinput = device->seat->libinput; struct path_input *input = (struct path_input*)libinput; struct libinput_seat *seat; - struct evdev_device *evdev = (struct evdev_device*)device; + struct evdev_device *evdev = evdev_device(device); struct path_device *dev; if (libinput->interface_backend != &interface_backend) { diff --git a/src/udev-seat.c b/src/udev-seat.c index d1eaed8..a19afb4 100644 --- a/src/udev-seat.c +++ b/src/udev-seat.c @@ -322,8 +322,8 @@ udev_device_change_seat(struct libinput_device *device, { struct libinput *libinput = device->seat->libinput; struct udev_input *input = (struct udev_input *)libinput; - struct evdev_device *evdev_device = (struct evdev_device *)device; - struct udev_device *udev_device = evdev_device->udev_device; + struct evdev_device *evdev = evdev_device(device); + struct udev_device *udev_device = evdev->udev_device; int rc; udev_device_ref(udev_device); -- 2.9.3 _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel