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

View file

@ -23,6 +23,7 @@ namespace KeybindManager {
void movewindow(std::string args); void movewindow(std::string args);
void movefocus(std::string args); void movefocus(std::string args);
void changeworkspace(std::string args); void changeworkspace(std::string args);
void changetolastworkspace(std::string args);
void toggleActiveWindowFullscreen(std::string args); void toggleActiveWindowFullscreen(std::string args);
void toggleActiveWindowFloating(std::string args); void toggleActiveWindowFloating(std::string args);
void movetoworkspace(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 == "movefocus") dispatcher = KeybindManager::movefocus;
if (HANDLER == "movetoworkspace") dispatcher = KeybindManager::movetoworkspace; if (HANDLER == "movetoworkspace") dispatcher = KeybindManager::movetoworkspace;
if (HANDLER == "workspace") dispatcher = KeybindManager::changeworkspace; if (HANDLER == "workspace") dispatcher = KeybindManager::changeworkspace;
if (HANDLER == "lastworkspace") dispatcher = KeybindManager::changetolastworkspace;
if (HANDLER == "togglefloating") dispatcher = KeybindManager::toggleActiveWindowFloating; if (HANDLER == "togglefloating") dispatcher = KeybindManager::toggleActiveWindowFloating;
if (dispatcher && KEY != 0) if (dispatcher && KEY != 0)

View file

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

View file

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