Merge pull request #66 from martinetd/leak_plumbing

Leak plumbing
This commit is contained in:
Drew DeVault 2017-08-11 14:22:02 -04:00 committed by GitHub
commit 9f103ca71e
11 changed files with 180 additions and 148 deletions

View File

@ -36,6 +36,7 @@ static void wlr_drm_backend_destroy(struct wlr_backend_state *drm) {
wlr_drm_resources_free(drm); wlr_drm_resources_free(drm);
wlr_session_close_file(drm->session, drm->fd); wlr_session_close_file(drm->session, drm->fd);
wl_event_source_remove(drm->drm_event); wl_event_source_remove(drm->drm_event);
list_free(drm->outputs);
free(drm); free(drm);
} }

View File

@ -78,7 +78,19 @@ static bool wlr_libinput_backend_init(struct wlr_backend_state *state) {
} }
static void wlr_libinput_backend_destroy(struct wlr_backend_state *state) { static void wlr_libinput_backend_destroy(struct wlr_backend_state *state) {
// TODO if (!state) {
return;
}
for (size_t i = 0; i < state->devices->length; i++) {
struct wlr_input_device *wlr_device = state->devices->items[i];
wlr_input_device_destroy(wlr_device);
}
list_free(state->devices);
libinput_unref(state->libinput);
free(state);
} }
static struct wlr_backend_impl backend_impl = { static struct wlr_backend_impl backend_impl = {

View File

@ -24,6 +24,11 @@ struct wlr_input_device *get_appropriate_device(
} }
static void wlr_libinput_device_destroy(struct wlr_input_device_state *state) { static void wlr_libinput_device_destroy(struct wlr_input_device_state *state) {
list_t *devices = libinput_device_get_user_data(state->handle);
// devices themselves are freed in wlr_libinput_backend_destroy
// this list only has a part of the same elements so just free list
list_free(devices);
libinput_device_unref(state->handle); libinput_device_unref(state->handle);
free(state); free(state);
} }

View File

@ -45,20 +45,19 @@ void handle_keyboard_key(struct libinput_event *event,
} }
struct libinput_event_keyboard *kbevent = struct libinput_event_keyboard *kbevent =
libinput_event_get_keyboard_event(event); libinput_event_get_keyboard_event(event);
struct wlr_event_keyboard_key *wlr_event = struct wlr_event_keyboard_key wlr_event = { 0 };
calloc(1, sizeof(struct wlr_event_keyboard_key)); wlr_event.time_sec = libinput_event_keyboard_get_time(kbevent);
wlr_event->time_sec = libinput_event_keyboard_get_time(kbevent); wlr_event.time_usec = libinput_event_keyboard_get_time_usec(kbevent);
wlr_event->time_usec = libinput_event_keyboard_get_time_usec(kbevent); wlr_event.keycode = libinput_event_keyboard_get_key(kbevent);
wlr_event->keycode = libinput_event_keyboard_get_key(kbevent);
enum libinput_key_state state = enum libinput_key_state state =
libinput_event_keyboard_get_key_state(kbevent); libinput_event_keyboard_get_key_state(kbevent);
switch (state) { switch (state) {
case LIBINPUT_KEY_STATE_RELEASED: case LIBINPUT_KEY_STATE_RELEASED:
wlr_event->state = WLR_KEY_RELEASED; wlr_event.state = WLR_KEY_RELEASED;
break; break;
case LIBINPUT_KEY_STATE_PRESSED: case LIBINPUT_KEY_STATE_PRESSED:
wlr_event->state = WLR_KEY_PRESSED; wlr_event.state = WLR_KEY_PRESSED;
break; break;
} }
wl_signal_emit(&dev->keyboard->events.key, wlr_event); wl_signal_emit(&dev->keyboard->events.key, &wlr_event);
} }

View File

