mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-02 09:01:38 -05:00
Merge pull request #549 from emersion/output-enabled
Add wlr_output::enabled
This commit is contained in:
commit
b331c5c2c5
17 changed files with 153 additions and 85 deletions
|
|
@ -263,10 +263,19 @@ static int config_ini_handler(void *user, const char *section, const char *name,
|
|||
oc->name = strdup(output_name);
|
||||
oc->transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||
oc->scale = 1;
|
||||
oc->enable = true;
|
||||
wl_list_insert(&config->outputs, &oc->link);
|
||||
}
|
||||
|
||||
if (strcmp(name, "x") == 0) {
|
||||
if (strcmp(name, "enable") == 0) {
|
||||
if (strcasecmp(value, "true") == 0) {
|
||||
oc->enable = true;
|
||||
} else if (strcasecmp(value, "false") == 0) {
|
||||
oc->enable = false;
|
||||
} else {
|
||||
wlr_log(L_ERROR, "got invalid output enable value: %s", value);
|
||||
}
|
||||
} else if (strcmp(name, "x") == 0) {
|
||||
oc->x = strtol(value, NULL, 10);
|
||||
} else if (strcmp(name, "y") == 0) {
|
||||
oc->y = strtol(value, NULL, 10);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdbool.h>
|
||||
#include <wayland-server.h>
|
||||
#include <wlr/types/wlr_input_device.h>
|
||||
#include <wlr/types/wlr_pointer.h>
|
||||
|
|
@ -85,6 +86,8 @@ static void pressed_keysyms_update(xkb_keysym_t *pressed_keysyms,
|
|||
|
||||
static const char *exec_prefix = "exec ";
|
||||
|
||||
static bool outputs_enabled = true;
|
||||
|
||||
static void keyboard_binding_execute(struct roots_keyboard *keyboard,
|
||||
const char *command) {
|
||||
struct roots_seat *seat = keyboard->seat;
|
||||
|
|
@ -119,6 +122,12 @@ static void keyboard_binding_execute(struct roots_keyboard *keyboard,
|
|||
}
|
||||
} else if (strcmp(command, "nop") == 0) {
|
||||
wlr_log(L_DEBUG, "nop command");
|
||||
} else if (strcmp(command, "toggle_outputs") == 0) {
|
||||
outputs_enabled = !outputs_enabled;
|
||||
struct roots_output *output;
|
||||
wl_list_for_each(output, &keyboard->input->server->desktop->outputs, link) {
|
||||
wlr_output_enable(output->wlr_output, outputs_enabled);
|
||||
}
|
||||
} else {
|
||||
wlr_log(L_ERROR, "unknown binding command: %s", command);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -224,6 +224,10 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
|
|||
struct roots_desktop *desktop = output->desktop;
|
||||
struct roots_server *server = desktop->server;
|
||||
|
||||
if (!wlr_output->enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct timespec now;
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
|
||||
|
|
@ -346,9 +350,10 @@ void output_add_notify(struct wl_listener *listener, void *data) {
|
|||
wlr_log(L_DEBUG, "'%s %s %s' %"PRId32"mm x %"PRId32"mm", wlr_output->make,
|
||||
wlr_output->model, wlr_output->serial, wlr_output->phys_width,
|
||||
wlr_output->phys_height);
|
||||
|
||||
if (wl_list_length(&wlr_output->modes) > 0) {
|
||||
struct wlr_output_mode *mode = NULL;
|
||||
mode = wl_container_of((&wlr_output->modes)->prev, mode, link);
|
||||
struct wlr_output_mode *mode =
|
||||
wl_container_of((&wlr_output->modes)->prev, mode, link);
|
||||
wlr_output_set_mode(wlr_output, mode);
|
||||
}
|
||||
|
||||
|
|
@ -363,13 +368,17 @@ void output_add_notify(struct wl_listener *listener, void *data) {
|
|||
struct roots_output_config *output_config =
|
||||
roots_config_get_output(config, wlr_output);
|
||||
if (output_config) {
|
||||
if (output_config->mode.width) {
|
||||
set_mode(wlr_output, output_config);
|
||||
if (output_config->enable) {
|
||||
if (output_config->mode.width) {
|
||||
set_mode(wlr_output, output_config);
|
||||
}
|
||||
wlr_output_set_scale(wlr_output, output_config->scale);
|
||||
wlr_output_set_transform(wlr_output, output_config->transform);
|
||||
wlr_output_layout_add(desktop->layout, wlr_output, output_config->x,
|
||||
output_config->y);
|
||||
} else {
|
||||
wlr_output_enable(wlr_output, false);
|
||||
}
|
||||
wlr_output_set_scale(wlr_output, output_config->scale);
|
||||
wlr_output_set_transform(wlr_output, output_config->transform);
|
||||
wlr_output_layout_add(desktop->layout, wlr_output, output_config->x,
|
||||
output_config->y);
|
||||
} else {
|
||||
wlr_output_layout_add_auto(desktop->layout, wlr_output);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue