Skip to content

Commit

Permalink
input: add cursor:warp_on_changeworkspace
Browse files Browse the repository at this point in the history
If enabled, warp the cursor to the last focused window on the workspace in the `changeworkspace' dispatcher, except if the cursor is currently on the WLR top layer.

Respect persistent warps.
  • Loading branch information
memchr committed Jun 13, 2024
1 parent 5de273a commit f032f17
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ CConfigManager::CConfigManager() {
m_pConfig->addConfigValue("cursor:inactive_timeout", Hyprlang::INT{0});
m_pConfig->addConfigValue("cursor:no_warps", Hyprlang::INT{0});
m_pConfig->addConfigValue("cursor:persistent_warps", Hyprlang::INT{0});
m_pConfig->addConfigValue("cursor:warp_on_change_workspace", Hyprlang::INT{0});
m_pConfig->addConfigValue("cursor:default_monitor", {STRVAL_EMPTY});
m_pConfig->addConfigValue("cursor:zoom_factor", {1.f});
m_pConfig->addConfigValue("cursor:zoom_rigid", Hyprlang::INT{0});
Expand Down
16 changes: 16 additions & 0 deletions src/managers/KeybindManager.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "../config/ConfigValue.hpp"
#include "../devices/IKeyboard.hpp"
#include "../managers/SeatManager.hpp"
#include "../protocols/LayerShell.hpp"
#include "../protocols/ShortcutsInhibit.hpp"
#include "../render/decorations/CHyprGroupBarDecoration.hpp"
#include "KeybindManager.hpp"
Expand Down Expand Up @@ -1086,6 +1087,8 @@ void CKeybindManager::changeworkspace(std::string args) {
if (!PMONITORWORKSPACEOWNER)
return;

updateRelativeCursorCoords();

g_pCompositor->setActiveMonitor(PMONITORWORKSPACEOWNER);

if (BISWORKSPACECURRENT) {
Expand Down Expand Up @@ -1114,6 +1117,19 @@ void CKeybindManager::changeworkspace(std::string args) {
else
g_pInputManager->simulateMouseMovement();
}

const static auto PWARPONWORKSPACECHANGE = CConfigValue<Hyprlang::INT>("cursor:warp_on_change_workspace");

if (*PWARPONWORKSPACECHANGE) {
Vector2D surfaceCoords;
PHLLS pFoundLayerSurface;
auto PLAST = pWorkspaceToChangeTo->getLastFocusedWindow();

if (PLAST &&
!g_pCompositor->vectorToLayerSurface(g_pInputManager->getMouseCoordsInternal(), &PMONITOR->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_TOP], &surfaceCoords,
&pFoundLayerSurface))
PLAST->warpCursor();
}
}

void CKeybindManager::fullscreenActive(std::string args) {
Expand Down

0 comments on commit f032f17

Please sign in to comment.