mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-12-14 08:56:26 -05:00
handle input device destroy
This commit is contained in:
parent
df0ee7f25f
commit
5c845f14ed
6 changed files with 39 additions and 2 deletions
|
|
@ -188,6 +188,18 @@ static void handle_input_add(struct compositor_state *state, struct
|
|||
}
|
||||
}
|
||||
|
||||
static void handle_input_remove(struct compositor_state *state, struct
|
||||
wlr_input_device *device) {
|
||||
struct sample_state *sample = state->data;
|
||||
struct sample_input_device *s_device, *tmp = NULL;
|
||||
wl_list_for_each_safe(s_device, tmp, &sample->devices, link) {
|
||||
if (s_device->device == device) {
|
||||
wl_list_remove(&s_device->link);
|
||||
free(s_device);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_cursor_motion(struct wl_listener *listener, void *data) {
|
||||
struct sample_state *sample = wl_container_of(listener, sample, cursor_motion);
|
||||
struct wlr_event_pointer_motion *event = data;
|
||||
|
|
@ -339,8 +351,7 @@ int main(int argc, char *argv[]) {
|
|||
compositor.output_resolution_cb = handle_output_resolution;
|
||||
compositor.output_frame_cb = handle_output_frame;
|
||||
compositor.input_add_cb = handle_input_add;
|
||||
// TODO input_remove_cb
|
||||
//compositor.input_remove_cb = handle_input_add;
|
||||
compositor.input_remove_cb = handle_input_remove;
|
||||
|
||||
state.compositor = &compositor;
|
||||
|
||||
|
|
|
|||
|
|
@ -401,6 +401,11 @@ static void tablet_pad_remove(struct wlr_input_device *device, struct compositor
|
|||
static void input_remove_notify(struct wl_listener *listener, void *data) {
|
||||
struct wlr_input_device *device = data;
|
||||
struct compositor_state *state = wl_container_of(listener, state, input_remove);
|
||||
|
||||
if (state->input_remove_cb) {
|
||||
state->input_remove_cb(state, device);
|
||||
}
|
||||
|
||||
switch (device->type) {
|
||||
case WLR_INPUT_DEVICE_KEYBOARD:
|
||||
keyboard_remove(device, state);
|
||||
|
|
|
|||
|
|
@ -77,6 +77,8 @@ struct tablet_pad_state {
|
|||
struct compositor_state {
|
||||
void (*input_add_cb)(struct compositor_state *compositor,
|
||||
struct wlr_input_device *device);
|
||||
void (*input_remove_cb)(struct compositor_state *compositor,
|
||||
struct wlr_input_device *device);
|
||||
void (*output_add_cb)(struct output_state *s);
|
||||
void (*keyboard_add_cb)(struct keyboard_state *s);
|
||||
void (*output_frame_cb)(struct output_state *s, struct timespec *ts);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue