mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-22 18:09:49 +01:00
Remove wlr_backend.events.{output_remove,device_remove}
This commit is contained in:
parent
5e58d46cc1
commit
10ecf871f2
25 changed files with 263 additions and 382 deletions
|
@ -19,10 +19,8 @@ void wlr_backend_init(struct wlr_backend *backend,
|
|||
assert(backend);
|
||||
backend->impl = impl;
|
||||
wl_signal_init(&backend->events.destroy);
|
||||
wl_signal_init(&backend->events.input_add);
|
||||
wl_signal_init(&backend->events.input_remove);
|
||||
wl_signal_init(&backend->events.output_add);
|
||||
wl_signal_init(&backend->events.output_remove);
|
||||
wl_signal_init(&backend->events.new_input);
|
||||
wl_signal_init(&backend->events.new_output);
|
||||
}
|
||||
|
||||
bool wlr_backend_start(struct wlr_backend *backend) {
|
||||
|
|
|
@ -871,7 +871,8 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *drm) {
|
|||
wlr_conn->state = WLR_DRM_CONN_NEEDS_MODESET;
|
||||
wlr_log(L_INFO, "Sending modesetting signal for '%s'",
|
||||
wlr_conn->output.name);
|
||||
wlr_signal_emit_safe(&drm->backend.events.output_add, &wlr_conn->output);
|
||||
wlr_signal_emit_safe(&drm->backend.events.new_output,
|
||||
&wlr_conn->output);
|
||||
} else if (wlr_conn->state == WLR_DRM_CONN_CONNECTED &&
|
||||
drm_conn->connection != DRM_MODE_CONNECTED) {
|
||||
wlr_log(L_INFO, "'%s' disconnected", wlr_conn->output.name);
|
||||
|
@ -979,8 +980,6 @@ void wlr_drm_connector_cleanup(struct wlr_drm_connector *conn) {
|
|||
return;
|
||||
}
|
||||
|
||||
struct wlr_drm_backend *drm = (struct wlr_drm_backend *)conn->output.backend;
|
||||
|
||||
switch (conn->state) {
|
||||
case WLR_DRM_CONN_CONNECTED:
|
||||
case WLR_DRM_CONN_CLEANUP:;
|
||||
|
@ -1014,8 +1013,8 @@ void wlr_drm_connector_cleanup(struct wlr_drm_connector *conn) {
|
|||
/* Fallthrough */
|
||||
case WLR_DRM_CONN_NEEDS_MODESET:
|
||||
wlr_log(L_INFO, "Emitting destruction signal for '%s'",
|
||||
conn->output.name);
|
||||
wlr_signal_emit_safe(&drm->backend.events.output_remove, &conn->output);
|
||||
conn->output.name);
|
||||
wlr_signal_emit_safe(&conn->output.events.destroy, &conn->output);
|
||||
break;
|
||||
case WLR_DRM_CONN_DISCONNECTED:
|
||||
break;
|
||||
|
|
|
@ -17,14 +17,14 @@ static bool backend_start(struct wlr_backend *wlr_backend) {
|
|||
wl_list_for_each(output, &backend->outputs, link) {
|
||||
wl_event_source_timer_update(output->frame_timer, output->frame_delay);
|
||||
wlr_output_update_enabled(&output->wlr_output, true);
|
||||
wlr_signal_emit_safe(&backend->backend.events.output_add,
|
||||
wlr_signal_emit_safe(&backend->backend.events.new_output,
|
||||
&output->wlr_output);
|
||||
}
|
||||
|
||||
struct wlr_headless_input_device *input_device;
|
||||
wl_list_for_each(input_device, &backend->input_devices,
|
||||
wlr_input_device.link) {
|
||||
wlr_signal_emit_safe(&backend->backend.events.input_add,
|
||||
wlr_signal_emit_safe(&backend->backend.events.new_input,
|
||||
&input_device->wlr_input_device);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
static void input_device_destroy(struct wlr_input_device *wlr_dev) {
|
||||
struct wlr_headless_input_device *device =
|
||||
(struct wlr_headless_input_device *)wlr_dev;
|
||||
wlr_signal_emit_safe(&device->backend->backend.events.input_remove, wlr_dev);
|
||||
free(device);
|
||||
}
|
||||
|
||||
|
@ -89,7 +88,7 @@ struct wlr_input_device *wlr_headless_add_input_device(
|
|||
wl_list_insert(&backend->input_devices, &wlr_device->link);
|
||||
|
||||
if (backend->started) {
|
||||
wlr_signal_emit_safe(&backend->backend.events.input_add, wlr_device);
|
||||
wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_device);
|
||||
}
|
||||
|
||||
return wlr_device;
|
||||
|
|
|
@ -137,7 +137,7 @@ struct wlr_output *wlr_headless_add_output(struct wlr_backend *wlr_backend,
|
|||
if (backend->started) {
|
||||
wl_event_source_timer_update(output->frame_timer, output->frame_delay);
|
||||
wlr_output_update_enabled(wlr_output, true);
|
||||
wlr_signal_emit_safe(&backend->backend.events.output_add, wlr_output);
|
||||
wlr_signal_emit_safe(&backend->backend.events.new_output, wlr_output);
|
||||
}
|
||||
|
||||
return wlr_output;
|
||||
|
|
|
@ -107,7 +107,6 @@ static void wlr_libinput_backend_destroy(struct wlr_backend *wlr_backend) {
|
|||
struct wl_list *wlr_devices = backend->wlr_device_lists.items[i];
|
||||
struct wlr_input_device *wlr_dev, *next;
|
||||
wl_list_for_each_safe(wlr_dev, next, wlr_devices, link) {
|
||||
wlr_signal_emit_safe(&backend->backend.events.input_remove, wlr_dev);
|
||||
wlr_input_device_destroy(wlr_dev);
|
||||
}
|
||||
free(wlr_devices);
|
||||
|
|
|
@ -89,7 +89,7 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
|
|||
free(wlr_dev);
|
||||
goto fail;
|
||||
}
|
||||
wlr_signal_emit_safe(&backend->backend.events.input_add, wlr_dev);
|
||||
wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_dev);
|
||||
}
|
||||
if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_POINTER)) {
|
||||
struct wlr_input_device *wlr_dev = allocate_device(backend,
|
||||
|
@ -102,7 +102,7 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
|
|||
free(wlr_dev);
|
||||
goto fail;
|
||||
}
|
||||
wlr_signal_emit_safe(&backend->backend.events.input_add, wlr_dev);
|
||||
wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_dev);
|
||||
}
|
||||
if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_TOUCH)) {
|
||||
struct wlr_input_device *wlr_dev = allocate_device(backend,
|
||||
|
@ -115,7 +115,7 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
|
|||
free(wlr_dev);
|
||||
goto fail;
|
||||
}
|
||||
wlr_signal_emit_safe(&backend->backend.events.input_add, wlr_dev);
|
||||
wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_dev);
|
||||
}
|
||||
if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_TABLET_TOOL)) {
|
||||
struct wlr_input_device *wlr_dev = allocate_device(backend,
|
||||
|
@ -128,7 +128,7 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
|
|||
free(wlr_dev);
|
||||
goto fail;
|
||||
}
|
||||
wlr_signal_emit_safe(&backend->backend.events.input_add, wlr_dev);
|
||||
wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_dev);
|
||||
}
|
||||
if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_TABLET_PAD)) {
|
||||
struct wlr_input_device *wlr_dev = allocate_device(backend,
|
||||
|
@ -141,7 +141,7 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
|
|||
free(wlr_dev);
|
||||
goto fail;
|
||||
}
|
||||
wlr_signal_emit_safe(&backend->backend.events.input_add, wlr_dev);
|
||||
wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_dev);
|
||||
}
|
||||
if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_GESTURE)) {
|
||||
// TODO
|
||||
|
@ -179,7 +179,6 @@ static void handle_device_removed(struct wlr_libinput_backend *backend,
|
|||
}
|
||||
struct wlr_input_device *dev, *tmp_dev;
|
||||
wl_list_for_each_safe(dev, tmp_dev, wlr_devices, link) {
|
||||
wlr_signal_emit_safe(&backend->backend.events.input_remove, dev);
|
||||
wlr_input_device_destroy(dev);
|
||||
}
|
||||
for (size_t i = 0; i < backend->wlr_device_lists.length; i++) {
|
||||
|
|
|
@ -11,11 +11,9 @@
|
|||
struct subbackend_state {
|
||||
struct wlr_backend *backend;
|
||||
struct wlr_backend *container;
|
||||
struct wl_listener input_add;
|
||||
struct wl_listener input_remove;
|
||||
struct wl_listener output_add;
|
||||
struct wl_listener output_remove;
|
||||
struct wl_listener backend_destroy;
|
||||
struct wl_listener new_input;
|
||||
struct wl_listener new_output;
|
||||
struct wl_listener destroy;
|
||||
struct wl_list link;
|
||||
};
|
||||
|
||||
|
@ -32,11 +30,9 @@ static bool multi_backend_start(struct wlr_backend *wlr_backend) {
|
|||
}
|
||||
|
||||
static void subbackend_state_destroy(struct subbackend_state *sub) {
|
||||
wl_list_remove(&sub->input_add.link);
|
||||
wl_list_remove(&sub->input_remove.link);
|
||||
wl_list_remove(&sub->output_add.link);
|
||||
wl_list_remove(&sub->output_remove.link);
|
||||
wl_list_remove(&sub->backend_destroy.link);
|
||||
wl_list_remove(&sub->new_input.link);
|
||||
wl_list_remove(&sub->new_output.link);
|
||||
wl_list_remove(&sub->destroy.link);
|
||||
wl_list_remove(&sub->link);
|
||||
free(sub);
|
||||
}
|
||||
|
@ -118,34 +114,21 @@ bool wlr_backend_is_multi(struct wlr_backend *b) {
|
|||
return b->impl == &backend_impl;
|
||||
}
|
||||
|
||||
static void input_add_reemit(struct wl_listener *listener, void *data) {
|
||||
static void new_input_reemit(struct wl_listener *listener, void *data) {
|
||||
struct subbackend_state *state = wl_container_of(listener,
|
||||
state, input_add);
|
||||
wlr_signal_emit_safe(&state->container->events.input_add, data);
|
||||
state, new_input);
|
||||
wlr_signal_emit_safe(&state->container->events.new_input, data);
|
||||
}
|
||||
|
||||
static void input_remove_reemit(struct wl_listener *listener, void *data) {
|
||||
static void new_output_reemit(struct wl_listener *listener, void *data) {
|
||||
struct subbackend_state *state = wl_container_of(listener,
|
||||
state, input_remove);
|
||||
wlr_signal_emit_safe(&state->container->events.input_remove, data);
|
||||
}
|
||||
|
||||
static void output_add_reemit(struct wl_listener *listener, void *data) {
|
||||
struct subbackend_state *state = wl_container_of(listener,
|
||||
state, output_add);
|
||||
wlr_signal_emit_safe(&state->container->events.output_add, data);
|
||||
}
|
||||
|
||||
static void output_remove_reemit(struct wl_listener *listener, void *data) {
|
||||
struct subbackend_state *state = wl_container_of(listener,
|
||||
state, output_remove);
|
||||
wlr_signal_emit_safe(&state->container->events.output_remove, data);
|
||||
state, new_output);
|
||||
wlr_signal_emit_safe(&state->container->events.new_output, data);
|
||||
}
|
||||
|
||||
static void handle_subbackend_destroy(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct subbackend_state *state = wl_container_of(listener,
|
||||
state, backend_destroy);
|
||||
struct subbackend_state *state = wl_container_of(listener, state, destroy);
|
||||
subbackend_state_destroy(state);
|
||||
}
|
||||
|
||||
|
@ -180,20 +163,14 @@ void wlr_multi_backend_add(struct wlr_backend *_multi,
|
|||
sub->backend = backend;
|
||||
sub->container = &multi->backend;
|
||||
|
||||
wl_signal_add(&backend->events.destroy, &sub->backend_destroy);
|
||||
sub->backend_destroy.notify = handle_subbackend_destroy;
|
||||
wl_signal_add(&backend->events.destroy, &sub->destroy);
|
||||
sub->destroy.notify = handle_subbackend_destroy;
|
||||
|
||||
wl_signal_add(&backend->events.input_add, &sub->input_add);
|
||||
sub->input_add.notify = input_add_reemit;
|
||||
wl_signal_add(&backend->events.new_input, &sub->new_input);
|
||||
sub->new_input.notify = new_input_reemit;
|
||||
|
||||
wl_signal_add(&backend->events.input_remove, &sub->input_remove);
|
||||
sub->input_remove.notify = input_remove_reemit;
|
||||
|
||||
wl_signal_add(&backend->events.output_add, &sub->output_add);
|
||||
sub->output_add.notify = output_add_reemit;
|
||||
|
||||
wl_signal_add(&backend->events.output_remove, &sub->output_remove);
|
||||
sub->output_remove.notify = output_remove_reemit;
|
||||
wl_signal_add(&backend->events.new_output, &sub->new_output);
|
||||
sub->new_output.notify = new_output_reemit;
|
||||
|
||||
wlr_signal_emit_safe(&multi->events.backend_add, backend);
|
||||
}
|
||||
|
|
|
@ -339,7 +339,7 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) {
|
|||
|
||||
wl_list_insert(&backend->outputs, &output->link);
|
||||
wlr_output_update_enabled(wlr_output, true);
|
||||
wlr_signal_emit_safe(&backend->backend.events.output_add, wlr_output);
|
||||
wlr_signal_emit_safe(&backend->backend.events.new_output, wlr_output);
|
||||
return wlr_output;
|
||||
|
||||
error:
|
||||
|
|
|
@ -193,9 +193,8 @@ static struct wl_keyboard_listener keyboard_listener = {
|
|||
.repeat_info = keyboard_handle_repeat_info
|
||||
};
|
||||
|
||||
static void input_device_destroy(struct wlr_input_device *_dev) {
|
||||
struct wlr_wl_input_device *dev = (struct wlr_wl_input_device *)_dev;
|
||||
wlr_signal_emit_safe(&dev->backend->backend.events.input_remove, &dev->wlr_input_device);
|
||||
static void input_device_destroy(struct wlr_input_device *wlr_dev) {
|
||||
struct wlr_wl_input_device *dev = (struct wlr_wl_input_device *)wlr_dev;
|
||||
if (dev->resource) {
|
||||
wl_proxy_destroy(dev->resource);
|
||||
}
|
||||
|
@ -257,7 +256,7 @@ static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
|
|||
wlr_device->pointer = &wlr_wl_pointer->wlr_pointer;
|
||||
wlr_pointer_init(wlr_device->pointer, NULL);
|
||||
wlr_wl_device->resource = wl_pointer;
|
||||
wlr_signal_emit_safe(&backend->backend.events.input_add, wlr_device);
|
||||
wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_device);
|
||||
backend->pointer = wl_pointer;
|
||||
}
|
||||
if ((caps & WL_SEAT_CAPABILITY_KEYBOARD)) {
|
||||
|
@ -281,7 +280,7 @@ static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
|
|||
struct wl_keyboard *wl_keyboard = wl_seat_get_keyboard(wl_seat);
|
||||
wl_keyboard_add_listener(wl_keyboard, &keyboard_listener, wlr_device);
|
||||
wlr_wl_device->resource = wl_keyboard;
|
||||
wlr_signal_emit_safe(&backend->backend.events.input_add, wlr_device);
|
||||
wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_device);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -230,9 +230,9 @@ static bool wlr_x11_backend_start(struct wlr_backend *backend) {
|
|||
xcb_flush(x11->xcb_conn);
|
||||
wlr_output_update_enabled(&output->wlr_output, true);
|
||||
|
||||
wlr_signal_emit_safe(&x11->backend.events.output_add, output);
|
||||
wlr_signal_emit_safe(&x11->backend.events.input_add, &x11->keyboard_dev);
|
||||
wlr_signal_emit_safe(&x11->backend.events.input_add, &x11->pointer_dev);
|
||||
wlr_signal_emit_safe(&x11->backend.events.new_output, output);
|
||||
wlr_signal_emit_safe(&x11->backend.events.new_input, &x11->keyboard_dev);
|
||||
wlr_signal_emit_safe(&x11->backend.events.new_input, &x11->pointer_dev);
|
||||
|
||||
wl_event_source_timer_update(x11->frame_timer, 16);
|
||||
|
||||
|
@ -249,8 +249,8 @@ static void wlr_x11_backend_destroy(struct wlr_backend *backend) {
|
|||
struct wlr_x11_output *output = &x11->output;
|
||||
wlr_output_destroy(&output->wlr_output);
|
||||
|
||||
wlr_signal_emit_safe(&backend->events.input_remove, &x11->pointer_dev);
|
||||
wlr_signal_emit_safe(&backend->events.input_remove, &x11->keyboard_dev);
|
||||
wlr_signal_emit_safe(&x11->pointer_dev.events.destroy, &x11->pointer_dev);
|
||||
wlr_signal_emit_safe(&x11->keyboard_dev.events.destroy, &x11->keyboard_dev);
|
||||
// TODO probably need to use wlr_keyboard_destroy, but the devices need to
|
||||
// be malloced for that to work
|
||||
if (x11->keyboard_dev.keyboard->keymap) {
|
||||
|
|
|
@ -56,10 +56,24 @@ static void keyboard_key_notify(struct wl_listener *listener, void *data) {
|
|||
}
|
||||
}
|
||||
|
||||
static void keyboard_destroy_notify(struct wl_listener *listener, void *data) {
|
||||
struct keyboard_state *kbstate = wl_container_of(listener, kbstate, destroy);
|
||||
struct compositor_state *state = kbstate->compositor;
|
||||
if (state->input_remove_cb) {
|
||||
state->input_remove_cb(state, kbstate->device);
|
||||
}
|
||||
wl_list_remove(&kbstate->link);
|
||||
wl_list_remove(&kbstate->destroy.link);
|
||||
wl_list_remove(&kbstate->key.link);
|
||||
free(kbstate);
|
||||
}
|
||||
|
||||
static void keyboard_add(struct wlr_input_device *device, struct compositor_state *state) {
|
||||
struct keyboard_state *kbstate = calloc(sizeof(struct keyboard_state), 1);
|
||||
kbstate->device = device;
|
||||
kbstate->compositor = state;
|
||||
kbstate->destroy.notify = keyboard_destroy_notify;
|
||||
wl_signal_add(&device->events.destroy, &kbstate->destroy);
|
||||
kbstate->key.notify = keyboard_key_notify;
|
||||
wl_signal_add(&device->keyboard->events.key, &kbstate->key);
|
||||
wl_list_insert(&state->keyboards, &kbstate->link);
|
||||
|
@ -117,17 +131,34 @@ static void pointer_axis_notify(struct wl_listener *listener, void *data) {
|
|||
}
|
||||
}
|
||||
|
||||
static void pointer_destroy_notify(struct wl_listener *listener, void *data) {
|
||||
struct pointer_state *pstate = wl_container_of(listener, pstate, destroy);
|
||||
struct compositor_state *state = pstate->compositor;
|
||||
if (state->input_remove_cb) {
|
||||
state->input_remove_cb(state, pstate->device);
|
||||
}
|
||||
wl_list_remove(&pstate->link);
|
||||
wl_list_remove(&pstate->destroy.link);
|
||||
wl_list_remove(&pstate->motion.link);
|
||||
wl_list_remove(&pstate->motion_absolute.link);
|
||||
wl_list_remove(&pstate->button.link);
|
||||
wl_list_remove(&pstate->axis.link);
|
||||
free(pstate);
|
||||
}
|
||||
|
||||
static void pointer_add(struct wlr_input_device *device, struct compositor_state *state) {
|
||||
struct pointer_state *pstate = calloc(sizeof(struct pointer_state), 1);
|
||||
pstate->device = device;
|
||||
pstate->compositor = state;
|
||||
pstate->destroy.notify = pointer_destroy_notify;
|
||||
wl_signal_add(&device->events.destroy, &pstate->destroy);
|
||||
pstate->motion.notify = pointer_motion_notify;
|
||||
pstate->motion_absolute.notify = pointer_motion_absolute_notify;
|
||||
pstate->button.notify = pointer_button_notify;
|
||||
pstate->axis.notify = pointer_axis_notify;
|
||||
wl_signal_add(&device->pointer->events.motion, &pstate->motion);
|
||||
pstate->motion_absolute.notify = pointer_motion_absolute_notify;
|
||||
wl_signal_add(&device->pointer->events.motion_absolute, &pstate->motion_absolute);
|
||||
pstate->button.notify = pointer_button_notify;
|
||||
wl_signal_add(&device->pointer->events.button, &pstate->button);
|
||||
pstate->axis.notify = pointer_axis_notify;
|
||||
wl_signal_add(&device->pointer->events.axis, &pstate->axis);
|
||||
wl_list_insert(&state->pointers, &pstate->link);
|
||||
}
|
||||
|
@ -166,17 +197,34 @@ static void touch_cancel_notify(struct wl_listener *listener, void *data) {
|
|||
}
|
||||
}
|
||||
|
||||
static void touch_destroy_notify(struct wl_listener *listener, void *data) {
|
||||
struct touch_state *tstate = wl_container_of(listener, tstate, destroy);
|
||||
struct compositor_state *state = tstate->compositor;
|
||||
if (state->input_remove_cb) {
|
||||
state->input_remove_cb(state, tstate->device);
|
||||
}
|
||||
wl_list_remove(&tstate->link);
|
||||
wl_list_remove(&tstate->destroy.link);
|
||||
wl_list_remove(&tstate->down.link);
|
||||
wl_list_remove(&tstate->motion.link);
|
||||
wl_list_remove(&tstate->up.link);
|
||||
wl_list_remove(&tstate->cancel.link);
|
||||
free(tstate);
|
||||
}
|
||||
|
||||
static void touch_add(struct wlr_input_device *device, struct compositor_state *state) {
|
||||
struct touch_state *tstate = calloc(sizeof(struct touch_state), 1);
|
||||
tstate->device = device;
|
||||
tstate->compositor = state;
|
||||
tstate->destroy.notify = touch_destroy_notify;
|
||||
wl_signal_add(&device->events.destroy, &tstate->destroy);
|
||||
tstate->down.notify = touch_down_notify;
|
||||
tstate->motion.notify = touch_motion_notify;
|
||||
tstate->up.notify = touch_up_notify;
|
||||
tstate->cancel.notify = touch_cancel_notify;
|
||||
wl_signal_add(&device->touch->events.down, &tstate->down);
|
||||
tstate->motion.notify = touch_motion_notify;
|
||||
wl_signal_add(&device->touch->events.motion, &tstate->motion);
|
||||
tstate->up.notify = touch_up_notify;
|
||||
wl_signal_add(&device->touch->events.up, &tstate->up);
|
||||
tstate->cancel.notify = touch_cancel_notify;
|
||||
wl_signal_add(&device->touch->events.cancel, &tstate->cancel);
|
||||
wl_list_insert(&state->touch, &tstate->link);
|
||||
}
|
||||
|
@ -205,18 +253,35 @@ static void tablet_tool_button_notify(struct wl_listener *listener, void *data)
|
|||
}
|
||||
}
|
||||
|
||||
static void tablet_tool_destroy_notify(struct wl_listener *listener, void *data) {
|
||||
struct tablet_tool_state *tstate = wl_container_of(listener, tstate, destroy);
|
||||
struct compositor_state *state = tstate->compositor;
|
||||
if (state->input_remove_cb) {
|
||||
state->input_remove_cb(state, tstate->device);
|
||||
}
|
||||
wl_list_remove(&tstate->link);
|
||||
wl_list_remove(&tstate->destroy.link);
|
||||
wl_list_remove(&tstate->axis.link);
|
||||
wl_list_remove(&tstate->proximity.link);
|
||||
//wl_list_remove(&tstate->tip.link);
|
||||
wl_list_remove(&tstate->button.link);
|
||||
free(tstate);
|
||||
}
|
||||
|
||||
static void tablet_tool_add(struct wlr_input_device *device,
|
||||
struct compositor_state *state) {
|
||||
struct tablet_tool_state *tstate = calloc(sizeof(struct tablet_tool_state), 1);
|
||||
tstate->device = device;
|
||||
tstate->compositor = state;
|
||||
tstate->destroy.notify = tablet_tool_destroy_notify;
|
||||
wl_signal_add(&device->events.destroy, &tstate->destroy);
|
||||
tstate->axis.notify = tablet_tool_axis_notify;
|
||||
tstate->proximity.notify = tablet_tool_proximity_notify;
|
||||
//tstate->tip.notify = tablet_tool_tip_notify;
|
||||
tstate->button.notify = tablet_tool_button_notify;
|
||||
wl_signal_add(&device->tablet_tool->events.axis, &tstate->axis);
|
||||
tstate->proximity.notify = tablet_tool_proximity_notify;
|
||||
wl_signal_add(&device->tablet_tool->events.proximity, &tstate->proximity);
|
||||
//tstate->tip.notify = tablet_tool_tip_notify;
|
||||
//wl_signal_add(&device->tablet_tool->events.tip, &tstate->tip);
|
||||
tstate->button.notify = tablet_tool_button_notify;
|
||||
wl_signal_add(&device->tablet_tool->events.button, &tstate->button);
|
||||
wl_list_insert(&state->tablet_tools, &tstate->link);
|
||||
}
|
||||
|
@ -229,19 +294,33 @@ static void tablet_pad_button_notify(struct wl_listener *listener, void *data) {
|
|||
}
|
||||
}
|
||||
|
||||
static void tablet_pad_destroy_notify(struct wl_listener *listener, void *data) {
|
||||
struct tablet_pad_state *pstate = wl_container_of(listener, pstate, destroy);
|
||||
struct compositor_state *state = pstate->compositor;
|
||||
if (state->input_remove_cb) {
|
||||
state->input_remove_cb(state, pstate->device);
|
||||
}
|
||||
wl_list_remove(&pstate->link);
|
||||
wl_list_remove(&pstate->destroy.link);
|
||||
wl_list_remove(&pstate->button.link);
|
||||
free(pstate);
|
||||
}
|
||||
|
||||
static void tablet_pad_add(struct wlr_input_device *device,
|
||||
struct compositor_state *state) {
|
||||
struct tablet_pad_state *pstate = calloc(sizeof(struct tablet_pad_state), 1);
|
||||
pstate->device = device;
|
||||
pstate->compositor = state;
|
||||
pstate->destroy.notify = tablet_pad_destroy_notify;
|
||||
wl_signal_add(&device->events.destroy, &pstate->destroy);
|
||||
pstate->button.notify = tablet_pad_button_notify;
|
||||
wl_signal_add(&device->tablet_pad->events.button, &pstate->button);
|
||||
wl_list_insert(&state->tablet_pads, &pstate->link);
|
||||
}
|
||||
|
||||
static void input_add_notify(struct wl_listener *listener, void *data) {
|
||||
static void new_input_notify(struct wl_listener *listener, void *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, new_input);
|
||||
switch (device->type) {
|
||||
case WLR_INPUT_DEVICE_KEYBOARD:
|
||||
keyboard_add(device, state);
|
||||
|
@ -267,123 +346,6 @@ static void input_add_notify(struct wl_listener *listener, void *data) {
|
|||
}
|
||||
}
|
||||
|
||||
static void keyboard_remove(struct wlr_input_device *device, struct compositor_state *state) {
|
||||
struct keyboard_state *kbstate = NULL, *_kbstate;
|
||||
wl_list_for_each(_kbstate, &state->keyboards, link) {
|
||||
if (_kbstate->device == device) {
|
||||
kbstate = _kbstate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!kbstate) {
|
||||
return;
|
||||
}
|
||||
wl_list_remove(&kbstate->link);
|
||||
wl_list_remove(&kbstate->key.link);
|
||||
free(kbstate);
|
||||
}
|
||||
|
||||
static void pointer_remove(struct wlr_input_device *device, struct compositor_state *state) {
|
||||
struct pointer_state *pstate = NULL, *_pstate;
|
||||
wl_list_for_each(_pstate, &state->pointers, link) {
|
||||
if (_pstate->device == device) {
|
||||
pstate = _pstate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!pstate) {
|
||||
return;
|
||||
}
|
||||
wl_list_remove(&pstate->link);
|
||||
wl_list_remove(&pstate->motion.link);
|
||||
wl_list_remove(&pstate->motion_absolute.link);
|
||||
wl_list_remove(&pstate->button.link);
|
||||
wl_list_remove(&pstate->axis.link);
|
||||
free(pstate);
|
||||
}
|
||||
|
||||
static void touch_remove(struct wlr_input_device *device, struct compositor_state *state) {
|
||||
struct touch_state *tstate = NULL, *_tstate;
|
||||
wl_list_for_each(_tstate, &state->touch, link) {
|
||||
if (_tstate->device == device) {
|
||||
tstate = _tstate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!tstate) {
|
||||
return;
|
||||
}
|
||||
wl_list_remove(&tstate->link);
|
||||
wl_list_remove(&tstate->down.link);
|
||||
wl_list_remove(&tstate->motion.link);
|
||||
wl_list_remove(&tstate->up.link);
|
||||
wl_list_remove(&tstate->cancel.link);
|
||||
free(tstate);
|
||||
}
|
||||
|
||||
static void tablet_tool_remove(struct wlr_input_device *device, struct compositor_state *state) {
|
||||
struct tablet_tool_state *tstate = NULL, *_tstate;
|
||||
wl_list_for_each(_tstate, &state->tablet_tools, link) {
|
||||
if (_tstate->device == device) {
|
||||
tstate = _tstate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!tstate) {
|
||||
return;
|
||||
}
|
||||
wl_list_remove(&tstate->link);
|
||||
wl_list_remove(&tstate->axis.link);
|
||||
wl_list_remove(&tstate->proximity.link);
|
||||
//wl_list_remove(&tstate->tip.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;
|
||||
}
|
||||
wl_list_remove(&pstate->button.link);
|
||||
free(pstate);
|
||||
}
|
||||
|
||||
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);
|
||||
break;
|
||||
case WLR_INPUT_DEVICE_POINTER:
|
||||
pointer_remove(device, state);
|
||||
break;
|
||||
case WLR_INPUT_DEVICE_TOUCH:
|
||||
touch_remove(device, state);
|
||||
break;
|
||||
case WLR_INPUT_DEVICE_TABLET_TOOL:
|
||||
tablet_tool_remove(device, state);
|
||||
break;
|
||||
case WLR_INPUT_DEVICE_TABLET_PAD:
|
||||
tablet_pad_remove(device, state);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void output_frame_notify(struct wl_listener *listener, void *data) {
|
||||
struct output_state *output = wl_container_of(listener, output, frame);
|
||||
struct compositor_state *compositor = output->compositor;
|
||||
|
@ -407,9 +369,21 @@ static void output_resolution_notify(struct wl_listener *listener, void *data) {
|
|||
}
|
||||
}
|
||||
|
||||
static void output_add_notify(struct wl_listener *listener, void *data) {
|
||||
static void output_destroy_notify(struct wl_listener *listener, void *data) {
|
||||
struct output_state *ostate = wl_container_of(listener, ostate, destroy);
|
||||
struct compositor_state *state = ostate->compositor;
|
||||
if (state->output_remove_cb) {
|
||||
state->output_remove_cb(ostate);
|
||||
}
|
||||
wl_list_remove(&ostate->link);
|
||||
wl_list_remove(&ostate->frame.link);
|
||||
wl_list_remove(&ostate->resolution.link);
|
||||
free(ostate);
|
||||
}
|
||||
|
||||
static void new_output_notify(struct wl_listener *listener, void *data) {
|
||||
struct wlr_output *output = data;
|
||||
struct compositor_state *state = wl_container_of(listener, state, output_add);
|
||||
struct compositor_state *state = wl_container_of(listener, state, new_output);
|
||||
wlr_log(L_DEBUG, "Output '%s' added", output->name);
|
||||
wlr_log(L_DEBUG, "%s %s %"PRId32"mm x %"PRId32"mm", output->make, output->model,
|
||||
output->phys_width, output->phys_height);
|
||||
|
@ -422,9 +396,11 @@ static void output_add_notify(struct wl_listener *listener, void *data) {
|
|||
clock_gettime(CLOCK_MONOTONIC, &ostate->last_frame);
|
||||
ostate->output = output;
|
||||
ostate->compositor = state;
|
||||
ostate->destroy.notify = output_destroy_notify;
|
||||
wl_signal_add(&output->events.destroy, &ostate->destroy);
|
||||
ostate->frame.notify = output_frame_notify;
|
||||
ostate->resolution.notify = output_resolution_notify;
|
||||
wl_signal_add(&output->events.frame, &ostate->frame);
|
||||
ostate->resolution.notify = output_resolution_notify;
|
||||
wl_signal_add(&output->events.mode, &ostate->resolution);
|
||||
wl_list_insert(&state->outputs, &ostate->link);
|
||||
if (state->output_add_cb) {
|
||||
|
@ -432,28 +408,6 @@ static void output_add_notify(struct wl_listener *listener, void *data) {
|
|||
}
|
||||
}
|
||||
|
||||
static void output_remove_notify(struct wl_listener *listener, void *data) {
|
||||
struct wlr_output *output = data;
|
||||
struct compositor_state *state = wl_container_of(listener, state, output_remove);
|
||||
struct output_state *ostate = NULL, *_ostate;
|
||||
wl_list_for_each(_ostate, &state->outputs, link) {
|
||||
if (_ostate->output == output) {
|
||||
ostate = _ostate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!ostate) {
|
||||
return; // We are unfamiliar with this output
|
||||
}
|
||||
if (state->output_remove_cb) {
|
||||
state->output_remove_cb(ostate);
|
||||
}
|
||||
wl_list_remove(&ostate->link);
|
||||
wl_list_remove(&ostate->frame.link);
|
||||
wl_list_remove(&ostate->resolution.link);
|
||||
free(ostate);
|
||||
}
|
||||
|
||||
void compositor_init(struct compositor_state *state) {
|
||||
state->display = wl_display_create();
|
||||
state->event_loop = wl_display_get_event_loop(state->display);
|
||||
|
@ -463,23 +417,19 @@ void compositor_init(struct compositor_state *state) {
|
|||
wl_list_init(&state->touch);
|
||||
wl_list_init(&state->tablet_tools);
|
||||
wl_list_init(&state->tablet_pads);
|
||||
state->input_add.notify = input_add_notify;
|
||||
state->input_remove.notify = input_remove_notify;
|
||||
|
||||
wl_list_init(&state->outputs);
|
||||
state->output_add.notify = output_add_notify;
|
||||
state->output_remove.notify = output_remove_notify;
|
||||
|
||||
struct wlr_backend *wlr = wlr_backend_autocreate(state->display);
|
||||
if (!wlr) {
|
||||
exit(1);
|
||||
}
|
||||
wl_signal_add(&wlr->events.input_add, &state->input_add);
|
||||
wl_signal_add(&wlr->events.input_remove, &state->input_remove);
|
||||
wl_signal_add(&wlr->events.output_add, &state->output_add);
|
||||
wl_signal_add(&wlr->events.output_remove, &state->output_remove);
|
||||
state->backend = wlr;
|
||||
|
||||
wl_signal_add(&wlr->events.new_input, &state->new_input);
|
||||
state->new_input.notify = new_input_notify;
|
||||
wl_signal_add(&wlr->events.new_output, &state->new_output);
|
||||
state->new_output.notify = new_output_notify;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &state->last_frame);
|
||||
|
||||
const char *socket = wl_display_add_socket_auto(state->display);
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
struct output_state {
|
||||
struct compositor_state *compositor;
|
||||
struct wlr_output *output;
|
||||
struct wl_listener destroy;
|
||||
struct wl_listener frame;
|
||||
struct wl_listener resolution;
|
||||
struct timespec last_frame;
|
||||
|
@ -25,6 +26,7 @@ struct output_state {
|
|||
struct keyboard_state {
|
||||
struct compositor_state *compositor;
|
||||
struct wlr_input_device *device;
|
||||
struct wl_listener destroy;
|
||||
struct wl_listener key;
|
||||
struct wl_list link;
|
||||
void *data;
|
||||
|
@ -33,6 +35,7 @@ struct keyboard_state {
|
|||
struct pointer_state {
|
||||
struct compositor_state *compositor;
|
||||
struct wlr_input_device *device;
|
||||
struct wl_listener destroy;
|
||||
struct wl_listener motion;
|
||||
struct wl_listener motion_absolute;
|
||||
struct wl_listener button;
|
||||
|
@ -44,6 +47,7 @@ struct pointer_state {
|
|||
struct touch_state {
|
||||
struct compositor_state *compositor;
|
||||
struct wlr_input_device *device;
|
||||
struct wl_listener destroy;
|
||||
struct wl_listener down;
|
||||
struct wl_listener up;
|
||||
struct wl_listener motion;
|
||||
|
@ -55,6 +59,7 @@ struct touch_state {
|
|||
struct tablet_tool_state {
|
||||
struct compositor_state *compositor;
|
||||
struct wlr_input_device *device;
|
||||
struct wl_listener destroy;
|
||||
struct wl_listener axis;
|
||||
struct wl_listener proximity;
|
||||
struct wl_listener tip;
|
||||
|
@ -66,6 +71,7 @@ struct tablet_tool_state {
|
|||
struct tablet_pad_state {
|
||||
struct compositor_state *compositor;
|
||||
struct wlr_input_device *device;
|
||||
struct wl_listener destroy;
|
||||
struct wl_listener button;
|
||||
struct wl_list link;
|
||||
void *data;
|
||||
|
@ -122,12 +128,10 @@ struct compositor_state {
|
|||
struct wl_list touch;
|
||||
struct wl_list tablet_tools;
|
||||
struct wl_list tablet_pads;
|
||||
struct wl_listener input_add;
|
||||
struct wl_listener input_remove;
|
||||
struct wl_listener new_input;
|
||||
|
||||
struct timespec last_frame;
|
||||
struct wl_listener output_add;
|
||||
struct wl_listener output_remove;
|
||||
struct wl_listener new_output;
|
||||
struct wl_list outputs;
|
||||
|
||||
void *data;
|
||||
|
|
|
@ -39,8 +39,7 @@ struct roots_desktop {
|
|||
struct wlr_primary_selection_device_manager *primary_selection_device_manager;
|
||||
struct wlr_idle *idle;
|
||||
|
||||
struct wl_listener output_add;
|
||||
struct wl_listener output_remove;
|
||||
struct wl_listener new_output;
|
||||
struct wl_listener layout_change;
|
||||
struct wl_listener xdg_shell_v6_surface;
|
||||
struct wl_listener wl_shell_surface;
|
||||
|
|
|
@ -13,8 +13,7 @@ struct roots_input {
|
|||
struct roots_config *config;
|
||||
struct roots_server *server;
|
||||
|
||||
struct wl_listener input_add;
|
||||
struct wl_listener input_remove;
|
||||
struct wl_listener new_input;
|
||||
|
||||
struct wl_list seats;
|
||||
};
|
||||
|
|
|
@ -13,6 +13,7 @@ struct roots_keyboard {
|
|||
struct roots_keyboard_config *config;
|
||||
struct wl_list link;
|
||||
|
||||
struct wl_listener device_destroy;
|
||||
struct wl_listener keyboard_key;
|
||||
struct wl_listener keyboard_modifiers;
|
||||
|
||||
|
|
|
@ -18,11 +18,11 @@ struct roots_output {
|
|||
struct timespec last_frame;
|
||||
struct wlr_output_damage *damage;
|
||||
|
||||
struct wl_listener destroy;
|
||||
struct wl_listener frame;
|
||||
};
|
||||
|
||||
void output_add_notify(struct wl_listener *listener, void *data);
|
||||
void output_remove_notify(struct wl_listener *listener, void *data);
|
||||
void handle_new_output(struct wl_listener *listener, void *data);
|
||||
|
||||
struct roots_view;
|
||||
struct roots_drag_icon;
|
||||
|
|
|
@ -56,18 +56,21 @@ struct roots_drag_icon {
|
|||
struct roots_pointer {
|
||||
struct roots_seat *seat;
|
||||
struct wlr_input_device *device;
|
||||
struct wl_listener device_destroy;
|
||||
struct wl_list link;
|
||||
};
|
||||
|
||||
struct roots_touch {
|
||||
struct roots_seat *seat;
|
||||
struct wlr_input_device *device;
|
||||
struct wl_listener device_destroy;
|
||||
struct wl_list link;
|
||||
};
|
||||
|
||||
struct roots_tablet_tool {
|
||||
struct roots_seat *seat;
|
||||
struct wlr_input_device *device;
|
||||
struct wl_listener device_destroy;
|
||||
struct wl_listener axis;
|
||||
struct wl_listener proximity;
|
||||
struct wl_listener tip;
|
||||
|
|
|
@ -12,10 +12,8 @@ struct wlr_backend {
|
|||
|
||||
struct {
|
||||
struct wl_signal destroy;
|
||||
struct wl_signal input_add;
|
||||
struct wl_signal input_remove;
|
||||
struct wl_signal output_add;
|
||||
struct wl_signal output_remove;
|
||||
struct wl_signal new_input;
|
||||
struct wl_signal new_output;
|
||||
} events;
|
||||
};
|
||||
|
||||
|
|
|
@ -622,11 +622,8 @@ struct roots_desktop *desktop_create(struct roots_server *server,
|
|||
wl_list_init(&desktop->views);
|
||||
wl_list_init(&desktop->outputs);
|
||||
|
||||
desktop->output_add.notify = output_add_notify;
|
||||
wl_signal_add(&server->backend->events.output_add, &desktop->output_add);
|
||||
desktop->output_remove.notify = output_remove_notify;
|
||||
wl_signal_add(&server->backend->events.output_remove,
|
||||
&desktop->output_remove);
|
||||
desktop->new_output.notify = handle_new_output;
|
||||
wl_signal_add(&server->backend->events.new_output, &desktop->new_output);
|
||||
|
||||
desktop->server = server;
|
||||
desktop->config = config;
|
||||
|
|
|
@ -40,9 +40,9 @@ struct roots_seat *input_get_seat(struct roots_input *input, char *name) {
|
|||
return seat;
|
||||
}
|
||||
|
||||
static void input_add_notify(struct wl_listener *listener, void *data) {
|
||||
static void handle_new_input(struct wl_listener *listener, void *data) {
|
||||
struct wlr_input_device *device = data;
|
||||
struct roots_input *input = wl_container_of(listener, input, input_add);
|
||||
struct roots_input *input = wl_container_of(listener, input, new_input);
|
||||
|
||||
char *seat_name = ROOTS_CONFIG_DEFAULT_SEAT_NAME;
|
||||
struct roots_device_config *dc =
|
||||
|
@ -74,16 +74,6 @@ static void input_add_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 roots_input *input = wl_container_of(listener, input, input_remove);
|
||||
|
||||
struct roots_seat *seat;
|
||||
wl_list_for_each(seat, &input->seats, link) {
|
||||
roots_seat_remove_device(seat, device);
|
||||
}
|
||||
}
|
||||
|
||||
struct roots_input *input_create(struct roots_server *server,
|
||||
struct roots_config *config) {
|
||||
wlr_log(L_DEBUG, "Initializing roots input");
|
||||
|
@ -99,10 +89,8 @@ struct roots_input *input_create(struct roots_server *server,
|
|||
|
||||
wl_list_init(&input->seats);
|
||||
|
||||
input->input_add.notify = input_add_notify;
|
||||
wl_signal_add(&server->backend->events.input_add, &input->input_add);
|
||||
input->input_remove.notify = input_remove_notify;
|
||||
wl_signal_add(&server->backend->events.input_remove, &input->input_remove);
|
||||
input->new_input.notify = handle_new_input;
|
||||
wl_signal_add(&server->backend->events.new_input, &input->new_input);
|
||||
|
||||
return input;
|
||||
}
|
||||
|
|
|
@ -644,9 +644,22 @@ static void set_mode(struct wlr_output *output,
|
|||
}
|
||||
}
|
||||
|
||||
void output_add_notify(struct wl_listener *listener, void *data) {
|
||||
static void output_handle_destroy(struct wl_listener *listener, void *data) {
|
||||
struct roots_output *output = wl_container_of(listener, output, destroy);
|
||||
|
||||
// TODO: cursor
|
||||
//example_config_configure_cursor(sample->config, sample->cursor,
|
||||
// sample->compositor);
|
||||
|
||||
wl_list_remove(&output->link);
|
||||
wl_list_remove(&output->destroy.link);
|
||||
wl_list_remove(&output->frame.link);
|
||||
free(output);
|
||||
}
|
||||
|
||||
void handle_new_output(struct wl_listener *listener, void *data) {
|
||||
struct roots_desktop *desktop = wl_container_of(listener, desktop,
|
||||
output_add);
|
||||
new_output);
|
||||
struct wlr_output *wlr_output = data;
|
||||
struct roots_input *input = desktop->server->input;
|
||||
struct roots_config *config = desktop->config;
|
||||
|
@ -670,6 +683,8 @@ void output_add_notify(struct wl_listener *listener, void *data) {
|
|||
|
||||
output->damage = wlr_output_damage_create(wlr_output);
|
||||
|
||||
output->destroy.notify = output_handle_destroy;
|
||||
wl_signal_add(&wlr_output->events.destroy, &output->destroy);
|
||||
output->frame.notify = output_damage_handle_frame;
|
||||
wl_signal_add(&output->damage->events.frame, &output->frame);
|
||||
|
||||
|
@ -699,31 +714,3 @@ void output_add_notify(struct wl_listener *listener, void *data) {
|
|||
|
||||
output_damage_whole(output);
|
||||
}
|
||||
|
||||
void output_remove_notify(struct wl_listener *listener, void *data) {
|
||||
struct wlr_output *wlr_output = data;
|
||||
struct roots_desktop *desktop =
|
||||
wl_container_of(listener, desktop, output_remove);
|
||||
|
||||
struct roots_output *output = NULL, *_output;
|
||||
wl_list_for_each(_output, &desktop->outputs, link) {
|
||||
if (_output->wlr_output == wlr_output) {
|
||||
output = _output;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!output) {
|
||||
return; // We are unfamiliar with this output
|
||||
}
|
||||
|
||||
wlr_output_layout_remove(desktop->layout, output->wlr_output);
|
||||
|
||||
// TODO: cursor
|
||||
//example_config_configure_cursor(sample->config, sample->cursor,
|
||||
// sample->compositor);
|
||||
|
||||
wl_list_remove(&output->link);
|
||||
wl_list_remove(&output->frame.link);
|
||||
wlr_output_damage_destroy(output->damage);
|
||||
free(output);
|
||||
}
|
||||
|
|
145
rootston/seat.c
145
rootston/seat.c
|
@ -404,6 +404,17 @@ static void seat_update_capabilities(struct roots_seat *seat) {
|
|||
}
|
||||
}
|
||||
|
||||
static void handle_keyboard_destroy(struct wl_listener *listener, void *data) {
|
||||
struct roots_keyboard *keyboard =
|
||||
wl_container_of(listener, keyboard, device_destroy);
|
||||
struct roots_seat *seat = keyboard->seat;
|
||||
roots_keyboard_destroy(keyboard);
|
||||
wl_list_remove(&keyboard->device_destroy.link);
|
||||
wl_list_remove(&keyboard->keyboard_key.link);
|
||||
wl_list_remove(&keyboard->keyboard_modifiers.link);
|
||||
seat_update_capabilities(seat);
|
||||
}
|
||||
|
||||
static void seat_add_keyboard(struct roots_seat *seat,
|
||||
struct wlr_input_device *device) {
|
||||
assert(device->type == WLR_INPUT_DEVICE_KEYBOARD);
|
||||
|
@ -418,10 +429,11 @@ static void seat_add_keyboard(struct roots_seat *seat,
|
|||
|
||||
wl_list_insert(&seat->keyboards, &keyboard->link);
|
||||
|
||||
keyboard->device_destroy.notify = handle_keyboard_destroy;
|
||||
wl_signal_add(&keyboard->device->events.destroy, &keyboard->device_destroy);
|
||||
keyboard->keyboard_key.notify = handle_keyboard_key;
|
||||
wl_signal_add(&keyboard->device->keyboard->events.key,
|
||||
&keyboard->keyboard_key);
|
||||
|
||||
keyboard->keyboard_modifiers.notify = handle_keyboard_modifiers;
|
||||
wl_signal_add(&keyboard->device->keyboard->events.modifiers,
|
||||
&keyboard->keyboard_modifiers);
|
||||
|
@ -429,6 +441,19 @@ static void seat_add_keyboard(struct roots_seat *seat,
|
|||
wlr_seat_set_keyboard(seat->seat, device);
|
||||
}
|
||||
|
||||
static void handle_pointer_destroy(struct wl_listener *listener, void *data) {
|
||||
struct roots_pointer *pointer =
|
||||
wl_container_of(listener, pointer, device_destroy);
|
||||
struct roots_seat *seat = pointer->seat;
|
||||
|
||||
wl_list_remove(&pointer->link);
|
||||
wlr_cursor_detach_input_device(seat->cursor->cursor, pointer->device);
|
||||
wl_list_remove(&pointer->device_destroy.link);
|
||||
free(pointer);
|
||||
|
||||
seat_update_capabilities(seat);
|
||||
}
|
||||
|
||||
static void seat_add_pointer(struct roots_seat *seat,
|
||||
struct wlr_input_device *device) {
|
||||
struct roots_pointer *pointer = calloc(sizeof(struct roots_pointer), 1);
|
||||
|
@ -441,10 +466,27 @@ static void seat_add_pointer(struct roots_seat *seat,
|
|||
pointer->device = device;
|
||||
pointer->seat = seat;
|
||||
wl_list_insert(&seat->pointers, &pointer->link);
|
||||
|
||||
pointer->device_destroy.notify = handle_pointer_destroy;
|
||||
wl_signal_add(&pointer->device->events.destroy, &pointer->device_destroy);
|
||||
|
||||
wlr_cursor_attach_input_device(seat->cursor->cursor, device);
|
||||
roots_seat_configure_cursor(seat);
|
||||
}
|
||||
|
||||
static void handle_touch_destroy(struct wl_listener *listener, void *data) {
|
||||
struct roots_pointer *touch =
|
||||
wl_container_of(listener, touch, device_destroy);
|
||||
struct roots_seat *seat = touch->seat;
|
||||
|
||||
wl_list_remove(&touch->link);
|
||||
wlr_cursor_detach_input_device(seat->cursor->cursor, touch->device);
|
||||
wl_list_remove(&touch->device_destroy.link);
|
||||
free(touch);
|
||||
|
||||
seat_update_capabilities(seat);
|
||||
}
|
||||
|
||||
static void seat_add_touch(struct roots_seat *seat,
|
||||
struct wlr_input_device *device) {
|
||||
struct roots_touch *touch = calloc(sizeof(struct roots_touch), 1);
|
||||
|
@ -457,6 +499,10 @@ static void seat_add_touch(struct roots_seat *seat,
|
|||
touch->device = device;
|
||||
touch->seat = seat;
|
||||
wl_list_insert(&seat->touch, &touch->link);
|
||||
|
||||
touch->device_destroy.notify = handle_touch_destroy;
|
||||
wl_signal_add(&touch->device->events.destroy, &touch->device_destroy);
|
||||
|
||||
wlr_cursor_attach_input_device(seat->cursor->cursor, device);
|
||||
roots_seat_configure_cursor(seat);
|
||||
}
|
||||
|
@ -466,6 +512,20 @@ static void seat_add_tablet_pad(struct roots_seat *seat,
|
|||
// TODO
|
||||
}
|
||||
|
||||
static void handle_tablet_tool_destroy(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct roots_pointer *tablet_tool =
|
||||
wl_container_of(listener, tablet_tool, device_destroy);
|
||||
struct roots_seat *seat = tablet_tool->seat;
|
||||
|
||||
wl_list_remove(&tablet_tool->link);
|
||||
wlr_cursor_detach_input_device(seat->cursor->cursor, tablet_tool->device);
|
||||
wl_list_remove(&tablet_tool->device_destroy.link);
|
||||
free(tablet_tool);
|
||||
|
||||
seat_update_capabilities(seat);
|
||||
}
|
||||
|
||||
static void seat_add_tablet_tool(struct roots_seat *seat,
|
||||
struct wlr_input_device *device) {
|
||||
struct roots_tablet_tool *tablet_tool =
|
||||
|
@ -479,6 +539,11 @@ static void seat_add_tablet_tool(struct roots_seat *seat,
|
|||
tablet_tool->device = device;
|
||||
tablet_tool->seat = seat;
|
||||
wl_list_insert(&seat->tablet_tools, &tablet_tool->link);
|
||||
|
||||
tablet_tool->device_destroy.notify = handle_tablet_tool_destroy;
|
||||
wl_signal_add(&tablet_tool->device->events.destroy,
|
||||
&tablet_tool->device_destroy);
|
||||
|
||||
wlr_cursor_attach_input_device(seat->cursor->cursor, device);
|
||||
roots_seat_configure_cursor(seat);
|
||||
}
|
||||
|
@ -506,84 +571,6 @@ void roots_seat_add_device(struct roots_seat *seat,
|
|||
seat_update_capabilities(seat);
|
||||
}
|
||||
|
||||
static void seat_remove_keyboard(struct roots_seat *seat,
|
||||
struct wlr_input_device *device) {
|
||||
struct roots_keyboard *keyboard;
|
||||
wl_list_for_each(keyboard, &seat->keyboards, link) {
|
||||
if (keyboard->device == device) {
|
||||
roots_keyboard_destroy(keyboard);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void seat_remove_pointer(struct roots_seat *seat,
|
||||
struct wlr_input_device *device) {
|
||||
struct roots_pointer *pointer;
|
||||
wl_list_for_each(pointer, &seat->pointers, link) {
|
||||
if (pointer->device == device) {
|
||||
wl_list_remove(&pointer->link);
|
||||
wlr_cursor_detach_input_device(seat->cursor->cursor, device);
|
||||
free(pointer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void seat_remove_touch(struct roots_seat *seat,
|
||||
struct wlr_input_device *device) {
|
||||
struct roots_touch *touch;
|
||||
wl_list_for_each(touch, &seat->touch, link) {
|
||||
if (touch->device == device) {
|
||||
wl_list_remove(&touch->link);
|
||||
wlr_cursor_detach_input_device(seat->cursor->cursor, device);
|
||||
free(touch);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void seat_remove_tablet_pad(struct roots_seat *seat,
|
||||
struct wlr_input_device *device) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
static void seat_remove_tablet_tool(struct roots_seat *seat,
|
||||
struct wlr_input_device *device) {
|
||||
struct roots_tablet_tool *tablet_tool;
|
||||
wl_list_for_each(tablet_tool, &seat->tablet_tools, link) {
|
||||
if (tablet_tool->device == device) {
|
||||
wl_list_remove(&tablet_tool->link);
|
||||
wlr_cursor_detach_input_device(seat->cursor->cursor, device);
|
||||
free(tablet_tool);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void roots_seat_remove_device(struct roots_seat *seat,
|
||||
struct wlr_input_device *device) {
|
||||
switch (device->type) {
|
||||
case WLR_INPUT_DEVICE_KEYBOARD:
|
||||
seat_remove_keyboard(seat, device);
|
||||
break;
|
||||
case WLR_INPUT_DEVICE_POINTER:
|
||||
seat_remove_pointer(seat, device);
|
||||
break;
|
||||
case WLR_INPUT_DEVICE_TOUCH:
|
||||
seat_remove_touch(seat, device);
|
||||
break;
|
||||
case WLR_INPUT_DEVICE_TABLET_PAD:
|
||||
seat_remove_tablet_pad(seat, device);
|
||||
break;
|
||||
case WLR_INPUT_DEVICE_TABLET_TOOL:
|
||||
seat_remove_tablet_tool(seat, device);
|
||||
break;
|
||||
}
|
||||
|
||||
seat_update_capabilities(seat);
|
||||
}
|
||||
|
||||
void roots_seat_configure_xcursor(struct roots_seat *seat) {
|
||||
const char *cursor_theme = NULL;
|
||||
struct roots_cursor_config *cc =
|
||||
|
|
|
@ -59,7 +59,6 @@ void wlr_input_device_destroy(struct wlr_input_device *dev) {
|
|||
if (dev->impl && dev->impl->destroy) {
|
||||
dev->impl->destroy(dev);
|
||||
} else {
|
||||
wl_list_remove(&dev->events.destroy.listener_list);
|
||||
free(dev);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -285,7 +285,6 @@ void wlr_output_destroy(struct wlr_output *output) {
|
|||
wlr_output_destroy_global(output);
|
||||
wlr_output_set_fullscreen_surface(output, NULL);
|
||||
|
||||
wlr_signal_emit_safe(&output->backend->events.output_remove, output);
|
||||
wlr_signal_emit_safe(&output->events.destroy, output);
|
||||
|
||||
struct wlr_output_mode *mode, *tmp_mode;
|
||||
|
|
Loading…
Reference in a new issue