added general:no_cursor_warps

This commit is contained in:
vaxerski 2022-08-01 18:50:16 +02:00
parent 338865e433
commit 1edd66618f
4 changed files with 21 additions and 5 deletions

View file

@ -1502,3 +1502,17 @@ void CCompositor::startHyprCtlTick() {
wl_event_source_timer_update(hyprCtlTickSource, 16); wl_event_source_timer_update(hyprCtlTickSource, 16);
} }
void CCompositor::warpCursorTo(const Vector2D& pos) {
// warpCursorTo should only be used for warps that
// should be disabled with no_cursor_warps
static auto *const PNOWARPS = &g_pConfigManager->getConfigValuePtr("general:no_cursor_warps")->intValue;
if (*PNOWARPS)
return;
wlr_cursor_warp(m_sWLRCursor, m_sSeat.mouse->mouse, pos.x, pos.y);
}

View file

@ -152,6 +152,7 @@ public:
void addToFadingOutSafe(SLayerSurface*); void addToFadingOutSafe(SLayerSurface*);
void addToFadingOutSafe(CWindow*); void addToFadingOutSafe(CWindow*);
CWindow* getWindowByRegex(const std::string&); CWindow* getWindowByRegex(const std::string&);
void warpCursorTo(const Vector2D&);
std::string explicitConfigPath; std::string explicitConfigPath;

View file

@ -45,6 +45,7 @@ void CConfigManager::setDefaultVars() {
configValues["general:col.active_border"].intValue = 0xffffffff; configValues["general:col.active_border"].intValue = 0xffffffff;
configValues["general:col.inactive_border"].intValue = 0xff444444; configValues["general:col.inactive_border"].intValue = 0xff444444;
configValues["general:cursor_inactive_timeout"].intValue = 0; configValues["general:cursor_inactive_timeout"].intValue = 0;
configValues["general:no_cursor_warps"].intValue = 0;
configValues["general:layout"].strValue = "dwindle"; configValues["general:layout"].strValue = "dwindle";

View file

@ -510,7 +510,7 @@ void CKeybindManager::changeworkspace(std::string args) {
// If the monitor is not the one our cursor's at, warp to it. // If the monitor is not the one our cursor's at, warp to it.
if (PMONITOR != g_pCompositor->getMonitorFromCursor()) { if (PMONITOR != g_pCompositor->getMonitorFromCursor()) {
Vector2D middle = PMONITOR->vecPosition + PMONITOR->vecSize / 2.f; Vector2D middle = PMONITOR->vecPosition + PMONITOR->vecSize / 2.f;
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, middle.x, middle.y); g_pCompositor->warpCursorTo(middle);
} }
// set active and deactivate all other in wlr // set active and deactivate all other in wlr
@ -744,7 +744,7 @@ void CKeybindManager::moveFocusTo(std::string args) {
auto switchToWindow = [&](CWindow* PWINDOWTOCHANGETO) { auto switchToWindow = [&](CWindow* PWINDOWTOCHANGETO) {
g_pCompositor->focusWindow(PWINDOWTOCHANGETO); g_pCompositor->focusWindow(PWINDOWTOCHANGETO);
Vector2D middle = PWINDOWTOCHANGETO->m_vRealPosition.goalv() + PWINDOWTOCHANGETO->m_vRealSize.goalv() / 2.f; Vector2D middle = PWINDOWTOCHANGETO->m_vRealPosition.goalv() + PWINDOWTOCHANGETO->m_vRealSize.goalv() / 2.f;
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, middle.x, middle.y); g_pCompositor->warpCursorTo(middle);
}; };
if (!g_pCompositor->windowValidMapped(PLASTWINDOW)) { if (!g_pCompositor->windowValidMapped(PLASTWINDOW)) {
@ -1245,7 +1245,7 @@ void CKeybindManager::circleNext(std::string arg) {
const auto MIDPOINT = g_pCompositor->m_pLastWindow->m_vRealPosition.goalv() + g_pCompositor->m_pLastWindow->m_vRealSize.goalv() / 2.f; const auto MIDPOINT = g_pCompositor->m_pLastWindow->m_vRealPosition.goalv() + g_pCompositor->m_pLastWindow->m_vRealSize.goalv() / 2.f;
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, MIDPOINT.x, MIDPOINT.y); g_pCompositor->warpCursorTo(MIDPOINT);
} }
void CKeybindManager::focusWindow(std::string regexp) { void CKeybindManager::focusWindow(std::string regexp) {
@ -1262,7 +1262,7 @@ void CKeybindManager::focusWindow(std::string regexp) {
const auto MIDPOINT = PWINDOW->m_vRealPosition.goalv() + PWINDOW->m_vRealSize.goalv() / 2.f; const auto MIDPOINT = PWINDOW->m_vRealPosition.goalv() + PWINDOW->m_vRealSize.goalv() / 2.f;
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, MIDPOINT.x, MIDPOINT.y); g_pCompositor->warpCursorTo(MIDPOINT);
} }
void CKeybindManager::setSubmap(std::string submap) { void CKeybindManager::setSubmap(std::string submap) {