Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customizable directional window resize logic #6571

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Compositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ PHLWINDOW CCompositor::vectorToWindowUnified(const Vector2D& pos, uint8_t proper
if (properties & ALLOW_FLOATING) {
for (auto& w : m_vWindows | std::views::reverse) {
const auto BB = w->getWindowBoxUnified(properties);
CBox box = BB.copy().expand(w->m_iX11Type == 2 ? BORDER_GRAB_AREA : 0);
CBox box = BB.copy().expand(w->m_iX11Type != 2 ? BORDER_GRAB_AREA : 0);
if (w->m_bIsFloating && w->m_bIsMapped && !w->isHidden() && !w->m_bX11ShouldntFocus && w->m_bPinned && !w->m_sAdditionalConfigData.noFocus && w != pIgnoreWindow) {
if (box.containsPoint(g_pPointerManager->position()))
return w;
Expand Down Expand Up @@ -730,7 +730,7 @@ PHLWINDOW CCompositor::vectorToWindowUnified(const Vector2D& pos, uint8_t proper
BB.x + BB.width <= PWINDOWMONITOR->vecPosition.x + PWINDOWMONITOR->vecSize.x && BB.y + BB.height <= PWINDOWMONITOR->vecPosition.y + PWINDOWMONITOR->vecSize.y)
continue;

CBox box = BB.copy().expand(w->m_iX11Type == 2 ? BORDER_GRAB_AREA : 0);
CBox box = BB.copy().expand(w->m_iX11Type != 2 ? BORDER_GRAB_AREA : 0);
if (w->m_bIsFloating && w->m_bIsMapped && isWorkspaceVisible(w->m_pWorkspace) && !w->isHidden() && !w->m_bPinned && !w->m_sAdditionalConfigData.noFocus &&
w != pIgnoreWindow && (!aboveFullscreen || w->m_bCreatedOverFullscreen)) {
// OR windows should add focus to parent
Expand Down
2 changes: 2 additions & 0 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ CConfigManager::CConfigManager() {
m_pConfig->addConfigValue("general:layout", {"dwindle"});
m_pConfig->addConfigValue("general:allow_tearing", Hyprlang::INT{0});
m_pConfig->addConfigValue("general:resize_corner", Hyprlang::INT{0});
m_pConfig->addConfigValue("general:edge_depth", {0.0f});
m_pConfig->addConfigValue("general:resize_mouse_bind_pattern", Hyprlang::INT{0});

m_pConfig->addConfigValue("misc:disable_hyprland_logo", Hyprlang::INT{0});
m_pConfig->addConfigValue("misc:disable_splash_rendering", Hyprlang::INT{0});
Expand Down
78 changes: 55 additions & 23 deletions src/layout/DwindleLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "../render/decorations/CHyprGroupBarDecoration.hpp"
#include "../Compositor.hpp"
#include "../config/ConfigValue.hpp"
#include "debug/Log.hpp"

void SDwindleNodeData::recalcSizePosRecursive(bool force, bool horizontalOverride, bool verticalOverride) {
if (children[0]) {
Expand Down Expand Up @@ -624,29 +625,60 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorn
if (!m_PseudoDragFlags.started) {
m_PseudoDragFlags.started = true;

const auto pseudoSize = PWINDOW->m_vRealSize.goal();
const auto mouseOffset = g_pInputManager->getMouseCoordsInternal() - (PNODE->box.pos() + ((PNODE->box.size() / 2) - (pseudoSize / 2)));

if (mouseOffset.x > 0 && mouseOffset.x < pseudoSize.x && mouseOffset.y > 0 && mouseOffset.y < pseudoSize.y) {
m_PseudoDragFlags.pseudo = true;
m_PseudoDragFlags.xExtent = mouseOffset.x > pseudoSize.x / 2;
m_PseudoDragFlags.yExtent = mouseOffset.y > pseudoSize.y / 2;

PWINDOW->m_vPseudoSize = pseudoSize;
} else {
// I know this appears like 4 times...
static auto b = CConfigValue<Hyprlang::INT>("general:border_size");
static auto r = CConfigValue<Hyprlang::INT>("general:resize_on_border");
static auto e = CConfigValue<Hyprlang::INT>("general:extend_border_grab_area");
const CBox h = {-(*b + *e * (*r != 0)), -(*b + *e * (*r != 0)), 2 * (*b + *e * (*r != 0)) + 1, 2 * (*b + *e * (*r != 0)) + 1}; // why weird vs IHyprlayout:432 ?
const CBox p = {PWINDOW->m_vRealPosition.goal() + h.pos(), PWINDOW->m_vRealSize.goal() + h.size()};

if (p.containsPoint(g_pInputManager->getMouseCoordsInternal())) {
m_PseudoDragFlags.pseudo = true;

switch (corner) {
case CORNER_TOPLEFT:
m_PseudoDragFlags.xExtent = -1;
m_PseudoDragFlags.yExtent = -1;
break;
case CORNER_TOPRIGHT:
m_PseudoDragFlags.xExtent = 1;
m_PseudoDragFlags.yExtent = -1;
break;
case CORNER_BOTTOMRIGHT:
m_PseudoDragFlags.xExtent = 1;
m_PseudoDragFlags.yExtent = 1;
break;
case CORNER_BOTTOMLEFT:
m_PseudoDragFlags.xExtent = -1;
m_PseudoDragFlags.yExtent = 1;
break;
case EDGE_TOP:
m_PseudoDragFlags.xExtent = 0;
m_PseudoDragFlags.yExtent = -1;
break;
case EDGE_RIGHT:
m_PseudoDragFlags.xExtent = 1;
m_PseudoDragFlags.yExtent = 0;
break;
case EDGE_BOTTOM:
m_PseudoDragFlags.xExtent = 0;
m_PseudoDragFlags.yExtent = 1;
break;
case EDGE_LEFT:
m_PseudoDragFlags.xExtent = -1;
m_PseudoDragFlags.yExtent = 0;
break;
default: break; // idk future problem
}

PWINDOW->m_vPseudoSize = pWindow->m_vRealSize.goal();
} else
m_PseudoDragFlags.pseudo = false;
}
}

if (m_PseudoDragFlags.pseudo) {
if (m_PseudoDragFlags.xExtent)
PWINDOW->m_vPseudoSize.x += pixResize.x * 2;
else
PWINDOW->m_vPseudoSize.x -= pixResize.x * 2;
if (m_PseudoDragFlags.yExtent)
PWINDOW->m_vPseudoSize.y += pixResize.y * 2;
else
PWINDOW->m_vPseudoSize.y -= pixResize.y * 2;
PWINDOW->m_vPseudoSize.x += 2 * pixResize.x * m_PseudoDragFlags.xExtent;
PWINDOW->m_vPseudoSize.y += 2 * pixResize.y * m_PseudoDragFlags.yExtent;

CBox wbox = PNODE->box;
wbox.round();
Expand Down Expand Up @@ -675,10 +707,10 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorn
SDwindleNodeData* PHOUTER = nullptr;
SDwindleNodeData* PHINNER = nullptr;

const auto LEFT = corner == CORNER_TOPLEFT || corner == CORNER_BOTTOMLEFT || DISPLAYRIGHT;
const auto TOP = corner == CORNER_TOPLEFT || corner == CORNER_TOPRIGHT || DISPLAYBOTTOM;
const auto RIGHT = corner == CORNER_TOPRIGHT || corner == CORNER_BOTTOMRIGHT || DISPLAYLEFT;
const auto BOTTOM = corner == CORNER_BOTTOMLEFT || corner == CORNER_BOTTOMRIGHT || DISPLAYTOP;
const auto LEFT = corner == EDGE_LEFT || corner == CORNER_TOPLEFT || corner == CORNER_BOTTOMLEFT /*|| DISPLAYRIGHT*/;
const auto TOP = corner == EDGE_TOP || corner == CORNER_TOPLEFT || corner == CORNER_TOPRIGHT /*|| DISPLAYBOTTOM*/;
const auto RIGHT = corner == EDGE_RIGHT || corner == CORNER_TOPRIGHT || corner == CORNER_BOTTOMRIGHT /*|| DISPLAYLEFT*/;
const auto BOTTOM = corner == EDGE_BOTTOM || corner == CORNER_BOTTOMLEFT || corner == CORNER_BOTTOMRIGHT /*|| DISPLAYTOP*/;
const auto NONE = corner == CORNER_NONE;

for (auto PCURRENT = PNODE; PCURRENT && PCURRENT->pParent; PCURRENT = PCURRENT->pParent) {
Expand Down
4 changes: 2 additions & 2 deletions src/layout/DwindleLayout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ class CHyprDwindleLayout : public IHyprLayout {
struct {
bool started = false;
bool pseudo = false;
bool xExtent = false;
bool yExtent = false;
int xExtent = 0;
int yExtent = 0;
} m_PseudoDragFlags;

std::optional<Vector2D> m_vOverrideFocalPoint; // for onWindowCreatedTiling.
Expand Down
Loading
Loading