@ -23,13 +23,12 @@ void handle_pointer_motion(struct libinput_event *event,
} }
struct libinput_event_pointer *pevent = struct libinput_event_pointer *pevent =
libinput_event_get_pointer_event(event); libinput_event_get_pointer_event(event);
struct wlr_event_pointer_motion *wlr_event = struct wlr_event_pointer_motion wlr_event = { 0 };
calloc(1, sizeof(struct wlr_event_pointer_motion)); wlr_event.time_sec = libinput_event_pointer_get_time(pevent);
wlr_event->time_sec = libinput_event_pointer_get_time(pevent); wlr_event.time_usec = libinput_event_pointer_get_time_usec(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_x = libinput_event_pointer_get_dx(pevent); wlr_event.delta_y = libinput_event_pointer_get_dy(pevent);
wlr_event->delta_y = libinput_event_pointer_get_dy(pevent); wl_signal_emit(&dev->pointer->events.motion, &wlr_event);
wl_signal_emit(&dev->pointer->events.motion, wlr_event);
} }
void handle_pointer_motion_abs(struct libinput_event *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 = struct libinput_event_pointer *pevent =
libinput_event_get_pointer_event(event); libinput_event_get_pointer_event(event);
struct wlr_event_pointer_motion_absolute *wlr_event = struct wlr_event_pointer_motion_absolute wlr_event = { 0 };
calloc(1, sizeof(struct wlr_event_pointer_motion_absolute)); wlr_event.time_sec = libinput_event_pointer_get_time(pevent);
wlr_event->time_sec = libinput_event_pointer_get_time(pevent); wlr_event.time_usec = libinput_event_pointer_get_time_usec(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->x_mm = libinput_event_pointer_get_absolute_x(pevent); wlr_event.y_mm = libinput_event_pointer_get_absolute_y(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);
libinput_device_get_size(device, &wlr_event->width_mm, &wlr_event->height_mm); wl_signal_emit(&dev->pointer->events.motion_absolute, &wlr_event);
wl_signal_emit(&dev->pointer->events.motion_absolute, wlr_event);
} }
void handle_pointer_button(struct libinput_event *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 = struct libinput_event_pointer *pevent =
libinput_event_get_pointer_event(event); libinput_event_get_pointer_event(event);
struct wlr_event_pointer_button *wlr_event = struct wlr_event_pointer_button wlr_event = { 0 };
calloc(1, sizeof(struct wlr_event_pointer_button)); wlr_event.time_sec = libinput_event_pointer_get_time(pevent);
wlr_event->time_sec = libinput_event_pointer_get_time(pevent); wlr_event.time_usec = libinput_event_pointer_get_time_usec(pevent);
wlr_event->time_usec = libinput_event_pointer_get_time_usec(pevent); wlr_event.button = libinput_event_pointer_get_button(pevent);
wlr_event->button = libinput_event_pointer_get_button(pevent);
switch (libinput_event_pointer_get_button_state(pevent)) { switch (libinput_event_pointer_get_button_state(pevent)) {
case LIBINPUT_BUTTON_STATE_PRESSED: case LIBINPUT_BUTTON_STATE_PRESSED:
wlr_event->state = WLR_BUTTON_PRESSED; wlr_event.state = WLR_BUTTON_PRESSED;
break; break;
case LIBINPUT_BUTTON_STATE_RELEASED: case LIBINPUT_BUTTON_STATE_RELEASED:
wlr_event->state = WLR_BUTTON_RELEASED; wlr_event.state = WLR_BUTTON_RELEASED;
break; 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, 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 = struct libinput_event_pointer *pevent =
libinput_event_get_pointer_event(event); libinput_event_get_pointer_event(event);
struct wlr_event_pointer_axis *wlr_event = struct wlr_event_pointer_axis wlr_event = { 0 };
calloc(1, sizeof(struct wlr_event_pointer_axis)); wlr_event.time_sec = libinput_event_pointer_get_time(pevent);
wlr_event->time_sec = libinput_event_pointer_get_time(pevent); wlr_event.time_usec = libinput_event_pointer_get_time_usec(pevent);
wlr_event->time_usec = libinput_event_pointer_get_time_usec(pevent);
switch (libinput_event_pointer_get_axis_source(pevent)) { switch (libinput_event_pointer_get_axis_source(pevent)) {
case LIBINPUT_POINTER_AXIS_SOURCE_WHEEL: case LIBINPUT_POINTER_AXIS_SOURCE_WHEEL:
wlr_event->source = WLR_AXIS_SOURCE_WHEEL; wlr_event.source = WLR_AXIS_SOURCE_WHEEL;
break; break;
case LIBINPUT_POINTER_AXIS_SOURCE_FINGER: case LIBINPUT_POINTER_AXIS_SOURCE_FINGER:
wlr_event->source = WLR_AXIS_SOURCE_FINGER; wlr_event.source = WLR_AXIS_SOURCE_FINGER;
break; break;
case LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS: case LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS:
wlr_event->source = WLR_AXIS_SOURCE_CONTINUOUS; wlr_event.source = WLR_AXIS_SOURCE_CONTINUOUS;
break; break;
case LIBINPUT_POINTER_AXIS_SOURCE_WHEEL_TILT: case LIBINPUT_POINTER_AXIS_SOURCE_WHEEL_TILT:
wlr_event->source = WLR_AXIS_SOURCE_WHEEL_TILT; wlr_event.source = WLR_AXIS_SOURCE_WHEEL_TILT;
break; break;
} }
enum libinput_pointer_axis axies[] = { 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])) { if (libinput_event_pointer_has_axis(pevent, axies[i])) {
switch (axies[i]) { switch (axies[i]) {
case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL: case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL:
wlr_event->orientation = WLR_AXIS_ORIENTATION_VERTICAL; wlr_event.orientation = WLR_AXIS_ORIENTATION_VERTICAL;
break; break;
case LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL: case LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL:
wlr_event->orientation = WLR_AXIS_ORIENTATION_HORIZONTAL; wlr_event.orientation = WLR_AXIS_ORIENTATION_HORIZONTAL;
break; break;
} }
wlr_event->delta = libinput_event_pointer_get_axis_value( wlr_event.delta = libinput_event_pointer_get_axis_value(
pevent, axies[i]); pevent, axies[i]);
} }
wl_signal_emit(&dev->pointer->events.axis, wlr_event); wl_signal_emit(&dev->pointer->events.axis, &wlr_event);
} }
} }

