aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorUjinT34 <[email protected]>2024-06-14 14:45:32 +0300
committerGitHub <[email protected]>2024-06-14 13:45:32 +0200
commita9d53a2252f7ec084e2487d18777e2df01c8c351 (patch)
treed9c57d21becd4fe0c5e4e9619612289b479e4b2a /src
parentb2590b58c51094424a9651d8df37dfab838b5bbb (diff)
downloadHyprland-a9d53a2252f7ec084e2487d18777e2df01c8c351.tar.gz
Hyprland-a9d53a2252f7ec084e2487d18777e2df01c8c351.zip
vrr: add option to fix mouse breaking vrr (#6483)
* option to fix mouse breaking vrr * skip damage on mouse move * remove this-> & cleanup * add cursor:min_refresh_rate to avoid cursor freezing * run clang-format --------- Co-authored-by: UjinT34 <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/config/ConfigManager.cpp2
-rw-r--r--src/helpers/Monitor.cpp18
-rw-r--r--src/helpers/Monitor.hpp1
-rw-r--r--src/managers/PointerManager.cpp2
-rw-r--r--src/managers/input/InputManager.cpp6
-rw-r--r--src/render/Renderer.cpp5
-rw-r--r--src/render/Renderer.hpp2
7 files changed, 30 insertions, 6 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index e0de33cf..f63ff552 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -522,6 +522,8 @@ CConfigManager::CConfigManager() {
m_pConfig->addConfigValue("opengl:force_introspection", Hyprlang::INT{2});
m_pConfig->addConfigValue("cursor:no_hardware_cursors", Hyprlang::INT{0});
+ m_pConfig->addConfigValue("cursor:no_break_fs_vrr", Hyprlang::INT{0});
+ m_pConfig->addConfigValue("cursor:min_refresh_rate", Hyprlang::INT{24});
m_pConfig->addConfigValue("cursor:hotspot_padding", Hyprlang::INT{1});
m_pConfig->addConfigValue("cursor:inactive_timeout", Hyprlang::INT{0});
m_pConfig->addConfigValue("cursor:no_warps", Hyprlang::INT{0});
diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp
index 027b47bd..58687e09 100644
--- a/src/helpers/Monitor.cpp
+++ b/src/helpers/Monitor.cpp
@@ -362,6 +362,24 @@ void CMonitor::addDamage(const CBox* box) {
g_pCompositor->scheduleFrameForMonitor(this);
}
+bool CMonitor::shouldSkipScheduleFrameOnMouseEvent() {
+ static auto PNOBREAK = CConfigValue<Hyprlang::INT>("cursor:no_break_fs_vrr");
+ static auto PMINRR = CConfigValue<Hyprlang::INT>("cursor:min_refresh_rate");
+
+ // skip scheduling extra frames for fullsreen apps with vrr
+ bool shouldSkip = *PNOBREAK && output->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED && activeWorkspace && activeWorkspace->m_bHasFullscreenWindow &&
+ activeWorkspace->m_efFullscreenMode == FULLSCREEN_FULL;
+
+ // keep requested minimum refresh rate
+ if (shouldSkip && *PMINRR && lastPresentationTimer.getMillis() > 1000 / *PMINRR) {
+ // damage whole screen because some previous cursor box damages were skipped
+ wlr_damage_ring_add_whole(&damage);
+ return false;
+ }
+
+ return shouldSkip;
+}
+
bool CMonitor::isMirror() {
return pMirrorOf != nullptr;
}
diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp
index 4bfbf53c..c59e00ac 100644
--- a/src/helpers/Monitor.hpp
+++ b/src/helpers/Monitor.hpp
@@ -158,6 +158,7 @@ class CMonitor {
void addDamage(const pixman_region32_t* rg);
void addDamage(const CRegion* rg);
void addDamage(const CBox* box);
+ bool shouldSkipScheduleFrameOnMouseEvent();
void setMirror(const std::string&);
bool isMirror();
bool matchesStaticSelector(const std::string& selector) const;
diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp
index bf7b5d0a..3a28ea8d 100644
--- a/src/managers/PointerManager.cpp
+++ b/src/managers/PointerManager.cpp
@@ -675,7 +675,7 @@ void CPointerManager::damageIfSoftware() {
continue;
if ((mw->softwareLocks > 0 || mw->hardwareFailed || *PNOHW) && b.overlaps({mw->monitor->vecPosition, mw->monitor->vecSize})) {
- g_pHyprRenderer->damageBox(&b);
+ g_pHyprRenderer->damageBox(&b, mw->monitor->shouldSkipScheduleFrameOnMouseEvent());
break;
}
}
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index 3aa8d2ae..81a46f97 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -187,7 +187,9 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
if (*PZOOMFACTOR != 1.f)
g_pHyprRenderer->damageMonitor(PMONITOR);
- if (!PMONITOR->solitaryClient.lock() && g_pHyprRenderer->shouldRenderCursor() && PMONITOR->output->software_cursor_locks > 0)
+ bool skipFrameSchedule = PMONITOR->shouldSkipScheduleFrameOnMouseEvent();
+
+ if (!PMONITOR->solitaryClient.lock() && g_pHyprRenderer->shouldRenderCursor() && PMONITOR->output->software_cursor_locks > 0 && !skipFrameSchedule)
g_pCompositor->scheduleFrameForMonitor(PMONITOR);
PHLWINDOW forcedFocus = m_pForcedFocus.lock();
@@ -370,7 +372,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
foundSurface =
g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND], &surfaceCoords, &pFoundLayerSurface);
- if (g_pCompositor->m_pLastMonitor->output->software_cursor_locks > 0)
+ if (g_pCompositor->m_pLastMonitor->output->software_cursor_locks > 0 && !skipFrameSchedule)
g_pCompositor->scheduleFrameForMonitor(g_pCompositor->m_pLastMonitor.get());
// grabs
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index 4fe35c7e..19b646a4 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -1763,7 +1763,7 @@ void CHyprRenderer::damageMonitor(CMonitor* pMonitor) {
Debug::log(LOG, "Damage: Monitor {}", pMonitor->szName);
}
-void CHyprRenderer::damageBox(CBox* pBox) {
+void CHyprRenderer::damageBox(CBox* pBox, bool skipFrameSchedule) {
if (g_pCompositor->m_bUnsafeState)
return;
@@ -1773,7 +1773,8 @@ void CHyprRenderer::damageBox(CBox* pBox) {
CBox damageBox = {pBox->x - m->vecPosition.x, pBox->y - m->vecPosition.y, pBox->width, pBox->height};
damageBox.scale(m->scale);
- m->addDamage(&damageBox);
+ if (!skipFrameSchedule)
+ m->addDamage(&damageBox);
}
static auto PLOGDAMAGE = CConfigValue<Hyprlang::INT>("debug:log_damage");
diff --git a/src/render/Renderer.hpp b/src/render/Renderer.hpp
index 60101e87..6adca72a 100644
--- a/src/render/Renderer.hpp
+++ b/src/render/Renderer.hpp
@@ -48,7 +48,7 @@ class CHyprRenderer {
void arrangeLayersForMonitor(const int&);
void damageSurface(SP<CWLSurfaceResource>, double, double, double scale = 1.0);
void damageWindow(PHLWINDOW, bool forceFull = false);
- void damageBox(CBox*);
+ void damageBox(CBox*, bool skipFrameSchedule = false);
void damageBox(const int& x, const int& y, const int& w, const int& h);
void damageRegion(const CRegion&);
void damageMonitor(CMonitor*);