summaryrefslogtreecommitdiff
path: root/src/desktop
diff options
context:
space:
mode:
Diffstat (limited to 'src/desktop')
-rw-r--r--src/desktop/Window.cpp13
-rw-r--r--src/desktop/Window.hpp8
2 files changed, 18 insertions, 3 deletions
diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp
index 9f5f9dd3..c478b766 100644
--- a/src/desktop/Window.cpp
+++ b/src/desktop/Window.cpp
@@ -1356,7 +1356,7 @@ void CWindow::activate(bool force) {
g_pCompositor->changeWindowZOrder(m_pSelf.lock(), true);
g_pCompositor->focusWindow(m_pSelf.lock());
- g_pCompositor->warpCursorTo(middle());
+ warpCursor();
}
void CWindow::onUpdateState() {
@@ -1530,3 +1530,14 @@ void CWindow::onX11Configure(CBox box) {
g_pHyprRenderer->damageWindow(m_pSelf.lock());
}
+
+void CWindow::warpCursor() {
+ static auto PERSISTENTWARPS = CConfigValue<Hyprlang::INT>("cursor:persistent_warps");
+ const auto coords = m_vRelativeCursorCoordsOnLastWarp;
+ m_vRelativeCursorCoordsOnLastWarp.x = -1; // reset m_vRelativeCursorCoordsOnLastWarp
+
+ if (*PERSISTENTWARPS && coords.x > 0 && coords.y > 0 && coords < m_vSize) // don't warp cursor outside the window
+ g_pCompositor->warpCursorTo(m_vPosition + coords);
+ else
+ g_pCompositor->warpCursorTo(middle());
+}
diff --git a/src/desktop/Window.hpp b/src/desktop/Window.hpp
index d4e26d5d..151d9809 100644
--- a/src/desktop/Window.hpp
+++ b/src/desktop/Window.hpp
@@ -245,8 +245,11 @@ class CWindow {
Vector2D m_vFloatingOffset = Vector2D(0, 0);
// this is used for pseudotiling
- bool m_bIsPseudotiled = false;
- Vector2D m_vPseudoSize = Vector2D(1280, 720);
+ bool m_bIsPseudotiled = false;
+ Vector2D m_vPseudoSize = Vector2D(1280, 720);
+
+ // for recovering relative cursor position
+ Vector2D m_vRelativeCursorCoordsOnLastWarp = Vector2D(-1, -1);
bool m_bFirstMap = false; // for layouts
bool m_bIsFloating = false;
@@ -446,6 +449,7 @@ class CWindow {
void onResourceChangeX11();
std::string fetchTitle();
std::string fetchClass();
+ void warpCursor();
// listeners
void onAck(uint32_t serial);