fix crash when changing TTY

also add an assertion to clarify the contract of `output_by_name`
This commit is contained in:
bi4k8 2022-03-20 22:07:14 +00:00 committed by Johan Malm
parent 4c3bae0794
commit 401b282772

View file

@ -128,6 +128,7 @@ configure_libinput(struct wlr_input_device *wlr_input_device)
static struct wlr_output * static struct wlr_output *
output_by_name(struct server *server, const char *name) output_by_name(struct server *server, const char *name)
{ {
assert(name != NULL);
struct output *output; struct output *output;
wl_list_for_each(output, &server->outputs, link) { wl_list_for_each(output, &server->outputs, link) {
if (!strcasecmp(output->wlr_output->name, name)) { if (!strcasecmp(output->wlr_output->name, name)) {
@ -150,8 +151,10 @@ new_pointer(struct seat *seat, struct input *input)
if (dev->type == WLR_INPUT_DEVICE_POINTER) { if (dev->type == WLR_INPUT_DEVICE_POINTER) {
wlr_log(WLR_INFO, "map pointer to output %s\n", wlr_log(WLR_INFO, "map pointer to output %s\n",
dev->pointer->output_name); dev->pointer->output_name);
struct wlr_output *output = struct wlr_output *output = NULL;
output_by_name(seat->server, dev->pointer->output_name); if (dev->pointer->output_name != NULL) {
output = output_by_name(seat->server, dev->pointer->output_name);
}
wlr_cursor_map_input_to_output(seat->cursor, dev, output); wlr_cursor_map_input_to_output(seat->cursor, dev, output);
wlr_cursor_map_input_to_region(seat->cursor, dev, NULL); wlr_cursor_map_input_to_region(seat->cursor, dev, NULL);
} }