Skip to content

Commit

Permalink
Rework/fix new_on_top/new_is_master fixes #3
Browse files Browse the repository at this point in the history
  • Loading branch information
zakk4223 committed Jun 29, 2023
1 parent 087cc14 commit 671ddc4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# and that you have ran `make protocols` in the hl dir.

all:
g++ -shared -Wall -fPIC --no-gnu-unique main.cpp nstackLayout.cpp -o nstackLayoutPlugin.so -g -I "/usr/include/pixman-1" -I "/usr/include/libdrm" -I "${HYPRLAND_HEADERS}" -std=c++23
g++ -shared -Wall -fPIC --no-gnu-unique main.cpp nstackLayout.cpp -o nstackLayoutPlugin.so -g `pkg-config --cflags pixman-1 libdrm hyprland` -std=c++23
clean:
rm ./nstackLayoutPlugin.so
4 changes: 2 additions & 2 deletions globals.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once

#include <src/plugins/PluginAPI.hpp>
#include <hyprland/src/plugins/PluginAPI.hpp>

inline HANDLE PHANDLE = nullptr;
inline HANDLE PHANDLE = nullptr;
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#define WLR_USE_UNSTABLE

#include <src/config/ConfigManager.hpp>
#include <hyprland/src/config/ConfigManager.hpp>
#include "globals.hpp"

#include "nstackLayout.hpp"
Expand Down
24 changes: 7 additions & 17 deletions nstackLayout.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "nstackLayout.hpp"
#include <src/Compositor.hpp>
#include <hyprland/src/Compositor.hpp>

SNstackNodeData* CHyprNstackLayout::getNodeFromWindow(CWindow* pWindow) {
for (auto& nd : m_lMasterNodesData) {
Expand Down Expand Up @@ -99,22 +99,12 @@ void CHyprNstackLayout::onWindowCreatedTiling(CWindow* pWindow) {

const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);

const auto PNODE = *PNEWTOP ? &m_lMasterNodesData.emplace_front() : &m_lMasterNodesData.emplace_back();

auto OPENINGON = isWindowTiled(g_pCompositor->m_pLastWindow) && g_pCompositor->m_pLastWindow->m_iWorkspaceID == pWindow->m_iWorkspaceID ?
getNodeFromWindow(g_pCompositor->m_pLastWindow) :
getMasterNodeOnWorkspace(pWindow->m_iWorkspaceID);

auto NODEPOS = *PNEWTOP ? m_lMasterNodesData.begin() : m_lMasterNodesData.end();
if (OPENINGON && OPENINGON != getMasterNodeOnWorkspace(pWindow->m_iWorkspaceID)) {
const auto OPENINGPOS = std::find(m_lMasterNodesData.begin(), m_lMasterNodesData.end(), *OPENINGON);
if (OPENINGPOS != m_lMasterNodesData.end()) {
NODEPOS = OPENINGPOS;
}


}

const auto PNODE = &(*m_lMasterNodesData.emplace(NODEPOS));


PNODE->workspaceID = pWindow->m_iWorkspaceID;
PNODE->pWindow = pWindow;
Expand All @@ -126,7 +116,9 @@ void CHyprNstackLayout::onWindowCreatedTiling(CWindow* pWindow) {
bool lastMasterAdjusted = false;


if (OPENINGON && OPENINGON->pWindow->m_sGroupData.pNextWindow && OPENINGON != PNODE && !g_pKeybindManager->m_bGroupsLocked) {
if (OPENINGON && OPENINGON->pWindow->m_sGroupData.pNextWindow && !OPENINGON->pWindow->getGroupHead()->m_sGroupData.locked && // target is an unlocked group
(!pWindow->m_sGroupData.pNextWindow || !pWindow->getGroupHead()->m_sGroupData.locked) // source is not group or is an unlocked group
&& OPENINGON != PNODE && !g_pKeybindManager->m_bGroupsLocked) {
m_lMasterNodesData.remove(*PNODE);

OPENINGON->pWindow->insertWindowToGroup(pWindow);
Expand All @@ -137,9 +129,7 @@ void CHyprNstackLayout::onWindowCreatedTiling(CWindow* pWindow) {
}

bool newWindowIsMaster = false;
if (OPENINGON && OPENINGON->isMaster)
newWindowIsMaster = true;
if (!OPENINGON && (*PNEWISMASTER || WINDOWSONWORKSPACE == 1))
if (*PNEWISMASTER || WINDOWSONWORKSPACE == 1 || (!pWindow->m_bFirstMap && OPENINGON->isMaster))
newWindowIsMaster = true;
if (newWindowIsMaster) {
for (auto& nd : m_lMasterNodesData) {
Expand Down
2 changes: 1 addition & 1 deletion nstackLayout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define WLR_USE_UNSTABLE

#include "globals.hpp"
#include <src/layout/IHyprLayout.hpp>
#include <hyprland/src/layout/IHyprLayout.hpp>
#include <vector>
#include <list>
#include <deque>
Expand Down

0 comments on commit 671ddc4

Please sign in to comment.