mirror of
https://github.com/hyprwm/Hyprland.git
synced 2024-12-29 02:33:05 +03:00
internal: workspace rule handling refactor (#3116)
modified: src/events/Windows.cpp
This commit is contained in:
parent
d4ec54d048
commit
00bee91bbc
@ -111,8 +111,6 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
|||||||
bool requestsMaximize = false;
|
bool requestsMaximize = false;
|
||||||
bool overridingNoFullscreen = false;
|
bool overridingNoFullscreen = false;
|
||||||
bool overridingNoMaximize = false;
|
bool overridingNoMaximize = false;
|
||||||
bool shouldFocus = true;
|
|
||||||
bool workspaceSpecial = false;
|
|
||||||
|
|
||||||
PWINDOW->m_szInitialTitle = g_pXWaylandManager->getTitle(PWINDOW);
|
PWINDOW->m_szInitialTitle = g_pXWaylandManager->getTitle(PWINDOW);
|
||||||
PWINDOW->m_szInitialClass = g_pXWaylandManager->getAppIDClass(PWINDOW);
|
PWINDOW->m_szInitialClass = g_pXWaylandManager->getAppIDClass(PWINDOW);
|
||||||
@ -231,71 +229,33 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
|||||||
if (PWINDOW->m_bPinned && !PWINDOW->m_bIsFloating)
|
if (PWINDOW->m_bPinned && !PWINDOW->m_bIsFloating)
|
||||||
PWINDOW->m_bPinned = false;
|
PWINDOW->m_bPinned = false;
|
||||||
|
|
||||||
if (requestedWorkspace != "") {
|
const CVarList WORKSPACEARGS = CVarList(requestedWorkspace, 2, ' ');
|
||||||
// process requested workspace
|
|
||||||
if (requestedWorkspace.contains(' ')) {
|
if (!WORKSPACEARGS[0].empty()) {
|
||||||
// check for silent
|
std::string requestedWorkspaceName;
|
||||||
if (requestedWorkspace.contains("silent")) {
|
const int REQUESTEDWORKSPACEID = getWorkspaceIDFromString(WORKSPACEARGS[0], requestedWorkspaceName);
|
||||||
|
|
||||||
|
if (REQUESTEDWORKSPACEID != INT_MAX) {
|
||||||
|
|
||||||
|
if (WORKSPACEARGS[1].find("silent") == 0)
|
||||||
workspaceSilent = true;
|
workspaceSilent = true;
|
||||||
shouldFocus = false;
|
|
||||||
|
|
||||||
requestedWorkspace = requestedWorkspace.substr(0, requestedWorkspace.find_first_of(' '));
|
auto pWorkspace = g_pCompositor->getWorkspaceByID(REQUESTEDWORKSPACEID);
|
||||||
|
|
||||||
|
if (!pWorkspace)
|
||||||
|
pWorkspace = g_pCompositor->createNewWorkspace(REQUESTEDWORKSPACEID, PWINDOW->m_iMonitorID, requestedWorkspaceName);
|
||||||
|
|
||||||
|
PWINDOW->m_iWorkspaceID = pWorkspace->m_iID;
|
||||||
|
PWINDOW->m_iMonitorID = pWorkspace->m_iMonitorID;
|
||||||
|
|
||||||
|
if (!workspaceSilent) {
|
||||||
|
if (pWorkspace->m_bIsSpecialWorkspace)
|
||||||
|
g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID)->setSpecialWorkspace(pWorkspace);
|
||||||
|
else
|
||||||
|
g_pKeybindManager->m_mDispatchers["workspace"](requestedWorkspaceName);
|
||||||
|
|
||||||
|
PMONITOR = g_pCompositor->m_pLastMonitor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!shouldFocus && requestedWorkspace == std::to_string(PMONITOR->activeWorkspace))
|
|
||||||
shouldFocus = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (requestedWorkspace.find("special") == 0) {
|
|
||||||
workspaceSpecial = true;
|
|
||||||
workspaceSilent = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!workspaceSilent) {
|
|
||||||
g_pKeybindManager->m_mDispatchers["workspace"](requestedWorkspace);
|
|
||||||
|
|
||||||
PWINDOW->m_iMonitorID = g_pCompositor->m_pLastMonitor->ID;
|
|
||||||
PWINDOW->m_iWorkspaceID = g_pCompositor->m_pLastMonitor->activeWorkspace;
|
|
||||||
|
|
||||||
PMONITOR = g_pCompositor->m_pLastMonitor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (workspaceSilent) {
|
|
||||||
// get the workspace
|
|
||||||
|
|
||||||
auto PWORKSPACE = g_pCompositor->getWorkspaceByString(requestedWorkspace);
|
|
||||||
|
|
||||||
if (!PWORKSPACE) {
|
|
||||||
std::string workspaceName = "";
|
|
||||||
int workspaceID = 0;
|
|
||||||
|
|
||||||
if (requestedWorkspace.find("name:") == 0) {
|
|
||||||
workspaceName = requestedWorkspace.substr(5);
|
|
||||||
workspaceID = g_pCompositor->getNextAvailableNamedWorkspace();
|
|
||||||
} else if (workspaceSpecial) {
|
|
||||||
workspaceName = "";
|
|
||||||
workspaceID = getWorkspaceIDFromString(requestedWorkspace, workspaceName);
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
workspaceID = std::stoi(requestedWorkspace);
|
|
||||||
} catch (...) {
|
|
||||||
workspaceID = -1;
|
|
||||||
Debug::log(ERR, "Invalid workspace requested in workspace silent rule!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (workspaceID < 1) {
|
|
||||||
workspaceID = -1; // means invalid
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (workspaceID != -1)
|
|
||||||
PWORKSPACE = g_pCompositor->createNewWorkspace(workspaceID, PWINDOW->m_iMonitorID, workspaceName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PWORKSPACE) {
|
|
||||||
PWINDOW->m_iWorkspaceID = PWORKSPACE->m_iID;
|
|
||||||
PWINDOW->m_iMonitorID = PWORKSPACE->m_iMonitorID;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -531,7 +491,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
|||||||
|
|
||||||
PWINDOW->updateToplevel();
|
PWINDOW->updateToplevel();
|
||||||
|
|
||||||
if (!shouldFocus) {
|
if (workspaceSilent) {
|
||||||
if (g_pCompositor->windowValidMapped(PFOCUSEDWINDOWPREV)) {
|
if (g_pCompositor->windowValidMapped(PFOCUSEDWINDOWPREV)) {
|
||||||
g_pCompositor->focusWindow(PFOCUSEDWINDOWPREV);
|
g_pCompositor->focusWindow(PFOCUSEDWINDOWPREV);
|
||||||
PFOCUSEDWINDOWPREV->updateWindowDecos(); // need to for some reason i cba to find out why
|
PFOCUSEDWINDOWPREV->updateWindowDecos(); // need to for some reason i cba to find out why
|
||||||
|
Loading…
Reference in New Issue
Block a user