Merge pull request #2987 from tomben13/master

[hyprland/workspaces] New options to change on click behaviour and active workspace status
This commit is contained in:
Alexis Rouillard 2024-03-22 23:16:57 +01:00 committed by GitHub
commit e30ddda23a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 2 deletions

View File

@ -127,6 +127,7 @@ class Workspaces : public AModule, public EventHandler {
auto allOutputs() const -> bool { return m_allOutputs; } auto allOutputs() const -> bool { return m_allOutputs; }
auto showSpecial() const -> bool { return m_showSpecial; } auto showSpecial() const -> bool { return m_showSpecial; }
auto activeOnly() const -> bool { return m_activeOnly; } auto activeOnly() const -> bool { return m_activeOnly; }
auto moveToMonitor() const -> bool { return m_moveToMonitor; }
auto getBarOutput() const -> std::string { return m_bar.output->name; } auto getBarOutput() const -> std::string { return m_bar.output->name; }
@ -183,6 +184,7 @@ class Workspaces : public AModule, public EventHandler {
bool m_allOutputs = false; bool m_allOutputs = false;
bool m_showSpecial = false; bool m_showSpecial = false;
bool m_activeOnly = false; bool m_activeOnly = false;
bool m_moveToMonitor = false;
Json::Value m_persistentWorkspaceConfig; Json::Value m_persistentWorkspaceConfig;
// Map for windows stored in workspaces not present in the current bar. // Map for windows stored in workspaces not present in the current bar.

View File

@ -52,6 +52,13 @@ Addressed by *hyprland/workspaces*
default: false ++ default: false ++
If set to true, only the active workspace will be shown. If set to true, only the active workspace will be shown.
*move-to-monitor*: ++
typeof: bool ++
default: false ++
If set to true, open the workspace on the current monitor when clicking on a workspace button.
Otherwise, the workspace will open on the monitor where it was previously assigned.
Analog to using `focusworkspaceoncurrentmonitor` dispatcher instead of `workspace` in Hyprland.
*ignore-workspaces*: ++ *ignore-workspaces*: ++
typeof: array ++ typeof: array ++
default: [] ++ default: [] ++

View File

@ -83,6 +83,11 @@ auto Workspaces::parseConfig(const Json::Value &config) -> void {
m_activeOnly = configActiveOnly.asBool(); m_activeOnly = configActiveOnly.asBool();
} }
auto configMoveToMonitor = config_["move-to-monitor"];
if (configMoveToMonitor.isBool()) {
m_moveToMonitor = configMoveToMonitor.asBool();
}
auto configSortBy = config_["sort-by"]; auto configSortBy = config_["sort-by"];
if (configSortBy.isString()) { if (configSortBy.isString()) {
auto sortByStr = configSortBy.asString(); auto sortByStr = configSortBy.asString();
@ -1034,9 +1039,17 @@ bool Workspace::handleClicked(GdkEventButton *bt) const {
if (bt->type == GDK_BUTTON_PRESS) { if (bt->type == GDK_BUTTON_PRESS) {
try { try {
if (id() > 0) { // normal if (id() > 0) { // normal
gIPC->getSocket1Reply("dispatch workspace " + std::to_string(id())); if (m_workspaceManager.moveToMonitor()) {
gIPC->getSocket1Reply("dispatch focusworkspaceoncurrentmonitor " + std::to_string(id()));
} else {
gIPC->getSocket1Reply("dispatch workspace " + std::to_string(id()));
}
} else if (!isSpecial()) { // named (this includes persistent) } else if (!isSpecial()) { // named (this includes persistent)
gIPC->getSocket1Reply("dispatch workspace name:" + name()); if (m_workspaceManager.moveToMonitor()) {
gIPC->getSocket1Reply("dispatch focusworkspaceoncurrentmonitor name:" + name());
} else {
gIPC->getSocket1Reply("dispatch workspace name:" + name());
}
} else if (id() != -99) { // named special } else if (id() != -99) { // named special
gIPC->getSocket1Reply("dispatch togglespecialworkspace " + name()); gIPC->getSocket1Reply("dispatch togglespecialworkspace " + name());
} else { // special } else { // special