aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAqa-Ib <[email protected]>2024-10-08 12:20:41 +0200
committerGitHub <[email protected]>2024-10-08 11:20:41 +0100
commit45e82199fb29f422ebbbfe06ce03022dfb6d645e (patch)
tree43877ae642661b159160d82bb4aa238bf011ee00
parent4711796d3800f1a6673eccbd50e8e8a02bb0fd85 (diff)
downloadHyprland-45e82199fb29f422ebbbfe06ce03022dfb6d645e.tar.gz
Hyprland-45e82199fb29f422ebbbfe06ce03022dfb6d645e.zip
layout: add drag_into_group to control merging dragging windows (#8004)
-rw-r--r--src/config/ConfigDescriptions.hpp6
-rw-r--r--src/config/ConfigManager.cpp1
-rw-r--r--src/layout/IHyprLayout.cpp65
-rw-r--r--src/render/decorations/CHyprGroupBarDecoration.cpp16
4 files changed, 63 insertions, 25 deletions
diff --git a/src/config/ConfigDescriptions.hpp b/src/config/ConfigDescriptions.hpp
index 385d4e59..2ca230be 100644
--- a/src/config/ConfigDescriptions.hpp
+++ b/src/config/ConfigDescriptions.hpp
@@ -778,6 +778,12 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
.type = CONFIG_OPTION_BOOL,
.data = SConfigOptionDescription::SBoolData{true},
},
+ SConfigOptionDescription{
+ .value = "group:drag_into_group",
+ .description = "whether dragging a window into a unlocked group will merge them. Options: 0 (disabled), 1 (enabled), 2 (only when dragging into the groupbar)",
+ .type = CONFIG_OPTION_CHOICE,
+ .data = SConfigOptionDescription::SChoiceData{0, "disabled,enabled,only when dragging into the groupbar"},
+ },
/*
* group:groupbar:
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index 018deaa7..9a5283fa 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -378,6 +378,7 @@ CConfigManager::CConfigManager() {
m_pConfig->addConfigValue("group:focus_removed_window", Hyprlang::INT{1});
m_pConfig->addConfigValue("group:merge_groups_on_drag", Hyprlang::INT{1});
m_pConfig->addConfigValue("group:auto_group", Hyprlang::INT{1});
+ m_pConfig->addConfigValue("group:drag_into_group", Hyprlang::INT{1});
m_pConfig->addConfigValue("group:groupbar:enabled", Hyprlang::INT{1});
m_pConfig->addConfigValue("group:groupbar:font_family", {STRVAL_EMPTY});
m_pConfig->addConfigValue("group:groupbar:font_size", Hyprlang::INT{8});
diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp
index f090e87d..f249d2b5 100644
--- a/src/layout/IHyprLayout.cpp
+++ b/src/layout/IHyprLayout.cpp
@@ -193,17 +193,7 @@ bool IHyprLayout::onWindowCreatedAutoGroup(PHLWINDOW pWindow) {
&& pWindow->canBeGroupedInto(OPENINGON) // check if the new window can be grouped into OPENINGON
&& !g_pXWaylandManager->shouldBeFloated(pWindow)) { // don't group XWayland windows that should be floated.
- switch (pWindow->m_bIsFloating) {
- case false:
- if (OPENINGON->m_bIsFloating)
- pWindow->m_bIsFloating = true;
- break;
-
- case true:
- if (!OPENINGON->m_bIsFloating)
- pWindow->m_bIsFloating = false;
- break;
- }
+ pWindow->m_bIsFloating = OPENINGON->m_bIsFloating; // match the floating state
static auto USECURRPOS = CConfigValue<Hyprlang::INT>("group:insert_after_current");
(*USECURRPOS ? OPENINGON : OPENINGON->getGroupTail())->insertWindowToGroup(pWindow);
@@ -335,21 +325,47 @@ void IHyprLayout::onEndDragWindow() {
g_pInputManager->currentlyDraggedWindow.reset();
g_pInputManager->m_bWasDraggingWindow = true;
- if (DRAGGINGWINDOW->m_bDraggingTiled) {
- DRAGGINGWINDOW->m_bIsFloating = false;
- g_pInputManager->refocus();
- changeWindowFloatingMode(DRAGGINGWINDOW);
- DRAGGINGWINDOW->m_vLastFloatingSize = m_vDraggingWindowOriginalFloatSize;
- } else if (g_pInputManager->dragMode == MBIND_MOVE) {
+ if (g_pInputManager->dragMode == MBIND_MOVE) {
g_pHyprRenderer->damageWindow(DRAGGINGWINDOW);
const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal();
- PHLWINDOW pWindow = g_pCompositor->vectorToWindowUnified(MOUSECOORDS, RESERVED_EXTENTS | INPUT_EXTENTS | ALLOW_FLOATING | FLOATING_ONLY, DRAGGINGWINDOW);
+ PHLWINDOW pWindow = g_pCompositor->vectorToWindowUnified(MOUSECOORDS, RESERVED_EXTENTS | INPUT_EXTENTS | ALLOW_FLOATING, DRAGGINGWINDOW);
if (pWindow) {
if (pWindow->checkInputOnDecos(INPUT_TYPE_DRAG_END, MOUSECOORDS, DRAGGINGWINDOW))
return;
- if (pWindow->m_sGroupData.pNextWindow.lock() && DRAGGINGWINDOW->canBeGroupedInto(pWindow)) {
+ bool denied = false;
+ if (!pWindow->m_bIsFloating && !DRAGGINGWINDOW->m_bDraggingTiled)
+ denied = true;
+
+ static auto PDRAGINTOGROUP = CConfigValue<Hyprlang::INT>("group:drag_into_group");
+ if (pWindow->m_sGroupData.pNextWindow.lock() && DRAGGINGWINDOW->canBeGroupedInto(pWindow) && *PDRAGINTOGROUP == 1 && !denied) {
+ if (DRAGGINGWINDOW->m_bDraggingTiled) {
+ changeWindowFloatingMode(DRAGGINGWINDOW);
+ DRAGGINGWINDOW->m_vLastFloatingSize = m_vDraggingWindowOriginalFloatSize;
+ DRAGGINGWINDOW->m_bDraggingTiled = false;
+ }
+
+ if (DRAGGINGWINDOW->m_sGroupData.pNextWindow.lock()) {
+ std::vector<PHLWINDOW> members;
+ PHLWINDOW curr = DRAGGINGWINDOW->getGroupHead();
+ do {
+ members.push_back(curr);
+ curr = curr->m_sGroupData.pNextWindow.lock();
+ } while (curr != members[0]);
+
+ for (auto it = members.begin(); it != members.end(); ++it) {
+ (*it)->m_bIsFloating = pWindow->m_bIsFloating; // match the floating state of group members
+ if (pWindow->m_bIsFloating)
+ (*it)->m_vRealSize = pWindow->m_vRealSize.goal(); // match the size of group members
+ }
+ }
+
+ DRAGGINGWINDOW->m_bIsFloating = pWindow->m_bIsFloating; // match the floating state of the window
+
+ if (pWindow->m_bIsFloating)
+ g_pXWaylandManager->setWindowSize(DRAGGINGWINDOW, pWindow->m_vRealSize.goal()); // match the size of the window
+
static auto USECURRPOS = CConfigValue<Hyprlang::INT>("group:insert_after_current");
(*USECURRPOS ? pWindow : pWindow->getGroupTail())->insertWindowToGroup(DRAGGINGWINDOW);
pWindow->setGroupCurrent(DRAGGINGWINDOW);
@@ -361,6 +377,13 @@ void IHyprLayout::onEndDragWindow() {
}
}
+ if (DRAGGINGWINDOW->m_bDraggingTiled) {
+ DRAGGINGWINDOW->m_bIsFloating = false;
+ g_pInputManager->refocus();
+ changeWindowFloatingMode(DRAGGINGWINDOW);
+ DRAGGINGWINDOW->m_vLastFloatingSize = m_vDraggingWindowOriginalFloatSize;
+ }
+
g_pHyprRenderer->damageWindow(DRAGGINGWINDOW);
g_pCompositor->focusWindow(DRAGGINGWINDOW);
@@ -553,10 +576,10 @@ void IHyprLayout::changeWindowFloatingMode(PHLWINDOW pWindow) {
pWindow->m_vLastFloatingSize = PSAVEDSIZE;
- // move to narnia because we don't wanna find our own node. onWindowCreated should apply the coords back.
+ // move to narnia because we don't wanna find our own node. onWindowCreatedTiling should apply the coords back.
pWindow->m_vPosition = Vector2D(-999999, -999999);
- onWindowCreated(pWindow);
+ onWindowCreatedTiling(pWindow);
pWindow->m_vRealPosition.setValue(PSAVEDPOS);
pWindow->m_vRealSize.setValue(PSAVEDSIZE);
diff --git a/src/render/decorations/CHyprGroupBarDecoration.cpp b/src/render/decorations/CHyprGroupBarDecoration.cpp
index 4cdb9043..ef6c81e6 100644
--- a/src/render/decorations/CHyprGroupBarDecoration.cpp
+++ b/src/render/decorations/CHyprGroupBarDecoration.cpp
@@ -402,8 +402,9 @@ bool CHyprGroupBarDecoration::onBeginWindowDragOnDeco(const Vector2D& pos) {
}
bool CHyprGroupBarDecoration::onEndWindowDragOnDeco(const Vector2D& pos, PHLWINDOW pDraggedWindow) {
- static auto PSTACKED = CConfigValue<Hyprlang::INT>("group:groupbar:stacked");
- if (!pDraggedWindow->canBeGroupedInto(m_pWindow.lock()))
+ static auto PSTACKED = CConfigValue<Hyprlang::INT>("group:groupbar:stacked");
+ static auto PDRAGINTOGROUP = CConfigValue<Hyprlang::INT>("group:drag_into_group");
+ if (!pDraggedWindow->canBeGroupedInto(m_pWindow.lock()) || (*PDRAGINTOGROUP != 1 && *PDRAGINTOGROUP != 2))
return false;
const float BARRELATIVE = *PSTACKED ? pos.y - assignedBoxGlobal().y - (m_fBarHeight + BAR_PADDING_OUTER_VERT) / 2 : pos.x - assignedBoxGlobal().x - m_fBarWidth / 2;
@@ -435,6 +436,9 @@ bool CHyprGroupBarDecoration::onEndWindowDragOnDeco(const Vector2D& pos, PHLWIND
// restores the group
for (auto it = members.begin(); it != members.end(); ++it) {
+ (*it)->m_bIsFloating = pWindowInsertAfter->m_bIsFloating; // match the floating state of group members
+ if (pWindowInsertAfter->m_bIsFloating)
+ (*it)->m_vRealSize = pWindowInsertAfter->m_vRealSize.goal(); // match the size of group members
if (std::next(it) != members.end())
(*it)->m_sGroupData.pNextWindow = *std::next(it);
else
@@ -442,9 +446,13 @@ bool CHyprGroupBarDecoration::onEndWindowDragOnDeco(const Vector2D& pos, PHLWIND
}
members[0]->m_sGroupData.head = true;
members[0]->m_sGroupData.locked = WASLOCKED;
- } else {
+ } else
g_pLayoutManager->getCurrentLayout()->onWindowRemoved(pDraggedWindow);
- }
+
+ pDraggedWindow->m_bIsFloating = pWindowInsertAfter->m_bIsFloating; // match the floating state of the window
+
+ if (pWindowInsertAfter->m_bIsFloating)
+ g_pXWaylandManager->setWindowSize(pDraggedWindow, pWindowInsertAfter->m_vRealSize.goal()); // match the size of the window
pWindowInsertAfter->insertWindowToGroup(pDraggedWindow);