Merge pull request #33 from imaphatduc/main

Change to the last opened workspace feature
This commit is contained in:
vaxerski 2022-01-07 15:06:20 +01:00 committed by GitHub
commit fad22f452b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 4 deletions

View file

@ -1,6 +1,7 @@
#include "KeybindManager.hpp"
#include "utilities/Util.hpp"
#include "events/events.hpp"
#include "windowManager.hpp"
#include <algorithm>
#include <string.h>
@ -157,11 +158,15 @@ void KeybindManager::changeworkspace(std::string arg) {
if (ID != -1) {
Debug::log(LOG, "Changing the current workspace to " + std::to_string(ID));
g_pWindowManager->changeWorkspaceByID(ID);
}
}
void KeybindManager::changetolastworkspace(std::string arg) {
Debug::log(LOG, "Changing the current workspace to the last workspace");
g_pWindowManager->changeToLastWorkspace();
}
void KeybindManager::toggleActiveWindowFullscreen(std::string unusedArg) {
g_pWindowManager->toggleWindowFullscrenn(g_pWindowManager->LastWindow);
}
@ -206,4 +211,4 @@ void KeybindManager::toggleActiveWindowFloating(std::string unusedArg) {
g_pWindowManager->setAllFloatingWindowsTop();
}
}
}

View file

@ -23,7 +23,8 @@ namespace KeybindManager {
void movewindow(std::string args);
void movefocus(std::string args);
void changeworkspace(std::string args);
void changetolastworkspace(std::string args);
void toggleActiveWindowFullscreen(std::string args);
void toggleActiveWindowFloating(std::string args);
void movetoworkspace(std::string args);
};
};

View file

@ -119,6 +119,7 @@ void handleBind(const std::string& command, const std::string& value) {
if (HANDLER == "movefocus") dispatcher = KeybindManager::movefocus;
if (HANDLER == "movetoworkspace") dispatcher = KeybindManager::movetoworkspace;
if (HANDLER == "workspace") dispatcher = KeybindManager::changeworkspace;
if (HANDLER == "lastworkspace") dispatcher = KeybindManager::changetolastworkspace;
if (HANDLER == "togglefloating") dispatcher = KeybindManager::toggleActiveWindowFloating;
if (dispatcher && KEY != 0)
@ -543,4 +544,4 @@ std::vector<SWindowRule> ConfigManager::getMatchingRules(xcb_window_t w) {
}
return returns;
}
}

View file

@ -1617,6 +1617,7 @@ void CWindowManager::changeWorkspaceByID(int ID) {
// save old workspace for anim
auto OLDWORKSPACE = activeWorkspaces[MONITOR->ID];
lastActiveWorkspaceID = OLDWORKSPACE;
for (auto& workspace : workspaces) {
if (workspace.getID() == ID) {
@ -1669,6 +1670,10 @@ void CWindowManager::changeWorkspaceByID(int ID) {
// no need for the new dirty, it's empty
}
void CWindowManager::changeToLastWorkspace() {
changeWorkspaceByID(lastActiveWorkspaceID);
}
void CWindowManager::focusOnWorkspace(const int& work) {
const auto PWORKSPACE = getWorkspaceByID(work);
const auto PMONITOR = getMonitorFromWorkspace(work);

View file

@ -47,6 +47,7 @@ public:
std::deque<CWorkspace> workspaces;
std::deque<int> activeWorkspaces;
int lastActiveWorkspaceID = 1;
// Pipes
SIPCPipe m_sIPCBarPipeIn = {ISDEBUG ? "/tmp/hypr/hyprbarind" : "/tmp/hypr/hyprbarin", 0};
@ -90,6 +91,7 @@ public:
void recalcAllDocks();
void changeWorkspaceByID(int);
void changeToLastWorkspace();
void setAllWorkspaceWindowsDirtyByID(int);
int getHighestWorkspaceID();
CWorkspace* getWorkspaceByID(int);