Merge branch 'master' into sensitivity

This commit is contained in:
jlo62 2023-10-24 20:53:58 +02:00 committed by GitHub
commit 8ff53f9094
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 38 additions and 20 deletions

1
.gitignore vendored
View file

@ -6,6 +6,7 @@ bin/
test/ test/
build/ build/
build-*/ build-*/
.cache/
.lvimrc .lvimrc
config-debug config-debug
wayland-*-protocol.* wayland-*-protocol.*

View file

@ -249,6 +249,8 @@ static void set_mode(struct wlr_output *output, struct wlr_output_state *pending
// as (int)(1000 * mHz / 1000.f) // as (int)(1000 * mHz / 1000.f)
// round() the result to avoid any error // round() the result to avoid any error
int mhz = (int)roundf(refresh_rate * 1000); 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) { if (wl_list_empty(&output->modes) || custom) {
sway_log(SWAY_DEBUG, "Assigning custom mode to %s", output->name); 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; struct wlr_output_mode *mode, *best = NULL;
int best_diff_mhz = INT_MAX;
wl_list_for_each(mode, &output->modes, link) { wl_list_for_each(mode, &output->modes, link) {
if (mode->width == width && mode->height == height) { if (mode->width == width && mode->height == height) {
if (mode->refresh == mhz) { int diff_mhz = abs(mode->refresh - mhz);
if (diff_mhz < best_diff_mhz) {
best_diff_mhz = diff_mhz;
best = mode; best = mode;
if (best_diff_mhz == 0) {
break; break;
} }
if (best == NULL || mode->refresh > best->refresh) {
best = mode;
} }
} }
} }
if (!best) { if (best) {
sway_log(SWAY_ERROR, "Configured mode for %s not available", output->name); sway_log(SWAY_INFO, "Assigning configured mode (%dx%d@%.3fHz) to %s",
sway_log(SWAY_INFO, "Picking preferred mode instead"); best->width, best->height, best->refresh / 1000.f, output->name);
best = wlr_output_preferred_mode(output);
} else { } 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); wlr_output_state_set_mode(pending, best);
} }

View file

@ -942,12 +942,15 @@ static void handle_commit(struct wl_listener *listener, void *data) {
return; 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_container(output, update_textures, NULL);
output_for_each_surface(output, update_output_scale_iterator, 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_layers(output);
arrange_output(output); arrange_output(output);
transaction_commit_dirty(); transaction_commit_dirty();
@ -955,7 +958,9 @@ static void handle_commit(struct wl_listener *listener, void *data) {
update_output_manager_config(output->server); 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; int width, height;
wlr_output_transformed_resolution(output->wlr_output, &width, &height); wlr_output_transformed_resolution(output->wlr_output, &width, &height);
wlr_damage_ring_set_bounds(&output->damage_ring, width, height); wlr_damage_ring_set_bounds(&output->damage_ring, width, height);

View file

@ -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) { static void handle_output_commit(struct wl_listener *listener, void *data) {
struct wlr_output_event_commit *event = data; struct wlr_output_event_commit *event = data;
struct sway_session_lock_surface *surf = wl_container_of(listener, surf, output_commit); 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_MODE |
WLR_OUTPUT_STATE_SCALE | WLR_OUTPUT_STATE_SCALE |
WLR_OUTPUT_STATE_TRANSFORM)) { WLR_OUTPUT_STATE_TRANSFORM)) {

View file

@ -121,11 +121,16 @@ The following commands may only be used in the configuration file.
*input* <identifier> map_from_region <X1xY1> <X2xY2> *input* <identifier> map_from_region <X1xY1> <X2xY2>
Ignores inputs from this device that do not occur within the specified 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 region. Can be in millimeters (e.g. 10x20mm 20x40mm) or the fraction of the
(e.g. 0.5x0.5 0.7x0.7). Not all devices support millimeters. Only meaningful full available space in terms of 0..1 (e.g. 0.5x0.5 0.7x0.7). Not all
if the device is not a keyboard and provides events in absolute terms (such devices support millimeters. Only meaningful if the device is not a
as a drawing tablet or touch screen - most pointers provide events relative keyboard and provides events in absolute terms (such as a drawing tablet
to the previous frame). 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 ## LIBINPUT CONFIGURATION

View file

@ -1422,7 +1422,7 @@ static void view_save_buffer_iterator(struct wlr_surface *surface,
int sx, int sy, void *data) { int sx, int sy, void *data) {
struct sway_view *view = data; struct sway_view *view = data;
if (surface && wlr_surface_has_buffer(surface)) { if (surface && surface->buffer) {
wlr_buffer_lock(&surface->buffer->base); wlr_buffer_lock(&surface->buffer->base);
struct sway_saved_buffer *saved_buffer = calloc(1, sizeof(struct sway_saved_buffer)); struct sway_saved_buffer *saved_buffer = calloc(1, sizeof(struct sway_saved_buffer));
saved_buffer->buffer = surface->buffer; saved_buffer->buffer = surface->buffer;