diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2017-01-30 18:01:09 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2017-01-31 07:36:12 +1000 |
commit | 60de087e6521d2e098e129dae86cf40f7f7af354 (patch) | |
tree | 0e86536b0ac2fcc1ba928036d89ed5a8a6cbe9d4 /src/evdev-tablet-pad.c | |
parent | dc15a42d6cae4195d327253f6f05b65665eb3a93 (diff) |
evdev: improve type-safety on dispatch switches
Set the dispatch type on creation, then check that whenever we try to get the
dispatch struct. This avoids a potential mismatch between the backends.
Plus, use of container_of means we're not dependent on the exact layout
anymore.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src/evdev-tablet-pad.c')
-rw-r--r-- | src/evdev-tablet-pad.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/evdev-tablet-pad.c b/src/evdev-tablet-pad.c index 82542bc..cc7553f 100644 --- a/src/evdev-tablet-pad.c +++ b/src/evdev-tablet-pad.c @@ -452,7 +452,7 @@ pad_process(struct evdev_dispatch *dispatch, struct input_event *e, uint64_t time) { - struct pad_dispatch *pad = (struct pad_dispatch *)dispatch; + struct pad_dispatch *pad = pad_dispatch(dispatch); switch (e->type) { case EV_ABS: @@ -481,7 +481,7 @@ static void pad_suspend(struct evdev_dispatch *dispatch, struct evdev_device *device) { - struct pad_dispatch *pad = (struct pad_dispatch *)dispatch; + struct pad_dispatch *pad = pad_dispatch(dispatch); struct libinput *libinput = pad_libinput_context(pad); unsigned int code; @@ -496,7 +496,7 @@ pad_suspend(struct evdev_dispatch *dispatch, static void pad_destroy(struct evdev_dispatch *dispatch) { - struct pad_dispatch *pad = (struct pad_dispatch*)dispatch; + struct pad_dispatch *pad = pad_dispatch(dispatch); pad_destroy_leds(pad); free(pad); @@ -556,6 +556,7 @@ pad_init_left_handed(struct evdev_device *device) static int pad_init(struct pad_dispatch *pad, struct evdev_device *device) { + pad->base.dispatch_type = DISPATCH_TABLET_PAD; pad->base.interface = &pad_interface; pad->device = device; pad->status = PAD_NONE; |