2022-04-11 19:51:37 +02:00
|
|
|
#include "Workspace.hpp"
|
|
|
|
#include "../Compositor.hpp"
|
2024-03-03 19:39:20 +01:00
|
|
|
#include "../config/ConfigValue.hpp"
|
2022-04-11 19:51:37 +02:00
|
|
|
|
2024-04-02 21:32:39 +02:00
|
|
|
PHLWORKSPACE CWorkspace::create(int id, int monitorID, std::string name, bool special) {
|
|
|
|
PHLWORKSPACE workspace = std::make_shared<CWorkspace>(id, monitorID, name, special);
|
|
|
|
workspace->init(workspace);
|
|
|
|
return workspace;
|
|
|
|
}
|
|
|
|
|
2024-03-08 18:39:53 +01:00
|
|
|
CWorkspace::CWorkspace(int id, int monitorID, std::string name, bool special) {
|
2022-12-16 18:17:31 +01:00
|
|
|
m_iMonitorID = monitorID;
|
2024-03-08 18:39:53 +01:00
|
|
|
m_iID = id;
|
2022-12-16 18:17:31 +01:00
|
|
|
m_szName = name;
|
2022-05-31 14:01:00 +02:00
|
|
|
m_bIsSpecialWorkspace = special;
|
2024-04-02 21:32:39 +02:00
|
|
|
}
|
2022-09-25 20:07:48 +02:00
|
|
|
|
2024-04-02 21:32:39 +02:00
|
|
|
void CWorkspace::init(PHLWORKSPACE self) {
|
|
|
|
m_pSelf = self;
|
|
|
|
|
|
|
|
m_vRenderOffset.create(m_bIsSpecialWorkspace ? g_pConfigManager->getAnimationPropertyConfig("specialWorkspace") : g_pConfigManager->getAnimationPropertyConfig("workspaces"),
|
|
|
|
self, AVARDAMAGE_ENTIRE);
|
|
|
|
m_fAlpha.create(AVARTYPE_FLOAT,
|
|
|
|
m_bIsSpecialWorkspace ? g_pConfigManager->getAnimationPropertyConfig("specialWorkspace") : g_pConfigManager->getAnimationPropertyConfig("workspaces"), self,
|
2024-03-29 01:23:16 +01:00
|
|
|
AVARDAMAGE_ENTIRE);
|
2023-01-05 19:25:45 +01:00
|
|
|
m_fAlpha.setValueAndWarp(1.f);
|
2022-06-28 12:39:56 +02:00
|
|
|
|
2022-11-04 16:56:31 +01:00
|
|
|
m_vRenderOffset.registerVar();
|
|
|
|
m_fAlpha.registerVar();
|
|
|
|
|
2024-04-05 17:54:30 +02:00
|
|
|
const auto RULEFORTHIS = g_pConfigManager->getWorkspaceRuleFor(self);
|
|
|
|
if (RULEFORTHIS.defaultName.has_value())
|
|
|
|
m_szName = RULEFORTHIS.defaultName.value();
|
2024-02-27 23:44:42 +01:00
|
|
|
|
2024-04-02 13:10:03 +02:00
|
|
|
m_pFocusedWindowHook = g_pHookSystem->hookDynamic("closeWindow", [this](void* self, SCallbackInfo& info, std::any param) {
|
|
|
|
const auto PWINDOW = std::any_cast<CWindow*>(param);
|
|
|
|
|
|
|
|
if (PWINDOW == m_pLastFocusedWindow)
|
|
|
|
m_pLastFocusedWindow = nullptr;
|
|
|
|
});
|
|
|
|
|
2024-04-02 21:32:39 +02:00
|
|
|
m_bInert = false;
|
|
|
|
|
2024-04-05 20:32:05 +02:00
|
|
|
const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(self);
|
|
|
|
m_bPersistent = WORKSPACERULE.isPersistent;
|
|
|
|
|
2024-04-06 16:53:32 +02:00
|
|
|
if (auto cmd = WORKSPACERULE.onCreatedEmptyRunCmd)
|
|
|
|
g_pKeybindManager->spawn(*cmd);
|
|
|
|
|
2023-07-06 15:23:11 +02:00
|
|
|
g_pEventManager->postEvent({"createworkspace", m_szName});
|
2024-03-08 18:39:53 +01:00
|
|
|
g_pEventManager->postEvent({"createworkspacev2", std::format("{},{}", m_iID, m_szName)});
|
2023-02-19 21:54:53 +01:00
|
|
|
EMIT_HOOK_EVENT("createWorkspace", this);
|
2022-04-11 19:51:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CWorkspace::~CWorkspace() {
|
2022-05-12 11:27:31 +02:00
|
|
|
m_vRenderOffset.unregister();
|
|
|
|
|
2023-09-06 12:51:36 +02:00
|
|
|
Debug::log(LOG, "Destroying workspace ID {}", m_iID);
|
2022-05-30 20:05:38 +02:00
|
|
|
|
2024-04-02 13:10:03 +02:00
|
|
|
g_pHookSystem->unhook(m_pFocusedWindowHook);
|
|
|
|
|
2023-07-06 15:23:11 +02:00
|
|
|
g_pEventManager->postEvent({"destroyworkspace", m_szName});
|
2024-03-08 18:39:53 +01:00
|
|
|
g_pEventManager->postEvent({"destroyworkspacev2", std::format("{},{}", m_iID, m_szName)});
|
2023-02-19 21:54:53 +01:00
|
|
|
EMIT_HOOK_EVENT("destroyWorkspace", this);
|
2022-05-16 23:13:32 +02:00
|
|
|
}
|
|
|
|
|
2022-05-30 20:05:38 +02:00
|
|
|
void CWorkspace::startAnim(bool in, bool left, bool instant) {
|
2024-03-03 19:39:20 +01:00
|
|
|
const auto ANIMSTYLE = m_fAlpha.m_pConfig->pValues->internalStyle;
|
|
|
|
static auto PWORKSPACEGAP = CConfigValue<Hyprlang::INT>("general:gaps_workspaces");
|
2022-05-16 23:13:32 +02:00
|
|
|
|
2024-03-31 03:14:26 +02:00
|
|
|
// set floating windows offset callbacks
|
|
|
|
m_vRenderOffset.setUpdateCallback([&](void*) {
|
|
|
|
for (auto& w : g_pCompositor->m_vWindows) {
|
2024-04-02 21:32:39 +02:00
|
|
|
if (!g_pCompositor->windowValidMapped(w.get()) || w->workspaceID() != m_iID)
|
2024-03-31 03:14:26 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
w->onWorkspaceAnimUpdate();
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2023-10-15 20:07:23 +02:00
|
|
|
if (ANIMSTYLE.starts_with("slidefade")) {
|
2023-08-17 22:30:20 +02:00
|
|
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
|
|
|
|
float movePerc = 100.f;
|
|
|
|
|
|
|
|
if (ANIMSTYLE.find("%") != std::string::npos) {
|
|
|
|
try {
|
|
|
|
auto percstr = ANIMSTYLE.substr(ANIMSTYLE.find_last_of(' ') + 1);
|
|
|
|
movePerc = std::stoi(percstr.substr(0, percstr.length() - 1));
|
2023-08-25 18:05:08 +02:00
|
|
|
} catch (std::exception& e) { Debug::log(ERR, "Error in startAnim: invalid percentage"); }
|
2023-08-17 22:30:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
m_fAlpha.setValueAndWarp(1.f);
|
|
|
|
m_vRenderOffset.setValueAndWarp(Vector2D(0, 0));
|
|
|
|
|
2023-10-15 20:07:23 +02:00
|
|
|
if (ANIMSTYLE.starts_with("slidefadevert")) {
|
2023-08-17 22:30:20 +02:00
|
|
|
if (in) {
|
|
|
|
m_fAlpha.setValueAndWarp(0.f);
|
|
|
|
m_vRenderOffset.setValueAndWarp(Vector2D(0, (left ? PMONITOR->vecSize.y : -PMONITOR->vecSize.y) * (movePerc / 100.f)));
|
|
|
|
m_fAlpha = 1.f;
|
|
|
|
m_vRenderOffset = Vector2D(0, 0);
|
|
|
|
} else {
|
|
|
|
m_fAlpha.setValueAndWarp(1.f);
|
|
|
|
m_fAlpha = 0.f;
|
|
|
|
m_vRenderOffset = Vector2D(0, (left ? -PMONITOR->vecSize.y : PMONITOR->vecSize.y) * (movePerc / 100.f));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (in) {
|
|
|
|
m_fAlpha.setValueAndWarp(0.f);
|
|
|
|
m_vRenderOffset.setValueAndWarp(Vector2D((left ? PMONITOR->vecSize.x : -PMONITOR->vecSize.x) * (movePerc / 100.f), 0));
|
|
|
|
m_fAlpha = 1.f;
|
|
|
|
m_vRenderOffset = Vector2D(0, 0);
|
|
|
|
} else {
|
|
|
|
m_fAlpha.setValueAndWarp(1.f);
|
|
|
|
m_fAlpha = 0.f;
|
|
|
|
m_vRenderOffset = Vector2D((left ? -PMONITOR->vecSize.x : PMONITOR->vecSize.x) * (movePerc / 100.f), 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (ANIMSTYLE == "fade") {
|
2022-05-18 12:39:20 +02:00
|
|
|
m_vRenderOffset.setValueAndWarp(Vector2D(0, 0)); // fix a bug, if switching from slide -> fade.
|
|
|
|
|
2022-05-16 23:13:32 +02:00
|
|
|
if (in) {
|
|
|
|
m_fAlpha.setValueAndWarp(0.f);
|
2023-01-05 19:25:45 +01:00
|
|
|
m_fAlpha = 1.f;
|
2022-05-16 23:13:32 +02:00
|
|
|
} else {
|
2023-01-05 19:25:45 +01:00
|
|
|
m_fAlpha.setValueAndWarp(1.f);
|
2022-05-16 23:13:32 +02:00
|
|
|
m_fAlpha = 0.f;
|
|
|
|
}
|
2022-06-01 20:51:21 +02:00
|
|
|
} else if (ANIMSTYLE == "slidevert") {
|
2022-05-31 17:56:33 +02:00
|
|
|
// fallback is slide
|
2023-12-06 23:54:56 +01:00
|
|
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
|
2024-03-03 19:39:20 +01:00
|
|
|
const auto YDISTANCE = PMONITOR->vecSize.y + *PWORKSPACEGAP;
|
2022-05-31 17:56:33 +02:00
|
|
|
|
2023-01-05 19:25:45 +01:00
|
|
|
m_fAlpha.setValueAndWarp(1.f); // fix a bug, if switching from fade -> slide.
|
2022-05-31 17:56:33 +02:00
|
|
|
|
|
|
|
if (in) {
|
2023-11-19 13:33:26 +01:00
|
|
|
m_vRenderOffset.setValueAndWarp(Vector2D(0, left ? YDISTANCE : -YDISTANCE));
|
2022-05-31 17:56:33 +02:00
|
|
|
m_vRenderOffset = Vector2D(0, 0);
|
|
|
|
} else {
|
2023-11-19 13:33:26 +01:00
|
|
|
m_vRenderOffset = Vector2D(0, left ? -YDISTANCE : YDISTANCE);
|
2022-05-31 17:56:33 +02:00
|
|
|
}
|
2022-05-16 23:13:32 +02:00
|
|
|
} else {
|
|
|
|
// fallback is slide
|
2023-12-06 23:54:56 +01:00
|
|
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
|
2024-03-03 19:39:20 +01:00
|
|
|
const auto XDISTANCE = PMONITOR->vecSize.x + *PWORKSPACEGAP;
|
2022-05-18 12:39:20 +02:00
|
|
|
|
2023-01-05 19:25:45 +01:00
|
|
|
m_fAlpha.setValueAndWarp(1.f); // fix a bug, if switching from fade -> slide.
|
2022-05-18 12:39:20 +02:00
|
|
|
|
2022-05-16 23:13:32 +02:00
|
|
|
if (in) {
|
2023-11-19 13:33:26 +01:00
|
|
|
m_vRenderOffset.setValueAndWarp(Vector2D(left ? XDISTANCE : -XDISTANCE, 0));
|
2022-05-16 23:13:32 +02:00
|
|
|
m_vRenderOffset = Vector2D(0, 0);
|
|
|
|
} else {
|
2023-11-19 13:33:26 +01:00
|
|
|
m_vRenderOffset = Vector2D(left ? -XDISTANCE : XDISTANCE, 0);
|
2022-05-16 23:13:32 +02:00
|
|
|
}
|
|
|
|
}
|
2022-05-30 20:05:38 +02:00
|
|
|
|
2023-08-25 18:05:08 +02:00
|
|
|
if (m_bIsSpecialWorkspace) {
|
|
|
|
// required for open/close animations
|
|
|
|
if (in) {
|
|
|
|
m_fAlpha.setValueAndWarp(0.f);
|
|
|
|
m_fAlpha = 1.f;
|
|
|
|
} else {
|
|
|
|
m_fAlpha.setValueAndWarp(1.f);
|
|
|
|
m_fAlpha = 0.f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-30 20:05:38 +02:00
|
|
|
if (instant) {
|
|
|
|
m_vRenderOffset.warp();
|
|
|
|
m_fAlpha.warp();
|
|
|
|
}
|
2022-05-25 10:25:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CWorkspace::setActive(bool on) {
|
2023-09-01 17:10:03 +02:00
|
|
|
; // empty until https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/40
|
2022-05-30 20:51:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CWorkspace::moveToMonitor(const int& id) {
|
2023-09-01 17:10:03 +02:00
|
|
|
; // empty until https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/40
|
2022-09-01 11:46:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CWindow* CWorkspace::getLastFocusedWindow() {
|
2024-04-02 21:32:39 +02:00
|
|
|
if (!g_pCompositor->windowValidMapped(m_pLastFocusedWindow) || m_pLastFocusedWindow->workspaceID() != m_iID)
|
2022-09-01 11:46:36 +02:00
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
return m_pLastFocusedWindow;
|
|
|
|
}
|
2023-04-10 21:07:49 +02:00
|
|
|
|
2024-04-02 21:32:39 +02:00
|
|
|
void CWorkspace::rememberPrevWorkspace(const PHLWORKSPACE& prev) {
|
2023-04-10 21:07:49 +02:00
|
|
|
if (!prev) {
|
|
|
|
m_sPrevWorkspace.iID = -1;
|
|
|
|
m_sPrevWorkspace.name = "";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-09-11 16:14:43 +02:00
|
|
|
if (prev->m_iID == m_iID) {
|
2023-04-10 21:07:49 +02:00
|
|
|
Debug::log(LOG, "Tried to set prev workspace to the same as current one");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_sPrevWorkspace.iID = prev->m_iID;
|
|
|
|
m_sPrevWorkspace.name = prev->m_szName;
|
|
|
|
}
|
2023-05-01 16:39:08 +02:00
|
|
|
|
|
|
|
std::string CWorkspace::getConfigName() {
|
|
|
|
if (m_bIsSpecialWorkspace) {
|
|
|
|
return "special:" + m_szName;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_iID > 0)
|
|
|
|
return std::to_string(m_iID);
|
|
|
|
|
|
|
|
return "name:" + m_szName;
|
|
|
|
}
|
2024-03-19 21:56:20 +01:00
|
|
|
|
|
|
|
bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
|
|
|
auto selector = removeBeginEndSpacesTabs(selector_);
|
|
|
|
|
|
|
|
if (selector.empty())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (isNumber(selector)) {
|
|
|
|
|
|
|
|
std::string wsname = "";
|
|
|
|
int wsid = getWorkspaceIDFromString(selector, wsname);
|
|
|
|
|
|
|
|
if (wsid == WORKSPACE_INVALID)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return wsid == m_iID;
|
|
|
|
|
|
|
|
} else if (selector.starts_with("name:")) {
|
|
|
|
return m_szName == selector.substr(5);
|
2024-04-02 23:58:45 +02:00
|
|
|
} else if (selector.starts_with("special")) {
|
2024-03-20 19:05:57 +01:00
|
|
|
return m_szName == selector;
|
2024-03-19 21:56:20 +01:00
|
|
|
} else {
|
|
|
|
// parse selector
|
|
|
|
|
|
|
|
for (size_t i = 0; i < selector.length(); ++i) {
|
|
|
|
const char& cur = selector[i];
|
|
|
|
if (std::isspace(cur))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Allowed selectors:
|
|
|
|
// r - range: r[1-5]
|
|
|
|
// s - special: s[true]
|
|
|
|
// n - named: n[true] or n[s:string] or n[e:string]
|
|
|
|
// m - monitor: m[monitor_selector]
|
|
|
|
// w - windowCount: w[0-4] or w[1], optional flag t or f for tiled or floating, e.g. w[t0-1]
|
|
|
|
|
|
|
|
const auto NEXTSPACE = selector.find_first_of(' ', i);
|
|
|
|
std::string prop = selector.substr(i, NEXTSPACE == std::string::npos ? std::string::npos : NEXTSPACE - i);
|
2024-03-20 03:33:39 +01:00
|
|
|
i = std::min(NEXTSPACE, std::string::npos - 1);
|
2024-03-19 21:56:20 +01:00
|
|
|
|
|
|
|
if (cur == 'r') {
|
|
|
|
int from = 0, to = 0;
|
|
|
|
if (!prop.starts_with("r[") || !prop.ends_with("]")) {
|
|
|
|
Debug::log(LOG, "Invalid selector {}", selector);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
prop = prop.substr(2, prop.length() - 3);
|
|
|
|
|
|
|
|
if (!prop.contains("-")) {
|
|
|
|
Debug::log(LOG, "Invalid selector {}", selector);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto DASHPOS = prop.find("-");
|
|
|
|
const auto LHS = prop.substr(0, DASHPOS), RHS = prop.substr(DASHPOS + 1);
|
|
|
|
|
|
|
|
if (!isNumber(LHS) || !isNumber(RHS)) {
|
|
|
|
Debug::log(LOG, "Invalid selector {}", selector);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
from = std::stoll(LHS);
|
|
|
|
to = std::stoll(RHS);
|
|
|
|
} catch (std::exception& e) {
|
|
|
|
Debug::log(LOG, "Invalid selector {}", selector);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (to < from || to < 1 || from < 1) {
|
|
|
|
Debug::log(LOG, "Invalid selector {}", selector);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (std::clamp(m_iID, from, to) != m_iID)
|
|
|
|
return false;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cur == 's') {
|
|
|
|
if (!prop.starts_with("s[") || !prop.ends_with("]")) {
|
|
|
|
Debug::log(LOG, "Invalid selector {}", selector);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
prop = prop.substr(2, prop.length() - 3);
|
|
|
|
|
|
|
|
const auto SHOULDBESPECIAL = configStringToInt(prop);
|
|
|
|
|
|
|
|
if ((bool)SHOULDBESPECIAL != m_bIsSpecialWorkspace)
|
|
|
|
return false;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cur == 'm') {
|
|
|
|
if (!prop.starts_with("m[") || !prop.ends_with("]")) {
|
|
|
|
Debug::log(LOG, "Invalid selector {}", selector);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
prop = prop.substr(2, prop.length() - 3);
|
|
|
|
|
|
|
|
const auto PMONITOR = g_pCompositor->getMonitorFromString(prop);
|
|
|
|
|
|
|
|
if (!(PMONITOR ? PMONITOR->ID == m_iMonitorID : false))
|
|
|
|
return false;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cur == 'n') {
|
|
|
|
if (!prop.starts_with("n[") || !prop.ends_with("]")) {
|
|
|
|
Debug::log(LOG, "Invalid selector {}", selector);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
prop = prop.substr(2, prop.length() - 3);
|
|
|
|
|
|
|
|
if (prop.starts_with("s:"))
|
|
|
|
return m_szName.starts_with(prop.substr(2));
|
|
|
|
if (prop.starts_with("e:"))
|
|
|
|
return m_szName.ends_with(prop.substr(2));
|
|
|
|
|
|
|
|
const auto WANTSNAMED = configStringToInt(prop);
|
|
|
|
|
|
|
|
if (WANTSNAMED != (m_iID <= -1337))
|
|
|
|
return false;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cur == 'w') {
|
|
|
|
int from = 0, to = 0;
|
|
|
|
if (!prop.starts_with("w[") || !prop.ends_with("]")) {
|
|
|
|
Debug::log(LOG, "Invalid selector {}", selector);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
prop = prop.substr(2, prop.length() - 3);
|
|
|
|
|
|
|
|
int wantsOnlyTiled = -1;
|
|
|
|
|
|
|
|
if (prop.starts_with("t")) {
|
|
|
|
wantsOnlyTiled = 1;
|
|
|
|
prop = prop.substr(1);
|
|
|
|
} else if (prop.starts_with("f")) {
|
|
|
|
wantsOnlyTiled = 0;
|
|
|
|
prop = prop.substr(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!prop.contains("-")) {
|
|
|
|
// try single
|
|
|
|
|
|
|
|
if (!isNumber(prop)) {
|
|
|
|
Debug::log(LOG, "Invalid selector {}", selector);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
from = std::stoll(prop);
|
|
|
|
} catch (std::exception& e) {
|
|
|
|
Debug::log(LOG, "Invalid selector {}", selector);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return g_pCompositor->getWindowsOnWorkspace(m_iID, wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled)) == from;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto DASHPOS = prop.find("-");
|
|
|
|
const auto LHS = prop.substr(0, DASHPOS), RHS = prop.substr(DASHPOS + 1);
|
|
|
|
|
|
|
|
if (!isNumber(LHS) || !isNumber(RHS)) {
|
|
|
|
Debug::log(LOG, "Invalid selector {}", selector);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
from = std::stoll(LHS);
|
|
|
|
to = std::stoll(RHS);
|
|
|
|
} catch (std::exception& e) {
|
|
|
|
Debug::log(LOG, "Invalid selector {}", selector);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (to < from || to < 1 || from < 1) {
|
|
|
|
Debug::log(LOG, "Invalid selector {}", selector);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto WINDOWSONWORKSPACE = g_pCompositor->getWindowsOnWorkspace(m_iID, wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled));
|
|
|
|
if (std::clamp(WINDOWSONWORKSPACE, from, to) != WINDOWSONWORKSPACE)
|
|
|
|
return false;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
Debug::log(LOG, "Invalid selector {}", selector);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
UNREACHABLE();
|
|
|
|
return false;
|
2024-03-20 03:33:39 +01:00
|
|
|
}
|
2024-04-02 21:32:39 +02:00
|
|
|
|
|
|
|
void CWorkspace::markInert() {
|
2024-04-05 17:57:46 +02:00
|
|
|
m_bInert = true;
|
|
|
|
m_iID = WORKSPACE_INVALID;
|
|
|
|
m_iMonitorID = -1;
|
|
|
|
m_bVisible = false;
|
2024-04-02 21:32:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CWorkspace::inert() {
|
|
|
|
return m_bInert;
|
|
|
|
}
|