mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-31 22:25:21 -04:00
Build libinput events on the stack instead of allocating
This commit is contained in:
parent
62d8b252c0
commit
0663b6d1e1
5 changed files with 129 additions and 145 deletions
|
|
@ -23,15 +23,14 @@ void handle_touch_down(struct libinput_event *event,
|
|||
}
|
||||
struct libinput_event_touch *tevent =
|
||||
libinput_event_get_touch_event(event);
|
||||
struct wlr_event_touch_down *wlr_event =
|
||||
calloc(1, sizeof(struct wlr_event_touch_down));
|
||||
wlr_event->time_sec = libinput_event_touch_get_time(tevent);
|
||||
wlr_event->time_usec = libinput_event_touch_get_time_usec(tevent);
|
||||
wlr_event->slot = libinput_event_touch_get_slot(tevent);
|
||||
wlr_event->x_mm = libinput_event_touch_get_x(tevent);
|
||||
wlr_event->y_mm = libinput_event_touch_get_y(tevent);
|
||||
libinput_device_get_size(device, &wlr_event->width_mm, &wlr_event->height_mm);
|
||||
wl_signal_emit(&dev->touch->events.down, wlr_event);
|
||||
struct wlr_event_touch_down wlr_event = { 0 };
|
||||
wlr_event.time_sec = libinput_event_touch_get_time(tevent);
|
||||
wlr_event.time_usec = libinput_event_touch_get_time_usec(tevent);
|
||||
wlr_event.slot = libinput_event_touch_get_slot(tevent);
|
||||
wlr_event.x_mm = libinput_event_touch_get_x(tevent);
|
||||
wlr_event.y_mm = libinput_event_touch_get_y(tevent);
|
||||
libinput_device_get_size(device, &wlr_event.width_mm, &wlr_event.height_mm);
|
||||
wl_signal_emit(&dev->touch->events.down, &wlr_event);
|
||||
}
|
||||
|
||||
void handle_touch_up(struct libinput_event *event,
|
||||
|
|
@ -44,12 +43,11 @@ void handle_touch_up(struct libinput_event *event,
|
|||
}
|
||||
struct libinput_event_touch *tevent =
|
||||
libinput_event_get_touch_event(event);
|
||||
struct wlr_event_touch_up *wlr_event =
|
||||
calloc(1, sizeof(struct wlr_event_touch_up));
|
||||
wlr_event->time_sec = libinput_event_touch_get_time(tevent);
|
||||
wlr_event->time_usec = libinput_event_touch_get_time_usec(tevent);
|
||||
wlr_event->slot = libinput_event_touch_get_slot(tevent);
|
||||
wl_signal_emit(&dev->touch->events.up, wlr_event);
|
||||
struct wlr_event_touch_up wlr_event = { 0 };
|
||||
wlr_event.time_sec = libinput_event_touch_get_time(tevent);
|
||||
wlr_event.time_usec = libinput_event_touch_get_time_usec(tevent);
|
||||
wlr_event.slot = libinput_event_touch_get_slot(tevent);
|
||||
wl_signal_emit(&dev->touch->events.up, &wlr_event);
|
||||
}
|
||||
|
||||
void handle_touch_motion(struct libinput_event *event,
|
||||
|
|
@ -62,15 +60,14 @@ void handle_touch_motion(struct libinput_event *event,
|
|||
}
|
||||
struct libinput_event_touch *tevent =
|
||||
libinput_event_get_touch_event(event);
|
||||
struct wlr_event_touch_motion *wlr_event =
|
||||
calloc(1, sizeof(struct wlr_event_touch_motion));
|
||||
wlr_event->time_sec = libinput_event_touch_get_time(tevent);
|
||||
wlr_event->time_usec = libinput_event_touch_get_time_usec(tevent);
|
||||
wlr_event->slot = libinput_event_touch_get_slot(tevent);
|
||||
wlr_event->x_mm = libinput_event_touch_get_x(tevent);
|
||||
wlr_event->y_mm = libinput_event_touch_get_y(tevent);
|
||||
libinput_device_get_size(device, &wlr_event->width_mm, &wlr_event->height_mm);
|
||||
wl_signal_emit(&dev->touch->events.motion, wlr_event);
|
||||
struct wlr_event_touch_motion wlr_event = { 0 };
|
||||
wlr_event.time_sec = libinput_event_touch_get_time(tevent);
|
||||
wlr_event.time_usec = libinput_event_touch_get_time_usec(tevent);
|
||||
wlr_event.slot = libinput_event_touch_get_slot(tevent);
|
||||
wlr_event.x_mm = libinput_event_touch_get_x(tevent);
|
||||
wlr_event.y_mm = libinput_event_touch_get_y(tevent);
|
||||
libinput_device_get_size(device, &wlr_event.width_mm, &wlr_event.height_mm);
|
||||
wl_signal_emit(&dev->touch->events.motion, &wlr_event);
|
||||
}
|
||||
|
||||
void handle_touch_cancel(struct libinput_event *event,
|
||||
|
|
@ -83,10 +80,9 @@ void handle_touch_cancel(struct libinput_event *event,
|
|||
}
|
||||
struct libinput_event_touch *tevent =
|
||||
libinput_event_get_touch_event(event);
|
||||
struct wlr_event_touch_cancel *wlr_event =
|
||||
calloc(1, sizeof(struct wlr_event_touch_cancel));
|
||||
wlr_event->time_sec = libinput_event_touch_get_time(tevent);
|
||||
wlr_event->time_usec = libinput_event_touch_get_time_usec(tevent);
|
||||
wlr_event->slot = libinput_event_touch_get_slot(tevent);
|
||||
wl_signal_emit(&dev->touch->events.cancel, wlr_event);
|
||||
struct wlr_event_touch_cancel wlr_event = { 0 };
|
||||
wlr_event.time_sec = libinput_event_touch_get_time(tevent);
|
||||
wlr_event.time_usec = libinput_event_touch_get_time_usec(tevent);
|
||||
wlr_event.slot = libinput_event_touch_get_slot(tevent);
|
||||
wl_signal_emit(&dev->touch->events.cancel, &wlr_event);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue