summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMightyPlaza <123664421+MightyPlaza@users.noreply.github.com>2023-11-19 12:29:01 +0000
committerGitHub <noreply@github.com>2023-11-19 12:29:01 +0000
commitadd23a9ba26c6363c7180ed0b23394d9f1328be2 (patch)
treeca3a75f67ee4a57da76d8262978ef4dd074737ae /src
parent3d89654254a3cc23a57e1bdcd39ad9f743bf98e2 (diff)
group: fix dragging into floating groups (#3719)
* allow dragging into floating groups modified: src/Compositor.cpp modified: src/Compositor.hpp modified: src/layout/IHyprLayout.cpp modified: src/render/decorations/CHyprGroupBarDecoration.cpp * floating-only modified: src/layout/IHyprLayout.cpp
Diffstat (limited to 'src')
-rw-r--r--src/Compositor.cpp12
-rw-r--r--src/Compositor.hpp5
-rw-r--r--src/layout/IHyprLayout.cpp29
-rw-r--r--src/render/decorations/CHyprGroupBarDecoration.cpp3
4 files changed, 40 insertions, 9 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index 0c6fbc60..1b27a0f4 100644
--- a/src/Compositor.cpp
+++ b/src/Compositor.cpp
@@ -650,7 +650,7 @@ CWindow* CCompositor::vectorToWindowTiled(const Vector2D& pos) {
return nullptr;
}
-CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) {
+CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos, CWindow* pIgnoreWindow) {
const auto PMONITOR = getMonitorFromVector(pos);
static auto* const PRESIZEONBORDER = &g_pConfigManager->getConfigValuePtr("general:resize_on_border")->intValue;
static auto* const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
@@ -661,7 +661,7 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) {
for (auto& w : m_vWindows | std::views::reverse) {
const auto BB = w->getWindowInputBox();
CBox box = {BB.x - BORDER_GRAB_AREA, BB.y - BORDER_GRAB_AREA, BB.width + 2 * BORDER_GRAB_AREA, BB.height + 2 * BORDER_GRAB_AREA};
- if (w->m_bIsFloating && w->m_bIsMapped && !w->isHidden() && !w->m_bX11ShouldntFocus && w->m_bPinned && !w->m_bNoFocus) {
+ if (w->m_bIsFloating && w->m_bIsMapped && !w->isHidden() && !w->m_bX11ShouldntFocus && w->m_bPinned && !w->m_bNoFocus && w.get() != pIgnoreWindow) {
if (box.containsPoint({m_sWLRCursor->x, m_sWLRCursor->y}))
return w.get();
@@ -681,7 +681,7 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) {
const auto BB = w->getWindowInputBox();
CBox box = {BB.x - BORDER_GRAB_AREA, BB.y - BORDER_GRAB_AREA, BB.width + 2 * BORDER_GRAB_AREA, BB.height + 2 * BORDER_GRAB_AREA};
- if (w->m_bIsFloating && w->m_bIsMapped && isWorkspaceVisible(w->m_iWorkspaceID) && !w->isHidden() && !w->m_bPinned && !w->m_bNoFocus) {
+ if (w->m_bIsFloating && w->m_bIsMapped && isWorkspaceVisible(w->m_iWorkspaceID) && !w->isHidden() && !w->m_bPinned && !w->m_bNoFocus && w.get() != pIgnoreWindow) {
// OR windows should add focus to parent
if (w->m_bX11ShouldntFocus && w->m_iX11Type != 2)
continue;
@@ -711,7 +711,8 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) {
const int64_t WORKSPACEID = special ? PMONITOR->specialWorkspaceID : PMONITOR->activeWorkspace;
- if (!w->m_bIsX11 && !w->m_bIsFloating && w->m_bIsMapped && w->m_iWorkspaceID == WORKSPACEID && !w->isHidden() && !w->m_bX11ShouldntFocus && !w->m_bNoFocus) {
+ if (!w->m_bIsX11 && !w->m_bIsFloating && w->m_bIsMapped && w->m_iWorkspaceID == WORKSPACEID && !w->isHidden() && !w->m_bX11ShouldntFocus && !w->m_bNoFocus &&
+ w.get() != pIgnoreWindow) {
if ((w)->hasPopupAt(pos))
return w.get();
}
@@ -723,7 +724,8 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) {
const int64_t WORKSPACEID = special ? PMONITOR->specialWorkspaceID : PMONITOR->activeWorkspace;
CBox box = {w->m_vPosition.x, w->m_vPosition.y, w->m_vSize.x, w->m_vSize.y};
- if (!w->m_bIsFloating && w->m_bIsMapped && box.containsPoint(pos) && w->m_iWorkspaceID == WORKSPACEID && !w->isHidden() && !w->m_bX11ShouldntFocus && !w->m_bNoFocus)
+ if (!w->m_bIsFloating && w->m_bIsMapped && box.containsPoint(pos) && w->m_iWorkspaceID == WORKSPACEID && !w->isHidden() && !w->m_bX11ShouldntFocus && !w->m_bNoFocus &&
+ w.get() != pIgnoreWindow)
return w.get();
}
diff --git a/src/Compositor.hpp b/src/Compositor.hpp
index 7d187a80..829b7e79 100644
--- a/src/Compositor.hpp
+++ b/src/Compositor.hpp
@@ -29,8 +29,7 @@
#include "plugins/PluginSystem.hpp"
#include "helpers/Watchdog.hpp"
-enum eManagersInitStage
-{
+enum eManagersInitStage {
STAGE_PRIORITY = 0,
STAGE_LATE
};
@@ -137,7 +136,7 @@ class CCompositor {
void focusSurface(wlr_surface*, CWindow* pWindowOwner = nullptr);
bool windowExists(CWindow*);
bool windowValidMapped(CWindow*);
- CWindow* vectorToWindowIdeal(const Vector2D&); // used only for finding a window to focus on, basically a "findFocusableWindow"
+ CWindow* vectorToWindowIdeal(const Vector2D&, CWindow* pIgnoreWindow = nullptr); // used only for finding a window to focus on, basically a "findFocusableWindow"
CWindow* vectorToWindowTiled(const Vector2D&);
wlr_surface* vectorToLayerSurface(const Vector2D&, std::vector<std::unique_ptr<SLayerSurface>>*, Vector2D*, SLayerSurface**);
wlr_surface* vectorWindowToSurface(const Vector2D&, CWindow*, Vector2D& sl);
diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp
index 8bb51daf..acd84684 100644
--- a/src/layout/IHyprLayout.cpp
+++ b/src/layout/IHyprLayout.cpp
@@ -1,6 +1,7 @@
#include "IHyprLayout.hpp"
#include "../defines.hpp"
#include "../Compositor.hpp"
+#include "../render/decorations/CHyprGroupBarDecoration.hpp"
void IHyprLayout::onWindowCreated(CWindow* pWindow, eDirection direction) {
if (pWindow->m_bIsFloating) {
@@ -264,10 +265,36 @@ void IHyprLayout::onEndDragWindow() {
g_pInputManager->refocus();
changeWindowFloatingMode(DRAGGINGWINDOW);
DRAGGINGWINDOW->m_vLastFloatingSize = m_vDraggingWindowOriginalFloatSize;
+ } else if (g_pInputManager->dragMode == MBIND_MOVE) {
+ g_pHyprRenderer->damageWindow(DRAGGINGWINDOW);
+ const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal();
+ CWindow* pWindow = g_pCompositor->vectorToWindowIdeal(MOUSECOORDS, DRAGGINGWINDOW);
+
+ if (pWindow && pWindow->m_bIsFloating) {
+ for (auto& wd : pWindow->m_dWindowDecorations) {
+ if (!(wd->getDecorationFlags() & DECORATION_ALLOWS_MOUSE_INPUT))
+ continue;
+
+ if (g_pDecorationPositioner->getWindowDecorationBox(wd.get()).containsPoint(MOUSECOORDS)) {
+ if (!wd->onEndWindowDragOnDeco(DRAGGINGWINDOW, MOUSECOORDS))
+ return;
+ break;
+ }
+ }
+
+ if (pWindow->m_sGroupData.pNextWindow && DRAGGINGWINDOW->canBeGroupedInto(pWindow)) {
+ static const auto* USECURRPOS = &g_pConfigManager->getConfigValuePtr("group:insert_after_current")->intValue;
+ (*USECURRPOS ? pWindow : pWindow->getGroupTail())->insertWindowToGroup(DRAGGINGWINDOW);
+ pWindow->setGroupCurrent(DRAGGINGWINDOW);
+ DRAGGINGWINDOW->updateWindowDecos();
+
+ if (!DRAGGINGWINDOW->getDecorationByType(DECORATION_GROUPBAR))
+ DRAGGINGWINDOW->addWindowDeco(std::make_unique<CHyprGroupBarDecoration>(DRAGGINGWINDOW));
+ }
+ }
}
g_pHyprRenderer->damageWindow(DRAGGINGWINDOW);
-
g_pCompositor->focusWindow(DRAGGINGWINDOW);
g_pInputManager->m_bWasDraggingWindow = false;
diff --git a/src/render/decorations/CHyprGroupBarDecoration.cpp b/src/render/decorations/CHyprGroupBarDecoration.cpp
index 4e6776b4..acf74cef 100644
--- a/src/render/decorations/CHyprGroupBarDecoration.cpp
+++ b/src/render/decorations/CHyprGroupBarDecoration.cpp
@@ -344,6 +344,9 @@ bool CHyprGroupBarDecoration::onEndWindowDragOnDeco(CWindow* pDraggedWindow, con
pDraggedWindow->updateWindowDecos();
g_pLayoutManager->getCurrentLayout()->recalculateWindow(pDraggedWindow);
+ if (!pDraggedWindow->getDecorationByType(DECORATION_GROUPBAR))
+ pDraggedWindow->addWindowDeco(std::make_unique<CHyprGroupBarDecoration>(pDraggedWindow));
+
return false;
}