mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-25 15:45:58 +01:00
fix groups and swallowing
modified: src/Compositor.cpp modified: src/Compositor.hpp modified: src/events/Windows.cpp
This commit is contained in:
parent
a0063aa3b0
commit
3f7d9b3048
3 changed files with 41 additions and 26 deletions
|
@ -1164,6 +1164,16 @@ int CCompositor::getWindowsOnWorkspace(const int& id) {
|
||||||
return no;
|
return no;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CCompositor::getVisibleWindowsOnWorkspace(const int& id) {
|
||||||
|
int no = 0;
|
||||||
|
for (auto& w : m_vWindows) {
|
||||||
|
if (w->m_iWorkspaceID == id && w->m_bIsMapped && !w->isHidden())
|
||||||
|
no++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return no;
|
||||||
|
}
|
||||||
|
|
||||||
CWindow* CCompositor::getUrgentWindow() {
|
CWindow* CCompositor::getUrgentWindow() {
|
||||||
for (auto& w : m_vWindows) {
|
for (auto& w : m_vWindows) {
|
||||||
if (w->m_bIsMapped && w->m_bIsUrgent)
|
if (w->m_bIsMapped && w->m_bIsUrgent)
|
||||||
|
|
|
@ -153,6 +153,7 @@ class CCompositor {
|
||||||
void sanityCheckWorkspaces();
|
void sanityCheckWorkspaces();
|
||||||
void updateWorkspaceWindowDecos(const int&);
|
void updateWorkspaceWindowDecos(const int&);
|
||||||
int getWindowsOnWorkspace(const int&);
|
int getWindowsOnWorkspace(const int&);
|
||||||
|
int getVisibleWindowsOnWorkspace(const int&);
|
||||||
CWindow* getUrgentWindow();
|
CWindow* getUrgentWindow();
|
||||||
bool hasUrgentWindowOnWorkspace(const int&);
|
bool hasUrgentWindowOnWorkspace(const int&);
|
||||||
CWindow* getFirstWindowOnWorkspace(const int&);
|
CWindow* getFirstWindowOnWorkspace(const int&);
|
||||||
|
|
|
@ -229,13 +229,15 @@ 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;
|
||||||
|
|
||||||
const CVarList WORKSPACEARGS = CVarList(requestedWorkspace, 2, ' ');
|
bool isWorkspaceSet = false;
|
||||||
|
const CVarList WORKSPACEARGS = CVarList(requestedWorkspace, 2, ' ');
|
||||||
|
|
||||||
if (!WORKSPACEARGS[0].empty()) {
|
if (!WORKSPACEARGS[0].empty()) {
|
||||||
std::string requestedWorkspaceName;
|
std::string requestedWorkspaceName;
|
||||||
const int REQUESTEDWORKSPACEID = getWorkspaceIDFromString(WORKSPACEARGS[0], requestedWorkspaceName);
|
const int REQUESTEDWORKSPACEID = getWorkspaceIDFromString(WORKSPACEARGS[0], requestedWorkspaceName);
|
||||||
|
|
||||||
if (REQUESTEDWORKSPACEID != INT_MAX) {
|
if (REQUESTEDWORKSPACEID != INT_MAX) {
|
||||||
|
isWorkspaceSet = true;
|
||||||
|
|
||||||
if (WORKSPACEARGS[1].find("silent") == 0)
|
if (WORKSPACEARGS[1].find("silent") == 0)
|
||||||
workspaceSilent = true;
|
workspaceSilent = true;
|
||||||
|
@ -255,35 +257,11 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
if (pWorkspace->m_bIsSpecialWorkspace)
|
if (pWorkspace->m_bIsSpecialWorkspace)
|
||||||
g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID)->setSpecialWorkspace(pWorkspace);
|
g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID)->setSpecialWorkspace(pWorkspace);
|
||||||
else
|
else
|
||||||
g_pKeybindManager->m_mDispatchers["workspace"](requestedWorkspaceName);
|
g_pKeybindManager->m_mDispatchers["workspace"](pWorkspace->m_szName);
|
||||||
|
|
||||||
PMONITOR = g_pCompositor->m_pLastMonitor;
|
PMONITOR = g_pCompositor->m_pLastMonitor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
auto pWorkspace = g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID);
|
|
||||||
auto workspaceRule = pWorkspace ? g_pConfigManager->getWorkspaceRuleFor(pWorkspace) : SWorkspaceRule{};
|
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
|
||||||
|
|
||||||
int maxSize = workspaceRule.maxSize;
|
|
||||||
if (maxSize != 0 && maxSize < g_pCompositor->getWindowsOnWorkspace(pWorkspace->m_iID)) {
|
|
||||||
if (pWorkspace->m_bIsSpecialWorkspace) {
|
|
||||||
PWINDOW->m_iWorkspaceID = PMONITOR->activeWorkspace;
|
|
||||||
PMONITOR->setSpecialWorkspace(nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
pWorkspace = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
|
|
||||||
workspaceRule = pWorkspace ? g_pConfigManager->getWorkspaceRuleFor(pWorkspace) : SWorkspaceRule{};
|
|
||||||
maxSize = workspaceRule.maxSize;
|
|
||||||
if (maxSize != 0 && maxSize < g_pCompositor->getWindowsOnWorkspace(pWorkspace->m_iID)) {
|
|
||||||
std::string requestedWorkspaceName;
|
|
||||||
const int REQUESTEDWORKSPACEID = getWorkspaceIDFromString("empty", requestedWorkspaceName);
|
|
||||||
// doesn't exist since it's empty
|
|
||||||
pWorkspace = g_pCompositor->createNewWorkspace(REQUESTEDWORKSPACEID, PWINDOW->m_iMonitorID, requestedWorkspaceName);
|
|
||||||
PWINDOW->m_iWorkspaceID = pWorkspace->m_iID;
|
|
||||||
g_pKeybindManager->m_mDispatchers["workspace"](requestedWorkspaceName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PWINDOW->m_bIsFloating) {
|
if (PWINDOW->m_bIsFloating) {
|
||||||
|
@ -594,6 +572,32 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isWorkspaceSet) {
|
||||||
|
auto pWorkspace = g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID);
|
||||||
|
auto workspaceRule = pWorkspace ? g_pConfigManager->getWorkspaceRuleFor(pWorkspace) : SWorkspaceRule{};
|
||||||
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
||||||
|
|
||||||
|
int maxSize = workspaceRule.maxSize;
|
||||||
|
if (maxSize != 0 && maxSize < g_pCompositor->getVisibleWindowsOnWorkspace(pWorkspace->m_iID)) {
|
||||||
|
if (pWorkspace->m_bIsSpecialWorkspace) {
|
||||||
|
g_pCompositor->moveWindowToWorkspaceSafe(PWINDOW, g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace));
|
||||||
|
PMONITOR->setSpecialWorkspace(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
pWorkspace = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
|
||||||
|
workspaceRule = pWorkspace ? g_pConfigManager->getWorkspaceRuleFor(pWorkspace) : SWorkspaceRule{};
|
||||||
|
maxSize = workspaceRule.maxSize;
|
||||||
|
if (maxSize != 0 && maxSize < g_pCompositor->getVisibleWindowsOnWorkspace(pWorkspace->m_iID)) {
|
||||||
|
std::string requestedWorkspaceName;
|
||||||
|
const int REQUESTEDWORKSPACEID = getWorkspaceIDFromString("empty", requestedWorkspaceName);
|
||||||
|
// doesn't exist since it's empty
|
||||||
|
pWorkspace = g_pCompositor->createNewWorkspace(REQUESTEDWORKSPACEID, PWINDOW->m_iMonitorID, requestedWorkspaceName);
|
||||||
|
g_pCompositor->moveWindowToWorkspaceSafe(PWINDOW, pWorkspace);
|
||||||
|
g_pKeybindManager->m_mDispatchers["workspace"](pWorkspace->m_szName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PWINDOW->m_bFirstMap = false;
|
PWINDOW->m_bFirstMap = false;
|
||||||
|
|
||||||
Debug::log(LOG, "Map request dispatched, monitor %s, xywh: %f %f %f %f", PMONITOR->szName.c_str(), PWINDOW->m_vRealPosition.goalv().x, PWINDOW->m_vRealPosition.goalv().y,
|
Debug::log(LOG, "Map request dispatched, monitor %s, xywh: %f %f %f %f", PMONITOR->szName.c_str(), PWINDOW->m_vRealPosition.goalv().x, PWINDOW->m_vRealPosition.goalv().y,
|
||||||
|
|
Loading…
Reference in a new issue