summaryrefslogtreecommitdiff
path: root/sway/config
diff options
context:
space:
mode:
Diffstat (limited to 'sway/config')
-rw-r--r--sway/config/input.c4
-rw-r--r--sway/config/output.c123
2 files changed, 70 insertions, 57 deletions
diff --git a/sway/config/input.c b/sway/config/input.c
index a998e170..a98204df 100644
--- a/sway/config/input.c
+++ b/sway/config/input.c
@@ -25,6 +25,7 @@ struct input_config *new_input_config(const char* identifier) {
input->drag = INT_MIN;
input->drag_lock = INT_MIN;
input->dwt = INT_MIN;
+ input->dwtp = INT_MIN;
input->send_events = INT_MIN;
input->click_method = INT_MIN;
input->middle_emulation = INT_MIN;
@@ -61,6 +62,9 @@ void merge_input_config(struct input_config *dst, struct input_config *src) {
if (src->dwt != INT_MIN) {
dst->dwt = src->dwt;
}
+ if (src->dwtp != INT_MIN) {
+ dst->dwtp = src->dwtp;
+ }
if (src->left_handed != INT_MIN) {
dst->left_handed = src->left_handed;
}
diff --git a/sway/config/output.c b/sway/config/output.c
index fa509252..9c7082d0 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -27,8 +27,10 @@ int output_name_cmp(const void *item, const void *data) {
void output_get_identifier(char *identifier, size_t len,
struct sway_output *output) {
struct wlr_output *wlr_output = output->wlr_output;
- snprintf(identifier, len, "%s %s %s", wlr_output->make, wlr_output->model,
- wlr_output->serial);
+ snprintf(identifier, len, "%s %s %s",
+ wlr_output->make ? wlr_output->make : "Unknown",
+ wlr_output->model ? wlr_output->model : "Unknown",
+ wlr_output->serial ? wlr_output->serial : "Unknown");
}
const char *sway_output_scale_filter_to_string(enum scale_filter_mode scale_filter) {
@@ -69,6 +71,7 @@ struct output_config *new_output_config(const char *name) {
oc->max_render_time = -1;
oc->adaptive_sync = -1;
oc->render_bit_depth = RENDER_BIT_DEPTH_DEFAULT;
+ oc->power = -1;
return oc;
}
@@ -130,8 +133,8 @@ void merge_output_config(struct output_config *dst, struct output_config *src) {
free(dst->background_fallback);
dst->background_fallback = strdup(src->background_fallback);
}
- if (src->dpms_state != 0) {
- dst->dpms_state = src->dpms_state;
+ if (src->power != -1) {
+ dst->power = src->power;
}
}
@@ -190,11 +193,11 @@ static void merge_id_on_name(struct output_config *oc) {
list_add(config->output_configs, ion_oc);
sway_log(SWAY_DEBUG, "Generated id on name output config \"%s\""
" (enabled: %d) (%dx%d@%fHz position %d,%d scale %f "
- "transform %d) (bg %s %s) (dpms %d) (max render time: %d)",
+ "transform %d) (bg %s %s) (power %d) (max render time: %d)",
ion_oc->name, ion_oc->enabled, ion_oc->width, ion_oc->height,
ion_oc->refresh_rate, ion_oc->x, ion_oc->y, ion_oc->scale,
ion_oc->transform, ion_oc->background,
- ion_oc->background_option, ion_oc->dpms_state,
+ ion_oc->background_option, ion_oc->power,
ion_oc->max_render_time);
}
}
@@ -235,18 +238,18 @@ struct output_config *store_output_config(struct output_config *oc) {
}
sway_log(SWAY_DEBUG, "Config stored for output %s (enabled: %d) (%dx%d@%fHz "
- "position %d,%d scale %f subpixel %s transform %d) (bg %s %s) (dpms %d) "
+ "position %d,%d scale %f subpixel %s transform %d) (bg %s %s) (power %d) "
"(max render time: %d)",
oc->name, oc->enabled, oc->width, oc->height, oc->refresh_rate,
oc->x, oc->y, oc->scale, sway_wl_output_subpixel_to_string(oc->subpixel),
- oc->transform, oc->background, oc->background_option, oc->dpms_state,
+ oc->transform, oc->background, oc->background_option, oc->power,
oc->max_render_time);
return oc;
}
-static void set_mode(struct wlr_output *output, int width, int height,
- float refresh_rate, bool custom) {
+static void set_mode(struct wlr_output *output, struct wlr_output_state *pending,
+ int width, int height, float refresh_rate, bool custom) {
// Not all floating point integers can be represented exactly
// as (int)(1000 * mHz / 1000.f)
// round() the result to avoid any error
@@ -254,7 +257,7 @@ static void set_mode(struct wlr_output *output, int width, int height,
if (wl_list_empty(&output->modes) || custom) {
sway_log(SWAY_DEBUG, "Assigning custom mode to %s", output->name);
- wlr_output_set_custom_mode(output, width, height,
+ wlr_output_state_set_custom_mode(pending, width, height,
refresh_rate > 0 ? mhz : 0);
return;
}
@@ -278,10 +281,11 @@ static void set_mode(struct wlr_output *output, int width, int height,
} else {
sway_log(SWAY_DEBUG, "Assigning configured mode to %s", output->name);
}
- wlr_output_set_mode(output, best);
+ wlr_output_state_set_mode(pending, best);
}
-static void set_modeline(struct wlr_output *output, drmModeModeInfo *drm_mode) {
+static void set_modeline(struct wlr_output *output,
+ struct wlr_output_state *pending, drmModeModeInfo *drm_mode) {
if (!wlr_output_is_drm(output)) {
sway_log(SWAY_ERROR, "Modeline can only be set to DRM output");
return;
@@ -289,7 +293,7 @@ static void set_modeline(struct wlr_output *output, drmModeModeInfo *drm_mode) {
sway_log(SWAY_DEBUG, "Assigning custom modeline to %s", output->name);
struct wlr_output_mode *mode = wlr_drm_connector_add_mode(output, drm_mode);
if (mode) {
- wlr_output_set_mode(output, mode);
+ wlr_output_state_set_mode(pending, mode);
}
}
@@ -311,23 +315,24 @@ static bool phys_size_is_aspect_ratio(struct wlr_output *output) {
// 1 inch = 25.4 mm
#define MM_PER_INCH 25.4
-static int compute_default_scale(struct wlr_output *output) {
+static int compute_default_scale(struct wlr_output *output,
+ struct wlr_output_state *pending) {
struct wlr_box box = { .width = output->width, .height = output->height };
- if (output->pending.committed & WLR_OUTPUT_STATE_MODE) {
- switch (output->pending.mode_type) {
+ if (pending->committed & WLR_OUTPUT_STATE_MODE) {
+ switch (pending->mode_type) {
case WLR_OUTPUT_STATE_MODE_FIXED:
- box.width = output->pending.mode->width;
- box.height = output->pending.mode->height;
+ box.width = pending->mode->width;
+ box.height = pending->mode->height;
break;
case WLR_OUTPUT_STATE_MODE_CUSTOM:
- box.width = output->pending.custom_mode.width;
- box.height = output->pending.custom_mode.height;
+ box.width = pending->custom_mode.width;
+ box.height = pending->custom_mode.height;
break;
}
}
enum wl_output_transform transform = output->transform;
- if (output->pending.committed & WLR_OUTPUT_STATE_TRANSFORM) {
- transform = output->pending.transform;
+ if (pending->committed & WLR_OUTPUT_STATE_TRANSFORM) {
+ transform = pending->transform;
}
wlr_box_transform(&box, &box, transform, box.width, box.height);
@@ -374,38 +379,38 @@ static const uint32_t *bit_depth_preferences[] = {
};
static void queue_output_config(struct output_config *oc,
- struct sway_output *output) {
+ struct sway_output *output, struct wlr_output_state *pending) {
if (output == root->fallback_output) {
return;
}
struct wlr_output *wlr_output = output->wlr_output;
- if (oc && (!oc->enabled || oc->dpms_state == DPMS_OFF)) {
+ if (oc && (!oc->enabled || oc->power == 0)) {
sway_log(SWAY_DEBUG, "Turning off output %s", wlr_output->name);
- wlr_output_enable(wlr_output, false);
+ wlr_output_state_set_enabled(pending, false);
return;
}
sway_log(SWAY_DEBUG, "Turning on output %s", wlr_output->name);
- wlr_output_enable(wlr_output, true);
+ wlr_output_state_set_enabled(pending, true);
if (oc && oc->drm_mode.type != 0 && oc->drm_mode.type != (uint32_t) -1) {
sway_log(SWAY_DEBUG, "Set %s modeline",
wlr_output->name);
- set_modeline(wlr_output, &oc->drm_mode);
+ set_modeline(wlr_output, pending, &oc->drm_mode);
} else if (oc && oc->width > 0 && oc->height > 0) {
sway_log(SWAY_DEBUG, "Set %s mode to %dx%d (%f Hz)",
wlr_output->name, oc->width, oc->height, oc->refresh_rate);
- set_mode(wlr_output, oc->width, oc->height,
+ set_mode(wlr_output, pending, oc->width, oc->height,
oc->refresh_rate, oc->custom_mode == 1);
} else if (!wl_list_empty(&wlr_output->modes)) {
sway_log(SWAY_DEBUG, "Set preferred mode");
struct wlr_output_mode *preferred_mode =
wlr_output_preferred_mode(wlr_output);
- wlr_output_set_mode(wlr_output, preferred_mode);
+ wlr_output_state_set_mode(pending, preferred_mode);
- if (!wlr_output_test(wlr_output)) {
+ if (!wlr_output_test_state(wlr_output, pending)) {
sway_log(SWAY_DEBUG, "Preferred mode rejected, "
"falling back to another mode");
struct wlr_output_mode *mode;
@@ -414,8 +419,8 @@ static void queue_output_config(struct output_config *oc,
continue;
}
- wlr_output_set_mode(wlr_output, mode);
- if (wlr_output_test(wlr_output)) {
+ wlr_output_state_set_mode(pending, mode);
+ if (wlr_output_test_state(wlr_output, pending)) {
break;
}
}
@@ -425,7 +430,7 @@ static void queue_output_config(struct output_config *oc,
if (oc && (oc->subpixel != WL_OUTPUT_SUBPIXEL_UNKNOWN || config->reloading)) {
sway_log(SWAY_DEBUG, "Set %s subpixel to %s", oc->name,
sway_wl_output_subpixel_to_string(oc->subpixel));
- wlr_output_set_subpixel(wlr_output, oc->subpixel);
+ wlr_output_state_set_subpixel(pending, oc->subpixel);
}
enum wl_output_transform tr = WL_OUTPUT_TRANSFORM_NORMAL;
@@ -437,7 +442,7 @@ static void queue_output_config(struct output_config *oc,
}
if (wlr_output->transform != tr) {
sway_log(SWAY_DEBUG, "Set %s transform to %d", oc->name, tr);
- wlr_output_set_transform(wlr_output, tr);
+ wlr_output_state_set_transform(pending, tr);
}
// Apply the scale last before the commit, because the scale auto-detection
@@ -446,18 +451,22 @@ static void queue_output_config(struct output_config *oc,
if (oc && oc->scale > 0) {
scale = oc->scale;
} else {
- scale = compute_default_scale(wlr_output);
+ scale = compute_default_scale(wlr_output, pending);
sway_log(SWAY_DEBUG, "Auto-detected output scale: %f", scale);
}
if (scale != wlr_output->scale) {
sway_log(SWAY_DEBUG, "Set %s scale to %f", wlr_output->name, scale);
- wlr_output_set_scale(wlr_output, scale);
+ wlr_output_state_set_scale(pending, scale);
}
if (oc && oc->adaptive_sync != -1) {
sway_log(SWAY_DEBUG, "Set %s adaptive sync to %d", wlr_output->name,
oc->adaptive_sync);
- wlr_output_enable_adaptive_sync(wlr_output, oc->adaptive_sync == 1);
+ wlr_output_state_set_adaptive_sync_enabled(pending, oc->adaptive_sync == 1);
+ if (oc->adaptive_sync == 1 && !wlr_output_test_state(wlr_output, pending)) {
+ sway_log(SWAY_DEBUG, "Adaptive sync failed, ignoring");
+ wlr_output_state_set_adaptive_sync_enabled(pending, false);
+ }
}
if (oc && oc->render_bit_depth != RENDER_BIT_DEPTH_DEFAULT) {
@@ -465,8 +474,8 @@ static void queue_output_config(struct output_config *oc,
assert(fmts);
for (size_t i = 0; fmts[i] != DRM_FORMAT_INVALID; i++) {
- wlr_output_set_render_format(wlr_output, fmts[i]);
- if (wlr_output_test(wlr_output)) {
+ wlr_output_state_set_render_format(pending, fmts[i]);
+ if (wlr_output_test_state(wlr_output, pending)) {
break;
}
@@ -487,14 +496,15 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
// Flag to prevent the output mode event handler from calling us
output->enabling = (!oc || oc->enabled);
- queue_output_config(oc, output);
+ struct wlr_output_state pending = {0};
+ queue_output_config(oc, output, &pending);
- if (!oc || oc->dpms_state != DPMS_OFF) {
- output->current_mode = wlr_output->pending.mode;
+ if (!oc || oc->power != 0) {
+ output->current_mode = pending.mode;
}
sway_log(SWAY_DEBUG, "Committing output %s", wlr_output->name);
- if (!wlr_output_commit(wlr_output)) {
+ if (!wlr_output_commit_state(wlr_output, &pending)) {
// Failed to commit output changes, maybe the output is missing a CRTC.
// Leave the output disabled for now and try again when the output gets
// the mode we asked for.
@@ -546,12 +556,12 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
}
// Update output->{lx, ly, width, height}
- struct wlr_box *output_box =
- wlr_output_layout_get_box(root->output_layout, wlr_output);
- output->lx = output_box->x;
- output->ly = output_box->y;
- output->width = output_box->width;
- output->height = output_box->height;
+ struct wlr_box output_box;
+ wlr_output_layout_get_box(root->output_layout, wlr_output, &output_box);
+ output->lx = output_box.x;
+ output->ly = output_box.y;
+ output->width = output_box.width;
+ output->height = output_box.height;
if (!output->enabled) {
output_enable(output);
@@ -577,15 +587,15 @@ bool test_output_config(struct output_config *oc, struct sway_output *output) {
return false;
}
- queue_output_config(oc, output);
- bool ok = wlr_output_test(output->wlr_output);
- wlr_output_rollback(output->wlr_output);
- return ok;
+ struct wlr_output_state pending = {0};
+ queue_output_config(oc, output, &pending);
+ return wlr_output_test_state(output->wlr_output, &pending);
}
static void default_output_config(struct output_config *oc,
struct wlr_output *wlr_output) {
oc->enabled = 1;
+ oc->power = 1;
struct wlr_output_mode *mode = wlr_output_preferred_mode(wlr_output);
if (mode != NULL) {
oc->width = mode->width;
@@ -598,7 +608,6 @@ static void default_output_config(struct output_config *oc,
struct sway_output *output = wlr_output->data;
oc->subpixel = output->detected_subpixel;
oc->transform = WL_OUTPUT_TRANSFORM_NORMAL;
- oc->dpms_state = DPMS_ON;
oc->max_render_time = 0;
}
@@ -653,10 +662,10 @@ static struct output_config *get_output_config(char *identifier,
sway_log(SWAY_DEBUG, "Generated output config \"%s\" (enabled: %d)"
" (%dx%d@%fHz position %d,%d scale %f transform %d) (bg %s %s)"
- " (dpms %d) (max render time: %d)", result->name, result->enabled,
+ " (power %d) (max render time: %d)", result->name, result->enabled,
result->width, result->height, result->refresh_rate,
result->x, result->y, result->scale, result->transform,
- result->background, result->background_option, result->dpms_state,
+ result->background, result->background_option, result->power,
result->max_render_time);
} else if (oc_name) {
// No identifier config, just return a copy of the name config