fix: always update tearing page flip output state if output can tear

This commit is contained in:
Ricardo Steijn 2024-04-06 17:48:59 +02:00
parent e12ac32741
commit 0b0d979f1e
2 changed files with 5 additions and 11 deletions

View file

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

View file

@ -299,9 +299,8 @@ static int output_repaint_timer_handler(void *data) {
}
}
if (output->tearing_state_changed) {
output->tearing_state_changed = false;
pending.tearing_page_flip = output->tearing_state;
if (output->can_tear) {
pending.tearing_page_flip = true;
if (!wlr_output_test_state(output->wlr_output, &pending)) {
output->allow_tearing = false;
@ -383,15 +382,11 @@ static void handle_frame(struct wl_listener *listener, void *user_data) {
int delay = msec_until_refresh - output->max_render_time;
struct sway_view *fullscreen_view = output_get_fullscreen_view(output);
bool can_tear = output_can_tear_fullscreen_view(output, fullscreen_view);
if (can_tear != output->tearing_state) {
output->tearing_state_changed = true;
}
output->tearing_state = can_tear;
output->can_tear = output_can_tear_fullscreen_view(output, fullscreen_view);
// 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.
if (delay < 1 || can_tear) {
if (delay < 1 || output->can_tear) {
output_repaint_timer_handler(output);
} else {
output->wlr_output->frame_pending = true;