src/output.c: refactor virtual output related functions

This commit moves the virtual output related functions
into their own file at `src/output-virtual.c` with its
own include file to reduce `include/labwc.h` bit by bit.

Additionally, it removes the need to keep the
`server->headless.pending_output_name` char array around
by temporarily disconnecting the handler when creating a
new virtual output. This allows to set the output name
right in the `output_virtual_add()` call rather than to
store the pending name until the new output event handler
has been called.

It also makes adding a virtual fallback output easier in
a follow-up PR.
This commit is contained in:
Consolatis 2024-03-07 00:22:51 +01:00 committed by Johan Malm
parent 40ce95a68c
commit 95e8573388
6 changed files with 132 additions and 65 deletions

View file

@ -211,7 +211,6 @@ struct server {
struct wlr_backend *backend;
struct headless {
struct wlr_backend *backend;
char pending_output_name[4096];
} headless;
struct wlr_session *session;
@ -491,8 +490,6 @@ struct wlr_box output_usable_area_in_layout_coords(struct output *output);
struct wlr_box output_usable_area_scaled(struct output *output);
void handle_output_power_manager_set_mode(struct wl_listener *listener,
void *data);
void output_add_virtual(struct server *server, const char *output_name);
void output_remove_virtual(struct server *server, const char *output_name);
void output_enable_adaptive_sync(struct wlr_output *output, bool enabled);
void new_tearing_hint(struct wl_listener *listener, void *data);

12
include/output-virtual.h Normal file
View file

@ -0,0 +1,12 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef LABWC_OUTPUT_VIRTUAL_H
#define LABWC_OUTPUT_VIRTUAL_H
struct server;
struct wlr_output;
void output_virtual_add(struct server *server, const char *output_name,
struct wlr_output **store_wlr_output);
void output_virtual_remove(struct server *server, const char *output_name);
#endif