View File

@ -23,20 +23,19 @@ void handle_tablet_pad_button(struct libinput_event *event,
} }
struct libinput_event_tablet_pad *pevent = struct libinput_event_tablet_pad *pevent =
libinput_event_get_tablet_pad_event(event); libinput_event_get_tablet_pad_event(event);
struct wlr_event_tablet_pad_button *wlr_event = struct wlr_event_tablet_pad_button wlr_event = { 0 };
calloc(1, sizeof(struct wlr_event_tablet_pad_button)); wlr_event.time_sec = libinput_event_tablet_pad_get_time(pevent);
wlr_event->time_sec = libinput_event_tablet_pad_get_time(pevent); wlr_event.time_usec = libinput_event_tablet_pad_get_time_usec(pevent);
wlr_event->time_usec = libinput_event_tablet_pad_get_time_usec(pevent); wlr_event.button = libinput_event_tablet_pad_get_button_number(pevent);
wlr_event->button = libinput_event_tablet_pad_get_button_number(pevent);
switch (libinput_event_tablet_pad_get_button_state(pevent)) { switch (libinput_event_tablet_pad_get_button_state(pevent)) {
case LIBINPUT_BUTTON_STATE_PRESSED: case LIBINPUT_BUTTON_STATE_PRESSED:
wlr_event->state = WLR_BUTTON_PRESSED; wlr_event.state = WLR_BUTTON_PRESSED;
break; break;
case LIBINPUT_BUTTON_STATE_RELEASED: case LIBINPUT_BUTTON_STATE_RELEASED:
wlr_event->state = WLR_BUTTON_RELEASED; wlr_event.state = WLR_BUTTON_RELEASED;
break; break;
} }
wl_signal_emit(&dev->tablet_pad->events.button, wlr_event); wl_signal_emit(&dev->tablet_pad->events.button, &wlr_event);
} }
void handle_tablet_pad_ring(struct libinput_event *event, void handle_tablet_pad_ring(struct libinput_event *event,
@ -49,21 +48,20 @@ void handle_tablet_pad_ring(struct libinput_event *event,
} }
struct libinput_event_tablet_pad *pevent = struct libinput_event_tablet_pad *pevent =
libinput_event_get_tablet_pad_event(event); libinput_event_get_tablet_pad_event(event);
struct wlr_event_tablet_pad_ring *wlr_event = struct wlr_event_tablet_pad_ring wlr_event = { 0 };
calloc(1, sizeof(struct wlr_event_tablet_pad_ring)); wlr_event.time_sec = libinput_event_tablet_pad_get_time(pevent);
wlr_event->time_sec = libinput_event_tablet_pad_get_time(pevent); wlr_event.time_usec = libinput_event_tablet_pad_get_time_usec(pevent);
wlr_event->time_usec = libinput_event_tablet_pad_get_time_usec(pevent); wlr_event.ring = libinput_event_tablet_pad_get_ring_number(pevent);
wlr_event->ring = libinput_event_tablet_pad_get_ring_number(pevent); wlr_event.position = libinput_event_tablet_pad_get_ring_position(pevent);
wlr_event->position = libinput_event_tablet_pad_get_ring_position(pevent);
switch (libinput_event_tablet_pad_get_ring_source(pevent)) { switch (libinput_event_tablet_pad_get_ring_source(pevent)) {
case LIBINPUT_TABLET_PAD_RING_SOURCE_UNKNOWN: case LIBINPUT_TABLET_PAD_RING_SOURCE_UNKNOWN:
wlr_event->source = WLR_TABLET_PAD_RING_SOURCE_UNKNOWN; wlr_event.source = WLR_TABLET_PAD_RING_SOURCE_UNKNOWN;
break; break;
case LIBINPUT_TABLET_PAD_RING_SOURCE_FINGER: case LIBINPUT_TABLET_PAD_RING_SOURCE_FINGER:
wlr_event->source = WLR_TABLET_PAD_RING_SOURCE_FINGER; wlr_event.source = WLR_TABLET_PAD_RING_SOURCE_FINGER;
break; break;
} }
wl_signal_emit(&dev->tablet_pad->events.ring, wlr_event); wl_signal_emit(&dev->tablet_pad->events.ring, &wlr_event);
} }
void handle_tablet_pad_strip(struct libinput_event *event, void handle_tablet_pad_strip(struct libinput_event *event,
@ -76,19 +74,18 @@ void handle_tablet_pad_strip(struct libinput_event *event,
} }
struct libinput_event_tablet_pad *pevent = struct libinput_event_tablet_pad *pevent =
libinput_event_get_tablet_pad_event(event); libinput_event_get_tablet_pad_event(event);
struct wlr_event_tablet_pad_strip *wlr_event = struct wlr_event_tablet_pad_strip wlr_event = { 0 };
calloc(1, sizeof(struct wlr_event_tablet_pad_strip)); wlr_event.time_sec = libinput_event_tablet_pad_get_time(pevent);
wlr_event->time_sec = libinput_event_tablet_pad_get_time(pevent); wlr_event.time_usec = libinput_event_tablet_pad_get_time_usec(pevent);
wlr_event->time_usec = libinput_event_tablet_pad_get_time_usec(pevent); wlr_event.strip = libinput_event_tablet_pad_get_strip_number(pevent);
wlr_event->strip = libinput_event_tablet_pad_get_strip_number(pevent); wlr_event.position = libinput_event_tablet_pad_get_strip_position(pevent);
wlr_event->position = libinput_event_tablet_pad_get_strip_position(pevent);
switch (libinput_event_tablet_pad_get_strip_source(pevent)) { switch (libinput_event_tablet_pad_get_strip_source(pevent)) {
case LIBINPUT_TABLET_PAD_STRIP_SOURCE_UNKNOWN: case LIBINPUT_TABLET_PAD_STRIP_SOURCE_UNKNOWN:
wlr_event->source = WLR_TABLET_PAD_STRIP_SOURCE_UNKNOWN; wlr_event.source = WLR_TABLET_PAD_STRIP_SOURCE_UNKNOWN;
break; break;
case LIBINPUT_TABLET_PAD_STRIP_SOURCE_FINGER: case LIBINPUT_TABLET_PAD_STRIP_SOURCE_FINGER:
wlr_event->source = WLR_TABLET_PAD_STRIP_SOURCE_FINGER; wlr_event.source = WLR_TABLET_PAD_STRIP_SOURCE_FINGER;
break; break;
} }
wl_signal_emit(&dev->tablet_pad->events.strip, wlr_event); wl_signal_emit(&dev->tablet_pad->events.strip, &wlr_event);
} }

