mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-12-20 08:56:27 -05: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
|
|
@ -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 =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue