aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2022-06-23 10:14:59 +0200
committervaxerski <[email protected]>2022-06-23 10:14:59 +0200
commit31dc70a41a605b09e31bb7394fc0e339a1b82418 (patch)
tree68c8ff8b332988836f624603adf4512506d2c86e
parentf9745b0d3b85c447c3c8d3421db638f1087a1e91 (diff)
downloadHyprland-31dc70a41a605b09e31bb7394fc0e339a1b82418.tar.gz
Hyprland-31dc70a41a605b09e31bb7394fc0e339a1b82418.zip
Added exact to resizeActive and added moveactive
-rw-r--r--src/layout/DwindleLayout.cpp22
-rw-r--r--src/layout/DwindleLayout.hpp1
-rw-r--r--src/layout/IHyprLayout.hpp6
-rw-r--r--src/managers/KeybindManager.cpp81
-rw-r--r--src/managers/KeybindManager.hpp1
5 files changed, 106 insertions, 5 deletions
diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp
index ce63ace6..ed8da473 100644
--- a/src/layout/DwindleLayout.cpp
+++ b/src/layout/DwindleLayout.cpp
@@ -545,11 +545,7 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow*
const auto PNODE = getNodeFromWindow(PWINDOW);
if (!PNODE) {
- PWINDOW->m_vRealSize.setValueAndWarp(PWINDOW->m_vRealSize.goalv() + pixResize);
- PWINDOW->m_vRealSize.setValueAndWarp(Vector2D(std::clamp(PWINDOW->m_vRealSize.vec().x, (double)20, (double)999999), std::clamp(PWINDOW->m_vRealSize.vec().y, (double)20, (double)999999)));
-
- g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv());
-
+ PWINDOW->m_vRealSize = Vector2D(std::clamp((PWINDOW->m_vRealSize.goalv() + pixResize).x, (double)20, (double)999999), std::clamp((PWINDOW->m_vRealSize.goalv() + pixResize).y, (double)20, (double)999999));
return;
}
@@ -992,4 +988,20 @@ void CHyprDwindleLayout::toggleSplit(CWindow* pWindow) {
std::string CHyprDwindleLayout::getLayoutName() {
return "dwindle";
+}
+
+void CHyprDwindleLayout::moveActiveWindow(const Vector2D& delta, CWindow* pWindow) {
+ const auto PWINDOW = pWindow ? pWindow : g_pCompositor->m_pLastWindow;
+
+ if (!g_pCompositor->windowValidMapped(PWINDOW))
+ return;
+
+ if (!PWINDOW->m_bIsFloating) {
+ Debug::log(LOG, "Dwindle cannot move a tiled window in moveActiveWindow!");
+ return;
+ }
+
+ PWINDOW->m_vRealPosition = PWINDOW->m_vRealPosition.goalv() + delta;
+
+ g_pHyprRenderer->damageWindow(PWINDOW);
} \ No newline at end of file
diff --git a/src/layout/DwindleLayout.hpp b/src/layout/DwindleLayout.hpp
index 766e9f6a..55c123ae 100644
--- a/src/layout/DwindleLayout.hpp
+++ b/src/layout/DwindleLayout.hpp
@@ -49,6 +49,7 @@ public:
virtual void changeWindowFloatingMode(CWindow*);
virtual void onBeginDragWindow();
virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr);
+ virtual void moveActiveWindow(const Vector2D&, CWindow* pWindow = nullptr);
virtual void onEndDragWindow();
virtual void onMouseMove(const Vector2D&);
virtual void onWindowCreatedFloating(CWindow*);
diff --git a/src/layout/IHyprLayout.hpp b/src/layout/IHyprLayout.hpp
index 8052fe42..a7268301 100644
--- a/src/layout/IHyprLayout.hpp
+++ b/src/layout/IHyprLayout.hpp
@@ -56,6 +56,12 @@ public:
*/
virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr) = 0;
/*
+ Called when a user requests a move of the current window by a vec
+ Vector2D holds pixel values
+ Optional pWindow for a specific window
+ */
+ virtual void moveActiveWindow(const Vector2D&, CWindow* pWindow = nullptr) = 0;
+ /*
Called when a window is ended being dragged
(mouse up)
*/
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 06075554..85fb3919 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -28,6 +28,7 @@ CKeybindManager::CKeybindManager() {
m_mDispatchers["togglespecialworkspace"] = toggleSpecialWorkspace;
m_mDispatchers["forcerendererreload"] = forceRendererReload;
m_mDispatchers["resizeactive"] = resizeActive;
+ m_mDispatchers["moveactive"] = moveActive;
m_mDispatchers["cyclenext"] = circleNext;
m_mDispatchers["focuswindowbyclass"] = focusWindowByClass;
m_mDispatchers["submap"] = setSubmap;
@@ -892,6 +893,37 @@ void CKeybindManager::resizeActive(std::string args) {
std::string x = args.substr(0, args.find_first_of(' '));
std::string y = args.substr(args.find_first_of(' ') + 1);
+ if (x == "exact") {
+ std::string newX = y.substr(0, y.find_first_of(' '));
+ std::string newY = y.substr(y.find_first_of(' ') + 1);
+
+ if (!isNumber(newX) || !isNumber(newY)) {
+ Debug::log(ERR, "resizeTiledWindow: exact args not numbers");
+ return;
+ }
+
+ const int X = std::stoi(newX);
+ const int Y = std::stoi(newY);
+
+ if (X < 10 || Y < 10) {
+ Debug::log(ERR, "resizeTiledWindow: exact args cannot be < 10");
+ return;
+ }
+
+ // calc the delta
+ if (!g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow))
+ return; // ignore
+
+ const auto PWINDOW = g_pCompositor->m_pLastWindow;
+
+ const int DX = X - PWINDOW->m_vRealSize.goalv().x;
+ const int DY = Y - PWINDOW->m_vRealSize.goalv().y;
+
+ g_pLayoutManager->getCurrentLayout()->resizeActiveWindow(Vector2D(DX, DY));
+
+ return;
+ }
+
if (!isNumber(x) || !isNumber(y)) {
Debug::log(ERR, "resizeTiledWindow: args not numbers");
return;
@@ -903,6 +935,55 @@ void CKeybindManager::resizeActive(std::string args) {
g_pLayoutManager->getCurrentLayout()->resizeActiveWindow(Vector2D(X, Y));
}
+void CKeybindManager::moveActive(std::string args) {
+ if (args.find_first_of(' ') == std::string::npos)
+ return;
+
+ std::string x = args.substr(0, args.find_first_of(' '));
+ std::string y = args.substr(args.find_first_of(' ') + 1);
+
+ if (x == "exact") {
+ std::string newX = y.substr(0, y.find_first_of(' '));
+ std::string newY = y.substr(y.find_first_of(' ') + 1);
+
+ if (!isNumber(newX) || !isNumber(newY)) {
+ Debug::log(ERR, "moveActive: exact args not numbers");
+ return;
+ }
+
+ const int X = std::stoi(newX);
+ const int Y = std::stoi(newY);
+
+ if (X < 10 || Y < 10) {
+ Debug::log(ERR, "moveActive: exact args cannot be < 10");
+ return;
+ }
+
+ // calc the delta
+ if (!g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow))
+ return; // ignore
+
+ const auto PWINDOW = g_pCompositor->m_pLastWindow;
+
+ const int DX = X - PWINDOW->m_vRealPosition.goalv().x;
+ const int DY = Y - PWINDOW->m_vRealPosition.goalv().y;
+
+ g_pLayoutManager->getCurrentLayout()->moveActiveWindow(Vector2D(DX, DY));
+
+ return;
+ }
+
+ if (!isNumber(x) || !isNumber(y)) {
+ Debug::log(ERR, "moveActive: args not numbers");
+ return;
+ }
+
+ const int X = std::stoi(x);
+ const int Y = std::stoi(y);
+
+ g_pLayoutManager->getCurrentLayout()->moveActiveWindow(Vector2D(X, Y));
+}
+
void CKeybindManager::circleNext(std::string) {
if (!g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow))
return;
diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp
index 4ebf94a3..c9132a11 100644
--- a/src/managers/KeybindManager.hpp
+++ b/src/managers/KeybindManager.hpp
@@ -58,6 +58,7 @@ private:
static void toggleSpecialWorkspace(std::string);
static void forceRendererReload(std::string);
static void resizeActive(std::string);
+ static void moveActive(std::string);
static void circleNext(std::string);
static void focusWindowByClass(std::string);
static void setSubmap(std::string);