mirror of
https://github.com/hyprwm/Hyprland
synced 2025-12-20 06:50:10 +01:00
desktop/history: init workspace + window history as desktop
This commit is contained in:
parent
e94934402c
commit
df20e24583
17 changed files with 293 additions and 182 deletions
|
|
@ -5,6 +5,8 @@
|
||||||
#include "debug/log/Logger.hpp"
|
#include "debug/log/Logger.hpp"
|
||||||
#include "desktop/DesktopTypes.hpp"
|
#include "desktop/DesktopTypes.hpp"
|
||||||
#include "desktop/state/FocusState.hpp"
|
#include "desktop/state/FocusState.hpp"
|
||||||
|
#include "desktop/history/WindowHistoryTracker.hpp"
|
||||||
|
#include "desktop/history/WorkspaceHistoryTracker.hpp"
|
||||||
#include "helpers/Splashes.hpp"
|
#include "helpers/Splashes.hpp"
|
||||||
#include "config/ConfigValue.hpp"
|
#include "config/ConfigValue.hpp"
|
||||||
#include "config/ConfigWatcher.hpp"
|
#include "config/ConfigWatcher.hpp"
|
||||||
|
|
@ -661,6 +663,11 @@ void CCompositor::initManagers(eManagersInitStage stage) {
|
||||||
|
|
||||||
Log::logger->log(Log::DEBUG, "Creating the SeatManager!");
|
Log::logger->log(Log::DEBUG, "Creating the SeatManager!");
|
||||||
g_pSeatManager = makeUnique<CSeatManager>();
|
g_pSeatManager = makeUnique<CSeatManager>();
|
||||||
|
|
||||||
|
// init focus state els
|
||||||
|
Desktop::History::windowTracker();
|
||||||
|
Desktop::History::workspaceTracker();
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case STAGE_LATE: {
|
case STAGE_LATE: {
|
||||||
Log::logger->log(Log::DEBUG, "Creating CHyprCtl");
|
Log::logger->log(Log::DEBUG, "Creating CHyprCtl");
|
||||||
|
|
@ -1447,16 +1454,14 @@ PHLWINDOW CCompositor::getWindowInDirection(const CBox& box, PHLWORKSPACE pWorks
|
||||||
|
|
||||||
// get idx
|
// get idx
|
||||||
int windowIDX = -1;
|
int windowIDX = -1;
|
||||||
const auto& HISTORY = Desktop::focusState()->windowHistory();
|
const auto& HISTORY = Desktop::History::windowTracker()->fullHistory();
|
||||||
for (size_t i = 0; i < HISTORY.size(); ++i) {
|
for (int64_t i = HISTORY.size() - 1; i > 0; --i) {
|
||||||
if (HISTORY[i] == w) {
|
if (HISTORY[i] == w) {
|
||||||
windowIDX = i;
|
windowIDX = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
windowIDX = Desktop::focusState()->windowHistory().size() - windowIDX;
|
|
||||||
|
|
||||||
if (windowIDX > leaderValue) {
|
if (windowIDX > leaderValue) {
|
||||||
leaderValue = windowIDX;
|
leaderValue = windowIDX;
|
||||||
leaderWindow = w;
|
leaderWindow = w;
|
||||||
|
|
@ -1560,10 +1565,9 @@ static PHLWINDOW getWeakWindowPred(Iterator cur, Iterator end, Iterator begin, c
|
||||||
PHLWINDOW CCompositor::getWindowCycleHist(PHLWINDOWREF cur, bool focusableOnly, std::optional<bool> floating, bool visible, bool next) {
|
PHLWINDOW CCompositor::getWindowCycleHist(PHLWINDOWREF cur, bool focusableOnly, std::optional<bool> floating, bool visible, bool next) {
|
||||||
const auto FINDER = [&](const PHLWINDOWREF& w) { return isWindowAvailableForCycle(cur, w, focusableOnly, floating, visible); };
|
const auto FINDER = [&](const PHLWINDOWREF& w) { return isWindowAvailableForCycle(cur, w, focusableOnly, floating, visible); };
|
||||||
// also m_vWindowFocusHistory has reverse order, so when it is next - we need to reverse again
|
// also m_vWindowFocusHistory has reverse order, so when it is next - we need to reverse again
|
||||||
return next ? getWeakWindowPred(std::ranges::find(Desktop::focusState()->windowHistory() | std::views::reverse, cur), Desktop::focusState()->windowHistory().rend(),
|
const auto& HISTORY = Desktop::History::windowTracker()->fullHistory();
|
||||||
Desktop::focusState()->windowHistory().rbegin(), FINDER) :
|
return next ? getWeakWindowPred(std::ranges::find(HISTORY, cur), HISTORY.end(), HISTORY.begin(), FINDER) :
|
||||||
getWeakWindowPred(std::ranges::find(Desktop::focusState()->windowHistory(), cur), Desktop::focusState()->windowHistory().end(),
|
getWeakWindowPred(std::ranges::find(HISTORY | std::views::reverse, cur), HISTORY.rend(), HISTORY.rbegin(), FINDER);
|
||||||
Desktop::focusState()->windowHistory().begin(), FINDER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PHLWINDOW CCompositor::getWindowCycle(PHLWINDOW cur, bool focusableOnly, std::optional<bool> floating, bool visible, bool prev) {
|
PHLWINDOW CCompositor::getWindowCycle(PHLWINDOW cur, bool focusableOnly, std::optional<bool> floating, bool visible, bool prev) {
|
||||||
|
|
@ -1808,9 +1812,6 @@ void CCompositor::swapActiveWorkspaces(PHLMONITOR pMonitorA, PHLMONITOR pMonitor
|
||||||
pMonitorA->m_activeWorkspace = PWORKSPACEB;
|
pMonitorA->m_activeWorkspace = PWORKSPACEB;
|
||||||
pMonitorB->m_activeWorkspace = PWORKSPACEA;
|
pMonitorB->m_activeWorkspace = PWORKSPACEA;
|
||||||
|
|
||||||
PWORKSPACEA->rememberPrevWorkspace(PWORKSPACEB);
|
|
||||||
PWORKSPACEB->rememberPrevWorkspace(PWORKSPACEA);
|
|
||||||
|
|
||||||
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(pMonitorA->m_id);
|
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(pMonitorA->m_id);
|
||||||
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(pMonitorB->m_id);
|
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(pMonitorB->m_id);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ using namespace Hyprutils::OS;
|
||||||
#include "helpers/MiscFunctions.hpp"
|
#include "helpers/MiscFunctions.hpp"
|
||||||
#include "../desktop/view/LayerSurface.hpp"
|
#include "../desktop/view/LayerSurface.hpp"
|
||||||
#include "../desktop/rule/Engine.hpp"
|
#include "../desktop/rule/Engine.hpp"
|
||||||
|
#include "../desktop/history/WindowHistoryTracker.hpp"
|
||||||
#include "../desktop/state/FocusState.hpp"
|
#include "../desktop/state/FocusState.hpp"
|
||||||
#include "../version.h"
|
#include "../version.h"
|
||||||
|
|
||||||
|
|
@ -354,9 +355,10 @@ static std::string getGroupedData(PHLWINDOW w, eHyprCtlOutputFormat format) {
|
||||||
|
|
||||||
std::string CHyprCtl::getWindowData(PHLWINDOW w, eHyprCtlOutputFormat format) {
|
std::string CHyprCtl::getWindowData(PHLWINDOW w, eHyprCtlOutputFormat format) {
|
||||||
auto getFocusHistoryID = [](PHLWINDOW wnd) -> int {
|
auto getFocusHistoryID = [](PHLWINDOW wnd) -> int {
|
||||||
for (size_t i = 0; i < Desktop::focusState()->windowHistory().size(); ++i) {
|
const auto& HISTORY = Desktop::History::windowTracker()->fullHistory();
|
||||||
if (Desktop::focusState()->windowHistory()[i].lock() == wnd)
|
for (size_t i = 0; i < HISTORY.size(); ++i) {
|
||||||
return i;
|
if (HISTORY[i].lock() == wnd)
|
||||||
|
return HISTORY.size() - i - 1; // reverse order for backwards compat
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -55,10 +55,6 @@ void CWorkspace::init(PHLWORKSPACE self) {
|
||||||
EMIT_HOOK_EVENT("createWorkspace", this);
|
EMIT_HOOK_EVENT("createWorkspace", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
SWorkspaceIDName CWorkspace::getPrevWorkspaceIDName() const {
|
|
||||||
return m_prevWorkspace;
|
|
||||||
}
|
|
||||||
|
|
||||||
CWorkspace::~CWorkspace() {
|
CWorkspace::~CWorkspace() {
|
||||||
Log::logger->log(Log::DEBUG, "Destroying workspace ID {}", m_id);
|
Log::logger->log(Log::DEBUG, "Destroying workspace ID {}", m_id);
|
||||||
|
|
||||||
|
|
@ -82,24 +78,6 @@ PHLWINDOW CWorkspace::getLastFocusedWindow() {
|
||||||
return m_lastFocusedWindow.lock();
|
return m_lastFocusedWindow.lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWorkspace::rememberPrevWorkspace(const PHLWORKSPACE& prev) {
|
|
||||||
if (!prev) {
|
|
||||||
m_prevWorkspace.id = -1;
|
|
||||||
m_prevWorkspace.name = "";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prev->m_id == m_id) {
|
|
||||||
Log::logger->log(Log::DEBUG, "Tried to set prev workspace to the same as current one");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_prevWorkspace.id = prev->m_id;
|
|
||||||
m_prevWorkspace.name = prev->m_name;
|
|
||||||
|
|
||||||
prev->m_monitor->addPrevWorkspaceID(prev->m_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string CWorkspace::getConfigName() {
|
std::string CWorkspace::getConfigName() {
|
||||||
if (m_isSpecialWorkspace) {
|
if (m_isSpecialWorkspace) {
|
||||||
return m_name;
|
return m_name;
|
||||||
|
|
|
||||||
|
|
@ -57,29 +57,27 @@ class CWorkspace {
|
||||||
bool m_wasCreatedEmpty = true;
|
bool m_wasCreatedEmpty = true;
|
||||||
|
|
||||||
// Inert: destroyed and invalid. If this is true, release the ptr you have.
|
// Inert: destroyed and invalid. If this is true, release the ptr you have.
|
||||||
bool inert();
|
bool inert();
|
||||||
MONITORID monitorID();
|
MONITORID monitorID();
|
||||||
PHLWINDOW getLastFocusedWindow();
|
PHLWINDOW getLastFocusedWindow();
|
||||||
void rememberPrevWorkspace(const PHLWORKSPACE& prevWorkspace);
|
std::string getConfigName();
|
||||||
std::string getConfigName();
|
bool matchesStaticSelector(const std::string& selector);
|
||||||
bool matchesStaticSelector(const std::string& selector);
|
void markInert();
|
||||||
void markInert();
|
void updateWindowDecos();
|
||||||
SWorkspaceIDName getPrevWorkspaceIDName() const;
|
void updateWindowData();
|
||||||
void updateWindowDecos();
|
int getWindows(std::optional<bool> onlyTiled = {}, std::optional<bool> onlyPinned = {}, std::optional<bool> onlyVisible = {});
|
||||||
void updateWindowData();
|
int getGroups(std::optional<bool> onlyTiled = {}, std::optional<bool> onlyPinned = {}, std::optional<bool> onlyVisible = {});
|
||||||
int getWindows(std::optional<bool> onlyTiled = {}, std::optional<bool> onlyPinned = {}, std::optional<bool> onlyVisible = {});
|
bool hasUrgentWindow();
|
||||||
int getGroups(std::optional<bool> onlyTiled = {}, std::optional<bool> onlyPinned = {}, std::optional<bool> onlyVisible = {});
|
PHLWINDOW getFirstWindow();
|
||||||
bool hasUrgentWindow();
|
PHLWINDOW getTopLeftWindow();
|
||||||
PHLWINDOW getFirstWindow();
|
PHLWINDOW getFullscreenWindow();
|
||||||
PHLWINDOW getTopLeftWindow();
|
bool isVisible();
|
||||||
PHLWINDOW getFullscreenWindow();
|
bool isVisibleNotCovered();
|
||||||
bool isVisible();
|
void rename(const std::string& name = "");
|
||||||
bool isVisibleNotCovered();
|
void forceReportSizesToWindows();
|
||||||
void rename(const std::string& name = "");
|
void updateWindows();
|
||||||
void forceReportSizesToWindows();
|
void setPersistent(bool persistent);
|
||||||
void updateWindows();
|
bool isPersistent();
|
||||||
void setPersistent(bool persistent);
|
|
||||||
bool isPersistent();
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
CSignalT<> destroy;
|
CSignalT<> destroy;
|
||||||
|
|
@ -89,10 +87,7 @@ class CWorkspace {
|
||||||
} m_events;
|
} m_events;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init(PHLWORKSPACE self);
|
void init(PHLWORKSPACE self);
|
||||||
// Previous workspace ID and name is stored during a workspace change, allowing travel
|
|
||||||
// to the previous workspace.
|
|
||||||
SWorkspaceIDName m_prevWorkspace;
|
|
||||||
|
|
||||||
SP<HOOK_CALLBACK_FN> m_focusedWindowHook;
|
SP<HOOK_CALLBACK_FN> m_focusedWindowHook;
|
||||||
bool m_inert = true;
|
bool m_inert = true;
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,13 @@
|
||||||
using namespace Desktop;
|
using namespace Desktop;
|
||||||
using namespace Desktop::History;
|
using namespace Desktop::History;
|
||||||
|
|
||||||
|
SP<CWindowHistoryTracker> History::windowTracker() {
|
||||||
|
static SP<CWindowHistoryTracker> tracker = makeShared<CWindowHistoryTracker>();
|
||||||
|
return tracker;
|
||||||
|
}
|
||||||
|
|
||||||
CWindowHistoryTracker::CWindowHistoryTracker() {
|
CWindowHistoryTracker::CWindowHistoryTracker() {
|
||||||
static auto P2 = g_pHookSystem->hookDynamic("activeWindow", [this](void* self, SCallbackInfo& info, std::any data) {
|
static auto P = g_pHookSystem->hookDynamic("activeWindow", [this](void* self, SCallbackInfo& info, std::any data) {
|
||||||
auto window = std::any_cast<PHLWINDOW>(data);
|
auto window = std::any_cast<PHLWINDOW>(data);
|
||||||
|
|
||||||
track(window);
|
track(window);
|
||||||
|
|
|
||||||
|
|
@ -23,4 +23,6 @@ namespace Desktop::History {
|
||||||
void track(PHLWINDOW w);
|
void track(PHLWINDOW w);
|
||||||
void gc();
|
void gc();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SP<CWindowHistoryTracker> windowTracker();
|
||||||
};
|
};
|
||||||
158
src/desktop/history/WorkspaceHistoryTracker.cpp
Normal file
158
src/desktop/history/WorkspaceHistoryTracker.cpp
Normal file
|
|
@ -0,0 +1,158 @@
|
||||||
|
#include "WorkspaceHistoryTracker.hpp"
|
||||||
|
|
||||||
|
#include "../../helpers/Monitor.hpp"
|
||||||
|
#include "../Workspace.hpp"
|
||||||
|
#include "../../managers/HookSystemManager.hpp"
|
||||||
|
#include "../../config/ConfigValue.hpp"
|
||||||
|
|
||||||
|
using namespace Desktop;
|
||||||
|
using namespace Desktop::History;
|
||||||
|
|
||||||
|
SP<CWorkspaceHistoryTracker> History::workspaceTracker() {
|
||||||
|
static SP<CWorkspaceHistoryTracker> tracker = makeShared<CWorkspaceHistoryTracker>();
|
||||||
|
return tracker;
|
||||||
|
}
|
||||||
|
|
||||||
|
CWorkspaceHistoryTracker::CWorkspaceHistoryTracker() {
|
||||||
|
static auto P = g_pHookSystem->hookDynamic("workspace", [this](void* self, SCallbackInfo& info, std::any data) {
|
||||||
|
auto workspace = std::any_cast<PHLWORKSPACE>(data);
|
||||||
|
track(workspace);
|
||||||
|
});
|
||||||
|
|
||||||
|
static auto P1 = g_pHookSystem->hookDynamic("monitorAdded", [this](void* self, SCallbackInfo& info, std::any data) {
|
||||||
|
auto mon = std::any_cast<PHLMONITOR>(data);
|
||||||
|
track(mon);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
CWorkspaceHistoryTracker::SMonitorData& CWorkspaceHistoryTracker::dataFor(PHLMONITOR mon) {
|
||||||
|
for (auto& ref : m_monitorDatas) {
|
||||||
|
if (ref.monitor != mon)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
return ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_monitorDatas.emplace_back(SMonitorData{
|
||||||
|
.monitor = mon,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
CWorkspaceHistoryTracker::SWorkspacePreviousData& CWorkspaceHistoryTracker::dataFor(PHLWORKSPACE ws) {
|
||||||
|
for (auto& ref : m_datas) {
|
||||||
|
if (ref.workspace != ws)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
return ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_datas.emplace_back(SWorkspacePreviousData{
|
||||||
|
.workspace = ws,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void CWorkspaceHistoryTracker::track(PHLWORKSPACE w) {
|
||||||
|
if (!w->m_monitor)
|
||||||
|
return;
|
||||||
|
|
||||||
|
static auto PALLOWWORKSPACECYCLES = CConfigValue<Hyprlang::INT>("binds:allow_workspace_cycles");
|
||||||
|
|
||||||
|
auto& data = dataFor(w);
|
||||||
|
auto& monData = dataFor(w->m_monitor.lock());
|
||||||
|
|
||||||
|
if (!monData.workspace) {
|
||||||
|
data.previous.reset();
|
||||||
|
data.previousID = WORKSPACE_INVALID;
|
||||||
|
data.previousName = "";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (monData.workspace == w && !*PALLOWWORKSPACECYCLES) {
|
||||||
|
track(w->m_monitor.lock());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
data.previous = monData.workspace;
|
||||||
|
data.previousName = monData.workspace->m_name;
|
||||||
|
data.previousID = monData.workspace->m_id;
|
||||||
|
data.previousMon = monData.workspace->m_monitor;
|
||||||
|
|
||||||
|
track(w->m_monitor.lock());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CWorkspaceHistoryTracker::track(PHLMONITOR mon) {
|
||||||
|
auto& data = dataFor(mon);
|
||||||
|
data.workspace = mon->m_activeWorkspace;
|
||||||
|
data.workspaceName = mon->m_activeWorkspace ? mon->m_activeWorkspace->m_name : "";
|
||||||
|
data.workspaceID = mon->activeWorkspaceID();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CWorkspaceHistoryTracker::gc() {
|
||||||
|
std::erase_if(m_datas, [](const auto& e) { return !e.workspace; });
|
||||||
|
std::erase_if(m_monitorDatas, [](const auto& e) { return !e.monitor; });
|
||||||
|
}
|
||||||
|
|
||||||
|
const CWorkspaceHistoryTracker::SWorkspacePreviousData* CWorkspaceHistoryTracker::previousWorkspace(PHLWORKSPACE ws) {
|
||||||
|
gc();
|
||||||
|
|
||||||
|
for (const auto& d : m_datas) {
|
||||||
|
if (d.workspace != ws)
|
||||||
|
continue;
|
||||||
|
return &d;
|
||||||
|
}
|
||||||
|
|
||||||
|
return &dataFor(ws);
|
||||||
|
}
|
||||||
|
|
||||||
|
SWorkspaceIDName CWorkspaceHistoryTracker::previousWorkspaceIDName(PHLWORKSPACE ws) {
|
||||||
|
gc();
|
||||||
|
|
||||||
|
for (const auto& d : m_datas) {
|
||||||
|
if (d.workspace != ws)
|
||||||
|
continue;
|
||||||
|
return SWorkspaceIDName{.id = d.previousID, .name = d.previousName, .isAutoIDd = d.previousID <= 0};
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& d = dataFor(ws);
|
||||||
|
return SWorkspaceIDName{.id = d.previousID, .name = d.previousName, .isAutoIDd = d.previousID <= 0};
|
||||||
|
}
|
||||||
|
|
||||||
|
const CWorkspaceHistoryTracker::SWorkspacePreviousData* CWorkspaceHistoryTracker::previousWorkspace(PHLWORKSPACE ws, PHLMONITOR restrict) {
|
||||||
|
if (!restrict)
|
||||||
|
return previousWorkspace(ws);
|
||||||
|
|
||||||
|
auto& data = dataFor(ws);
|
||||||
|
while (true) {
|
||||||
|
|
||||||
|
// case 1: previous exists
|
||||||
|
if (data.previous) {
|
||||||
|
if (data.previous->m_monitor != restrict) {
|
||||||
|
data = dataFor(data.previous.lock());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// case 2: previous doesnt exist, but we have mon
|
||||||
|
if (data.previousMon) {
|
||||||
|
if (data.previousMon != restrict)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// case 3: no mon and no previous
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return &data;
|
||||||
|
}
|
||||||
|
|
||||||
|
SWorkspaceIDName CWorkspaceHistoryTracker::previousWorkspaceIDName(PHLWORKSPACE ws, PHLMONITOR restrict) {
|
||||||
|
const auto DATA = previousWorkspace(ws, restrict);
|
||||||
|
if (!DATA)
|
||||||
|
return SWorkspaceIDName{.id = WORKSPACE_INVALID};
|
||||||
|
|
||||||
|
return SWorkspaceIDName{.id = DATA->previousID, .name = DATA->previousName, .isAutoIDd = DATA->previousID <= 0};
|
||||||
|
}
|
||||||
52
src/desktop/history/WorkspaceHistoryTracker.hpp
Normal file
52
src/desktop/history/WorkspaceHistoryTracker.hpp
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../DesktopTypes.hpp"
|
||||||
|
#include "../../SharedDefs.hpp"
|
||||||
|
#include "../../macros.hpp"
|
||||||
|
#include "../../helpers/MiscFunctions.hpp"
|
||||||
|
|
||||||
|
namespace Desktop::History {
|
||||||
|
class CWorkspaceHistoryTracker {
|
||||||
|
public:
|
||||||
|
CWorkspaceHistoryTracker();
|
||||||
|
~CWorkspaceHistoryTracker() = default;
|
||||||
|
|
||||||
|
CWorkspaceHistoryTracker(const CWorkspaceHistoryTracker&) = delete;
|
||||||
|
CWorkspaceHistoryTracker(CWorkspaceHistoryTracker&) = delete;
|
||||||
|
CWorkspaceHistoryTracker(CWorkspaceHistoryTracker&&) = delete;
|
||||||
|
|
||||||
|
struct SWorkspacePreviousData {
|
||||||
|
PHLWORKSPACEREF workspace;
|
||||||
|
PHLWORKSPACEREF previous;
|
||||||
|
PHLMONITORREF previousMon;
|
||||||
|
std::string previousName = "";
|
||||||
|
WORKSPACEID previousID = WORKSPACE_INVALID;
|
||||||
|
};
|
||||||
|
|
||||||
|
const SWorkspacePreviousData* previousWorkspace(PHLWORKSPACE ws);
|
||||||
|
SWorkspaceIDName previousWorkspaceIDName(PHLWORKSPACE ws);
|
||||||
|
|
||||||
|
const SWorkspacePreviousData* previousWorkspace(PHLWORKSPACE ws, PHLMONITOR restrict);
|
||||||
|
SWorkspaceIDName previousWorkspaceIDName(PHLWORKSPACE ws, PHLMONITOR restrict);
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct SMonitorData {
|
||||||
|
PHLMONITORREF monitor;
|
||||||
|
PHLWORKSPACEREF workspace;
|
||||||
|
std::string workspaceName = "";
|
||||||
|
WORKSPACEID workspaceID = WORKSPACE_INVALID;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<SWorkspacePreviousData> m_datas;
|
||||||
|
std::vector<SMonitorData> m_monitorDatas;
|
||||||
|
|
||||||
|
void track(PHLWORKSPACE w);
|
||||||
|
void track(PHLMONITOR mon);
|
||||||
|
void gc();
|
||||||
|
|
||||||
|
SMonitorData& dataFor(PHLMONITOR mon);
|
||||||
|
SWorkspacePreviousData& dataFor(PHLWORKSPACE ws);
|
||||||
|
};
|
||||||
|
|
||||||
|
SP<CWorkspaceHistoryTracker> workspaceTracker();
|
||||||
|
};
|
||||||
|
|
@ -16,19 +16,7 @@ SP<CFocusState> Desktop::focusState() {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
Desktop::CFocusState::CFocusState() {
|
Desktop::CFocusState::CFocusState() = default;
|
||||||
m_windowOpen = g_pHookSystem->hookDynamic("openWindowEarly", [this](void* self, SCallbackInfo& info, std::any data) {
|
|
||||||
auto window = std::any_cast<PHLWINDOW>(data);
|
|
||||||
|
|
||||||
addWindowToHistory(window);
|
|
||||||
});
|
|
||||||
|
|
||||||
m_windowClose = g_pHookSystem->hookDynamic("closeWindow", [this](void* self, SCallbackInfo& info, std::any data) {
|
|
||||||
auto window = std::any_cast<PHLWINDOW>(data);
|
|
||||||
|
|
||||||
removeWindowFromHistory(window);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
struct SFullscreenWorkspaceFocusResult {
|
struct SFullscreenWorkspaceFocusResult {
|
||||||
PHLWINDOW overrideFocusWindow = nullptr;
|
PHLWINDOW overrideFocusWindow = nullptr;
|
||||||
|
|
@ -73,7 +61,7 @@ static SFullscreenWorkspaceFocusResult onFullscreenWorkspaceFocusWindow(PHLWINDO
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFocusState::fullWindowFocus(PHLWINDOW pWindow, SP<CWLSurfaceResource> surface, bool preserveFocusHistory, bool forceFSCycle) {
|
void CFocusState::fullWindowFocus(PHLWINDOW pWindow, SP<CWLSurfaceResource> surface, bool forceFSCycle) {
|
||||||
if (pWindow) {
|
if (pWindow) {
|
||||||
if (!pWindow->m_workspace)
|
if (!pWindow->m_workspace)
|
||||||
return;
|
return;
|
||||||
|
|
@ -93,10 +81,10 @@ void CFocusState::fullWindowFocus(PHLWINDOW pWindow, SP<CWLSurfaceResource> surf
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
rawWindowFocus(pWindow, surface, preserveFocusHistory);
|
rawWindowFocus(pWindow, surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFocusState::rawWindowFocus(PHLWINDOW pWindow, SP<CWLSurfaceResource> surface, bool preserveFocusHistory) {
|
void CFocusState::rawWindowFocus(PHLWINDOW pWindow, SP<CWLSurfaceResource> surface) {
|
||||||
static auto PFOLLOWMOUSE = CConfigValue<Hyprlang::INT>("input:follow_mouse");
|
static auto PFOLLOWMOUSE = CConfigValue<Hyprlang::INT>("input:follow_mouse");
|
||||||
static auto PSPECIALFALLTHROUGH = CConfigValue<Hyprlang::INT>("input:special_fallthrough");
|
static auto PSPECIALFALLTHROUGH = CConfigValue<Hyprlang::INT>("input:special_fallthrough");
|
||||||
|
|
||||||
|
|
@ -164,8 +152,6 @@ void CFocusState::rawWindowFocus(PHLWINDOW pWindow, SP<CWLSurfaceResource> surfa
|
||||||
const auto PWORKSPACE = pWindow->m_workspace;
|
const auto PWORKSPACE = pWindow->m_workspace;
|
||||||
// This is to fix incorrect feedback on the focus history.
|
// This is to fix incorrect feedback on the focus history.
|
||||||
PWORKSPACE->m_lastFocusedWindow = pWindow;
|
PWORKSPACE->m_lastFocusedWindow = pWindow;
|
||||||
if (m_focusMonitor->m_activeWorkspace)
|
|
||||||
PWORKSPACE->rememberPrevWorkspace(m_focusMonitor->m_activeWorkspace);
|
|
||||||
if (PWORKSPACE->m_isSpecialWorkspace)
|
if (PWORKSPACE->m_isSpecialWorkspace)
|
||||||
m_focusMonitor->changeWorkspace(PWORKSPACE, false, true); // if special ws, open on current monitor
|
m_focusMonitor->changeWorkspace(PWORKSPACE, false, true); // if special ws, open on current monitor
|
||||||
else if (PMONITOR)
|
else if (PMONITOR)
|
||||||
|
|
@ -214,11 +200,6 @@ void CFocusState::rawWindowFocus(PHLWINDOW pWindow, SP<CWLSurfaceResource> surfa
|
||||||
|
|
||||||
g_pInputManager->recheckIdleInhibitorStatus();
|
g_pInputManager->recheckIdleInhibitorStatus();
|
||||||
|
|
||||||
if (!preserveFocusHistory) {
|
|
||||||
// move to front of the window history
|
|
||||||
moveWindowToLatestInHistory(pWindow);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*PFOLLOWMOUSE == 0)
|
if (*PFOLLOWMOUSE == 0)
|
||||||
g_pInputManager->sendMotionEventsToFocused();
|
g_pInputManager->sendMotionEventsToFocused();
|
||||||
|
|
||||||
|
|
@ -308,23 +289,3 @@ PHLWINDOW CFocusState::window() {
|
||||||
PHLMONITOR CFocusState::monitor() {
|
PHLMONITOR CFocusState::monitor() {
|
||||||
return m_focusMonitor.lock();
|
return m_focusMonitor.lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<PHLWINDOWREF>& CFocusState::windowHistory() {
|
|
||||||
return m_windowFocusHistory;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CFocusState::removeWindowFromHistory(PHLWINDOW w) {
|
|
||||||
std::erase_if(m_windowFocusHistory, [&w](const auto& e) { return !e || e == w; });
|
|
||||||
}
|
|
||||||
|
|
||||||
void CFocusState::addWindowToHistory(PHLWINDOW w) {
|
|
||||||
m_windowFocusHistory.emplace_back(w);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CFocusState::moveWindowToLatestInHistory(PHLWINDOW w) {
|
|
||||||
const auto HISTORYPIVOT = std::ranges::find_if(m_windowFocusHistory, [&w](const auto& other) { return other.lock() == w; });
|
|
||||||
if (HISTORYPIVOT == m_windowFocusHistory.end())
|
|
||||||
Log::logger->log(Log::TRACE, "CFocusState: {} has no pivot in history, ignoring request to move to latest", w);
|
|
||||||
else
|
|
||||||
std::rotate(m_windowFocusHistory.begin(), HISTORYPIVOT, HISTORYPIVOT + 1);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -15,28 +15,21 @@ namespace Desktop {
|
||||||
CFocusState(CFocusState&) = delete;
|
CFocusState(CFocusState&) = delete;
|
||||||
CFocusState(const CFocusState&) = delete;
|
CFocusState(const CFocusState&) = delete;
|
||||||
|
|
||||||
void fullWindowFocus(PHLWINDOW w, SP<CWLSurfaceResource> surface = nullptr, bool preserveFocusHistory = false, bool forceFSCycle = false);
|
void fullWindowFocus(PHLWINDOW w, SP<CWLSurfaceResource> surface = nullptr, bool forceFSCycle = false);
|
||||||
void rawWindowFocus(PHLWINDOW w, SP<CWLSurfaceResource> surface = nullptr, bool preserveFocusHistory = false);
|
void rawWindowFocus(PHLWINDOW w, SP<CWLSurfaceResource> surface = nullptr);
|
||||||
void rawSurfaceFocus(SP<CWLSurfaceResource> s, PHLWINDOW pWindowOwner = nullptr);
|
void rawSurfaceFocus(SP<CWLSurfaceResource> s, PHLWINDOW pWindowOwner = nullptr);
|
||||||
void rawMonitorFocus(PHLMONITOR m);
|
void rawMonitorFocus(PHLMONITOR m);
|
||||||
|
|
||||||
SP<CWLSurfaceResource> surface();
|
SP<CWLSurfaceResource> surface();
|
||||||
PHLWINDOW window();
|
PHLWINDOW window();
|
||||||
PHLMONITOR monitor();
|
PHLMONITOR monitor();
|
||||||
const std::vector<PHLWINDOWREF>& windowHistory();
|
|
||||||
|
|
||||||
void addWindowToHistory(PHLWINDOW w);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void removeWindowFromHistory(PHLWINDOW w);
|
WP<CWLSurfaceResource> m_focusSurface;
|
||||||
void moveWindowToLatestInHistory(PHLWINDOW w);
|
PHLWINDOWREF m_focusWindow;
|
||||||
|
PHLMONITORREF m_focusMonitor;
|
||||||
|
|
||||||
WP<CWLSurfaceResource> m_focusSurface;
|
SP<HOOK_CALLBACK_FN> m_windowOpen, m_windowClose;
|
||||||
PHLWINDOWREF m_focusWindow;
|
|
||||||
PHLMONITORREF m_focusMonitor;
|
|
||||||
std::vector<PHLWINDOWREF> m_windowFocusHistory; // first element is the most recently focused
|
|
||||||
|
|
||||||
SP<HOOK_CALLBACK_FN> m_windowOpen, m_windowClose;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SP<CFocusState> focusState();
|
SP<CFocusState> focusState();
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
#include "Window.hpp"
|
#include "Window.hpp"
|
||||||
#include "LayerSurface.hpp"
|
#include "LayerSurface.hpp"
|
||||||
#include "../state/FocusState.hpp"
|
#include "../state/FocusState.hpp"
|
||||||
|
#include "../history/WindowHistoryTracker.hpp"
|
||||||
#include "../../Compositor.hpp"
|
#include "../../Compositor.hpp"
|
||||||
#include "../../render/decorations/CHyprDropShadowDecoration.hpp"
|
#include "../../render/decorations/CHyprDropShadowDecoration.hpp"
|
||||||
#include "../../render/decorations/CHyprGroupBarDecoration.hpp"
|
#include "../../render/decorations/CHyprGroupBarDecoration.hpp"
|
||||||
|
|
@ -1553,7 +1554,7 @@ PHLWINDOW CWindow::getSwallower() {
|
||||||
return candidates[0];
|
return candidates[0];
|
||||||
|
|
||||||
// walk up the focus history and find the last focused
|
// walk up the focus history and find the last focused
|
||||||
for (auto const& w : Desktop::focusState()->windowHistory()) {
|
for (auto const& w : Desktop::History::windowTracker()->fullHistory() | std::views::reverse) {
|
||||||
if (!w)
|
if (!w)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include "../Compositor.hpp"
|
#include "../Compositor.hpp"
|
||||||
#include "../managers/TokenManager.hpp"
|
#include "../managers/TokenManager.hpp"
|
||||||
#include "../desktop/state/FocusState.hpp"
|
#include "../desktop/state/FocusState.hpp"
|
||||||
|
#include "../desktop/history/WorkspaceHistoryTracker.hpp"
|
||||||
#include "Monitor.hpp"
|
#include "Monitor.hpp"
|
||||||
#include "../config/ConfigManager.hpp"
|
#include "../config/ConfigManager.hpp"
|
||||||
#include "fs/FsUtils.hpp"
|
#include "fs/FsUtils.hpp"
|
||||||
|
|
@ -179,7 +180,7 @@ SWorkspaceIDName getWorkspaceIDNameFromString(const std::string& in) {
|
||||||
if (!valid(PWORKSPACE))
|
if (!valid(PWORKSPACE))
|
||||||
return {WORKSPACE_INVALID};
|
return {WORKSPACE_INVALID};
|
||||||
|
|
||||||
const auto PREVWORKSPACEIDNAME = PWORKSPACE->getPrevWorkspaceIDName();
|
const auto PREVWORKSPACEIDNAME = Desktop::History::workspaceTracker()->previousWorkspaceIDName(PWORKSPACE);
|
||||||
|
|
||||||
if (PREVWORKSPACEIDNAME.id == -1)
|
if (PREVWORKSPACEIDNAME.id == -1)
|
||||||
return {WORKSPACE_INVALID};
|
return {WORKSPACE_INVALID};
|
||||||
|
|
|
||||||
|
|
@ -1480,29 +1480,6 @@ void CMonitor::moveTo(const Vector2D& pos) {
|
||||||
m_position = pos;
|
m_position = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWorkspaceIDName CMonitor::getPrevWorkspaceIDName(const WORKSPACEID id) {
|
|
||||||
while (!m_prevWorkSpaces.empty()) {
|
|
||||||
const int PREVID = m_prevWorkSpaces.top();
|
|
||||||
m_prevWorkSpaces.pop();
|
|
||||||
if (PREVID == id) // skip same workspace
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// recheck if previous workspace's was moved to another monitor
|
|
||||||
const auto ws = g_pCompositor->getWorkspaceByID(PREVID);
|
|
||||||
if (ws && ws->monitorID() == m_id)
|
|
||||||
return {.id = PREVID, .name = ws->m_name};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {.id = WORKSPACE_INVALID};
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMonitor::addPrevWorkspaceID(const WORKSPACEID id) {
|
|
||||||
if (!m_prevWorkSpaces.empty() && m_prevWorkSpaces.top() == id)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_prevWorkSpaces.emplace(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2D CMonitor::middle() {
|
Vector2D CMonitor::middle() {
|
||||||
return m_position + m_size / 2.f;
|
return m_position + m_size / 2.f;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -351,10 +351,6 @@ class CMonitor {
|
||||||
return m_position == rhs.m_position && m_size == rhs.m_size && m_name == rhs.m_name;
|
return m_position == rhs.m_position && m_size == rhs.m_size && m_name == rhs.m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// workspace previous per monitor functionality
|
|
||||||
SWorkspaceIDName getPrevWorkspaceIDName(const WORKSPACEID id);
|
|
||||||
void addPrevWorkspaceID(const WORKSPACEID id);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupDefaultWS(const SMonitorRule&);
|
void setupDefaultWS(const SMonitorRule&);
|
||||||
WORKSPACEID findAvailableDefaultWS();
|
WORKSPACEID findAvailableDefaultWS();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
#include "../config/ConfigValue.hpp"
|
#include "../config/ConfigValue.hpp"
|
||||||
#include "../devices/IKeyboard.hpp"
|
#include "../devices/IKeyboard.hpp"
|
||||||
#include "../desktop/state/FocusState.hpp"
|
#include "../desktop/state/FocusState.hpp"
|
||||||
|
#include "../desktop/history/WindowHistoryTracker.hpp"
|
||||||
|
#include "../desktop/history/WorkspaceHistoryTracker.hpp"
|
||||||
#include "../managers/SeatManager.hpp"
|
#include "../managers/SeatManager.hpp"
|
||||||
#include "../protocols/LayerShell.hpp"
|
#include "../protocols/LayerShell.hpp"
|
||||||
#include "../protocols/ShortcutsInhibit.hpp"
|
#include "../protocols/ShortcutsInhibit.hpp"
|
||||||
|
|
@ -360,7 +362,6 @@ bool CKeybindManager::tryMoveFocusToMonitor(PHLMONITOR monitor) {
|
||||||
const auto PNEWMAINWORKSPACE = monitor->m_activeWorkspace;
|
const auto PNEWMAINWORKSPACE = monitor->m_activeWorkspace;
|
||||||
|
|
||||||
g_pInputManager->unconstrainMouse();
|
g_pInputManager->unconstrainMouse();
|
||||||
PNEWMAINWORKSPACE->rememberPrevWorkspace(PWORKSPACE);
|
|
||||||
|
|
||||||
const auto PNEWWORKSPACE = monitor->m_activeSpecialWorkspace ? monitor->m_activeSpecialWorkspace : PNEWMAINWORKSPACE;
|
const auto PNEWWORKSPACE = monitor->m_activeSpecialWorkspace ? monitor->m_activeSpecialWorkspace : PNEWMAINWORKSPACE;
|
||||||
|
|
||||||
|
|
@ -384,7 +385,7 @@ bool CKeybindManager::tryMoveFocusToMonitor(PHLMONITOR monitor) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKeybindManager::switchToWindow(PHLWINDOW PWINDOWTOCHANGETO, bool preserveFocusHistory, bool forceFSCycle) {
|
void CKeybindManager::switchToWindow(PHLWINDOW PWINDOWTOCHANGETO, bool forceFSCycle) {
|
||||||
static auto PFOLLOWMOUSE = CConfigValue<Hyprlang::INT>("input:follow_mouse");
|
static auto PFOLLOWMOUSE = CConfigValue<Hyprlang::INT>("input:follow_mouse");
|
||||||
static auto PNOWARPS = CConfigValue<Hyprlang::INT>("cursor:no_warps");
|
static auto PNOWARPS = CConfigValue<Hyprlang::INT>("cursor:no_warps");
|
||||||
|
|
||||||
|
|
@ -397,10 +398,10 @@ void CKeybindManager::switchToWindow(PHLWINDOW PWINDOWTOCHANGETO, bool preserveF
|
||||||
g_pInputManager->unconstrainMouse();
|
g_pInputManager->unconstrainMouse();
|
||||||
|
|
||||||
if (PLASTWINDOW && PLASTWINDOW->m_workspace == PWINDOWTOCHANGETO->m_workspace && PLASTWINDOW->isFullscreen())
|
if (PLASTWINDOW && PLASTWINDOW->m_workspace == PWINDOWTOCHANGETO->m_workspace && PLASTWINDOW->isFullscreen())
|
||||||
Desktop::focusState()->fullWindowFocus(PWINDOWTOCHANGETO, nullptr, preserveFocusHistory, forceFSCycle);
|
Desktop::focusState()->fullWindowFocus(PWINDOWTOCHANGETO, nullptr, forceFSCycle);
|
||||||
else {
|
else {
|
||||||
updateRelativeCursorCoords();
|
updateRelativeCursorCoords();
|
||||||
Desktop::focusState()->fullWindowFocus(PWINDOWTOCHANGETO, nullptr, preserveFocusHistory, forceFSCycle);
|
Desktop::focusState()->fullWindowFocus(PWINDOWTOCHANGETO, nullptr, forceFSCycle);
|
||||||
PWINDOWTOCHANGETO->warpCursor();
|
PWINDOWTOCHANGETO->warpCursor();
|
||||||
|
|
||||||
// Move mouse focus to the new window if required by current follow_mouse and warp modes
|
// Move mouse focus to the new window if required by current follow_mouse and warp modes
|
||||||
|
|
@ -1187,7 +1188,8 @@ static SWorkspaceIDName getWorkspaceToChangeFromArgs(std::string args, PHLWORKSP
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool PER_MON = args.contains("_per_monitor");
|
const bool PER_MON = args.contains("_per_monitor");
|
||||||
const SWorkspaceIDName PPREVWS = PER_MON ? PMONITOR->getPrevWorkspaceIDName(PCURRENTWORKSPACE->m_id) : PCURRENTWORKSPACE->getPrevWorkspaceIDName();
|
const SWorkspaceIDName PPREVWS = PER_MON ? Desktop::History::workspaceTracker()->previousWorkspaceIDName(PCURRENTWORKSPACE, PMONITOR.lock()) :
|
||||||
|
Desktop::History::workspaceTracker()->previousWorkspaceIDName(PCURRENTWORKSPACE);
|
||||||
// Do nothing if there's no previous workspace, otherwise switch to it.
|
// Do nothing if there's no previous workspace, otherwise switch to it.
|
||||||
if (PPREVWS.id == -1 || PPREVWS.id == PCURRENTWORKSPACE->m_id) {
|
if (PPREVWS.id == -1 || PPREVWS.id == PCURRENTWORKSPACE->m_id) {
|
||||||
Log::logger->log(Log::DEBUG, "No previous workspace to change to");
|
Log::logger->log(Log::DEBUG, "No previous workspace to change to");
|
||||||
|
|
@ -1205,7 +1207,6 @@ SDispatchResult CKeybindManager::changeworkspace(std::string args) {
|
||||||
// Workspace_back_and_forth being enabled means that an attempt to switch to
|
// Workspace_back_and_forth being enabled means that an attempt to switch to
|
||||||
// the current workspace will instead switch to the previous.
|
// the current workspace will instead switch to the previous.
|
||||||
static auto PBACKANDFORTH = CConfigValue<Hyprlang::INT>("binds:workspace_back_and_forth");
|
static auto PBACKANDFORTH = CConfigValue<Hyprlang::INT>("binds:workspace_back_and_forth");
|
||||||
static auto PALLOWWORKSPACECYCLES = CConfigValue<Hyprlang::INT>("binds:allow_workspace_cycles");
|
|
||||||
static auto PWORKSPACECENTERON = CConfigValue<Hyprlang::INT>("binds:workspace_center_on");
|
static auto PWORKSPACECENTERON = CConfigValue<Hyprlang::INT>("binds:workspace_center_on");
|
||||||
static auto PHIDESPECIALONWORKSPACECHANGE = CConfigValue<Hyprlang::INT>("binds:hide_special_on_workspace_change");
|
static auto PHIDESPECIALONWORKSPACECHANGE = CConfigValue<Hyprlang::INT>("binds:hide_special_on_workspace_change");
|
||||||
|
|
||||||
|
|
@ -1226,7 +1227,8 @@ SDispatchResult CKeybindManager::changeworkspace(std::string args) {
|
||||||
if (workspaceToChangeTo == WORKSPACE_NOT_CHANGED)
|
if (workspaceToChangeTo == WORKSPACE_NOT_CHANGED)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
const SWorkspaceIDName PPREVWS = args.contains("_per_monitor") ? PMONITOR->getPrevWorkspaceIDName(PCURRENTWORKSPACE->m_id) : PCURRENTWORKSPACE->getPrevWorkspaceIDName();
|
const SWorkspaceIDName PPREVWS = args.contains("_per_monitor") ? Desktop::History::workspaceTracker()->previousWorkspaceIDName(PCURRENTWORKSPACE, PMONITOR) :
|
||||||
|
Desktop::History::workspaceTracker()->previousWorkspaceIDName(PCURRENTWORKSPACE);
|
||||||
|
|
||||||
const bool BISWORKSPACECURRENT = workspaceToChangeTo == PCURRENTWORKSPACE->m_id;
|
const bool BISWORKSPACECURRENT = workspaceToChangeTo == PCURRENTWORKSPACE->m_id;
|
||||||
if (BISWORKSPACECURRENT && (!(*PBACKANDFORTH || EXPLICITPREVIOUS) || PPREVWS.id == -1)) {
|
if (BISWORKSPACECURRENT && (!(*PBACKANDFORTH || EXPLICITPREVIOUS) || PPREVWS.id == -1)) {
|
||||||
|
|
@ -1261,14 +1263,6 @@ SDispatchResult CKeybindManager::changeworkspace(std::string args) {
|
||||||
|
|
||||||
Desktop::focusState()->rawMonitorFocus(PMONITORWORKSPACEOWNER);
|
Desktop::focusState()->rawMonitorFocus(PMONITORWORKSPACEOWNER);
|
||||||
|
|
||||||
if (BISWORKSPACECURRENT) {
|
|
||||||
if (*PALLOWWORKSPACECYCLES)
|
|
||||||
pWorkspaceToChangeTo->rememberPrevWorkspace(PCURRENTWORKSPACE);
|
|
||||||
else if (!EXPLICITPREVIOUS && !*PBACKANDFORTH)
|
|
||||||
pWorkspaceToChangeTo->rememberPrevWorkspace(nullptr);
|
|
||||||
} else
|
|
||||||
pWorkspaceToChangeTo->rememberPrevWorkspace(PCURRENTWORKSPACE);
|
|
||||||
|
|
||||||
if (*PHIDESPECIALONWORKSPACECHANGE)
|
if (*PHIDESPECIALONWORKSPACECHANGE)
|
||||||
PMONITORWORKSPACEOWNER->setSpecialWorkspace(nullptr);
|
PMONITORWORKSPACEOWNER->setSpecialWorkspace(nullptr);
|
||||||
PMONITORWORKSPACEOWNER->changeWorkspace(pWorkspaceToChangeTo, false, true);
|
PMONITORWORKSPACEOWNER->changeWorkspace(pWorkspaceToChangeTo, false, true);
|
||||||
|
|
@ -1419,8 +1413,6 @@ SDispatchResult CKeybindManager::moveActiveToWorkspace(std::string args) {
|
||||||
else if (POLDWS->m_isSpecialWorkspace)
|
else if (POLDWS->m_isSpecialWorkspace)
|
||||||
POLDWS->m_monitor.lock()->setSpecialWorkspace(nullptr);
|
POLDWS->m_monitor.lock()->setSpecialWorkspace(nullptr);
|
||||||
|
|
||||||
pWorkspace->rememberPrevWorkspace(POLDWS);
|
|
||||||
|
|
||||||
pMonitor->changeWorkspace(pWorkspace);
|
pMonitor->changeWorkspace(pWorkspace);
|
||||||
|
|
||||||
Desktop::focusState()->fullWindowFocus(PWINDOW);
|
Desktop::focusState()->fullWindowFocus(PWINDOW);
|
||||||
|
|
@ -1514,7 +1506,7 @@ SDispatchResult CKeybindManager::moveFocusTo(std::string args) {
|
||||||
|
|
||||||
// Found window in direction, switch to it
|
// Found window in direction, switch to it
|
||||||
if (PWINDOWTOCHANGETO) {
|
if (PWINDOWTOCHANGETO) {
|
||||||
switchToWindow(PWINDOWTOCHANGETO, false, *PFULLCYCLE && PLASTWINDOW->isFullscreen());
|
switchToWindow(PWINDOWTOCHANGETO, *PFULLCYCLE && PLASTWINDOW->isFullscreen());
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1571,9 +1563,9 @@ SDispatchResult CKeybindManager::moveFocusTo(std::string args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SDispatchResult CKeybindManager::focusUrgentOrLast(std::string args) {
|
SDispatchResult CKeybindManager::focusUrgentOrLast(std::string args) {
|
||||||
const auto PWINDOWURGENT = g_pCompositor->getUrgentWindow();
|
const auto& HISTORY = Desktop::History::windowTracker()->fullHistory();
|
||||||
const auto PWINDOWPREV = Desktop::focusState()->window() ? (Desktop::focusState()->windowHistory().size() < 2 ? nullptr : Desktop::focusState()->windowHistory()[1].lock()) :
|
const auto PWINDOWURGENT = g_pCompositor->getUrgentWindow();
|
||||||
(Desktop::focusState()->windowHistory().empty() ? nullptr : Desktop::focusState()->windowHistory()[0].lock());
|
const auto PWINDOWPREV = Desktop::focusState()->window() ? (HISTORY.size() < 2 ? nullptr : HISTORY[1].lock()) : (HISTORY.empty() ? nullptr : HISTORY[0].lock());
|
||||||
|
|
||||||
if (!PWINDOWURGENT && !PWINDOWPREV)
|
if (!PWINDOWURGENT && !PWINDOWPREV)
|
||||||
return {.success = false, .error = "Window not found"};
|
return {.success = false, .error = "Window not found"};
|
||||||
|
|
@ -1584,8 +1576,8 @@ SDispatchResult CKeybindManager::focusUrgentOrLast(std::string args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SDispatchResult CKeybindManager::focusCurrentOrLast(std::string args) {
|
SDispatchResult CKeybindManager::focusCurrentOrLast(std::string args) {
|
||||||
const auto PWINDOWPREV = Desktop::focusState()->window() ? (Desktop::focusState()->windowHistory().size() < 2 ? nullptr : Desktop::focusState()->windowHistory()[1].lock()) :
|
const auto& HISTORY = Desktop::History::windowTracker()->fullHistory();
|
||||||
(Desktop::focusState()->windowHistory().empty() ? nullptr : Desktop::focusState()->windowHistory()[0].lock());
|
const auto PWINDOWPREV = Desktop::focusState()->window() ? (HISTORY.size() < 2 ? nullptr : HISTORY[1].lock()) : (HISTORY.empty() ? nullptr : HISTORY[0].lock());
|
||||||
|
|
||||||
if (!PWINDOWPREV)
|
if (!PWINDOWPREV)
|
||||||
return {.success = false, .error = "Window not found"};
|
return {.success = false, .error = "Window not found"};
|
||||||
|
|
@ -2064,7 +2056,7 @@ SDispatchResult CKeybindManager::focusWorkspaceOnCurrentMonitor(std::string args
|
||||||
}
|
}
|
||||||
|
|
||||||
static auto PBACKANDFORTH = CConfigValue<Hyprlang::INT>("binds:workspace_back_and_forth");
|
static auto PBACKANDFORTH = CConfigValue<Hyprlang::INT>("binds:workspace_back_and_forth");
|
||||||
const auto PREVWS = pWorkspace->getPrevWorkspaceIDName();
|
const auto PREVWS = Desktop::History::workspaceTracker()->previousWorkspaceIDName(pWorkspace);
|
||||||
|
|
||||||
if (*PBACKANDFORTH && PCURRMONITOR->activeWorkspaceID() == workspaceID && PREVWS.id != -1) {
|
if (*PBACKANDFORTH && PCURRMONITOR->activeWorkspaceID() == workspaceID && PREVWS.id != -1) {
|
||||||
// Workspace to focus is previous workspace
|
// Workspace to focus is previous workspace
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,7 @@ class CKeybindManager {
|
||||||
static void moveWindowOutOfGroup(PHLWINDOW pWindow, const std::string& dir = "");
|
static void moveWindowOutOfGroup(PHLWINDOW pWindow, const std::string& dir = "");
|
||||||
static void moveWindowIntoGroup(PHLWINDOW pWindow, PHLWINDOW pWindowInDirection);
|
static void moveWindowIntoGroup(PHLWINDOW pWindow, PHLWINDOW pWindowInDirection);
|
||||||
|
|
||||||
static void switchToWindow(PHLWINDOW PWINDOWTOCHANGETO, bool preserveFocusHistory = false, bool forceFSCycle = false);
|
static void switchToWindow(PHLWINDOW PWINDOWTOCHANGETO, bool forceFSCycle = false);
|
||||||
static uint64_t spawnRawProc(std::string, PHLWORKSPACE pInitialWorkspace, const std::string& execRuleToken = "");
|
static uint64_t spawnRawProc(std::string, PHLWORKSPACE pInitialWorkspace, const std::string& execRuleToken = "");
|
||||||
static uint64_t spawnWithRules(std::string, PHLWORKSPACE pInitialWorkspace);
|
static uint64_t spawnWithRules(std::string, PHLWORKSPACE pInitialWorkspace);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -246,7 +246,6 @@ void CUnifiedWorkspaceSwipeGesture::end() {
|
||||||
else {
|
else {
|
||||||
m_monitor->changeWorkspace(g_pCompositor->createNewWorkspace(workspaceIDLeft, m_monitor->m_id));
|
m_monitor->changeWorkspace(g_pCompositor->createNewWorkspace(workspaceIDLeft, m_monitor->m_id));
|
||||||
PWORKSPACEL = g_pCompositor->getWorkspaceByID(workspaceIDLeft);
|
PWORKSPACEL = g_pCompositor->getWorkspaceByID(workspaceIDLeft);
|
||||||
PWORKSPACEL->rememberPrevWorkspace(m_workspaceBegin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PWORKSPACEL->m_renderOffset->setValue(RENDEROFFSET);
|
PWORKSPACEL->m_renderOffset->setValue(RENDEROFFSET);
|
||||||
|
|
@ -273,7 +272,6 @@ void CUnifiedWorkspaceSwipeGesture::end() {
|
||||||
else {
|
else {
|
||||||
m_monitor->changeWorkspace(g_pCompositor->createNewWorkspace(workspaceIDRight, m_monitor->m_id));
|
m_monitor->changeWorkspace(g_pCompositor->createNewWorkspace(workspaceIDRight, m_monitor->m_id));
|
||||||
PWORKSPACER = g_pCompositor->getWorkspaceByID(workspaceIDRight);
|
PWORKSPACER = g_pCompositor->getWorkspaceByID(workspaceIDRight);
|
||||||
PWORKSPACER->rememberPrevWorkspace(m_workspaceBegin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PWORKSPACER->m_renderOffset->setValue(RENDEROFFSET);
|
PWORKSPACER->m_renderOffset->setValue(RENDEROFFSET);
|
||||||
|
|
@ -292,7 +290,6 @@ void CUnifiedWorkspaceSwipeGesture::end() {
|
||||||
|
|
||||||
pSwitchedTo = PWORKSPACER;
|
pSwitchedTo = PWORKSPACER;
|
||||||
}
|
}
|
||||||
pSwitchedTo->rememberPrevWorkspace(m_workspaceBegin);
|
|
||||||
|
|
||||||
g_pHyprRenderer->damageMonitor(m_monitor.lock());
|
g_pHyprRenderer->damageMonitor(m_monitor.lock());
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue