Implement key binds to control virtual outputs

It is now possible to use keybinds to add and remove virtual outputs
(also called headless backend in wlroots terminology).
This commit is contained in:
kyak 2023-12-05 19:06:56 +03:00
parent 5d2f594626
commit 45012d322a
5 changed files with 149 additions and 1 deletions

View file

@ -3,6 +3,8 @@
#include "config.h"
#include <signal.h>
#include <sys/wait.h>
#include <wlr/backend/headless.h>
#include <wlr/backend/multi.h>
#include <wlr/types/wlr_data_control_v1.h>
#include <wlr/types/wlr_export_dmabuf_v1.h>
#include <wlr/types/wlr_fractional_scale_v1.h>
@ -256,6 +258,24 @@ server_init(struct server *server)
exit(EXIT_FAILURE);
}
/*
* Create headless backend to enable adding virtual outputs later on.
*/
server->headless.backend = wlr_headless_backend_create(server->wl_display);
if (!server->headless.backend) {
wlr_log(WLR_ERROR, "failed to create virtual output");
exit(EXIT_FAILURE);
}
wlr_multi_backend_add(server->backend, server->headless.backend);
/*
* If we don't populate headless backend with a virtual output (that we
* create and immediately destroy), then virtual outputs being added
* later do not work properly when overlayed on real output. Content is
* drawn on the virtual output, but not drawn on the real output.
*/
wlr_output_destroy(wlr_headless_add_output(server->headless.backend, 0, 0));
/*
* Autocreates a renderer, either Pixman, GLES2 or Vulkan for us. The
* user can also specify a renderer using the WLR_RENDERER env var.