feat: add hy3:warpcursor

This commit is contained in:
outfoxxed 2024-05-05 18:02:31 -07:00
parent 311939d443
commit 584a1b1e35
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
5 changed files with 24 additions and 0 deletions

View file

@ -2,6 +2,7 @@
## Upcoming ## Upcoming
- Added `hy3:warpcursor` dispatcher to warp cursor to current node.
- Added cursor warping options for `hy3:movefocus`. - Added cursor warping options for `hy3:movefocus`.
## hl0.37.1 and before ## hl0.37.1 and before

View file

@ -321,6 +321,7 @@ plugin {
- `visible` - only move between visible nodes, not hidden tabs - `visible` - only move between visible nodes, not hidden tabs
- `warp` - warp the mouse to the selected window, even if `general:no_cursor_warps` is true. - `warp` - warp the mouse to the selected window, even if `general:no_cursor_warps` is true.
- `nowarp` - does not warp the mouse to the selected window, even if `general:no_cursor_warps` is false. - `nowarp` - does not warp the mouse to the selected window, even if `general:no_cursor_warps` is false.
- `hy3:warpcursor` - warp the cursor to the center of the focused node
- `hy3:movewindow, <l | u | d | r | left | down | up | right>, [once], [visible]` - move a window left, up, down, or right - `hy3:movewindow, <l | u | d | r | left | down | up | right>, [once], [visible]` - move a window left, up, down, or right
- `once` - only move directly to the neighboring group, without moving into any of its subgroups - `once` - only move directly to the neighboring group, without moving into any of its subgroups
- `visible` - only move between visible nodes, not hidden tabs - `visible` - only move between visible nodes, not hidden tabs

View file

@ -925,6 +925,22 @@ void Hy3Layout::shiftFocus(
} }
} }
void Hy3Layout::warpCursor() {
auto current_window = g_pCompositor->m_pLastWindow.lock();
if (current_window != nullptr) {
if (current_window != nullptr) {
g_pCompositor->warpCursorTo(current_window->middle(), true);
}
} else {
auto* node = this->getWorkspaceFocusedNode(g_pCompositor->m_pLastMonitor->activeWorkspace);
if (node != nullptr) {
g_pCompositor->warpCursorTo(node->position + node->size / 2);
}
}
}
void changeNodeWorkspaceRecursive(Hy3Node& node, const PHLWORKSPACE& workspace) { void changeNodeWorkspaceRecursive(Hy3Node& node, const PHLWORKSPACE& workspace) {
node.workspace = workspace; node.workspace = workspace;

View file

@ -113,6 +113,7 @@ public:
void shiftNode(Hy3Node&, ShiftDirection, bool once, bool visible); void shiftNode(Hy3Node&, ShiftDirection, bool once, bool visible);
void shiftWindow(const PHLWORKSPACE& workspace, ShiftDirection, bool once, bool visible); void shiftWindow(const PHLWORKSPACE& workspace, ShiftDirection, bool once, bool visible);
void shiftFocus(const PHLWORKSPACE& workspace, ShiftDirection, bool visible, bool warp); void shiftFocus(const PHLWORKSPACE& workspace, ShiftDirection, bool visible, bool warp);
void warpCursor();
void moveNodeToWorkspace(const PHLWORKSPACE& origin, std::string wsname, bool follow); void moveNodeToWorkspace(const PHLWORKSPACE& origin, std::string wsname, bool follow);
void changeFocus(const PHLWORKSPACE& workspace, FocusShift); void changeFocus(const PHLWORKSPACE& workspace, FocusShift);
void focusTab( void focusTab(

View file

@ -129,6 +129,10 @@ void dispatch_movefocus(std::string value) {
g_Hy3Layout->shiftFocus(workspace, shift.value(), visible, warp_cursor); g_Hy3Layout->shiftFocus(workspace, shift.value(), visible, warp_cursor);
} }
void dispatch_warpcursor(std::string value) {
g_Hy3Layout->warpCursor();
}
void dispatch_move_to_workspace(std::string value) { void dispatch_move_to_workspace(std::string value) {
auto origin_workspace = workspace_for_action(true); auto origin_workspace = workspace_for_action(true);
if (!valid(origin_workspace)) return; if (!valid(origin_workspace)) return;
@ -259,6 +263,7 @@ void registerDispatchers() {
HyprlandAPI::addDispatcher(PHANDLE, "hy3:changegroup", dispatch_changegroup); HyprlandAPI::addDispatcher(PHANDLE, "hy3:changegroup", dispatch_changegroup);
HyprlandAPI::addDispatcher(PHANDLE, "hy3:setephemeral", dispatch_setephemeral); HyprlandAPI::addDispatcher(PHANDLE, "hy3:setephemeral", dispatch_setephemeral);
HyprlandAPI::addDispatcher(PHANDLE, "hy3:movefocus", dispatch_movefocus); HyprlandAPI::addDispatcher(PHANDLE, "hy3:movefocus", dispatch_movefocus);
HyprlandAPI::addDispatcher(PHANDLE, "hy3:warpcursor", dispatch_warpcursor);
HyprlandAPI::addDispatcher(PHANDLE, "hy3:movewindow", dispatch_movewindow); HyprlandAPI::addDispatcher(PHANDLE, "hy3:movewindow", dispatch_movewindow);
HyprlandAPI::addDispatcher(PHANDLE, "hy3:movetoworkspace", dispatch_move_to_workspace); HyprlandAPI::addDispatcher(PHANDLE, "hy3:movetoworkspace", dispatch_move_to_workspace);
HyprlandAPI::addDispatcher(PHANDLE, "hy3:changefocus", dispatch_changefocus); HyprlandAPI::addDispatcher(PHANDLE, "hy3:changefocus", dispatch_changefocus);