mirror of
https://github.com/labwc/labwc.git
synced 2026-02-05 04:06:33 -05:00
Add optional headless fallback output
This allows configuring a headless fallback output that is automatically created whenever there is no other output around. It is destroyed when a new output is discovered. It can be enabled by setting the environment variable LABWC_FALLBACK_OUTPUT to the desired output name. The feature benefits applications like wayvnc the most as there is always an output available to connect to. Co-Authored-By: Simon Long <simon@raspberrypi.com>
This commit is contained in:
parent
e00f7cd6db
commit
60aab98e8d
5 changed files with 63 additions and 1 deletions
|
|
@ -68,3 +68,18 @@
|
||||||
|
|
||||||
# XDG_CURRENT_DESKTOP=wlroots
|
# XDG_CURRENT_DESKTOP=wlroots
|
||||||
|
|
||||||
|
##
|
||||||
|
## This causes a virtual output to be created automatically whenever there
|
||||||
|
## are no outputs around. This helps for cases like wayvnc so there is always
|
||||||
|
## an output available to connect to. The name can be chosen freely but there
|
||||||
|
## must be no duplicate output names, for this reason using VIRTUAL-x or a
|
||||||
|
## physical connector name like HDMI-A-1 is not recommended as wlroots may
|
||||||
|
## want to create outputs with those names later on which would then fail.
|
||||||
|
##
|
||||||
|
## Using an output name that starts with NOOP- has the additional benefit
|
||||||
|
## that wayvnc will detect it being a virtual output and allow clients to
|
||||||
|
## resize the output to match the client resolution.
|
||||||
|
##
|
||||||
|
|
||||||
|
# LABWC_FALLBACK_OUTPUT=NOOP-fallback
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,5 +8,6 @@ struct wlr_output;
|
||||||
void output_virtual_add(struct server *server, const char *output_name,
|
void output_virtual_add(struct server *server, const char *output_name,
|
||||||
struct wlr_output **store_wlr_output);
|
struct wlr_output **store_wlr_output);
|
||||||
void output_virtual_remove(struct server *server, const char *output_name);
|
void output_virtual_remove(struct server *server, const char *output_name);
|
||||||
|
void output_virtual_update_fallback(struct server *server);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,14 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-only
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <wlr/backend/headless.h>
|
#include <wlr/backend/headless.h>
|
||||||
#include <wlr/types/wlr_output.h>
|
#include <wlr/types/wlr_output.h>
|
||||||
|
#include "common/string-helpers.h"
|
||||||
#include "labwc.h"
|
#include "labwc.h"
|
||||||
#include "output-virtual.h"
|
#include "output-virtual.h"
|
||||||
|
|
||||||
|
static struct wlr_output *fallback_output = NULL;
|
||||||
|
|
||||||
void
|
void
|
||||||
output_virtual_add(struct server *server, const char *output_name,
|
output_virtual_add(struct server *server, const char *output_name,
|
||||||
struct wlr_output **store_wlr_output)
|
struct wlr_output **store_wlr_output)
|
||||||
|
|
@ -77,7 +81,8 @@ output_virtual_remove(struct server *server, const char *output_name)
|
||||||
{
|
{
|
||||||
struct output *output;
|
struct output *output;
|
||||||
wl_list_for_each(output, &server->outputs, link) {
|
wl_list_for_each(output, &server->outputs, link) {
|
||||||
if (!wlr_output_is_headless(output->wlr_output)) {
|
if (!wlr_output_is_headless(output->wlr_output)
|
||||||
|
|| output->wlr_output == fallback_output) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,3 +105,32 @@ output_virtual_remove(struct server *server, const char *output_name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
output_virtual_update_fallback(struct server *server)
|
||||||
|
{
|
||||||
|
struct wl_list *layout_outputs = &server->output_layout->outputs;
|
||||||
|
const char *fallback_output_name = getenv("LABWC_FALLBACK_OUTPUT");
|
||||||
|
|
||||||
|
if (!fallback_output && wl_list_empty(layout_outputs)
|
||||||
|
&& !string_null_or_empty(fallback_output_name)) {
|
||||||
|
wlr_log(WLR_DEBUG, "adding fallback output %s", fallback_output_name);
|
||||||
|
|
||||||
|
output_virtual_add(server, fallback_output_name, &fallback_output);
|
||||||
|
} else if (fallback_output && (wl_list_length(layout_outputs) > 1
|
||||||
|
|| string_null_or_empty(fallback_output_name))) {
|
||||||
|
wlr_log(WLR_DEBUG, "destroying fallback output %s",
|
||||||
|
fallback_output->name);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We must reset fallback_output to NULL before destroying it.
|
||||||
|
*
|
||||||
|
* Otherwise we may end up trying to destroy the same wlr_output
|
||||||
|
* twice due to wlr_output_destroy() removing the output from the
|
||||||
|
* layout which in turn causes us to be called again.
|
||||||
|
*/
|
||||||
|
struct wlr_output *wlr_output = fallback_output;
|
||||||
|
fallback_output = NULL;
|
||||||
|
wlr_output_destroy(wlr_output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
#include "labwc.h"
|
#include "labwc.h"
|
||||||
#include "layers.h"
|
#include "layers.h"
|
||||||
#include "node.h"
|
#include "node.h"
|
||||||
|
#include "output-virtual.h"
|
||||||
#include "regions.h"
|
#include "regions.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
#include "xwayland.h"
|
#include "xwayland.h"
|
||||||
|
|
@ -694,6 +695,12 @@ handle_output_layout_change(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
struct server *server =
|
struct server *server =
|
||||||
wl_container_of(listener, server, output_layout_change);
|
wl_container_of(listener, server, output_layout_change);
|
||||||
|
|
||||||
|
/* Prevents unnecessary layout recalculations */
|
||||||
|
server->pending_output_layout_change++;
|
||||||
|
output_virtual_update_fallback(server);
|
||||||
|
server->pending_output_layout_change--;
|
||||||
|
|
||||||
do_output_layout_change(server);
|
do_output_layout_change(server);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
#include "labwc.h"
|
#include "labwc.h"
|
||||||
#include "layers.h"
|
#include "layers.h"
|
||||||
#include "menu/menu.h"
|
#include "menu/menu.h"
|
||||||
|
#include "output-virtual.h"
|
||||||
#include "regions.h"
|
#include "regions.h"
|
||||||
#include "resize_indicator.h"
|
#include "resize_indicator.h"
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
|
|
@ -69,6 +70,7 @@ handle_sighup(int signal, void *data)
|
||||||
{
|
{
|
||||||
session_environment_init();
|
session_environment_init();
|
||||||
reload_config_and_theme();
|
reload_config_and_theme();
|
||||||
|
output_virtual_update_fallback(g_server);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -490,6 +492,9 @@ server_start(struct server *server)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Potentially set up the initial fallback output */
|
||||||
|
output_virtual_update_fallback(server);
|
||||||
|
|
||||||
if (setenv("WAYLAND_DISPLAY", socket, true) < 0) {
|
if (setenv("WAYLAND_DISPLAY", socket, true) < 0) {
|
||||||
wlr_log_errno(WLR_ERROR, "unable to set WAYLAND_DISPLAY");
|
wlr_log_errno(WLR_ERROR, "unable to set WAYLAND_DISPLAY");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue