summaryrefslogtreecommitdiff
path: root/src/layout
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-03-20 11:14:24 +0100
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-03-20 11:14:24 +0100
commita4b026df2b7f94b2985d38b1ef6fb127782c1a27 (patch)
treec85f054baed6951fa096a358096fecc4e5c08a19 /src/layout
parenta4d69a15b34e54d8438a7242b151b1d31cbef46a (diff)
floating windows support
Diffstat (limited to 'src/layout')
-rw-r--r--src/layout/DwindleLayout.cpp47
-rw-r--r--src/layout/DwindleLayout.hpp9
-rw-r--r--src/layout/IHyprLayout.hpp11
3 files changed, 58 insertions, 9 deletions
diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp
index 12650963..2b69e2d9 100644
--- a/src/layout/DwindleLayout.cpp
+++ b/src/layout/DwindleLayout.cpp
@@ -213,11 +213,6 @@ void CHyprDwindleLayout::onWindowRemoved(CWindow* pWindow) {
if (!PNODE)
return;
- if (PNODE->isNode) {
- Debug::log(LOG, "WHAT THE FUCKKKKKKKK");
- return;
- }
-
const auto PPARENT = PNODE->pParent;
if (!PPARENT) {
@@ -258,3 +253,45 @@ void CHyprDwindleLayout::recalculateMonitor(const int& monid) {
TOPNODE->recalcSizePosRecursive();
}
}
+
+void CHyprDwindleLayout::changeWindowFloatingMode(CWindow* pWindow) {
+ const auto PNODE = getNodeFromWindow(pWindow);
+
+ if (!PNODE) {
+ onWindowCreated(pWindow);
+ } else {
+ onWindowRemoved(pWindow);
+ }
+}
+
+void CHyprDwindleLayout::onBeginDragWindow() {
+ const auto DRAGGINGWINDOW = g_pInputManager->currentlyDraggedWindow;
+
+ // Window will be floating. Let's check if it's valid. It should be, but I don't like crashing.
+ if (!g_pCompositor->windowValidMapped(DRAGGINGWINDOW)) {
+ Debug::log(ERR, "Dragging attempted on an invalid window!");
+ return;
+ }
+
+ m_vBeginDragXY = g_pInputManager->getMouseCoordsInternal();
+ m_vBeginDragPositionXY = DRAGGINGWINDOW->m_vRealPosition;
+ m_vBeginDragSizeXY = DRAGGINGWINDOW->m_vRealSize;
+}
+
+void CHyprDwindleLayout::onMouseMove(const Vector2D& mousePos) {
+ const auto DRAGGINGWINDOW = g_pInputManager->currentlyDraggedWindow;
+
+ if (!g_pCompositor->windowValidMapped(DRAGGINGWINDOW))
+ return;
+
+ const auto DELTA = Vector2D(mousePos.x - m_vBeginDragXY.x, mousePos.y - m_vBeginDragXY.y);
+
+ if (g_pInputManager->dragButton == BTN_LEFT) {
+ DRAGGINGWINDOW->m_vRealPosition = m_vBeginDragPositionXY + DELTA;
+ } else {
+ DRAGGINGWINDOW->m_vRealSize = m_vBeginDragSizeXY + DELTA;
+ DRAGGINGWINDOW->m_vRealSize = Vector2D(std::clamp(DRAGGINGWINDOW->m_vRealSize.x, (double)20, (double)999999), std::clamp(DRAGGINGWINDOW->m_vRealSize.y, (double)20, (double)999999));
+
+ g_pXWaylandManager->setWindowSize(DRAGGINGWINDOW, DRAGGINGWINDOW->m_vRealSize);
+ }
+} \ No newline at end of file
diff --git a/src/layout/DwindleLayout.hpp b/src/layout/DwindleLayout.hpp
index cb3e4a68..b9136727 100644
--- a/src/layout/DwindleLayout.hpp
+++ b/src/layout/DwindleLayout.hpp
@@ -32,11 +32,18 @@ public:
virtual void onWindowCreated(CWindow*);
virtual void onWindowRemoved(CWindow*);
virtual void recalculateMonitor(const int&);
+ virtual void changeWindowFloatingMode(CWindow*);
+ virtual void onBeginDragWindow();
+ virtual void onMouseMove(const Vector2D&);
-private:
+ private:
std::list<SDwindleNodeData> m_lDwindleNodesData;
+ Vector2D m_vBeginDragXY;
+ Vector2D m_vBeginDragPositionXY;
+ Vector2D m_vBeginDragSizeXY;
+
int getNodesOnMonitor(const int&);
void applyNodeDataToWindow(SDwindleNodeData*);
SDwindleNodeData* getNodeFromWindow(CWindow*);
diff --git a/src/layout/IHyprLayout.hpp b/src/layout/IHyprLayout.hpp
index 2a7ff3aa..bf0d135b 100644
--- a/src/layout/IHyprLayout.hpp
+++ b/src/layout/IHyprLayout.hpp
@@ -6,8 +6,13 @@
interface IHyprLayout {
public:
- virtual void onWindowCreated(CWindow*) = 0;
- virtual void onWindowRemoved(CWindow*) = 0;
- virtual void recalculateMonitor(const int&) = 0;
+ virtual void onWindowCreated(CWindow*) = 0;
+ virtual void onWindowRemoved(CWindow*) = 0;
+ virtual void recalculateMonitor(const int&) = 0;
+
+ // Floating windows
+ virtual void changeWindowFloatingMode(CWindow*) = 0;
+ virtual void onBeginDragWindow() = 0;
+ virtual void onMouseMove(const Vector2D&) = 0;
}; \ No newline at end of file