mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 21:06:01 +01:00
added resizewindowpixel and movewindowpixel
This commit is contained in:
parent
d47bfe6af1
commit
b0b3a5af10
4 changed files with 77 additions and 79 deletions
|
@ -1563,4 +1563,43 @@ SLayerSurface* CCompositor::getLayerSurfaceFromSurface(wlr_surface* pSurface) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns a delta
|
||||||
|
Vector2D CCompositor::parseWindowVectorArgsRelative(const std::string& args, const Vector2D& relativeTo) {
|
||||||
|
if (!args.contains(' '))
|
||||||
|
return relativeTo;
|
||||||
|
|
||||||
|
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, "parseWindowVectorArgsRelative: exact args not numbers");
|
||||||
|
return relativeTo;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int X = std::stoi(newX);
|
||||||
|
const int Y = std::stoi(newY);
|
||||||
|
|
||||||
|
if (X < 0 || Y < 0) {
|
||||||
|
Debug::log(ERR, "parseWindowVectorArgsRelative: exact args cannot be < 0");
|
||||||
|
return relativeTo;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Vector2D(X, Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isNumber(x) || !isNumber(y)) {
|
||||||
|
Debug::log(ERR, "parseWindowVectorArgsRelative: args not numbers");
|
||||||
|
return relativeTo;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int X = std::stoi(x);
|
||||||
|
const int Y = std::stoi(y);
|
||||||
|
|
||||||
|
return Vector2D(X + relativeTo.x, Y + relativeTo.y);
|
||||||
}
|
}
|
|
@ -158,6 +158,7 @@ public:
|
||||||
SLayerSurface* getLayerSurfaceFromWlr(wlr_layer_surface_v1*);
|
SLayerSurface* getLayerSurfaceFromWlr(wlr_layer_surface_v1*);
|
||||||
SLayerSurface* getLayerSurfaceFromSurface(wlr_surface*);
|
SLayerSurface* getLayerSurfaceFromSurface(wlr_surface*);
|
||||||
void closeWindow(CWindow*);
|
void closeWindow(CWindow*);
|
||||||
|
Vector2D parseWindowVectorArgsRelative(const std::string&, const Vector2D&);
|
||||||
|
|
||||||
|
|
||||||
std::string explicitConfigPath;
|
std::string explicitConfigPath;
|
||||||
|
|
|
@ -37,6 +37,8 @@ CKeybindManager::CKeybindManager() {
|
||||||
m_mDispatchers["layoutmsg"] = layoutmsg;
|
m_mDispatchers["layoutmsg"] = layoutmsg;
|
||||||
m_mDispatchers["toggleopaque"] = toggleOpaque;
|
m_mDispatchers["toggleopaque"] = toggleOpaque;
|
||||||
m_mDispatchers["dpms"] = dpms;
|
m_mDispatchers["dpms"] = dpms;
|
||||||
|
m_mDispatchers["movewindowpixel"] = moveWindow;
|
||||||
|
m_mDispatchers["resizewindowpixel"] = resizeWindow;
|
||||||
|
|
||||||
m_tScrollTimer.reset();
|
m_tScrollTimer.reset();
|
||||||
}
|
}
|
||||||
|
@ -1138,107 +1140,61 @@ void CKeybindManager::forceRendererReload(std::string args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKeybindManager::resizeActive(std::string args) {
|
void CKeybindManager::resizeActive(std::string args) {
|
||||||
if (!args.contains(' '))
|
|
||||||
return;
|
|
||||||
|
|
||||||
const auto PWINDOW = g_pCompositor->m_pLastWindow;
|
|
||||||
|
|
||||||
// calc the delta
|
|
||||||
if (!g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow))
|
if (!g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow))
|
||||||
return; // ignore
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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));
|
|
||||||
|
|
||||||
if (PWINDOW->m_vRealSize.goalv().x > 1 && PWINDOW->m_vRealSize.goalv().y > 1)
|
|
||||||
PWINDOW->m_bHidden = false;
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (!isNumber(x) || !isNumber(y)) {
|
const auto SIZ = g_pCompositor->parseWindowVectorArgsRelative(args, g_pCompositor->m_pLastWindow->m_vRealSize.goalv());
|
||||||
Debug::log(ERR, "resizeTiledWindow: args not numbers");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int X = std::stoi(x);
|
g_pLayoutManager->getCurrentLayout()->resizeActiveWindow(SIZ - g_pCompositor->m_pLastWindow->m_vRealSize.goalv());
|
||||||
const int Y = std::stoi(y);
|
|
||||||
|
|
||||||
g_pLayoutManager->getCurrentLayout()->resizeActiveWindow(Vector2D(X, Y));
|
if (g_pCompositor->m_pLastWindow->m_vRealSize.goalv().x > 1 && g_pCompositor->m_pLastWindow->m_vRealSize.goalv().y > 1)
|
||||||
|
g_pCompositor->m_pLastWindow->m_bHidden = false;
|
||||||
if (PWINDOW->m_vRealSize.goalv().x > 1 && PWINDOW->m_vRealSize.goalv().y > 1)
|
|
||||||
PWINDOW->m_bHidden = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKeybindManager::moveActive(std::string args) {
|
void CKeybindManager::moveActive(std::string args) {
|
||||||
if (!args.contains(' '))
|
if (!g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::string x = args.substr(0, args.find_first_of(' '));
|
const auto POS = g_pCompositor->parseWindowVectorArgsRelative(args, g_pCompositor->m_pLastWindow->m_vRealPosition.goalv());
|
||||||
std::string y = args.substr(args.find_first_of(' ') + 1);
|
|
||||||
|
|
||||||
if (x == "exact") {
|
g_pLayoutManager->getCurrentLayout()->moveActiveWindow(POS - g_pCompositor->m_pLastWindow->m_vRealPosition.goalv());
|
||||||
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)) {
|
void CKeybindManager::moveWindow(std::string args) {
|
||||||
Debug::log(ERR, "moveActive: exact args not numbers");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int X = std::stoi(newX);
|
const auto WINDOWREGEX = args.substr(args.find_first_of(',') + 1);
|
||||||
const int Y = std::stoi(newY);
|
const auto MOVECMD = args.substr(0, args.find_first_of(','));
|
||||||
|
|
||||||
if (X < 0 || Y < 0) {
|
const auto PWINDOW = g_pCompositor->getWindowByRegex(WINDOWREGEX);
|
||||||
Debug::log(ERR, "moveActive: exact args cannot be < 0");
|
|
||||||
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));
|
|
||||||
|
|
||||||
|
if (!PWINDOW) {
|
||||||
|
Debug::log(ERR, "moveWindow: no window");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isNumber(x) || !isNumber(y)) {
|
const auto POS = g_pCompositor->parseWindowVectorArgsRelative(MOVECMD, PWINDOW->m_vRealPosition.goalv());
|
||||||
Debug::log(ERR, "moveActive: args not numbers");
|
|
||||||
|
g_pLayoutManager->getCurrentLayout()->moveActiveWindow(POS - PWINDOW->m_vRealPosition.goalv(), PWINDOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CKeybindManager::resizeWindow(std::string args) {
|
||||||
|
|
||||||
|
const auto WINDOWREGEX = args.substr(args.find_first_of(',') + 1);
|
||||||
|
const auto MOVECMD = args.substr(0, args.find_first_of(','));
|
||||||
|
|
||||||
|
const auto PWINDOW = g_pCompositor->getWindowByRegex(WINDOWREGEX);
|
||||||
|
|
||||||
|
if (!PWINDOW) {
|
||||||
|
Debug::log(ERR, "resizeWindow: no window");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int X = std::stoi(x);
|
const auto SIZ = g_pCompositor->parseWindowVectorArgsRelative(MOVECMD, PWINDOW->m_vRealSize.goalv());
|
||||||
const int Y = std::stoi(y);
|
|
||||||
|
|
||||||
g_pLayoutManager->getCurrentLayout()->moveActiveWindow(Vector2D(X, Y));
|
g_pLayoutManager->getCurrentLayout()->resizeActiveWindow(SIZ - PWINDOW->m_vRealSize.goalv(), PWINDOW);
|
||||||
|
|
||||||
|
if (PWINDOW->m_vRealSize.goalv().x > 1 && PWINDOW->m_vRealSize.goalv().y > 1)
|
||||||
|
PWINDOW->m_bHidden = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKeybindManager::circleNext(std::string arg) {
|
void CKeybindManager::circleNext(std::string arg) {
|
||||||
|
|
|
@ -94,6 +94,8 @@ private:
|
||||||
static void forceRendererReload(std::string);
|
static void forceRendererReload(std::string);
|
||||||
static void resizeActive(std::string);
|
static void resizeActive(std::string);
|
||||||
static void moveActive(std::string);
|
static void moveActive(std::string);
|
||||||
|
static void moveWindow(std::string);
|
||||||
|
static void resizeWindow(std::string);
|
||||||
static void circleNext(std::string);
|
static void circleNext(std::string);
|
||||||
static void focusWindow(std::string);
|
static void focusWindow(std::string);
|
||||||
static void setSubmap(std::string);
|
static void setSubmap(std::string);
|
||||||
|
|
Loading…
Reference in a new issue