mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-25 16:06:00 +01:00
Merge pull request #1 from MightyPlaza/maxsize
add "maxsize" workspace rule
This commit is contained in:
commit
a0063aa3b0
4 changed files with 27 additions and 9 deletions
|
@ -417,8 +417,6 @@ void CWindow::onUnmap() {
|
|||
|
||||
void CWindow::onMap() {
|
||||
|
||||
static auto* const PISOLATESPECIAL = &g_pConfigManager->getConfigValuePtr("misc:isolate_special")->intValue;
|
||||
|
||||
m_pWLSurface.assign(g_pXWaylandManager->getWindowSurface(this));
|
||||
|
||||
// JIC, reset the callbacks. If any are set, we'll make sure they are cleared so we don't accidentally unset them. (In case a window got remapped)
|
||||
|
@ -449,12 +447,6 @@ void CWindow::onMap() {
|
|||
|
||||
hyprListener_unmapWindow.initCallback(m_bIsX11 ? &m_uSurface.xwayland->surface->events.unmap : &m_uSurface.xdg->surface->events.unmap, &Events::listener_unmapWindow, this,
|
||||
"CWindow");
|
||||
|
||||
if (*PISOLATESPECIAL && g_pCompositor->getWindowsOnWorkspace(m_iWorkspaceID) > *PISOLATESPECIAL && g_pCompositor->isWorkspaceSpecial(m_iWorkspaceID)) {
|
||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
|
||||
this->moveToWorkspace(PMONITOR->activeWorkspace);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CWindow::onBorderAngleAnimEnd(void* ptr) {
|
||||
|
|
|
@ -114,7 +114,6 @@ void CConfigManager::setDefaultVars() {
|
|||
configValues["misc:groupbar_titles_font_size"].intValue = 8;
|
||||
configValues["misc:groupbar_gradients"].intValue = 1;
|
||||
configValues["misc:close_special_on_empty"].intValue = 1;
|
||||
configValues["misc:isolate_special"].intValue = 0;
|
||||
configValues["misc:groupbar_text_color"].intValue = 0xffffffff;
|
||||
configValues["misc:background_color"].intValue = 0xff111111;
|
||||
|
||||
|
@ -1159,6 +1158,8 @@ void CConfigManager::handleWorkspaceRules(const std::string& command, const std:
|
|||
wsRule.monitor = rule.substr(delim + 8);
|
||||
else if ((delim = rule.find("default:")) != std::string::npos)
|
||||
wsRule.isDefault = configStringToInt(rule.substr(delim + 8));
|
||||
else if ((delim = rule.find("maxsize:")) != std::string::npos)
|
||||
wsRule.maxSize = configStringToInt(rule.substr(delim + 8));
|
||||
};
|
||||
|
||||
size_t pos = 0;
|
||||
|
|
|
@ -42,6 +42,7 @@ struct SWorkspaceRule {
|
|||
std::string workspaceName = "";
|
||||
int workspaceId = -1;
|
||||
bool isDefault = false;
|
||||
int maxSize = 0;
|
||||
std::optional<int64_t> gapsIn;
|
||||
std::optional<int64_t> gapsOut;
|
||||
std::optional<int64_t> borderSize;
|
||||
|
|
|
@ -260,6 +260,30 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
|||
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) {
|
||||
|
|
Loading…
Reference in a new issue