mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-22 18:09:50 +01:00
Added exact to resizeActive and added moveactive
This commit is contained in:
parent
f9745b0d3b
commit
31dc70a41a
5 changed files with 106 additions and 5 deletions
|
@ -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);
|
||||
}
|
|
@ -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*);
|
||||
|
|
|
@ -55,6 +55,12 @@ public:
|
|||
Optional pWindow for a specific window
|
||||
*/
|
||||
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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue