aboutsummaryrefslogtreecommitdiff
path: root/backend/libinput/pointer.c
diff options
context:
space:
mode:
Diffstat (limited to 'backend/libinput/pointer.c')
-rw-r--r--backend/libinput/pointer.c66
1 files changed, 31 insertions, 35 deletions
diff --git a/backend/libinput/pointer.c b/backend/libinput/pointer.c
index 59e219d8..08855167 100644
--- a/backend/libinput/pointer.c
+++ b/backend/libinput/pointer.c
@@ -23,13 +23,12 @@ void handle_pointer_motion(struct libinput_event *event,
}
struct libinput_event_pointer *pevent =
libinput_event_get_pointer_event(event);
- struct wlr_event_pointer_motion *wlr_event =
- calloc(1, sizeof(struct wlr_event_pointer_motion));
- wlr_event->time_sec = libinput_event_pointer_get_time(pevent);
- wlr_event->time_usec = libinput_event_pointer_get_time_usec(pevent);
- wlr_event->delta_x = libinput_event_pointer_get_dx(pevent);
- wlr_event->delta_y = libinput_event_pointer_get_dy(pevent);
- wl_signal_emit(&dev->pointer->events.motion, wlr_event);
+ struct wlr_event_pointer_motion wlr_event = { 0 };
+ wlr_event.time_sec = libinput_event_pointer_get_time(pevent);
+ wlr_event.time_usec = libinput_event_pointer_get_time_usec(pevent);
+ wlr_event.delta_x = libinput_event_pointer_get_dx(pevent);
+ wlr_event.delta_y = libinput_event_pointer_get_dy(pevent);
+ wl_signal_emit(&dev->pointer->events.motion, &wlr_event);
}
void handle_pointer_motion_abs(struct libinput_event *event,
@@ -42,14 +41,13 @@ void handle_pointer_motion_abs(struct libinput_event *event,
}
struct libinput_event_pointer *pevent =
libinput_event_get_pointer_event(event);
- struct wlr_event_pointer_motion_absolute *wlr_event =
- calloc(1, sizeof(struct wlr_event_pointer_motion_absolute));
- wlr_event->time_sec = libinput_event_pointer_get_time(pevent);
- wlr_event->time_usec = libinput_event_pointer_get_time_usec(pevent);
- wlr_event->x_mm = libinput_event_pointer_get_absolute_x(pevent);
- wlr_event->y_mm = libinput_event_pointer_get_absolute_y(pevent);
- libinput_device_get_size(device, &wlr_event->width_mm, &wlr_event->height_mm);
- wl_signal_emit(&dev->pointer->events.motion_absolute, wlr_event);
+ struct wlr_event_pointer_motion_absolute wlr_event = { 0 };
+ wlr_event.time_sec = libinput_event_pointer_get_time(pevent);
+ wlr_event.time_usec = libinput_event_pointer_get_time_usec(pevent);
+ wlr_event.x_mm = libinput_event_pointer_get_absolute_x(pevent);
+ wlr_event.y_mm = libinput_event_pointer_get_absolute_y(pevent);
+ libinput_device_get_size(device, &wlr_event.width_mm, &wlr_event.height_mm);
+ wl_signal_emit(&dev->pointer->events.motion_absolute, &wlr_event);
}
void handle_pointer_button(struct libinput_event *event,
@@ -62,20 +60,19 @@ void handle_pointer_button(struct libinput_event *event,
}
struct libinput_event_pointer *pevent =
libinput_event_get_pointer_event(event);
- struct wlr_event_pointer_button *wlr_event =
- calloc(1, sizeof(struct wlr_event_pointer_button));
- wlr_event->time_sec = libinput_event_pointer_get_time(pevent);
- wlr_event->time_usec = libinput_event_pointer_get_time_usec(pevent);
- wlr_event->button = libinput_event_pointer_get_button(pevent);
+ struct wlr_event_pointer_button wlr_event = { 0 };
+ wlr_event.time_sec = libinput_event_pointer_get_time(pevent);
+ wlr_event.time_usec = libinput_event_pointer_get_time_usec(pevent);
+ wlr_event.button = libinput_event_pointer_get_button(pevent);
switch (libinput_event_pointer_get_button_state(pevent)) {
case LIBINPUT_BUTTON_STATE_PRESSED:
- wlr_event->state = WLR_BUTTON_PRESSED;
+ wlr_event.state = WLR_BUTTON_PRESSED;
break;
case LIBINPUT_BUTTON_STATE_RELEASED:
- wlr_event->state = WLR_BUTTON_RELEASED;
+ wlr_event.state = WLR_BUTTON_RELEASED;
break;
}
- wl_signal_emit(&dev->pointer->events.button, wlr_event);
+ wl_signal_emit(&dev->pointer->events.button, &wlr_event);
}
void handle_pointer_axis(struct libinput_event *event,
@@ -88,22 +85,21 @@ void handle_pointer_axis(struct libinput_event *event,
}
struct libinput_event_pointer *pevent =
libinput_event_get_pointer_event(event);
- struct wlr_event_pointer_axis *wlr_event =
- calloc(1, sizeof(struct wlr_event_pointer_axis));
- wlr_event->time_sec = libinput_event_pointer_get_time(pevent);
- wlr_event->time_usec = libinput_event_pointer_get_time_usec(pevent);
+ struct wlr_event_pointer_axis wlr_event = { 0 };
+ wlr_event.time_sec = libinput_event_pointer_get_time(pevent);
+ wlr_event.time_usec = libinput_event_pointer_get_time_usec(pevent);
switch (libinput_event_pointer_get_axis_source(pevent)) {
case LIBINPUT_POINTER_AXIS_SOURCE_WHEEL:
- wlr_event->source = WLR_AXIS_SOURCE_WHEEL;
+ wlr_event.source = WLR_AXIS_SOURCE_WHEEL;
break;
case LIBINPUT_POINTER_AXIS_SOURCE_FINGER:
- wlr_event->source = WLR_AXIS_SOURCE_FINGER;
+ wlr_event.source = WLR_AXIS_SOURCE_FINGER;
break;
case LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS:
- wlr_event->source = WLR_AXIS_SOURCE_CONTINUOUS;
+ wlr_event.source = WLR_AXIS_SOURCE_CONTINUOUS;
break;
case LIBINPUT_POINTER_AXIS_SOURCE_WHEEL_TILT:
- wlr_event->source = WLR_AXIS_SOURCE_WHEEL_TILT;
+ wlr_event.source = WLR_AXIS_SOURCE_WHEEL_TILT;
break;
}
enum libinput_pointer_axis axies[] = {
@@ -114,15 +110,15 @@ void handle_pointer_axis(struct libinput_event *event,
if (libinput_event_pointer_has_axis(pevent, axies[i])) {
switch (axies[i]) {
case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL:
- wlr_event->orientation = WLR_AXIS_ORIENTATION_VERTICAL;
+ wlr_event.orientation = WLR_AXIS_ORIENTATION_VERTICAL;
break;
case LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL:
- wlr_event->orientation = WLR_AXIS_ORIENTATION_HORIZONTAL;
+ wlr_event.orientation = WLR_AXIS_ORIENTATION_HORIZONTAL;
break;
}
- wlr_event->delta = libinput_event_pointer_get_axis_value(
+ wlr_event.delta = libinput_event_pointer_get_axis_value(
pevent, axies[i]);
}
- wl_signal_emit(&dev->pointer->events.axis, wlr_event);
+ wl_signal_emit(&dev->pointer->events.axis, &wlr_event);
}
}