virtual outputs: address code review

This commit is contained in:
kyak 2023-12-08 05:28:32 +03:00
parent 0c37cd5e25
commit 9a41e91718
4 changed files with 62 additions and 60 deletions

View file

@ -629,58 +629,6 @@ run_if_action(struct view *view, struct server *server, struct action *action)
}
}
static void
virtual_output_add(struct server *server, const char *output_name)
{
if (output_name) {
/*
* Prevent creating outputs with the same name
*/
struct output *output;
wl_list_for_each(output, &server->outputs, link) {
if (wlr_output_is_headless(output->wlr_output)) {
if (!strcmp(output->wlr_output->name, output_name)) {
wlr_log(WLR_DEBUG,
"refusing to create virtual output with duplicate name");
return;
}
}
}
strncpy(server->headless.pending_output_name, output_name,
sizeof(server->headless.pending_output_name));
} else {
server->headless.pending_output_name[0] = '\0';
}
wlr_headless_add_output(server->headless.backend, 1920, 1080);
}
static void
virtual_output_remove(struct server *server, const char *output_name)
{
struct output *output;
wl_list_for_each(output, &server->outputs, link) {
if (wlr_output_is_headless(output->wlr_output)) {
if (output_name) {
/*
* Given virtual output name, find and destroy virtual output by
* that name.
*/
if (!strcmp(output->wlr_output->name, output_name)) {
wlr_output_destroy(output->wlr_output);
return;
}
} else {
/*
* When virtual output name was no supplied by user, simply
* destroy the first virtual output found.
*/
wlr_output_destroy(output->wlr_output);
return;
}
}
}
}
void
actions_run(struct view *activator, struct server *server,
struct wl_list *actions, uint32_t resize_edges)