Skip to content

Commit

Permalink
config: set no_hw_cursors to auto by default and disable on tearing
Browse files Browse the repository at this point in the history
when tearing, updates to the overlay plane may be ignored by the kernel. To avoid the cursor being a slideshow, disable hw cursors
  • Loading branch information
vaxerski committed Feb 15, 2025
1 parent 1309b59 commit 2f96703
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/config/ConfigDescriptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,7 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
},
SConfigOptionDescription{
.value = "cursor:no_hardware_cursors",
.description = "disables hardware cursors",
.description = "disables hardware cursors. Auto = disable when tearing",
.type = CONFIG_OPTION_CHOICE,
.data = SConfigOptionDescription::SChoiceData{0, "Disabled,Enabled,Auto"},
},
Expand Down
5 changes: 3 additions & 2 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ CConfigManager::CConfigManager() {

m_pConfig->addConfigValue("opengl:nvidia_anti_flicker", Hyprlang::INT{1});

m_pConfig->addConfigValue("cursor:no_hardware_cursors", Hyprlang::INT{0});
m_pConfig->addConfigValue("cursor:no_hardware_cursors", Hyprlang::INT{2});
m_pConfig->addConfigValue("cursor:no_break_fs_vrr", Hyprlang::INT{2});
m_pConfig->addConfigValue("cursor:min_refresh_rate", Hyprlang::INT{24});
m_pConfig->addConfigValue("cursor:hotspot_padding", Hyprlang::INT{0});
Expand Down Expand Up @@ -2798,12 +2798,13 @@ const std::vector<SConfigOptionDescription>& CConfigManager::getAllDescriptions(
return CONFIG_OPTIONS;
}

bool CConfigManager::shouldUseSoftwareCursors() {
bool CConfigManager::shouldUseSoftwareCursors(PHLMONITOR pMonitor) {
static auto PNOHW = CConfigValue<Hyprlang::INT>("cursor:no_hardware_cursors");

switch (*PNOHW) {
case 0: return false;
case 1: return true;
case 2: return pMonitor->tearingState.activelyTearing;
default: break;
}

Expand Down
2 changes: 1 addition & 1 deletion src/config/ConfigManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class CConfigManager {
void ensureMonitorStatus();
void ensureVRR(PHLMONITOR pMonitor = nullptr);

bool shouldUseSoftwareCursors();
bool shouldUseSoftwareCursors(PHLMONITOR pMonitor);
void updateWatcher();

std::string parseKeyword(const std::string&, const std::string&);
Expand Down
5 changes: 3 additions & 2 deletions src/managers/PointerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ void CPointerManager::updateCursorBackend() {
continue;
}

if (state->softwareLocks > 0 || g_pConfigManager->shouldUseSoftwareCursors() || !attemptHardwareCursor(state)) {
if (state->softwareLocks > 0 || g_pConfigManager->shouldUseSoftwareCursors(m) || !attemptHardwareCursor(state)) {
Debug::log(TRACE, "Output {} rejected hardware cursors, falling back to sw", m->szName);
state->box = getCursorBoxLogicalForMonitor(state->monitor.lock());
state->hardwareFailed = true;
Expand Down Expand Up @@ -737,7 +737,8 @@ void CPointerManager::damageIfSoftware() {
if (mw->monitor.expired() || !mw->monitor->output)
continue;

if ((mw->softwareLocks > 0 || mw->hardwareFailed || g_pConfigManager->shouldUseSoftwareCursors()) && b.overlaps({mw->monitor->vecPosition, mw->monitor->vecSize})) {
if ((mw->softwareLocks > 0 || mw->hardwareFailed || g_pConfigManager->shouldUseSoftwareCursors(mw->monitor.lock())) &&
b.overlaps({mw->monitor->vecPosition, mw->monitor->vecSize})) {
g_pHyprRenderer->damageBox(b, mw->monitor->shouldSkipScheduleFrameOnMouseEvent());
break;
}
Expand Down

0 comments on commit 2f96703

Please sign in to comment.