From 8a8fb76ec1d0b9a269b86688cff419201d1e6f62 Mon Sep 17 00:00:00 2001 From: iff <98851855+iffse@users.noreply.github.com> Date: Sun, 10 Sep 2023 21:28:07 +0200 Subject: [PATCH 1/5] Update sway-input.5.scd --- sway/sway-input.5.scd | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/sway/sway-input.5.scd b/sway/sway-input.5.scd index 8a1f27001..442311bb9 100644 --- a/sway/sway-input.5.scd +++ b/sway/sway-input.5.scd @@ -121,11 +121,16 @@ The following commands may only be used in the configuration file. *input* map_from_region Ignores inputs from this device that do not occur within the specified - region. Can be in millimeters (e.g. 10x20mm 20x40mm) or in terms of 0..1 - (e.g. 0.5x0.5 0.7x0.7). Not all devices support millimeters. Only meaningful - if the device is not a keyboard and provides events in absolute terms (such - as a drawing tablet or touch screen - most pointers provide events relative - to the previous frame). + region. Can be in millimeters (e.g. 10x20mm 20x40mm) or the fraction of the + full available space in terms of 0..1 (e.g. 0.5x0.5 0.7x0.7). Not all + devices support millimeters. Only meaningful if the device is not a + keyboard and provides events in absolute terms (such as a drawing tablet + or touch screen - most pointers provide events relative to the previous + frame). + + Commonly used to maintain the aspect ratio of the input device and screen. + Cropping a 16:10 input region to match a 16:9 display can use 0x0 1x0.9 as + the argument. ## LIBINPUT CONFIGURATION From 4326a26ad6fb64b8f8de7d32c1e7b6423e1f84f3 Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Fri, 6 Oct 2023 07:29:01 -0400 Subject: [PATCH 2/5] Chase wlroots!4331 --- sway/desktop/output.c | 11 ++++++++--- sway/lock.c | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/sway/desktop/output.c b/sway/desktop/output.c index aed1fdeb0..0670b3dd5 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -942,12 +942,15 @@ static void handle_commit(struct wl_listener *listener, void *data) { return; } - if (event->committed & WLR_OUTPUT_STATE_SCALE) { + if (event->state->committed & WLR_OUTPUT_STATE_SCALE) { output_for_each_container(output, update_textures, NULL); output_for_each_surface(output, update_output_scale_iterator, NULL); } - if (event->committed & (WLR_OUTPUT_STATE_MODE | WLR_OUTPUT_STATE_TRANSFORM | WLR_OUTPUT_STATE_SCALE)) { + if (event->state->committed & ( + WLR_OUTPUT_STATE_MODE | + WLR_OUTPUT_STATE_TRANSFORM | + WLR_OUTPUT_STATE_SCALE)) { arrange_layers(output); arrange_output(output); transaction_commit_dirty(); @@ -955,7 +958,9 @@ static void handle_commit(struct wl_listener *listener, void *data) { update_output_manager_config(output->server); } - if (event->committed & (WLR_OUTPUT_STATE_MODE | WLR_OUTPUT_STATE_TRANSFORM)) { + if (event->state->committed & ( + WLR_OUTPUT_STATE_MODE | + WLR_OUTPUT_STATE_TRANSFORM)) { int width, height; wlr_output_transformed_resolution(output->wlr_output, &width, &height); wlr_damage_ring_set_bounds(&output->damage_ring, width, height); diff --git a/sway/lock.c b/sway/lock.c index 70ac39691..199624fc4 100644 --- a/sway/lock.c +++ b/sway/lock.c @@ -46,7 +46,7 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) { static void handle_output_commit(struct wl_listener *listener, void *data) { struct wlr_output_event_commit *event = data; struct sway_session_lock_surface *surf = wl_container_of(listener, surf, output_commit); - if (event->committed & ( + if (event->state->committed & ( WLR_OUTPUT_STATE_MODE | WLR_OUTPUT_STATE_SCALE | WLR_OUTPUT_STATE_TRANSFORM)) { From f2425b516309aae7b6458365e53c850701b055c0 Mon Sep 17 00:00:00 2001 From: Tamino Bauknecht Date: Wed, 18 Oct 2023 16:29:02 +0200 Subject: [PATCH 3/5] gitignore: Ignore clangd-generated directory .cache/ --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1ec0cb523..167960e2e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ bin/ test/ build/ build-*/ +.cache/ .lvimrc config-debug wayland-*-protocol.* From 0dfaf7ea639570ed8fcbc8c1592740b0791b7705 Mon Sep 17 00:00:00 2001 From: Tamino Bauknecht Date: Wed, 18 Oct 2023 22:30:10 +0200 Subject: [PATCH 4/5] config/output: Allow approximation of output refresh rate Previous behavior was that only if resolution and refresh rate match exactly, the mode was accepted. As fallback, the mode with the highest refresh rate and the same resolution was chosen. New behavior is that the mode with the closest match for the refresh rate is used with a limit of up to 1Hz. The fallback behavior stays the same. Additionally, the logging was made more verbose. --- sway/config/output.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/sway/config/output.c b/sway/config/output.c index 0985b0e8a..eefde22b6 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -249,6 +249,8 @@ static void set_mode(struct wlr_output *output, struct wlr_output_state *pending // as (int)(1000 * mHz / 1000.f) // round() the result to avoid any error int mhz = (int)roundf(refresh_rate * 1000); + // If no target refresh rate is given, match highest available + mhz = mhz <= 0 ? INT_MAX : mhz; if (wl_list_empty(&output->modes) || custom) { sway_log(SWAY_DEBUG, "Assigning custom mode to %s", output->name); @@ -258,23 +260,28 @@ static void set_mode(struct wlr_output *output, struct wlr_output_state *pending } struct wlr_output_mode *mode, *best = NULL; + int best_diff_mhz = INT_MAX; wl_list_for_each(mode, &output->modes, link) { if (mode->width == width && mode->height == height) { - if (mode->refresh == mhz) { - best = mode; - break; - } - if (best == NULL || mode->refresh > best->refresh) { + int diff_mhz = abs(mode->refresh - mhz); + if (diff_mhz < best_diff_mhz) { + best_diff_mhz = diff_mhz; best = mode; + if (best_diff_mhz == 0) { + break; + } } } } - if (!best) { - sway_log(SWAY_ERROR, "Configured mode for %s not available", output->name); - sway_log(SWAY_INFO, "Picking preferred mode instead"); - best = wlr_output_preferred_mode(output); + if (best) { + sway_log(SWAY_INFO, "Assigning configured mode (%dx%d@%.3fHz) to %s", + best->width, best->height, best->refresh / 1000.f, output->name); } else { - sway_log(SWAY_DEBUG, "Assigning configured mode to %s", output->name); + best = wlr_output_preferred_mode(output); + sway_log(SWAY_INFO, "Configured mode (%dx%d@%.3fHz) not available, " + "applying preferred mode (%dx%d@%.3fHz)", + width, height, refresh_rate, + best->width, best->height, best->refresh / 1000.f); } wlr_output_state_set_mode(pending, best); } From 47263aca289ab4d89ba69a543357603e64719ff6 Mon Sep 17 00:00:00 2001 From: Kirill Primak Date: Tue, 24 Oct 2023 15:24:51 +0300 Subject: [PATCH 5/5] view: check if the buffer was uploaded on save wlr_surface_has_buffer() is insufficient; if a client has committed a buffer but it couldn't be applied, NULL deref happens in the next line. --- sway/tree/view.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway/tree/view.c b/sway/tree/view.c index ec54fed81..a9035de7e 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -1422,7 +1422,7 @@ static void view_save_buffer_iterator(struct wlr_surface *surface, int sx, int sy, void *data) { struct sway_view *view = data; - if (surface && wlr_surface_has_buffer(surface)) { + if (surface && surface->buffer) { wlr_buffer_lock(&surface->buffer->base); struct sway_saved_buffer *saved_buffer = calloc(1, sizeof(struct sway_saved_buffer)); saved_buffer->buffer = surface->buffer;