mirror of
https://github.com/swaywm/sway.git
synced 2024-11-14 06:24:20 +01:00
Compare commits
4 Commits
dd581b3da8
...
6a447fb02e
Author | SHA1 | Date | |
---|---|---|---|
|
6a447fb02e | ||
|
d417a8fcd0 | ||
|
f38719f575 | ||
|
1e53007bc3 |
@ -1,7 +1,7 @@
|
||||
#!/bin/sh -eu
|
||||
|
||||
prev=$(git describe --tags --abbrev=0)
|
||||
next=$(meson rewrite kwargs info project / 2>&1 >/dev/null | jq -r '.kwargs["project#/"].version')
|
||||
next=$(meson rewrite kwargs info project / | jq -r '.kwargs["project#/"].version')
|
||||
|
||||
case "$next" in
|
||||
*-dev)
|
||||
|
@ -457,19 +457,47 @@ static void handle_request_state(struct wl_listener *listener, void *data) {
|
||||
struct sway_output *output =
|
||||
wl_container_of(listener, output, request_state);
|
||||
const struct wlr_output_event_request_state *event = data;
|
||||
const struct wlr_output_state *state = event->state;
|
||||
|
||||
uint32_t committed = event->state->committed;
|
||||
wlr_output_commit_state(output->wlr_output, event->state);
|
||||
// Store the requested changes so that the active configuration is
|
||||
// consistent with the current state, and to avoid duplicate logic to apply
|
||||
// the changes.
|
||||
struct output_config *oc = new_output_config(output->wlr_output->name);
|
||||
if (!oc) {
|
||||
sway_log(SWAY_ERROR, "Allocation failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (committed & (
|
||||
WLR_OUTPUT_STATE_MODE |
|
||||
WLR_OUTPUT_STATE_TRANSFORM |
|
||||
WLR_OUTPUT_STATE_SCALE)) {
|
||||
arrange_layers(output);
|
||||
arrange_output(output);
|
||||
transaction_commit_dirty();
|
||||
int committed = state->committed;
|
||||
if (committed & WLR_OUTPUT_STATE_MODE) {
|
||||
if (state->mode != NULL) {
|
||||
oc->width = state->mode->width;
|
||||
oc->height = state->mode->height;
|
||||
oc->refresh_rate = state->mode->refresh / 1000.f;
|
||||
} else {
|
||||
oc->width = state->custom_mode.width;
|
||||
oc->height = state->custom_mode.height;
|
||||
oc->refresh_rate = state->custom_mode.refresh / 1000.f;
|
||||
}
|
||||
committed &= ~WLR_OUTPUT_STATE_MODE;
|
||||
}
|
||||
if (committed & WLR_OUTPUT_STATE_SCALE) {
|
||||
oc->scale = state->scale;
|
||||
committed &= ~WLR_OUTPUT_STATE_SCALE;
|
||||
}
|
||||
if (committed & WLR_OUTPUT_STATE_TRANSFORM) {
|
||||
oc->transform = state->transform;
|
||||
committed &= ~WLR_OUTPUT_STATE_TRANSFORM;
|
||||
}
|
||||
|
||||
update_output_manager_config(output->server);
|
||||
// We do not expect or support any other changes here
|
||||
assert(committed == 0);
|
||||
store_output_config(oc);
|
||||
apply_stored_output_configs();
|
||||
|
||||
if (server.delayed_modeset != NULL) {
|
||||
wl_event_source_remove(server.delayed_modeset);
|
||||
server.delayed_modeset = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -554,6 +582,10 @@ void handle_new_output(struct wl_listener *listener, void *data) {
|
||||
static struct output_config *output_config_for_config_head(
|
||||
struct wlr_output_configuration_head_v1 *config_head) {
|
||||
struct output_config *oc = new_output_config(config_head->state.output->name);
|
||||
if (!oc) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
oc->enabled = config_head->state.enabled;
|
||||
if (!oc->enabled) {
|
||||
return oc;
|
||||
@ -584,7 +616,8 @@ static void output_manager_apply(struct sway_server *server,
|
||||
size_t configs_len = config->output_configs->length + wl_list_length(&cfg->heads);
|
||||
struct output_config **configs = calloc(configs_len, sizeof(*configs));
|
||||
if (!configs) {
|
||||
goto done;
|
||||
sway_log(SWAY_ERROR, "Allocation failed");
|
||||
goto error;
|
||||
}
|
||||
size_t start_new_configs = config->output_configs->length;
|
||||
for (size_t idx = 0; idx < start_new_configs; idx++) {
|
||||
@ -597,6 +630,10 @@ static void output_manager_apply(struct sway_server *server,
|
||||
// Generate the configuration and store it as a temporary
|
||||
// config. We keep a record of it so we can remove it later.
|
||||
struct output_config *oc = output_config_for_config_head(config_head);
|
||||
if (!oc) {
|
||||
sway_log(SWAY_ERROR, "Allocation failed");
|
||||
goto error_config;
|
||||
}
|
||||
configs[config_idx++] = oc;
|
||||
}
|
||||
|
||||
@ -604,6 +641,8 @@ static void output_manager_apply(struct sway_server *server,
|
||||
// if any output configured for enablement fails to be enabled, even if it
|
||||
// was not part of the config heads we were asked to configure.
|
||||
ok = apply_output_configs(configs, configs_len, test_only, false);
|
||||
|
||||
error_config:
|
||||
for (size_t idx = start_new_configs; idx < configs_len; idx++) {
|
||||
struct output_config *cfg = configs[idx];
|
||||
if (!test_only && ok) {
|
||||
@ -614,7 +653,7 @@ static void output_manager_apply(struct sway_server *server,
|
||||
}
|
||||
free(configs);
|
||||
|
||||
done:
|
||||
error:
|
||||
if (ok) {
|
||||
wlr_output_configuration_v1_send_succeeded(cfg);
|
||||
if (server->delayed_modeset != NULL) {
|
||||
@ -649,6 +688,11 @@ void handle_output_power_manager_set_mode(struct wl_listener *listener,
|
||||
struct sway_output *output = event->output->data;
|
||||
|
||||
struct output_config *oc = new_output_config(output->wlr_output->name);
|
||||
if (!oc) {
|
||||
sway_log(SWAY_ERROR, "Allocation failed");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event->mode) {
|
||||
case ZWLR_OUTPUT_POWER_V1_MODE_OFF:
|
||||
oc->power = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user