mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-04 22:22:00 -07:00
dwindle: add better automatic window drag and drop direction detection (#9704)
This commit is contained in:
@@ -1757,6 +1757,12 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
|
|||||||
.type = CONFIG_OPTION_CHOICE,
|
.type = CONFIG_OPTION_CHOICE,
|
||||||
.data = SConfigOptionDescription::SChoiceData{0, "positional,current,opening"},
|
.data = SConfigOptionDescription::SChoiceData{0, "positional,current,opening"},
|
||||||
},
|
},
|
||||||
|
SConfigOptionDescription{
|
||||||
|
.value = "dwindle:precise_move",
|
||||||
|
.description = "if enabled, bindm movewindow will drop the window more precisely depending on where your mouse is.",
|
||||||
|
.type = CONFIG_OPTION_BOOL,
|
||||||
|
.data = SConfigOptionDescription::SBoolData{true},
|
||||||
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* master:
|
* master:
|
||||||
|
@@ -592,6 +592,7 @@ CConfigManager::CConfigManager() {
|
|||||||
registerConfigVar("dwindle:split_bias", Hyprlang::INT{0});
|
registerConfigVar("dwindle:split_bias", Hyprlang::INT{0});
|
||||||
registerConfigVar("dwindle:smart_split", Hyprlang::INT{0});
|
registerConfigVar("dwindle:smart_split", Hyprlang::INT{0});
|
||||||
registerConfigVar("dwindle:smart_resizing", Hyprlang::INT{1});
|
registerConfigVar("dwindle:smart_resizing", Hyprlang::INT{1});
|
||||||
|
registerConfigVar("dwindle:precise_move", Hyprlang::INT{0});
|
||||||
|
|
||||||
registerConfigVar("master:special_scale_factor", {1.f});
|
registerConfigVar("master:special_scale_factor", {1.f});
|
||||||
registerConfigVar("master:mfact", {0.55f});
|
registerConfigVar("master:mfact", {0.55f});
|
||||||
|
@@ -362,9 +362,33 @@ void IHyprLayout::onEndDragWindow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (DRAGGINGWINDOW->m_draggingTiled) {
|
if (DRAGGINGWINDOW->m_draggingTiled) {
|
||||||
|
static auto PPRECISEMOUSE = CConfigValue<Hyprlang::INT>("dwindle:precise_mouse_move");
|
||||||
DRAGGINGWINDOW->m_isFloating = false;
|
DRAGGINGWINDOW->m_isFloating = false;
|
||||||
g_pInputManager->refocus();
|
g_pInputManager->refocus();
|
||||||
changeWindowFloatingMode(DRAGGINGWINDOW);
|
|
||||||
|
if (*PPRECISEMOUSE) {
|
||||||
|
eDirection direction = DIRECTION_DEFAULT;
|
||||||
|
|
||||||
|
const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal();
|
||||||
|
const PHLWINDOW pReferenceWindow = g_pCompositor->vectorToWindowUnified(MOUSECOORDS, RESERVED_EXTENTS | INPUT_EXTENTS | ALLOW_FLOATING, DRAGGINGWINDOW);
|
||||||
|
|
||||||
|
if (pReferenceWindow && pReferenceWindow != DRAGGINGWINDOW) {
|
||||||
|
const Vector2D draggedCenter = DRAGGINGWINDOW->m_realPosition->goal() + DRAGGINGWINDOW->m_realSize->goal() / 2.f;
|
||||||
|
const Vector2D referenceCenter = pReferenceWindow->m_realPosition->goal() + pReferenceWindow->m_realSize->goal() / 2.f;
|
||||||
|
const float xDiff = draggedCenter.x - referenceCenter.x;
|
||||||
|
const float yDiff = draggedCenter.y - referenceCenter.y;
|
||||||
|
|
||||||
|
if (fabs(xDiff) > fabs(yDiff))
|
||||||
|
direction = xDiff < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
|
||||||
|
else
|
||||||
|
direction = yDiff < 0 ? DIRECTION_UP : DIRECTION_DOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
onWindowRemovedTiling(DRAGGINGWINDOW);
|
||||||
|
onWindowCreatedTiling(DRAGGINGWINDOW, direction);
|
||||||
|
} else
|
||||||
|
changeWindowFloatingMode(DRAGGINGWINDOW);
|
||||||
|
|
||||||
DRAGGINGWINDOW->m_lastFloatingSize = m_draggingWindowOriginalFloatSize;
|
DRAGGINGWINDOW->m_lastFloatingSize = m_draggingWindowOriginalFloatSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user