move window to relative workspace

This commit is contained in:
end-4 2023-01-22 22:11:30 +07:00
parent 404296a173
commit e94a78af16
6 changed files with 25 additions and 0 deletions

View file

@ -10,6 +10,10 @@ While Wayland is the future
I still want Xorg
<br/>
# Stuff fixed/added so far
- Workspace animation direction
- Relative workspace switching
<p align="center">
<img src="https://i.imgur.com/LtC153m.png" />
<img src="https://github.com/vaxerski/Hypr/actions/workflows/c-cpp.yml/badge.svg" />

View file

@ -171,6 +171,18 @@ void KeybindManager::movefocus(std::string arg) {
g_pWindowManager->moveActiveFocusTo(arg[0]);
}
void KeybindManager::movetorelativeworkspace(std::string arg) {
try {
if (arg == "+")
g_pWindowManager->moveActiveWindowToRelativeWorkspace(1);
else if (arg == "-")
g_pWindowManager->moveActiveWindowToRelativeWorkspace(-1);
} catch (...) {
Debug::log(ERR, "Invalid arg in movetoworkspace, arg: " + arg);
}
}
void KeybindManager::movetoworkspace(std::string arg) {
try {
if (arg == "scratchpad")

View file

@ -28,6 +28,7 @@ namespace KeybindManager {
void toggleActiveWindowFullscreen(std::string args);
void toggleActiveWindowFloating(std::string args);
void movetoworkspace(std::string args);
void movetorelativeworkspace(std::string args);
void changeSplitRatio(std::string args);
void togglePseudoActive(std::string args);
void toggleScratchpad(std::string args);

View file

@ -129,6 +129,7 @@ void handleBind(const std::string& command, const std::string& value) {
if (HANDLER == "movewindow") dispatcher = KeybindManager::movewindow;
if (HANDLER == "movefocus") dispatcher = KeybindManager::movefocus;
if (HANDLER == "movetoworkspace") dispatcher = KeybindManager::movetoworkspace;
if (HANDLER == "movetorelativeworkspace") dispatcher = KeybindManager::movetorelativeworkspace;
if (HANDLER == "workspace" || HANDLER == "ws") dispatcher = KeybindManager::changeworkspace;
if (HANDLER == "relativeworkspace") dispatcher = KeybindManager::changetorelativeworkspace;
if (HANDLER == "lastworkspace") dispatcher = KeybindManager::changetolastworkspace;

View file

@ -1553,6 +1553,12 @@ void CWindowManager::warpCursorTo(Vector2D to) {
free(pointerreply);
}
void CWindowManager::moveActiveWindowToRelativeWorkspace(int relativenum) {
if (activeWorkspaceID + relativenum < lowerWorkspaceLimit) return;
if (activeWorkspaceID + relativenum > upperWorkspaceLimit) return;
moveActiveWindowToWorkspace(activeWorkspaceID + relativenum);
}
void CWindowManager::moveActiveWindowToWorkspace(int workspace) {
auto PWINDOW = getWindowFromDrawable(LastWindow);

View file

@ -96,6 +96,7 @@ public:
void moveActiveWindowTo(char);
void moveActiveFocusTo(char);
void moveActiveWindowToWorkspace(int);
void moveActiveWindowToRelativeWorkspace(int);
void warpCursorTo(Vector2D);
void toggleWindowFullscrenn(const int&);
void recalcAllDocks();