Skip to content

ContainerWidget: clean up unreachable startSystemMove call site #2601

Description

@ten9876

Background

PR #2576 centralized frameless title-bar move handling in FramelessMoveHelper, migrating 6+ frameless title bars to a consistent macOS/Linux/Windows pattern. One call site was deliberately left out of that refactor and is worth a small follow-up.

The site

src/gui/containers/ContainerWidget.cpp:144-158:

void ContainerWidget::onTitleBarDragStart(const QPoint& /*globalPos*/)
{
    if (!m_titleBar) return;

    if (m_dockMode == DockMode::Floating) {
        if (auto* w = window()) {
            if (auto* h = w->windowHandle()) {
                h->startSystemMove();   // ← unguarded, no fallback, no Q_OS_MAC skip
                return;
            }
        }
    }
    // ... drag-to-reorder QDrag path follows
}

This is the same startSystemMove() pattern PR #2576 removed everywhere else, with two differences:

  1. No Q_OS_MAC guard — would re-introduce the macOS 5–10 second dead-zone bug if the line ever fires
  2. No return-value check or fallback — if startSystemMove() refuses, the user gets no movement at all

Currently unreachable, but worth fixing anyway

Tracing the state machine after #2576:

  • ContainerTitleBar::mousePressEvent early-returns when m_isFloating == true and never sets m_pressed
  • mouseMoveEvent short-circuits without emitting dragStartRequested when m_pressed is false
  • So ContainerWidget::onTitleBarDragStart is only reachable in the docked (non-floating) state, where m_dockMode == DockMode::Floating is false and the startSystemMove() branch is skipped

That makes the call effectively dead code right now. But: if a future refactor lets ContainerTitleBar::m_isFloating and ContainerWidget::m_dockMode == DockMode::Floating desync, that line would resurface and reproduce the macOS bug class that #2576 just fixed.

Suggested fix

Two reasonable options:

(a) Delete the dead branch. Simplest. The early-return logic in ContainerTitleBar makes it unreachable, and if floating-mode container drag ever gets re-enabled it should go through FramelessMoveHelper not startSystemMove.

void ContainerWidget::onTitleBarDragStart(const QPoint&)
{
    if (!m_titleBar) return;
    // (drag-to-reorder QDrag path follows)
}

(b) Route through FramelessMoveHelper. Preserves the floating-mode branch but routes it through the centralized helper so the macOS skip + manual fallback behavior is consistent with every other title bar.

I'd lean (a) — dead code carries no value, and if the feature comes back the helper integration is a one-liner at that point.

Context

73, Jeremy KK7GWY & Claude (AI dev partner)

Metadata

Metadata

Assignees

No one assigned

    Labels

    GUIUser interfaceenhancementImprovement to existing featuregood first issueGood for newcomersmaintainer-reviewRequires maintainer review before any action is taken

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions