wlr_input_device: remove anon union field

This union is unnecessary since the recent input device refactor and can
now be replaced by wlr_*_from_input_device() functions.
This commit is contained in:
Isaac Freund 2022-06-20 16:57:29 +02:00 committed by Simon Ser
parent 5c4384a133
commit 91943a68a6
31 changed files with 216 additions and 130 deletions

View file

@ -30,17 +30,6 @@ struct wlr_input_device {
unsigned int vendor, product;
char *name;
/* wlr_input_device.type determines which of these is valid */
union {
void *_device;
struct wlr_keyboard *keyboard;
struct wlr_pointer *pointer;
struct wlr_switch *switch_device;
struct wlr_touch *touch;
struct wlr_tablet *tablet;
struct wlr_tablet_pad *tablet_pad;
};
struct {
struct wl_signal destroy;
} events;

View file

@ -101,6 +101,14 @@ struct wlr_keyboard_key_event {
enum wl_keyboard_key_state state;
};
/**
* Get a struct wlr_keyboard from a struct wlr_input_device.
*
* Asserts that the input device is a keyboard.
*/
struct wlr_keyboard *wlr_keyboard_from_input_device(
struct wlr_input_device *input_device);
bool wlr_keyboard_set_keymap(struct wlr_keyboard *kb,
struct xkb_keymap *keymap);

View file

@ -145,4 +145,12 @@ struct wlr_pointer_hold_end_event {
bool cancelled;
};
/**
* Get a struct wlr_pointer from a struct wlr_input_device.
*
* Asserts that the input device is a pointer.
*/
struct wlr_pointer *wlr_pointer_from_input_device(
struct wlr_input_device *input_device);
#endif

View file

@ -43,4 +43,12 @@ struct wlr_switch_toggle_event {
enum wlr_switch_state switch_state;
};
/**
* Get a struct wlr_switch from a struct wlr_input_device.
*
* Asserts that the input device is a switch.
*/
struct wlr_switch *wlr_switch_from_input_device(
struct wlr_input_device *input_device);
#endif

View file

@ -92,4 +92,12 @@ struct wlr_tablet_pad_strip_event {
unsigned int mode;
};
/**
* Get a struct wlr_tablet_pad from a struct wlr_input_device.
*
* Asserts that the input device is a tablet pad.
*/
struct wlr_tablet_pad *wlr_tablet_pad_from_input_device(
struct wlr_input_device *);
#endif

View file

@ -144,4 +144,12 @@ struct wlr_tablet_tool_button_event {
enum wlr_button_state state;
};
/**
* Get a struct wlr_tablet from a struct wlr_input_device.
*
* Asserts that the input device is a tablet tool.
*/
struct wlr_tablet *wlr_tablet_from_input_device(
struct wlr_input_device *input_device);
#endif

View file

@ -62,4 +62,12 @@ struct wlr_touch_cancel_event {
int32_t touch_id;
};
/**
* Get a struct wlr_touch from a struct wlr_input_device.
*
* Asserts that the input device is a touch device.
*/
struct wlr_touch *wlr_touch_from_input_device(
struct wlr_input_device *input_device);
#endif