aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2022-06-01 21:04:06 +0200
committervaxerski <[email protected]>2022-06-01 21:04:06 +0200
commit8d850b0ce157cabca551127e901fe17f20ba6ac8 (patch)
tree652b8c2a6dd6a894f5add679bd29ae3476adcd9b
parent0f28d2ae5515c5f8f6f50cad743f049ce1fda584 (diff)
downloadHyprland-8d850b0ce157cabca551127e901fe17f20ba6ac8.tar.gz
Hyprland-8d850b0ce157cabca551127e901fe17f20ba6ac8.zip
Added workspace/monitor unset and workspace silent rules
-rw-r--r--src/events/Windows.cpp56
1 files changed, 47 insertions, 9 deletions
diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp
index 35b61db8..d1f588ef 100644
--- a/src/events/Windows.cpp
+++ b/src/events/Windows.cpp
@@ -73,16 +73,23 @@ void Events::listener_mapWindow(void* owner, void* data) {
// window rules
const auto WINDOWRULES = g_pConfigManager->getMatchingRules(PWINDOW);
+ std::string requestedWorkspace = "";
+ bool workspaceSilent = false;
for (auto& r : WINDOWRULES) {
if (r.szRule.find("monitor") == 0) {
try {
- const long int MONITOR = std::stoi(r.szRule.substr(r.szRule.find(" ")));
+ const auto MONITORSTR = r.szRule.substr(r.szRule.find(" "));
- if (MONITOR >= (long int)g_pCompositor->m_lMonitors.size() || MONITOR < (long int)0)
- PWINDOW->m_iMonitorID = 0;
- else
- PWINDOW->m_iMonitorID = MONITOR;
+ if (MONITORSTR == "unset") {
+ PWINDOW->m_iMonitorID = PMONITOR->ID;
+ } else {
+ const long int MONITOR = std::stoi(MONITORSTR);
+ if (MONITOR >= (long int)g_pCompositor->m_lMonitors.size() || MONITOR < (long int)0)
+ PWINDOW->m_iMonitorID = 0;
+ else
+ PWINDOW->m_iMonitorID = MONITOR;
+ }
PWINDOW->m_iWorkspaceID = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID)->activeWorkspace;
@@ -91,11 +98,14 @@ void Events::listener_mapWindow(void* owner, void* data) {
Debug::log(ERR, "Rule monitor failed, rule: %s -> %s | err: %s", r.szRule.c_str(), r.szValue.c_str(), e.what());
}
} else if (r.szRule.find("workspace") == 0) {
- // switch to workspace
- g_pKeybindManager->m_mDispatchers["workspace"](r.szRule.substr(r.szRule.find_first_of(' ') + 1));
+ // check if it isnt unset
+ const auto WORKSPACERQ = r.szRule.substr(r.szRule.find_first_of(' ') + 1);
- PWINDOW->m_iMonitorID = g_pCompositor->m_pLastMonitor->ID;
- PWINDOW->m_iWorkspaceID = g_pCompositor->m_pLastMonitor->activeWorkspace;
+ if (WORKSPACERQ == "unset") {
+ requestedWorkspace = "";
+ } else {
+ requestedWorkspace = WORKSPACERQ;
+ }
Debug::log(LOG, "Rule workspace matched by window %x, %s applied.", PWINDOW, r.szValue.c_str());
} else if (r.szRule.find("float") == 0) {
@@ -132,6 +142,25 @@ void Events::listener_mapWindow(void* owner, void* data) {
}
}
+ if (requestedWorkspace != "") {
+ // process requested workspace
+ if (requestedWorkspace.find_first_of(' ') != std::string::npos) {
+ // check for silent
+ if (requestedWorkspace.find("silent") != std::string::npos) {
+ workspaceSilent = true;
+ }
+
+ requestedWorkspace = requestedWorkspace.substr(0, requestedWorkspace.find_first_of(' '));
+ }
+
+ if (!workspaceSilent) {
+ g_pKeybindManager->m_mDispatchers["workspace"](requestedWorkspace);
+
+ PWINDOW->m_iMonitorID = g_pCompositor->m_pLastMonitor->ID;
+ PWINDOW->m_iWorkspaceID = g_pCompositor->m_pLastMonitor->activeWorkspace;
+ }
+ }
+
if (PWINDOW->m_bIsFloating) {
g_pLayoutManager->getCurrentLayout()->onWindowCreatedFloating(PWINDOW);
PWINDOW->m_bCreatedOverFullscreen = true;
@@ -205,6 +234,15 @@ void Events::listener_mapWindow(void* owner, void* data) {
// do the animation thing
g_pAnimationManager->onWindowPostCreateClose(PWINDOW, false);
+ if (workspaceSilent) {
+ // move the window
+ if (g_pCompositor->m_pLastWindow == PWINDOW) {
+ g_pKeybindManager->m_mDispatchers["movetoworkspacesilent"](requestedWorkspace);
+ } else {
+ Debug::log(ERR, "Tried to set workspace silent rule to a nofocus window!");
+ }
+ }
+
Debug::log(LOG, "Map request dispatched, monitor %s, xywh: %f %f %f %f", PMONITOR->szName.c_str(), PWINDOW->m_vRealPosition.goalv().x, PWINDOW->m_vRealPosition.goalv().y, PWINDOW->m_vRealSize.goalv().x, PWINDOW->m_vRealSize.goalv().y);
}