Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

option to fix mouse breaking vrr #6483

Merged
merged 5 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ 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:hotspot_padding", Hyprlang::INT{1});
m_pConfig->addConfigValue("cursor:inactive_timeout", Hyprlang::INT{0});
m_pConfig->addConfigValue("cursor:no_warps", Hyprlang::INT{0});
Expand Down
12 changes: 12 additions & 0 deletions src/helpers/Monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,18 @@ void CMonitor::addDamage(const CBox* box) {
g_pCompositor->scheduleFrameForMonitor(this);
}

bool CMonitor::shouldSkipScheduleFrameOnMouseEvent() {
static auto PNOBREAK = CConfigValue<Hyprlang::INT>("cursor:no_break_fs_vrr");

// skip scheduling extra frames for fullsreen apps with vrr
if (*PNOBREAK && this->output->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED) {
UjinT34 marked this conversation as resolved.
Show resolved Hide resolved
const auto PWORKSPACE = this->activeWorkspace;
return PWORKSPACE && PWORKSPACE->m_bHasFullscreenWindow && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL;
}

return false;
}

bool CMonitor::isMirror() {
return pMirrorOf != nullptr;
}
Expand Down
1 change: 1 addition & 0 deletions src/helpers/Monitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/managers/PointerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/managers/input/InputManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/render/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/render/Renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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*);
Expand Down