Verified Commit 199ff3d4 authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

containments/panel: fix icon applet hack in `addApplet`

childAt in currentLayout will return nothing when the initialization
process is still running, which will place the icon applet at a wrong
position and ruin the order of other applets.

BUG: 454105
FIXED-IN: 5.25
parent 3adba639
......@@ -26,11 +26,7 @@ function addApplet(applet, x, y) {
return applet.status !== PlasmaCore.Types.HiddenStatus || (!plasmoid.immutable && plasmoid.userConfiguring);
});
if (x >= 0 && y >= 0) {
appletsModel.insert(indexAtCoordinates(x, y), new_element)
// Insert icons to the left of whatever is at the center (usually a Task Manager),
// if it exists.
// Insert icons to the left of a Task Manager if it exists.
// FIXME TODO: This is a real-world fix to produce a sensible initial position for
// launcher icons added by launcher menu applets. The basic approach has been used
// since Plasma 1. However, "add launcher to X" is a generic-enough concept and
......@@ -39,9 +35,25 @@ function addApplet(applet, x, y) {
// of a specific type, and the containment caring about the applet type. In a better
// system the containment would be informed of requested launchers, and determine by
// itself what it wants to do with that information.
} else if (applet.pluginName === "org.kde.plasma.icon" &&
(middle = currentLayout.childAt(root.width / 2, root.height / 2))) {
appletsModel.insert(middle.index, new_element);
// x === 0 && y === 0: when adding a new application icon applet
// x === -1 && y === -1: when adding an application icon applet from the configuration
if (applet.pluginName === "org.kde.plasma.icon" && x === 0 && y === 0) {
let targetIndex = 0;
// Find task manager applet's index
for (let i = 0; i < appletsModel.count; ++i) {
const child = appletsModel.get(i).applet;
if (child.pluginName === "org.kde.plasma.icontasks"
|| child.pluginName === "org.kde.plasma.taskmanager"
|| child.pluginName === "org.kde.plasma.windowlist") {
targetIndex = i;
break;
}
}
appletsModel.insert(targetIndex, new_element);
} else if (x >= 0 && y >= 0) {
appletsModel.insert(indexAtCoordinates(x, y), new_element);
// Fall through to determining an appropriate insert position.
} else {
appletsModel.append(new_element);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment