-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from levnikmyskin/feature/remember_workspace_mo…
…nitor New virtual desk 2.0b.
- Loading branch information
Showing
10 changed files
with
755 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#pragma once | ||
|
||
#define VDESK_H | ||
|
||
#include <string> | ||
#include <unordered_map> | ||
#include <unordered_set> | ||
|
||
#include <src/helpers/Monitor.hpp> | ||
#include "globals.hpp" | ||
#include "utils.hpp" | ||
|
||
typedef std::unordered_map<int, int> WorkspaceMap; | ||
typedef std::unordered_map<std::string, int> Layout; | ||
typedef std::string MonitorName; | ||
|
||
/* | ||
* Each virtual desk holds a list of layouts. Layouts remember which workspace was on which monitor | ||
* when those exact monitors (or that exact number of monitors) is/was connected. | ||
* VirtualDeskManager holds instead a map of vdesk_id -> virtual desk. | ||
*/ | ||
|
||
class VirtualDesk { | ||
public: | ||
VirtualDesk(int id = 1, std::string name = "1"); | ||
int id; | ||
std::string name; | ||
std::vector<Layout> layouts; | ||
|
||
const Layout& activeLayout(const RememberLayoutConf&); | ||
Layout& searchActiveLayout(const RememberLayoutConf&); | ||
std::unordered_set<std::string> setFromMonitors(const std::vector<std::shared_ptr<CMonitor>>&); | ||
void changeWorkspaceOnMonitor(int, CMonitor*); | ||
void invalidateActiveLayout(); | ||
void resetLayout(); | ||
void deleteInvalidMonitor(CMonitor*); | ||
void deleteInvalidMonitorOnAllLayouts(CMonitor*); | ||
|
||
private: | ||
int m_activeLayout_idx; | ||
bool activeIsValid = false; | ||
Layout generateCurrentMonitorLayout(); | ||
std::vector<std::shared_ptr<CMonitor>> currentlyEnabledMonitors(); | ||
static std::string monitorDesc(const CMonitor&); | ||
void checkAndAdaptLayout(Layout*); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
#pragma once | ||
|
||
#define VDESK_MANAGER_H | ||
|
||
#include "VirtualDesk.hpp" | ||
|
||
class VirtualDeskManager { | ||
|
||
public: | ||
VirtualDeskManager(); | ||
std::unordered_map<int, std::shared_ptr<VirtualDesk>> vdesksMap; | ||
int prevDesk = -1; | ||
std::unordered_map<int, std::string> vdeskNamesMap = {{1, "1"}}; | ||
RememberLayoutConf conf; | ||
const std::shared_ptr<VirtualDesk>& activeVdesk(); | ||
void changeActiveDesk(std::string&, bool); | ||
void changeActiveDesk(int, bool); | ||
void previousDesk(); | ||
void nextDesk(bool cycle); | ||
void applyCurrentVDesk(); | ||
int moveToDesk(std::string&); | ||
void loadLayoutConf(); | ||
void invalidateAllLayouts(); | ||
void resetAllVdesks(); | ||
void resetVdesk(const std::string& arg); | ||
void deleteInvalidMonitorsOnAllVdesks(CMonitor*); | ||
|
||
private: | ||
int m_activeDeskKey = 1; | ||
bool confLoaded = false; | ||
void cycleWorkspaces(); | ||
int getDeskIdFromName(const std::string& name, bool createIfNotFound = true); | ||
CMonitor* getCurrentMonitor(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#pragma once | ||
|
||
#define UTILS_H | ||
|
||
#include "src/debug/Log.hpp" | ||
#include "globals.hpp" | ||
#include "src/config/ConfigManager.hpp" | ||
#include <string> | ||
|
||
const std::string VIRTUALDESK_NAMES_CONF = "plugin:virtual-desktops:names"; | ||
const std::string CYCLEWORKSPACES_CONF = "plugin:virtual-desktops:cycleworkspaces"; | ||
const std::string REMEMBER_LAYOUT_CONF = "plugin:virtual-desktops:rememberlayout"; | ||
const std::string NOTIFY_INIT = "plugin:virtual-desktops:notifyinit"; | ||
const std::string VERBOSE_LOGS = "plugin:virtual-desktops:verbose_logging"; | ||
const std::string VDESK_DISPATCH_STR = "vdesk"; | ||
const std::string MOVETODESK_DISPATCH_STR = "movetodesk"; | ||
const std::string MOVETODESKSILENT_DISPATCH_STR = "movetodesksilent"; | ||
const std::string RESET_VDESK_DISPATCH_STR = "vdeskreset"; | ||
const std::string PREVDESK_DISPATCH_STR = "prevdesk"; | ||
const std::string NEXTDESK_DISPATCH_STR = "nextdesk"; | ||
const std::string PRINTDESK_DISPATCH_STR = "printdesk"; | ||
const std::string PRINTLAYOUT_DISPATCH_STR = "printlayout"; | ||
const std::string CYCLEVDESK_DISPATCH_STR = "cyclevdesks"; | ||
|
||
const std::string REMEMBER_NONE = "none"; | ||
const std::string REMEMBER_SIZE = "size"; | ||
const std::string REMEMBER_MONITORS = "monitors"; | ||
|
||
enum RememberLayoutConf { | ||
none = 0, | ||
size = 1, | ||
monitors = 2 | ||
}; | ||
|
||
RememberLayoutConf layoutConfFromInt(const int64_t); | ||
RememberLayoutConf layoutConfFromString(const std::string& conf); | ||
void printLog(std::string s, LogLevel level = INFO); | ||
|
||
std::string parseMoveDispatch(std::string& arg); | ||
|
||
bool isVerbose(); |
Oops, something went wrong.