View File

@ -23,48 +23,47 @@ void handle_tablet_tool_axis(struct libinput_event *event,
} }
struct libinput_event_tablet_tool *tevent = struct libinput_event_tablet_tool *tevent =
libinput_event_get_tablet_tool_event(event); libinput_event_get_tablet_tool_event(event);
struct wlr_event_tablet_tool_axis *wlr_event = struct wlr_event_tablet_tool_axis wlr_event = { 0 };
calloc(1, sizeof(struct wlr_event_tablet_tool_axis)); wlr_event.time_sec = libinput_event_tablet_tool_get_time(tevent);
wlr_event->time_sec = libinput_event_tablet_tool_get_time(tevent); wlr_event.time_usec = libinput_event_tablet_tool_get_time_usec(tevent);
wlr_event->time_usec = libinput_event_tablet_tool_get_time_usec(tevent); libinput_device_get_size(device, &wlr_event.width_mm, &wlr_event.height_mm);
libinput_device_get_size(device, &wlr_event->width_mm, &wlr_event->height_mm);
if (libinput_event_tablet_tool_x_has_changed(tevent)) { if (libinput_event_tablet_tool_x_has_changed(tevent)) {
wlr_event->updated_axes |= WLR_TABLET_TOOL_AXIS_X; wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_X;
wlr_event->x_mm = libinput_event_tablet_tool_get_x(tevent); wlr_event.x_mm = libinput_event_tablet_tool_get_x(tevent);
} }
if (libinput_event_tablet_tool_y_has_changed(tevent)) { if (libinput_event_tablet_tool_y_has_changed(tevent)) {
wlr_event->updated_axes |= WLR_TABLET_TOOL_AXIS_Y; wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_Y;
wlr_event->y_mm = libinput_event_tablet_tool_get_y(tevent); wlr_event.y_mm = libinput_event_tablet_tool_get_y(tevent);
} }
if (libinput_event_tablet_tool_pressure_has_changed(tevent)) { if (libinput_event_tablet_tool_pressure_has_changed(tevent)) {
wlr_event->updated_axes |= WLR_TABLET_TOOL_AXIS_PRESSURE; wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_PRESSURE;
wlr_event->pressure = libinput_event_tablet_tool_get_pressure(tevent); wlr_event.pressure = libinput_event_tablet_tool_get_pressure(tevent);
} }
if (libinput_event_tablet_tool_distance_has_changed(tevent)) { if (libinput_event_tablet_tool_distance_has_changed(tevent)) {
wlr_event->updated_axes |= WLR_TABLET_TOOL_AXIS_DISTANCE; wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_DISTANCE;
wlr_event->distance = libinput_event_tablet_tool_get_distance(tevent); wlr_event.distance = libinput_event_tablet_tool_get_distance(tevent);
} }
if (libinput_event_tablet_tool_tilt_x_has_changed(tevent)) { if (libinput_event_tablet_tool_tilt_x_has_changed(tevent)) {
wlr_event->updated_axes |= WLR_TABLET_TOOL_AXIS_TILT_X; wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_TILT_X;
wlr_event->tilt_x = libinput_event_tablet_tool_get_tilt_x(tevent); wlr_event.tilt_x = libinput_event_tablet_tool_get_tilt_x(tevent);
} }
if (libinput_event_tablet_tool_tilt_y_has_changed(tevent)) { if (libinput_event_tablet_tool_tilt_y_has_changed(tevent)) {
wlr_event->updated_axes |= WLR_TABLET_TOOL_AXIS_TILT_Y; wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_TILT_Y;
wlr_event->tilt_y = libinput_event_tablet_tool_get_tilt_y(tevent); wlr_event.tilt_y = libinput_event_tablet_tool_get_tilt_y(tevent);
} }
if (libinput_event_tablet_tool_rotation_has_changed(tevent)) { if (libinput_event_tablet_tool_rotation_has_changed(tevent)) {
wlr_event->updated_axes |= WLR_TABLET_TOOL_AXIS_ROTATION; wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_ROTATION;
wlr_event->rotation = libinput_event_tablet_tool_get_rotation(tevent); wlr_event.rotation = libinput_event_tablet_tool_get_rotation(tevent);
} }
if (libinput_event_tablet_tool_slider_has_changed(tevent)) { if (libinput_event_tablet_tool_slider_has_changed(tevent)) {
wlr_event->updated_axes |= WLR_TABLET_TOOL_AXIS_SLIDER; wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_SLIDER;
wlr_event->slider = libinput_event_tablet_tool_get_slider_position(tevent); wlr_event.slider = libinput_event_tablet_tool_get_slider_position(tevent);
} }
if (libinput_event_tablet_tool_wheel_has_changed(tevent)) { if (libinput_event_tablet_tool_wheel_has_changed(tevent)) {
wlr_event->updated_axes |= WLR_TABLET_TOOL_AXIS_WHEEL; wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_WHEEL;
wlr_event->wheel_delta = libinput_event_tablet_tool_get_wheel_delta(tevent); wlr_event.wheel_delta = libinput_event_tablet_tool_get_wheel_delta(tevent);
} }
wl_signal_emit(&dev->tablet_tool->events.axis, wlr_event); wl_signal_emit(&dev->tablet_tool->events.axis, &wlr_event);
} }
void handle_tablet_tool_proximity(struct libinput_event *event, void handle_tablet_tool_proximity(struct libinput_event *event,
@ -77,20 +76,19 @@ void handle_tablet_tool_proximity(struct libinput_event *event,
} }
struct libinput_event_tablet_tool *tevent = struct libinput_event_tablet_tool *tevent =
libinput_event_get_tablet_tool_event(event); libinput_event_get_tablet_tool_event(event);
struct wlr_event_tablet_tool_proximity *wlr_event = struct wlr_event_tablet_tool_proximity wlr_event = { 0 };
calloc(1, sizeof(struct wlr_event_tablet_tool_proximity)); wlr_event.time_sec = libinput_event_tablet_tool_get_time(tevent);
wlr_event->time_sec = libinput_event_tablet_tool_get_time(tevent); wlr_event.time_usec = libinput_event_tablet_tool_get_time_usec(tevent);
wlr_event->time_usec = libinput_event_tablet_tool_get_time_usec(tevent);
switch (libinput_event_tablet_tool_get_proximity_state(tevent)) { switch (libinput_event_tablet_tool_get_proximity_state(tevent)) {
case LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT: case LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT:
wlr_event->state = WLR_TABLET_TOOL_PROXIMITY_OUT; wlr_event.state = WLR_TABLET_TOOL_PROXIMITY_OUT;
break; break;
case LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN: case LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN:
wlr_event->state = WLR_TABLET_TOOL_PROXIMITY_IN; wlr_event.state = WLR_TABLET_TOOL_PROXIMITY_IN;
handle_tablet_tool_axis(event, device); handle_tablet_tool_axis(event, device);
break; break;
} }
wl_signal_emit(&dev->tablet_tool->events.proximity, wlr_event); wl_signal_emit(&dev->tablet_tool->events.proximity, &wlr_event);
} }
void handle_tablet_tool_tip(struct libinput_event *event, void handle_tablet_tool_tip(struct libinput_event *event,
@ -104,19 +102,18 @@ void handle_tablet_tool_tip(struct libinput_event *event,
handle_tablet_tool_axis(event, device); handle_tablet_tool_axis(event, device);
struct libinput_event_tablet_tool *tevent = struct libinput_event_tablet_tool *tevent =
libinput_event_get_tablet_tool_event(event); libinput_event_get_tablet_tool_event(event);
struct wlr_event_tablet_tool_tip *wlr_event = struct wlr_event_tablet_tool_tip wlr_event = { 0 };
calloc(1, sizeof(struct wlr_event_tablet_tool_tip)); wlr_event.time_sec = libinput_event_tablet_tool_get_time(tevent);
wlr_event->time_sec = libinput_event_tablet_tool_get_time(tevent); wlr_event.time_usec = libinput_event_tablet_tool_get_time_usec(tevent);
wlr_event->time_usec = libinput_event_tablet_tool_get_time_usec(tevent);
switch (libinput_event_tablet_tool_get_tip_state(tevent)) { switch (libinput_event_tablet_tool_get_tip_state(tevent)) {
case LIBINPUT_TABLET_TOOL_TIP_UP: case LIBINPUT_TABLET_TOOL_TIP_UP:
wlr_event->state = WLR_TABLET_TOOL_TIP_UP; wlr_event.state = WLR_TABLET_TOOL_TIP_UP;
break; break;
case LIBINPUT_TABLET_TOOL_TIP_DOWN: case LIBINPUT_TABLET_TOOL_TIP_DOWN:
wlr_event->state = WLR_TABLET_TOOL_TIP_DOWN; wlr_event.state = WLR_TABLET_TOOL_TIP_DOWN;
break; break;
} }
wl_signal_emit(&dev->tablet_tool->events.tip, wlr_event); wl_signal_emit(&dev->tablet_tool->events.tip, &wlr_event);
} }
void handle_tablet_tool_button(struct libinput_event *event, void handle_tablet_tool_button(struct libinput_event *event,
@ -130,18 +127,17 @@ void handle_tablet_tool_button(struct libinput_event *event,
handle_tablet_tool_axis(event, device); handle_tablet_tool_axis(event, device);
struct libinput_event_tablet_tool *tevent = struct libinput_event_tablet_tool *tevent =
libinput_event_get_tablet_tool_event(event); libinput_event_get_tablet_tool_event(event);
struct wlr_event_tablet_tool_button *wlr_event = struct wlr_event_tablet_tool_button wlr_event = { 0 };
calloc(1, sizeof(struct wlr_event_tablet_tool_button)); wlr_event.time_sec = libinput_event_tablet_tool_get_time(tevent);
wlr_event->time_sec = libinput_event_tablet_tool_get_time(tevent); wlr_event.time_usec = libinput_event_tablet_tool_get_time_usec(tevent);
wlr_event->time_usec = libinput_event_tablet_tool_get_time_usec(tevent); wlr_event.button = libinput_event_tablet_tool_get_button(tevent);
wlr_event->button = libinput_event_tablet_tool_get_button(tevent);
switch (libinput_event_tablet_tool_get_button_state(tevent)) { switch (libinput_event_tablet_tool_get_button_state(tevent)) {
case LIBINPUT_BUTTON_STATE_RELEASED: case LIBINPUT_BUTTON_STATE_RELEASED:
wlr_event->state = WLR_BUTTON_RELEASED; wlr_event.state = WLR_BUTTON_RELEASED;
break; break;
case LIBINPUT_BUTTON_STATE_PRESSED: case LIBINPUT_BUTTON_STATE_PRESSED:
wlr_event->state = WLR_BUTTON_PRESSED; wlr_event.state = WLR_BUTTON_PRESSED;
break; break;
} }
wl_signal_emit(&dev->tablet_tool->events.button, wlr_event); wl_signal_emit(&dev->tablet_tool->events.button, &wlr_event);
} }

View File

@ -23,15 +23,14 @@ void handle_touch_down(struct libinput_event *event,
} }
struct libinput_event_touch *tevent = struct libinput_event_touch *tevent =
libinput_event_get_touch_event(event); libinput_event_get_touch_event(event);
struct wlr_event_touch_down *wlr_event = struct wlr_event_touch_down wlr_event = { 0 };
calloc(1, sizeof(struct wlr_event_touch_down)); wlr_event.time_sec = libinput_event_touch_get_time(tevent);
wlr_event->time_sec = libinput_event_touch_get_time(tevent); wlr_event.time_usec = libinput_event_touch_get_time_usec(tevent);
wlr_event->time_usec = libinput_event_touch_get_time_usec(tevent); wlr_event.slot = libinput_event_touch_get_slot(tevent);
wlr_event->slot = libinput_event_touch_get_slot(tevent); wlr_event.x_mm = libinput_event_touch_get_x(tevent);
wlr_event->x_mm = libinput_event_touch_get_x(tevent); wlr_event.y_mm = libinput_event_touch_get_y(tevent);
wlr_event->y_mm = libinput_event_touch_get_y(tevent); libinput_device_get_size(device, &wlr_event.width_mm, &wlr_event.height_mm);
libinput_device_get_size(device, &wlr_event->width_mm, &wlr_event->height_mm); wl_signal_emit(&dev->touch->events.down, &wlr_event);
wl_signal_emit(&dev->touch->events.down, wlr_event);
} }
void handle_touch_up(struct libinput_event *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 = struct libinput_event_touch *tevent =
libinput_event_get_touch_event(event); libinput_event_get_touch_event(event);
struct wlr_event_touch_up *wlr_event = struct wlr_event_touch_up wlr_event = { 0 };
calloc(1, sizeof(struct wlr_event_touch_up)); wlr_event.time_sec = libinput_event_touch_get_time(tevent);
wlr_event->time_sec = libinput_event_touch_get_time(tevent); wlr_event.time_usec = libinput_event_touch_get_time_usec(tevent);
wlr_event->time_usec = libinput_event_touch_get_time_usec(tevent); wlr_event.slot = libinput_event_touch_get_slot(tevent);
wlr_event->slot = libinput_event_touch_get_slot(tevent); wl_signal_emit(&dev->touch->events.up, &wlr_event);
wl_signal_emit(&dev->touch->events.up, wlr_event);
} }
void handle_touch_motion(struct libinput_event *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 = struct libinput_event_touch *tevent =
libinput_event_get_touch_event(event); libinput_event_get_touch_event(event);
struct wlr_event_touch_motion *wlr_event = struct wlr_event_touch_motion wlr_event = { 0 };
calloc(1, sizeof(struct wlr_event_touch_motion)); wlr_event.time_sec = libinput_event_touch_get_time(tevent);
wlr_event->time_sec = libinput_event_touch_get_time(tevent); wlr_event.time_usec = libinput_event_touch_get_time_usec(tevent);
wlr_event->time_usec = libinput_event_touch_get_time_usec(tevent); wlr_event.slot = libinput_event_touch_get_slot(tevent);
wlr_event->slot = libinput_event_touch_get_slot(tevent); wlr_event.x_mm = libinput_event_touch_get_x(tevent);
wlr_event->x_mm = libinput_event_touch_get_x(tevent); wlr_event.y_mm = libinput_event_touch_get_y(tevent);
wlr_event->y_mm = libinput_event_touch_get_y(tevent); libinput_device_get_size(device, &wlr_event.width_mm, &wlr_event.height_mm);
libinput_device_get_size(device, &wlr_event->width_mm, &wlr_event->height_mm); wl_signal_emit(&dev->touch->events.motion, &wlr_event);
wl_signal_emit(&dev->touch->events.motion, wlr_event);
} }
void handle_touch_cancel(struct libinput_event *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 = struct libinput_event_touch *tevent =
libinput_event_get_touch_event(event); libinput_event_get_touch_event(event);
struct wlr_event_touch_cancel *wlr_event = struct wlr_event_touch_cancel wlr_event = { 0 };
calloc(1, sizeof(struct wlr_event_touch_cancel)); wlr_event.time_sec = libinput_event_touch_get_time(tevent);
wlr_event->time_sec = libinput_event_touch_get_time(tevent); wlr_event.time_usec = libinput_event_touch_get_time_usec(tevent);
wlr_event->time_usec = libinput_event_touch_get_time_usec(tevent); wlr_event.slot = libinput_event_touch_get_slot(tevent);
wlr_event->slot = libinput_event_touch_get_slot(tevent); wl_signal_emit(&dev->touch->events.cancel, &wlr_event);
wl_signal_emit(&dev->touch->events.cancel, wlr_event);
} }

