Skip to content
Merged
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
60 changes: 3 additions & 57 deletions panels/dock/taskmanager/package/TaskManager.qml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ ContainmentItem {
// Defined in main.qml as dockItemIconSize = dockItemMaxSize * 9 / 14.
// At default dock size (56), icon = 36px; at min (37), icon ≈ 24px; at max (100), icon ≈ 64px.
readonly property real iconWidthToMaxSizeRatio: 9 / 14
readonly property int minimumDockItemSize: Math.max(
Dock.MIN_DOCK_SIZE,
Math.round(Panel.rootObject.dockSize * Dock.MIN_DOCK_SIZE / Dock.DEFAULT_DOCK_SIZE))
readonly property real startPadding: Math.max(0, appTitleSpacing - (Panel.rootObject.dockItemMaxSize * (multitaskViewIconRatio - iconWidthToMaxSizeRatio) / 2))

implicitWidth: {
Expand Down Expand Up @@ -105,12 +102,10 @@ ContainmentItem {

TaskOverflowController {
id: taskOverflow
// Window-split title layout has priority. Only fall back to adaptive icon
// shrinking and overflow when no title layout can fit the available space.
enabled: Panel.fashionModeEnabled
&& (!textCalculator.enabled || textCalculator.totalWidth <= 0)
// Window-split title layout has priority. Otherwise keep the dock-sized
// icons and move excess tasks into overflow.
enabled: !textCalculator.enabled || textCalculator.totalWidth <= 0
availableExtent: Math.max(0, taskmanager.calcRemainingSpace(Panel.rootObject.dockItemMaxSize) - taskmanager.startPadding)
minimumReached: Panel.rootObject.dockItemMaxSize <= taskmanager.minimumDockItemSize + 0.5
fallbackItemExtent: Math.max(1, Panel.rootObject.dockItemMaxSize * taskmanager.iconWidthToMaxSizeRatio)
spacing: taskmanager.appTitleSpacing
overflowSidePadding: taskmanager.appTitleSpacing + 1
Expand Down Expand Up @@ -515,57 +510,8 @@ ContainmentItem {
}
}


// Solve for S (dockItemMaxSize). The forward layout equation is:
// totalSpace = appCount×S×itemRatio + gaps×max(10, S×spacingRatio)
// + max(0, spacing - S×k) + otherCount×S×multitaskViewIconRatio
//
// The max(10,…) makes this piecewise. Ignoring Math.round (continuous approx):
//
// Regime 1 (S×spacingRatio ≥ 10): no clamp, every term ∝ S.
// Factor out S → S = totalSpace / sum_of_coefficients.
//
// Regime 2 (S×spacingRatio < 10): spacing clamped to 10 (constant).
// startPad flips from S×(spacingRatio-k) to 10 - S×k.
// Separate constants from S-terms → S = (total - constants) / S_coefficient.
function solveMaxSizeFull(totalSpace, appCount, otherCount) {
if (appCount <= 0) {
return totalSpace;
}

const spacingRatio = iconWidthToMaxSizeRatio / 3; // 9/14 / 3
const k = (multitaskViewIconRatio - iconWidthToMaxSizeRatio) / 2; // ≈ 0.0786
const gaps = Math.max(0, appCount - 1);
const otherRatio = otherCount > 0 ? otherCount * multitaskViewIconRatio : 0;

// Regime 1: continuous spacing model
const S = totalSpace / (appCount * iconWidthToMaxSizeRatio + gaps * spacingRatio + otherRatio + spacingRatio - k);

// Regime 2: spacing clamped to 10
if (S * spacingRatio < 10) {
return Math.max(0, (totalSpace - gaps * 10 - 10) / (appCount * iconWidthToMaxSizeRatio - k + otherRatio));
}
return Math.max(0, S);
}

Component.onCompleted: {
taskmanager.Applet.setFashionMode(fashionMode)
Panel.rootObject.dockItemMaxSize = Qt.binding(function(){
const dockSize = Panel.rootObject.dockSize;
const appCount = visualModel.count;

if (appCount <= 0 || dockSize <= 0)
return dockSize;

if (textCalculator.enabled && textCalculator.totalWidth > 0)
return dockSize;

const otherItems = Math.max(0, Panel.rootObject.dockCenterPartCount - 1);
const optimal = solveMaxSizeFull(Panel.rootObject.dockEffectiveCenterSpace, appCount, otherItems);
const fitted = optimal >= dockSize ? dockSize : optimal;
// Before task overflow, icons kept shrinking to fit all tasks.
return Panel.fashionModeEnabled ? Math.max(taskmanager.minimumDockItemSize, fitted) : fitted;
})
taskOverflow.scheduleSync()
}
}
10 changes: 1 addition & 9 deletions panels/dock/taskmanager/taskoverflowcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,6 @@ void TaskOverflowController::setAvailableExtent(qreal availableExtent)
}
}

void TaskOverflowController::setMinimumReached(bool minimumReached)
{
if (m_minimumReached != minimumReached) {
m_minimumReached = minimumReached;
scheduleSync();
}
}

void TaskOverflowController::setFallbackItemExtent(qreal fallbackItemExtent)
{
fallbackItemExtent = std::isfinite(fallbackItemExtent) ? std::max<qreal>(1, fallbackItemExtent) : 1;
Expand Down Expand Up @@ -379,7 +371,7 @@ bool TaskOverflowController::syncEnabledState(int totalCount, qreal fullExtent)
const qreal stopThreshold = std::max<qreal>(0, m_availableExtent - OverflowReleaseHysteresis);
const bool nextLatched = m_latched
? fullExtent > stopThreshold
: (m_minimumReached && fullExtent > startThreshold);
: fullExtent > startThreshold;
m_latched = nextLatched;
return m_latched;
}
Expand Down
8 changes: 0 additions & 8 deletions panels/dock/taskmanager/taskoverflowcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class TaskOverflowController : public QObject
Q_OBJECT
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(qreal availableExtent READ availableExtent WRITE setAvailableExtent)
Q_PROPERTY(bool minimumReached READ minimumReached WRITE setMinimumReached)
Q_PROPERTY(qreal fallbackItemExtent READ fallbackItemExtent WRITE setFallbackItemExtent NOTIFY fallbackItemExtentChanged)
Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
Q_PROPERTY(qreal overflowSidePadding READ overflowSidePadding WRITE setOverflowSidePadding NOTIFY overflowSidePaddingChanged)
Expand Down Expand Up @@ -70,12 +69,6 @@ class TaskOverflowController : public QObject
}
void setAvailableExtent(qreal availableExtent);

bool minimumReached() const
{
return m_minimumReached;
}
void setMinimumReached(bool minimumReached);

qreal fallbackItemExtent() const
{
return m_fallbackItemExtent;
Expand Down Expand Up @@ -162,7 +155,6 @@ private Q_SLOTS:

bool m_enabled = true;
qreal m_availableExtent = 0;
bool m_minimumReached = false;
qreal m_fallbackItemExtent = 1;
qreal m_spacing = 0;
qreal m_overflowSidePadding = 0;
Expand Down
Loading