fix: review comments

This commit is contained in:
Ricardo Steijn 2024-07-13 19:30:59 +02:00
parent 81e67e18bb
commit a9ba469715
7 changed files with 34 additions and 38 deletions

View file

@ -73,7 +73,7 @@ struct sway_output {
int max_render_time; // In milliseconds int max_render_time; // In milliseconds
struct wl_event_source *repaint_timer; struct wl_event_source *repaint_timer;
bool gamma_lut_changed; bool gamma_lut_changed;
bool allow_tearing, can_tear; bool allow_tearing, enable_tearing;
}; };
struct sway_output_non_desktop { struct sway_output_non_desktop {

View file

@ -11,8 +11,7 @@ struct cmd_results *cmd_allow_tearing(int argc, char **argv) {
struct sway_container *container = config->handler_context.container; struct sway_container *container = config->handler_context.container;
if (!container || !container->view) { if (!container || !container->view) {
return cmd_results_new(CMD_INVALID, return cmd_results_new(CMD_INVALID, "Tearing can only be allowed on views");
"Tearing can only be allowed on views");
} }
bool wants_tearing = parse_boolean(argv[0], true); bool wants_tearing = parse_boolean(argv[0], true);

View file

@ -299,19 +299,14 @@ static int output_repaint_timer_handler(void *data) {
} }
} }
if (output->can_tear) { if (output->enable_tearing) {
pending.tearing_page_flip = true; pending.tearing_page_flip = true;
if (!wlr_output_test_state(output->wlr_output, &pending)) { if (!wlr_output_test_state(output->wlr_output, &pending)) {
sway_log(SWAY_ERROR, "Output test failed on '%s', retrying without tearing page-flip", sway_log(SWAY_DEBUG, "Output test failed on '%s', retrying without tearing page-flip",
output->wlr_output->name); output->wlr_output->name);
pending.tearing_page_flip = false; pending.tearing_page_flip = false;
if (!wlr_output_test_state(output->wlr_output, &pending)) {
wlr_output_state_finish(&pending);
return 0;
}
} }
} }
@ -388,11 +383,11 @@ static void handle_frame(struct wl_listener *listener, void *user_data) {
int delay = msec_until_refresh - output->max_render_time; int delay = msec_until_refresh - output->max_render_time;
struct sway_view *fullscreen_view = output_get_fullscreen_view(output); struct sway_view *fullscreen_view = output_get_fullscreen_view(output);
output->can_tear = output_can_tear_fullscreen_view(output, fullscreen_view); output->enable_tearing = output_can_tear_fullscreen_view(output, fullscreen_view);
// If the delay is less than 1 millisecond (which is the least we can wait) // If the delay is less than 1 millisecond (which is the least we can wait)
// or if the output is allowed to tear, then just render right away. // or if the output is allowed to tear, then just render right away.
if (delay < 1 || output->can_tear) { if (delay < 1 || output->enable_tearing) {
output_repaint_timer_handler(output); output_repaint_timer_handler(output);
} else { } else {
output->wlr_output->frame_pending = true; output->wlr_output->frame_pending = true;

View file

@ -191,17 +191,19 @@ must be separated by one space. For example:
HDR support features. HDR support features.
*output* <name> allow_tearing yes|no *output* <name> allow_tearing yes|no
Allows or disallows screen tearing as a result of asynchronous page flips, Allows or disallows screen tearing as a result of immediate page flips,
and an immediate presentation mode from a client. and an immediate presentation mode from a client. The default is that no
screen tearing is allowed.
With asynchronous page flips, frames from the client are presented as soon With immediate page flips, frames from the client are presented as soon
as possible instead of synchronizing with the monitor's vblank interval as possible instead of synchronizing with the monitor's vblank interval
(VSync). This prevents stutter and reduces latency in games. (VSync).
To adjust whether tearing is allowed for specific applications, see To adjust whether tearing is allowed for specific applications, see
*allow_tearing* in *sway*(5). *allow_tearing* in *sway*(5). Note that tearing will only be enabled
when it's allowed for both the output and the application.
This setting only has effect on fullscreen windows. This setting only has effect when a window is fullscreen on the output.
# SEE ALSO # SEE ALSO

View file

@ -216,7 +216,7 @@ set|plus|minus|toggle <amount>
further details. further details.
*allow_tearing* yes|no *allow_tearing* yes|no
Allows or disallows screen tearing as a result of asynchronous page flips Allows or disallows screen tearing as a result of immediate page flips
for a fullscreen application. for a fullscreen application.
When this option is not set, the tearing hints provided by the application When this option is not set, the tearing hints provided by the application