mirror of
https://github.com/labwc/labwc.git
synced 2026-04-13 08:21:15 -04:00
virtual outputs: address code review
This commit is contained in:
parent
0c37cd5e25
commit
9a41e91718
4 changed files with 62 additions and 60 deletions
52
src/action.c
52
src/action.c
|
|
@ -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)
|
||||
|
|
|
|||
53
src/output.c
53
src/output.c
|
|
@ -201,6 +201,7 @@ new_output_notify(struct wl_listener *listener, void *data)
|
|||
*/
|
||||
if (wlr_output_is_headless(wlr_output) && server->headless.pending_output_name[0] != '\0') {
|
||||
wlr_output_set_name(wlr_output, server->headless.pending_output_name);
|
||||
server->headless.pending_output_name[0] = '\0';
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -777,3 +778,55 @@ handle_output_power_manager_set_mode(struct wl_listener *listener, void *data)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue