From 94d89bdefcf5666b21b1f5f262ad9bf3a9e94254 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Wed, 24 Jun 2026 07:47:46 +0800 Subject: [PATCH] fix: fix fullscreen tearing only --- src/mango.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/mango.c b/src/mango.c index b90c06b2..bfe21445 100644 --- a/src/mango.c +++ b/src/mango.c @@ -951,6 +951,7 @@ static void global_draw_group_bar(Client *c, int32_t x, int32_t y, static void client_reparent_group(Client *c); static void client_change_mon(Client *c, Monitor *m); +static void check_vrr_enable(Client *c); #include "data/static_keymap.h" #include "dispatch/bind_declare.h" @@ -3996,6 +3997,7 @@ void focusclient(Client *c, int32_t lift) { c->isfocusing = true; check_keep_idle_inhibit(c); + check_vrr_enable(c); if (last_focus_client && !last_focus_client->iskilling && last_focus_client != c) { @@ -5857,6 +5859,7 @@ void setfullscreen(Client *c, int32_t fullscreen, } client_reparent_group(c); + check_vrr_enable(c); if (rearrange) arrange(c->mon, false, false); @@ -6657,19 +6660,27 @@ void check_keep_idle_inhibit(Client *c) { if (c && c->idleinhibit_when_focus && keep_idle_inhibit_source) { wl_event_source_timer_update(keep_idle_inhibit_source, 1000); } +} - if (c && c->mon && c->vrr_only_fullscreen && c->isfullscreen && - !c->mon->is_vrr_opening) { - struct wlr_output_state state = {0}; +void check_vrr_enable(Client *c) { + + if (!c || !c->mon) + return; + + struct wlr_output_state state = {0}; + + if (c->vrr_only_fullscreen && c->isfullscreen && !c->mon->is_vrr_opening) { enable_adaptive_sync(c->mon, &state); - } else if (c && c->mon && (!c->vrr_only_fullscreen || !c->isfullscreen)) { - if (!c->mon->is_vrr_opening && c->mon->vrr_global_enable) { - struct wlr_output_state state = {0}; - enable_adaptive_sync(c->mon, &state); - } else if (c->mon->is_vrr_opening && !c->mon->vrr_global_enable) { - struct wlr_output_state state = {0}; - disable_adaptive_sync(c->mon, &state); - } + wlr_output_commit_state(c->mon->wlr_output, &state); + return; + } + + if (!c->mon->is_vrr_opening && c->mon->vrr_global_enable) { + enable_adaptive_sync(c->mon, &state); + wlr_output_commit_state(c->mon->wlr_output, &state); + } else if (c->mon->is_vrr_opening && !c->mon->vrr_global_enable) { + disable_adaptive_sync(c->mon, &state); + wlr_output_commit_state(c->mon->wlr_output, &state); } }