mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-14 11:35:46 -07:00
windows: add misc:initial_workspace_tracking
By default enabled, will track the initial opened workspace of a window spawned for 2 minutes or until it's moved to a different workspace. For example: you run a launcher and open an app on workspace 1, but quickly switch to workspace 2. The app will now open on workspace 1 regardless of your switch.
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "../render/decorations/CHyprBorderDecoration.hpp"
|
||||
#include "../config/ConfigValue.hpp"
|
||||
#include <any>
|
||||
#include "../managers/TokenManager.hpp"
|
||||
|
||||
CWindow::CWindow() {
|
||||
m_vRealPosition.create(g_pConfigManager->getAnimationPropertyConfig("windowsIn"), this, AVARDAMAGE_ENTIRE);
|
||||
@@ -384,6 +385,11 @@ void CWindow::moveToWorkspace(PHLWORKSPACE pWorkspace) {
|
||||
if (m_pWorkspace == pWorkspace)
|
||||
return;
|
||||
|
||||
if (!m_szInitialWorkspaceToken.empty()) {
|
||||
g_pTokenManager->removeToken(g_pTokenManager->getToken(m_szInitialWorkspaceToken));
|
||||
m_szInitialWorkspaceToken = "";
|
||||
}
|
||||
|
||||
static auto PCLOSEONLASTSPECIAL = CConfigValue<Hyprlang::INT>("misc:close_special_on_empty");
|
||||
|
||||
const auto OLDWORKSPACE = m_pWorkspace;
|
||||
@@ -1241,3 +1247,42 @@ int CWindow::workspaceID() {
|
||||
bool CWindow::onSpecialWorkspace() {
|
||||
return m_pWorkspace ? m_pWorkspace->m_bIsSpecialWorkspace : g_pCompositor->isWorkspaceSpecial(m_iLastWorkspace);
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, std::string> CWindow::getEnv() {
|
||||
|
||||
const auto PID = getPID();
|
||||
|
||||
if (PID <= 1)
|
||||
return {};
|
||||
|
||||
std::unordered_map<std::string, std::string> results;
|
||||
|
||||
//
|
||||
std::string environFile = "/proc/" + std::to_string(PID) + "/environ";
|
||||
std::ifstream ifs(environFile, std::ios::binary);
|
||||
|
||||
if (!ifs.good())
|
||||
return {};
|
||||
|
||||
std::vector<char> buffer;
|
||||
size_t needle = 0;
|
||||
buffer.resize(512, '\0');
|
||||
while (ifs.read(buffer.data() + needle, 512)) {
|
||||
buffer.resize(buffer.size() + 512, '\0');
|
||||
needle += 512;
|
||||
}
|
||||
|
||||
std::replace(buffer.begin(), buffer.end() - 1, '\0', '\n');
|
||||
|
||||
CVarList envs(std::string{buffer.data(), needle - 1}, 0, '\n', true);
|
||||
|
||||
for (auto& e : envs) {
|
||||
if (!e.contains('='))
|
||||
continue;
|
||||
|
||||
const auto EQ = e.find_first_of('=');
|
||||
results[e.substr(0, EQ)] = e.substr(EQ + 1);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
Reference in New Issue
Block a user