summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-04-02 20:04:32 +0200
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-04-02 20:04:32 +0200
commit3f99dad7f563593d298bcd548002e5b53a886825 (patch)
tree4bdd69de02aff2b8a8352ff8abbb6b38d5d91c8c /src
parent7add082217b1e86f36bb152aec658eb5977622fa (diff)
Added pseudotiling
Diffstat (limited to 'src')
-rw-r--r--src/Window.hpp6
-rw-r--r--src/config/ConfigManager.cpp3
-rw-r--r--src/events/Windows.cpp13
-rw-r--r--src/layout/DwindleLayout.cpp36
-rw-r--r--src/layout/DwindleLayout.hpp1
-rw-r--r--src/layout/IHyprLayout.hpp8
-rw-r--r--src/managers/KeybindManager.cpp12
-rw-r--r--src/managers/KeybindManager.hpp1
8 files changed, 76 insertions, 4 deletions
diff --git a/src/Window.hpp b/src/Window.hpp
index eacf69bf..f59e037a 100644
--- a/src/Window.hpp
+++ b/src/Window.hpp
@@ -24,8 +24,6 @@ public:
wlr_xwayland_surface* xwayland;
} m_uSurface;
- // TODO: XWayland
-
// this is the position and size of the "bounding box"
Vector2D m_vPosition = Vector2D(0,0);
Vector2D m_vSize = Vector2D(0,0);
@@ -38,6 +36,10 @@ public:
Vector2D m_vRealPosition = Vector2D(0,0);
Vector2D m_vRealSize = Vector2D(0,0);
+ // this is used for pseudotiling
+ bool m_bIsPseudotiled = false;
+ Vector2D m_vPseudoSize = Vector2D(0,0);
+
uint64_t m_iTags = 0;
bool m_bIsFloating = false;
bool m_bIsFullscreen = false;
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index 8d016c4d..52b2ef90 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -22,6 +22,8 @@ CConfigManager::CConfigManager() {
configValues["general:col.active_border"].intValue = 0xffffffff;
configValues["general:col.inactive_border"].intValue = 0xff444444;
+ configValues["dwindle:pseudotile"].intValue = 0;
+
configValues["animations:enabled"].intValue = 1;
configValues["animations:speed"].floatValue = 7.f;
configValues["animations:windows_speed"].floatValue = 0.f;
@@ -186,6 +188,7 @@ void CConfigManager::handleWindowRule(const std::string& command, const std::str
&& RULE != "tile"
&& RULE.find("move") != 0
&& RULE.find("size") != 0
+ && RULE.find("pseudo") != 0
&& RULE.find("monitor") != 0) {
Debug::log(ERR, "Invalid rule found: %s", RULE.c_str());
parseError = "Invalid rule found: " + RULE;
diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp
index 3d50f1f4..6d000231 100644
--- a/src/events/Windows.cpp
+++ b/src/events/Windows.cpp
@@ -73,6 +73,8 @@ void Events::listener_mapWindow(void* owner, void* data) {
PWINDOW->m_bIsFloating = true;
} else if (r.szRule.find("tile") == 0) {
PWINDOW->m_bIsFloating = false;
+ } else if (r.szRule.find("pseudo") == 0) {
+ PWINDOW->m_bIsPseudotiled = true;
}
}
@@ -109,10 +111,19 @@ void Events::listener_mapWindow(void* owner, void* data) {
}
}
}
+
+ // set the pseudo size to the GOAL of our current size
+ // because the windows are animated on RealSize
+ PWINDOW->m_vPseudoSize = PWINDOW->m_vEffectiveSize;
}
- else
+ else {
g_pLayoutManager->getCurrentLayout()->onWindowCreated(PWINDOW);
+ // Set the pseudo size here too so that it doesnt end up being 0x0
+ PWINDOW->m_vPseudoSize = PWINDOW->m_vEffectiveSize - Vector2D(10,10);
+ }
+
+
PWINDOW->m_szTitle = g_pXWaylandManager->getTitle(PWINDOW);
if (!PWINDOW->m_bIsModal)
diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp
index 58eca936..ce1e2a3f 100644
--- a/src/layout/DwindleLayout.cpp
+++ b/src/layout/DwindleLayout.cpp
@@ -109,6 +109,30 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode) {
PWINDOW->m_vEffectivePosition = PWINDOW->m_vEffectivePosition + OFFSETTOPLEFT;
PWINDOW->m_vEffectiveSize = PWINDOW->m_vEffectiveSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT;
+ if (PWINDOW->m_bIsPseudotiled) {
+ // Calculate pseudo
+ float scale = 1;
+
+ // adjust if doesnt fit
+ if (PWINDOW->m_vPseudoSize.x > PWINDOW->m_vEffectiveSize.x || PWINDOW->m_vPseudoSize.y > PWINDOW->m_vEffectiveSize.y) {
+ if (PWINDOW->m_vPseudoSize.x > PWINDOW->m_vEffectiveSize.x) {
+ scale = PWINDOW->m_vEffectiveSize.x / PWINDOW->m_vPseudoSize.x;
+ }
+
+ if (PWINDOW->m_vPseudoSize.y * scale > PWINDOW->m_vEffectiveSize.y) {
+ scale = PWINDOW->m_vEffectiveSize.y / PWINDOW->m_vPseudoSize.y;
+ }
+
+ auto DELTA = PWINDOW->m_vEffectiveSize - PWINDOW->m_vPseudoSize * scale;
+ PWINDOW->m_vEffectiveSize = PWINDOW->m_vPseudoSize * scale;
+ PWINDOW->m_vEffectivePosition = PWINDOW->m_vEffectivePosition + DELTA / 2.f; // center
+ } else {
+ auto DELTA = PWINDOW->m_vEffectiveSize - PWINDOW->m_vPseudoSize;
+ PWINDOW->m_vEffectivePosition = PWINDOW->m_vEffectivePosition + DELTA / 2.f; // center
+ PWINDOW->m_vEffectiveSize = PWINDOW->m_vPseudoSize;
+ }
+ }
+
g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vEffectiveSize);
}
@@ -271,6 +295,9 @@ void CHyprDwindleLayout::changeWindowFloatingMode(CWindow* pWindow) {
const auto PSAVEDPOS = pWindow->m_vRealPosition;
const auto PSAVEDSIZE = pWindow->m_vRealSize;
+ // if the window is pseudo, update its size
+ pWindow->m_vPseudoSize = pWindow->m_vRealSize;
+
onWindowCreated(pWindow);
pWindow->m_vRealPosition = PSAVEDPOS;
@@ -430,3 +457,12 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow) {
// because otherwise they'd still be recieving mouse events
g_pCompositor->fixXWaylandWindowsOnWorkspace(PMONITOR->activeWorkspace);
}
+
+void CHyprDwindleLayout::recalculateWindow(CWindow* pWindow) {
+ const auto PNODE = getNodeFromWindow(pWindow);
+
+ if (!PNODE)
+ return;
+
+ PNODE->recalcSizePosRecursive();
+} \ No newline at end of file
diff --git a/src/layout/DwindleLayout.hpp b/src/layout/DwindleLayout.hpp
index 61b76be7..f1411322 100644
--- a/src/layout/DwindleLayout.hpp
+++ b/src/layout/DwindleLayout.hpp
@@ -32,6 +32,7 @@ public:
virtual void onWindowCreated(CWindow*);
virtual void onWindowRemoved(CWindow*);
virtual void recalculateMonitor(const int&);
+ virtual void recalculateWindow(CWindow*);
virtual void changeWindowFloatingMode(CWindow*);
virtual void onBeginDragWindow();
virtual void onMouseMove(const Vector2D&);
diff --git a/src/layout/IHyprLayout.hpp b/src/layout/IHyprLayout.hpp
index e437d703..b214dd50 100644
--- a/src/layout/IHyprLayout.hpp
+++ b/src/layout/IHyprLayout.hpp
@@ -15,12 +15,18 @@ public:
*/
virtual void onWindowRemoved(CWindow*) = 0;
/*
- Called when a the monitor requires a layout recalculation
+ Called when the monitor requires a layout recalculation
this usually means reserved area changes
*/
virtual void recalculateMonitor(const int&) = 0;
/*
+ Called when the compositor requests a window
+ to be recalculated, e.g. when pseudo is toggled.
+ */
+ virtual void recalculateWindow(CWindow*) = 0;
+
+ /*
Called when a window is requested to be floated
*/
virtual void changeWindowFloatingMode(CWindow*) = 0;
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index d9d2fa72..d820e83e 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -53,6 +53,7 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t
else if (k.handler == "workspace") { changeworkspace(k.arg); }
else if (k.handler == "fullscreen") { fullscreenActive(k.arg); }
else if (k.handler == "movetoworkspace") { moveActiveToWorkspace(k.arg); }
+ else if (k.handler == "pseudo") { toggleActivePseudo(k.arg); }
found = true;
}
@@ -114,6 +115,17 @@ void CKeybindManager::toggleActiveFloating(std::string args) {
}
}
+void CKeybindManager::toggleActivePseudo(std::string args) {
+ const auto ACTIVEWINDOW = g_pCompositor->m_pLastWindow;
+
+ if (!g_pCompositor->windowValidMapped(ACTIVEWINDOW))
+ return;
+
+ ACTIVEWINDOW->m_bIsPseudotiled = !ACTIVEWINDOW->m_bIsPseudotiled;
+
+ g_pLayoutManager->getCurrentLayout()->recalculateWindow(ACTIVEWINDOW);
+}
+
void CKeybindManager::changeworkspace(std::string args) {
int workspaceToChangeTo = 0;
try {
diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp
index 019ba9bf..f68f8314 100644
--- a/src/managers/KeybindManager.hpp
+++ b/src/managers/KeybindManager.hpp
@@ -27,6 +27,7 @@ private:
void killActive(std::string);
void spawn(std::string);
void toggleActiveFloating(std::string);
+ void toggleActivePseudo(std::string);
void changeworkspace(std::string);
void fullscreenActive(std::string);
void moveActiveToWorkspace(std::string);