mirror of
https://github.com/swaywm/sway.git
synced 2026-05-03 06:46:26 -04:00
name backend outputs
This commit is contained in:
parent
6b9ae074fa
commit
91841e6ee4
2 changed files with 29 additions and 16 deletions
|
|
@ -48,7 +48,16 @@ static struct cmd_results *backend_cmd_add(int argc, char **argv) {
|
|||
static struct cmd_results *backend_cmd_add_output(int argc, char **argv,
|
||||
struct sway_subbackend *backend) {
|
||||
// TODO allow to name the output
|
||||
sway_subbackend_add_output(&server, backend, NULL);
|
||||
char *name = NULL;
|
||||
if (argc > 0) {
|
||||
name = argv[0];
|
||||
if (strlen(name) > 16) {
|
||||
return cmd_results_new(CMD_INVALID, "backend <cmd> [args]",
|
||||
"output name must be less than 16 characters");
|
||||
}
|
||||
}
|
||||
|
||||
sway_subbackend_add_output(&server, backend, name);
|
||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||
}
|
||||
|
||||
|
|
@ -58,20 +67,7 @@ static struct cmd_results *backend_cmd_del_output(int argc, char **argv,
|
|||
if ((error = checkarg(argc, "backend", EXPECTED_AT_LEAST, 1))) {
|
||||
return error;
|
||||
}
|
||||
|
||||
for (int i = 0; i < root_container.children->length; ++i) {
|
||||
swayc_t *output = root_container.children->items[i];
|
||||
if (output->type != C_OUTPUT) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const char *name = output->sway_output->wlr_output->name;
|
||||
|
||||
if (output->sway_output->wlr_output->backend == backend->backend &&
|
||||
strcmp(argv[0], name) == 0) {
|
||||
wlr_output_destroy(output->sway_output->wlr_output);
|
||||
}
|
||||
}
|
||||
sway_subbackend_remove_output(&server, backend, argv[0]);
|
||||
|
||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#define _POSIX_C_SOURCE 200112L
|
||||
#define _XOPEN_SOURCE 700
|
||||
#include <strings.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <wayland-server.h>
|
||||
|
|
@ -19,6 +21,7 @@
|
|||
#include <wlr/util/log.h>
|
||||
#include "sway/commands.h"
|
||||
#include "sway/config.h"
|
||||
#include "sway/output.h"
|
||||
#include "sway/server.h"
|
||||
#include "sway/input/input-manager.h"
|
||||
#include "log.h"
|
||||
|
|
@ -296,7 +299,6 @@ void sway_subbackend_add_output(struct sway_server *server,
|
|||
wlr_log(L_DEBUG, "creating DRM subbackend outputs is not supported");
|
||||
break;
|
||||
case SWAY_SUBBACKEND_HEADLESS:
|
||||
// TODO allow to name the output
|
||||
wlr_output =
|
||||
wlr_headless_add_output(subbackend->backend, 1280, 960);
|
||||
break;
|
||||
|
|
@ -310,10 +312,25 @@ void sway_subbackend_add_output(struct sway_server *server,
|
|||
struct subbackend_output *output =
|
||||
calloc(1, sizeof(struct subbackend_output));
|
||||
if (output == NULL) {
|
||||
wlr_output_destroy(wlr_output);
|
||||
wlr_log(L_ERROR, "could not allocate subbackend output");
|
||||
return;
|
||||
}
|
||||
|
||||
strncpy(wlr_output->name, name, sizeof(wlr_output->name));
|
||||
for (int i = 0; i < root_container.children->length; ++i) {
|
||||
swayc_t *output = root_container.children->items[i];
|
||||
if (output->type != C_OUTPUT) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (output->sway_output->wlr_output == wlr_output) {
|
||||
free(output->name);
|
||||
output->name = strdup(name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
output->wlr_output = wlr_output;
|
||||
|
||||
wl_signal_add(&wlr_output->events.destroy, &output->output_destroy);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue