mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-07-26 01:31:54 -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:
@@ -3,8 +3,10 @@
|
||||
#include "debug/Log.hpp"
|
||||
#include "helpers/VarList.hpp"
|
||||
#include "../config/ConfigValue.hpp"
|
||||
#include "TokenManager.hpp"
|
||||
|
||||
#include <regex>
|
||||
#include <tuple>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
@@ -17,6 +19,23 @@
|
||||
#include <sys/consio.h>
|
||||
#endif
|
||||
|
||||
static std::vector<std::pair<std::string, std::string>> getHyprlandLaunchEnv() {
|
||||
static auto PINITIALWSTRACKING = CConfigValue<Hyprlang::INT>("misc:initial_workspace_tracking");
|
||||
|
||||
if (!*PINITIALWSTRACKING)
|
||||
return {};
|
||||
|
||||
const auto PMONITOR = g_pCompositor->m_pLastMonitor;
|
||||
if (!PMONITOR || !PMONITOR->activeWorkspace)
|
||||
return {};
|
||||
|
||||
std::vector<std::pair<std::string, std::string>> result;
|
||||
|
||||
result.push_back(std::make_pair<>("HL_INITIAL_WORKSPACE_TOKEN", g_pTokenManager->registerNewToken(PMONITOR->activeWorkspace->getConfigName(), std::chrono::minutes(2))));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
CKeybindManager::CKeybindManager() {
|
||||
// initialize all dispatchers
|
||||
|
||||
@@ -774,7 +793,9 @@ void CKeybindManager::spawn(std::string args) {
|
||||
uint64_t CKeybindManager::spawnRaw(std::string args) {
|
||||
Debug::log(LOG, "Executing {}", args);
|
||||
|
||||
int socket[2];
|
||||
const auto HLENV = getHyprlandLaunchEnv();
|
||||
|
||||
int socket[2];
|
||||
if (pipe(socket) != 0) {
|
||||
Debug::log(LOG, "Unable to create pipe for fork");
|
||||
}
|
||||
@@ -797,6 +818,9 @@ uint64_t CKeybindManager::spawnRaw(std::string args) {
|
||||
grandchild = fork();
|
||||
if (grandchild == 0) {
|
||||
// run in grandchild
|
||||
for (auto& e : HLENV) {
|
||||
setenv(e.first.c_str(), e.second.c_str(), 1);
|
||||
}
|
||||
close(socket[0]);
|
||||
close(socket[1]);
|
||||
execl("/bin/sh", "/bin/sh", "-c", args.c_str(), nullptr);
|
||||
|
Reference in New Issue
Block a user