View File

@ -217,6 +217,7 @@ void wlr_udev_destroy(struct wlr_udev *udev) {
wl_event_source_remove(udev->event); wl_event_source_remove(udev->event);
udev_monitor_unref(udev->mon); udev_monitor_unref(udev->mon);
udev_unref(udev->udev); udev_unref(udev->udev);
free(udev);
} }
bool wlr_udev_signal_add(struct wlr_udev *udev, dev_t dev, struct wl_listener *listener) { bool wlr_udev_signal_add(struct wlr_udev *udev, dev_t dev, struct wl_listener *listener) {

View File

@ -313,6 +313,7 @@ static void keyboard_remove(struct wlr_input_device *device, struct compositor_s
} }
wl_list_remove(&kbstate->link); wl_list_remove(&kbstate->link);
wl_list_remove(&kbstate->key.link); wl_list_remove(&kbstate->key.link);
free(kbstate);
} }
static void pointer_remove(struct wlr_input_device *device, struct compositor_state *state) { static void pointer_remove(struct wlr_input_device *device, struct compositor_state *state) {
@ -331,6 +332,7 @@ static void pointer_remove(struct wlr_input_device *device, struct compositor_st
wl_list_remove(&pstate->motion_absolute.link); wl_list_remove(&pstate->motion_absolute.link);
wl_list_remove(&pstate->button.link); wl_list_remove(&pstate->button.link);
wl_list_remove(&pstate->axis.link); wl_list_remove(&pstate->axis.link);
free(pstate);
} }
static void touch_remove(struct wlr_input_device *device, struct compositor_state *state) { static void touch_remove(struct wlr_input_device *device, struct compositor_state *state) {
@ -349,6 +351,7 @@ static void touch_remove(struct wlr_input_device *device, struct compositor_stat
wl_list_remove(&tstate->motion.link); wl_list_remove(&tstate->motion.link);
wl_list_remove(&tstate->up.link); wl_list_remove(&tstate->up.link);
wl_list_remove(&tstate->cancel.link); wl_list_remove(&tstate->cancel.link);
free(tstate);
} }
static void tablet_tool_remove(struct wlr_input_device *device, struct compositor_state *state) { static void tablet_tool_remove(struct wlr_input_device *device, struct compositor_state *state) {
@ -367,8 +370,25 @@ static void tablet_tool_remove(struct wlr_input_device *device, struct composito
wl_list_remove(&tstate->proximity.link); wl_list_remove(&tstate->proximity.link);
//wl_list_remove(&tstate->tip.link); //wl_list_remove(&tstate->tip.link);
wl_list_remove(&tstate->button.link); wl_list_remove(&tstate->button.link);
free(tstate);
} }
static void tablet_pad_remove(struct wlr_input_device *device, struct compositor_state *state) {
struct tablet_pad_state *pstate = NULL, *_pstate;
wl_list_for_each(_pstate, &state->tablet_pads, link) {
if (_pstate->device ==device) {
pstate = _pstate;
break;
}
}
if (!pstate) {
return;
}
// TODO probably missing more actions
free(pstate);
}
// TODO missing something that calls this on teardown
static void input_remove_notify(struct wl_listener *listener, void *data) { static void input_remove_notify(struct wl_listener *listener, void *data) {
struct wlr_input_device *device = data; struct wlr_input_device *device = data;
struct compositor_state *state = wl_container_of(listener, state, input_add); struct compositor_state *state = wl_container_of(listener, state, input_add);
@ -385,6 +405,9 @@ static void input_remove_notify(struct wl_listener *listener, void *data) {
case WLR_INPUT_DEVICE_TABLET_TOOL: case WLR_INPUT_DEVICE_TABLET_TOOL:
tablet_tool_remove(device, state); tablet_tool_remove(device, state);
break; break;
case WLR_INPUT_DEVICE_TABLET_PAD:
tablet_pad_remove(device, state);
break;
default: default:
break; break;
} }
@ -444,6 +467,7 @@ static void output_remove_notify(struct wl_listener *listener, void *data) {
} }
wl_list_remove(&ostate->link); wl_list_remove(&ostate->link);
wl_list_remove(&ostate->frame.link); wl_list_remove(&ostate->frame.link);
free(ostate);
} }
void compositor_init(struct compositor_state *state) { void compositor_init(struct compositor_state *state) {

View File

@ -171,10 +171,15 @@ bool wlr_output_move_cursor(struct wlr_output *output, int x, int y) {
} }
void wlr_output_destroy(struct wlr_output *output) { void wlr_output_destroy(struct wlr_output *output) {
if (!output) return; if (!output) {
return;
}
output->impl->destroy(output->state); output->impl->destroy(output->state);
for (size_t i = 0; output->modes && i < output->modes->length; ++i) { for (size_t i = 0; output->modes && i < output->modes->length; ++i) {
free(output->modes->items[i]); struct wlr_output_mode *mode = output->modes->items[i];
free(mode->state);
free(mode);
} }
list_free(output->modes); list_free(output->modes);
free(output); free(output);