introduce plasmoid:TasksExtendedManager

--All the Tasks WORKSAROUNDS for libtaskmanager
limitation in one place
pull/6/head
Michail Vourlakos 6 years ago
parent b7f1440385
commit 7ffe7d436d

@ -1295,7 +1295,7 @@ Item {
}
function setGlobalDirectRender(value) {
if (latteApplet && latteApplet.waitingLaunchers.length > 0)
if (latteApplet && latteApplet.tasksExtendedManager.waitingLaunchersLength() > 0)
return;
if (value === true) {

@ -38,15 +38,6 @@ Item {
property int lastRealTaskIndex: -1
property int countRealTasks: -1
//tasks that change state (launcher,startup,window) and
//at the next state must look the same
//(id, mScale)
property variant frozenTasks: []
//new launchers in order to be moved in correct place
//(launcher, pos)
property variant launchersToBeMoved: []
Connections{
target: root
onTasksCountChanged: parManager.updateTasksEdgesIndexes();
@ -241,41 +232,6 @@ Item {
return false;
}
//! Frozen Tasks functions
function getFrozenTask(identifier) {
for(var i=0; i<frozenTasks.length; ++i) {
if (frozenTasks[i].id === identifier) {
return frozenTasks[i];
}
}
}
function removeFrozenTask(identifier) {
var taskIndex = -1;
for(var i=0; i<frozenTasks.length; ++i) {
if (frozenTasks[i].id === identifier) {
taskIndex = i;
}
}
if (taskIndex > -1) {
frozenTasks.splice(taskIndex, 1);
}
}
function setFrozenTask(identifier, scale) {
var frozenTaskExists = false;
console.log("SET FROZEN :: "+identifier+" - "+scale);
var frozenTask = getFrozenTask(identifier);
if (frozenTask) {
frozenTask.mScale = scale;
} else {
frozenTasks.push({id: identifier, mScale: scale});
}
}
function availableLowerIndex(from) {
var next = from;
@ -454,102 +410,4 @@ Item {
else
return "";
}
//! launchersToBeMoved, new launchers to have been added and must be repositioned
function addLauncherToBeMoved(launcherUrl, toPos) {
if (!isLauncherToBeMoved(launcherUrl)) {
launchersToBeMoved.push({launcher: launcherUrl, pos: Math.max(0,toPos)});
//console.log("-add launcher-");
//printLaunchersToBeMoved()
}
}
function printLaunchersToBeMoved(){
for (var j=0; j<launchersToBeMoved.length; ++j){
console.log(launchersToBeMoved[j].launcher+ " - "+launchersToBeMoved[j].pos);
}
}
function moveLauncherToCorrectPos(launcherUrl, from) {
if (isLauncherToBeMoved(launcherUrl)) {
launchersToBeMovedTimer.from = from;
launchersToBeMovedTimer.to = posOfLauncherToBeMoved(launcherUrl);
launchersToBeMovedTimer.launcherUrl = launcherUrl
removeLauncherToBeMoved(launcherUrl);
launchersToBeMovedTimer.start();
}
}
function removeLauncherToBeMoved(launcherUrl) {
if (isLauncherToBeMoved(launcherUrl)) {
var sLength = launchersToBeMoved.length;
var index = -1;
for (var i=0; i<sLength; ++i) {
//!safety checker
if (i>=launchersToBeMoved.length)
return -1;
if (launchersToBeMoved[i].launcher === launcherUrl) {
index = i;
break;
}
}
if (index > -1) {
// console.log("removing launcher to be moved:: "+launcherUrl);
launchersToBeMoved.splice(index, 1);
}
}
}
function posOfLauncherToBeMoved(launcherUrl) {
var sLength = launchersToBeMoved.length;
for (var i=0; i<sLength; ++i) {
//!safety checker
if (i>=launchersToBeMoved.length)
return -1;
if (launchersToBeMoved[i].launcher === launcherUrl)
return launchersToBeMoved[i].pos;
}
return -1;
}
function isLauncherToBeMoved(launcher) {
return (posOfLauncherToBeMoved(launcher) >= 0);
}
//!Trying to avoid a binding loop in TaskItem for modelLauncherUrl
Timer {
id: launchersToBeMovedTimer
interval: 50
property int from: -1
property int to: -1
property string launcherUrl: ""
onTriggered: {
//console.log("to be moved: "+launcherUrl + " - " + from +" -> "+to)
tasksModel.move(from, to);
if (latteView && latteView.launchersGroup >= Latte.Types.LayoutLaunchers) {
latteView.layoutsManager.launchersSignals.moveTask(root.viewLayoutName,
plasmoid.id, latteView.launchersGroup, from, to);
}
delayedLaynchersSyncTimer.start();
}
}
//! delay a bit the launchers syncing in order to avoid a crash
//! the crash was caused from ParabolicManager when adding and moving a launcher (e.g. internal separator)
//! and there were more than one synced docks
Timer {
id: delayedLaynchersSyncTimer
interval: 200
onTriggered: tasksModel.syncLaunchers();
}
}

@ -0,0 +1,273 @@
/*
* Copyright 2019 Michail Vourlakos <mvourlakos@gmail.com>
*
*
* This file is part of Latte-Dock
*
* Latte-Dock is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* Latte-Dock is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.0
import org.kde.plasma.plasmoid 2.0
import org.kde.latte 0.2 as Latte
//! Trying to WORKAROUND all the Plasma LibTaskManager limitations
//! concerning Tasks AND Launchers.
//!
//! Plasma LibTaskManager constantly creates ADDITIONS/REMOVALS when
//! a Task is changing its type from Launcher<->Startup<->Window.
//! This libtaskmanager behavior limits a lot the animations that
//! can be created in order to provide a moder user experience
//!
//! All the logic that is trying to improve the mentioned limits is provided
//! from this class
Item {
id: tasksExtManager
/// Launchers that are playing an ADD or REMOVAL animation
/// and their Starups/Windows should be aware of
property variant waitingLaunchers: []
//! Launchers that must be shown IMMEDIATELY after a window removal
//! because they are already present from a present libtaskmanager state
property variant immediateLaunchers: []
//! New launchers in order to be moved in correct place:
//! launcher, pos)
property variant launchersToBeMoved: []
//! Tasks that change state (launcher,startup,window) and
//! at the next state must look the same concerning the parabolic effect:
//! (id, mScale)
property variant frozenTasks: []
signal waitingLauncherRemoved(string launch);
/////////// FUNCTIONALITY ////////////////////
/// WAITING LAUNCHERS
function addWaitingLauncher(launch){
if (waitingLauncherExists(launch)) {
return;
}
waitingLaunchers.push(launch);
}
function removeWaitingLauncher(launch){
for(var i=0; i<waitingLaunchers.length; ++i){
if (equalsWaitingLauncher(waitingLaunchers[i], launch)) {
waitingLaunchers.splice(i,1);
waitingLauncherRemoved(launch);
return;
}
}
}
function waitingLauncherExists(launch){
for(var i=0; i<waitingLaunchers.length; ++i){
if (equalsWaitingLauncher(waitingLaunchers[i], launch)) {
return true;
}
}
return false;
}
function equalsWaitingLauncher(waitingLauncher, launcher) {
var equals = ( launcher !== ""
&& waitingLauncher !== ""
&& (launcher.indexOf(waitingLauncher) >= 0 || waitingLauncher.indexOf(launcher) >= 0));
return equals;
}
function waitingLaunchersLength() {
return waitingLaunchers.length;
}
//! IMMEDIATELAUNCHERS
function addImmediateLauncher(launch){
if (!immediateLauncherExists(launch)) {
//console.log("Immediate Launcher Added::: "+launch);
immediateLaunchers.push(launch);
}
}
function removeImmediateLauncher(launch){
for(var i=0; i<immediateLaunchers.length; ++i){
if (immediateLaunchers[i]===launch) {
immediateLaunchers.splice(i,1);
//console.log("Immediate Launcher Removed::: "+launch);
return;
}
}
}
function immediateLauncherExists(launch){
for(var i=0; i<immediateLaunchers.length; ++i){
if (immediateLaunchers[i]===launch) {
return true;
}
}
return false;
}
//!
//! FROZENTASKS
function getFrozenTask(identifier) {
for(var i=0; i<frozenTasks.length; ++i) {
if (frozenTasks[i].id === identifier) {
return frozenTasks[i];
}
}
}
function removeFrozenTask(identifier) {
var taskIndex = -1;
for(var i=0; i<frozenTasks.length; ++i) {
if (frozenTasks[i].id === identifier) {
taskIndex = i;
}
}
if (taskIndex > -1) {
frozenTasks.splice(taskIndex, 1);
}
}
function setFrozenTask(identifier, scale) {
var frozenTaskExists = false;
console.log("SET FROZEN :: "+identifier+" - "+scale);
var frozenTask = getFrozenTask(identifier);
if (frozenTask) {
frozenTask.mScale = scale;
} else {
frozenTasks.push({id: identifier, mScale: scale});
}
}
//! LAUNCHERSTOBEMOVED
//! launchersToBeMoved, new launchers to have been added and must be repositioned
function addLauncherToBeMoved(launcherUrl, toPos) {
if (!isLauncherToBeMoved(launcherUrl)) {
launchersToBeMoved.push({launcher: launcherUrl, pos: Math.max(0,toPos)});
//console.log("-add launcher-");
//printLaunchersToBeMoved()
}
}
function printLaunchersToBeMoved(){
for (var j=0; j<launchersToBeMoved.length; ++j){
console.log(launchersToBeMoved[j].launcher+ " - "+launchersToBeMoved[j].pos);
}
}
function moveLauncherToCorrectPos(launcherUrl, from) {
if (isLauncherToBeMoved(launcherUrl)) {
launchersToBeMovedTimer.from = from;
launchersToBeMovedTimer.to = posOfLauncherToBeMoved(launcherUrl);
launchersToBeMovedTimer.launcherUrl = launcherUrl
removeLauncherToBeMoved(launcherUrl);
launchersToBeMovedTimer.start();
}
}
function removeLauncherToBeMoved(launcherUrl) {
if (isLauncherToBeMoved(launcherUrl)) {
var sLength = launchersToBeMoved.length;
var index = -1;
for (var i=0; i<sLength; ++i) {
//!safety checker
if (i>=launchersToBeMoved.length)
return -1;
if (launchersToBeMoved[i].launcher === launcherUrl) {
index = i;
break;
}
}
if (index > -1) {
// console.log("removing launcher to be moved:: "+launcherUrl);
launchersToBeMoved.splice(index, 1);
}
}
}
function posOfLauncherToBeMoved(launcherUrl) {
var sLength = launchersToBeMoved.length;
for (var i=0; i<sLength; ++i) {
//!safety checker
if (i>=launchersToBeMoved.length)
return -1;
if (launchersToBeMoved[i].launcher === launcherUrl)
return launchersToBeMoved[i].pos;
}
return -1;
}
function isLauncherToBeMoved(launcher) {
return (posOfLauncherToBeMoved(launcher) >= 0);
}
//!Trying to avoid a binding loop in TaskItem for modelLauncherUrl
Timer {
id: launchersToBeMovedTimer
interval: 50
property int from: -1
property int to: -1
property string launcherUrl: ""
onTriggered: {
//console.log("to be moved: "+launcherUrl + " - " + from +" -> "+to)
tasksModel.move(from, to);
/*if (latteView && latteView.launchersGroup >= Latte.Types.LayoutLaunchers) {
latteView.layoutsManager.launchersSignals.moveTask(root.viewLayoutName,
plasmoid.id,
latteView.launchersGroup,
from,
to);
}*/
delayedLaynchersSyncTimer.start();
}
}
//! delay a bit the launchers syncing in order to avoid a crash
//! the crash was caused from TasksExtendedManager when adding and moving a launcher (e.g. internal separator)
//! and there were more than one synced docks
Timer {
id: delayedLaynchersSyncTimer
interval: 450
onTriggered: tasksModel.syncLaunchers();
}
}

@ -122,18 +122,13 @@ Item {
//in launcher reference from libtaskmanager
property variant badgers:[]
property variant launchersOnActivities: []
property variant waitingLaunchers: []
//! launchers that are shown after a window removal and must be shown
//! immediately because they are already present!
property variant immediateLaunchers: []
//global plasmoid reference to the context menu
property QtObject contextMenu: null
property QtObject contextMenuComponent: Qt.createComponent("ContextMenu.qml");
property Item dragSource: null
property Item parabolicManager: _parabolicManager
property Item tasksExtendedManager: _tasksExtendedManager
//separator calculations based on audoban's design
property int maxSeparatorLength: {
@ -300,7 +295,6 @@ Item {
signal updateScale(int delegateIndex, real newScale, real step)
signal mimicEnterForParabolic();
signal publishTasksGeometries();
signal waitingLauncherRemoved(string launch);
signal windowsHovered(variant winIds, bool hovered)
//onAnimationsChanged: console.log(animations);
@ -507,68 +501,6 @@ Item {
return launch;
}
/// waiting launchers... this is used in order to check
/// a window or startup if its launcher is playing its animation
function addWaitingLauncher(launch){
for(var i=0; i<waitingLaunchers.length; ++i){
if (waitingLaunchers[i]===launch) {
return;
}
}
waitingLaunchers.push(launch);
}
function removeWaitingLauncher(launch){
for(var i=0; i<waitingLaunchers.length; ++i){
if (waitingLaunchers[i]===launch) {
waitingLaunchers.splice(i,1);
waitingLauncherRemoved(launch);
return;
}
}
}
function waitingLauncherExists(launch){
for(var i=0; i<waitingLaunchers.length; ++i){
if (waitingLaunchers[i]===launch) {
return true;
}
}
return false;
}
//! ImmediateLaunchers
function addImmediateLauncher(launch){
if (!immediateLauncherExists(launch)) {
//console.log("Immediate Launcher Added::: "+launch);
immediateLaunchers.push(launch);
}
}
function removeImmediateLauncher(launch){
for(var i=0; i<immediateLaunchers.length; ++i){
if (immediateLaunchers[i]===launch) {
immediateLaunchers.splice(i,1);
//console.log("Immediate Launcher Removed::: "+launch);
return;
}
}
}
function immediateLauncherExists(launch){
for(var i=0; i<immediateLaunchers.length; ++i){
if (immediateLaunchers[i]===launch) {
return true;
}
}
return false;
}
//!
function hidePreview(){
windowsPreviewDlg.hide(11);
}
@ -997,6 +929,10 @@ Item {
id: _parabolicManager
}
TasksExtendedManager {
id: _tasksExtendedManager
}
/* IconsModel{
id: iconsmdl
}*/
@ -1678,7 +1614,7 @@ Item {
var separatorName = parabolicManager.freeAvailableSeparatorName();
if (separatorName !== "") {
parabolicManager.addLauncherToBeMoved(separatorName, Math.max(0,pos));
tasksExtendedManager.addLauncherToBeMoved(separatorName, Math.max(0,pos));
if (latteView && latteView.launchersGroup >= Latte.Types.LayoutLaunchers) {
latteView.layoutsManager.launchersSignals.addLauncher(root.viewLayoutName,
@ -1891,7 +1827,7 @@ Item {
var separatorName = parabolicManager.freeAvailableSeparatorName();
if (separatorName !== "") {
parabolicManager.addLauncherToBeMoved(separatorName, Math.max(0,pos));
tasksExtendedManager.addLauncherToBeMoved(separatorName, Math.max(0,pos));
if (latteView && latteView.launchersGroup >= Latte.Types.LayoutLaunchers) {
latteView.layoutsManager.launchersSignals.addLauncher(latteView.launchersGroup, separatorName);
@ -2004,7 +1940,7 @@ Item {
}
function setGlobalDirectRender(value) {
if (waitingLaunchers.length > 0)
if (tasksExtendedManager.waitingLaunchersLength() > 0)
return;
if (latteView) {

@ -570,7 +570,7 @@ MouseArea{
if (isSeparator) {
root.separatorsUpdated();
if (parabolicManager.isLauncherToBeMoved(launcherUrl) && itemIndex>=0) {
if (tasksExtendedManager.isLauncherToBeMoved(launcherUrl) && itemIndex>=0) {
parabolicManager.moveLauncherToCorrectPos(launcherUrl, itemIndex);
}
} else {
@ -1097,7 +1097,7 @@ MouseArea{
// if ((lastButtonClicked == Qt.LeftButton)||(lastButtonClicked == Qt.MidButton)){
if (Latte.WindowSystem.compositingActive) {
inBouncingAnimation = true;
root.addWaitingLauncher(taskItem.launcherUrl);
tasksExtendedManager.addWaitingLauncher(taskItem.launcherUrl);
}
if (root.disableAllWindowsFunctionality) {
@ -1442,8 +1442,8 @@ MouseArea{
if (!Latte.WindowSystem.compositingActive) {
visible = true;
} else if ( (isWindow || isStartup || isLauncher) && root.waitingLauncherExists(launcherUrl)) {
root.waitingLauncherRemoved.connect(slotWaitingLauncherRemoved);
} else if ( (isWindow || isStartup || isLauncher) && tasksExtendedManager.waitingLauncherExists(launcherUrl)) {
tasksExtendedManager.waitingLauncherRemoved.connect(slotWaitingLauncherRemoved);
visible = false;
} else if (hideStartup){
visible = false;
@ -1456,7 +1456,6 @@ MouseArea{
}
Component.onDestruction: {
root.waitingLauncherRemoved.disconnect(slotWaitingLauncherRemoved);
root.draggingFinished.disconnect(handlerDraggingFinished);
root.clearZoomSignal.disconnect(clearZoom);
root.publishTasksGeometries.disconnect(slotPublishGeometries);
@ -1464,6 +1463,8 @@ MouseArea{
root.mimicEnterForParabolic.disconnect(slotMimicEnterForParabolic);
root.launchersUpdatedFor.disconnect(slotLaunchersChangedFor);
tasksExtendedManager.waitingLauncherRemoved.disconnect(slotWaitingLauncherRemoved);
wrapper.sendEndOfNeedBothAxisAnimation();
}

@ -189,7 +189,7 @@ Item{
function signalUpdateScale(nIndex, nScale, step){
if (!taskItem.containsMouse && (index === nIndex)
&& (taskItem.hoverEnabled || inMimicParabolicAnimation)&&(waitingLaunchers.length===0)){
&& (taskItem.hoverEnabled || inMimicParabolicAnimation)&&(tasksExtendedManager.waitingLaunchersLength()===0)){
if (taskItem.inAttentionAnimation) {
var subSpacerScale = (nScale-1)/2;

@ -93,7 +93,7 @@ SequentialAnimation{
onStopped: {
if (!taskItem.inRemoveStage) {
taskItem.inBouncingAnimation = false;
root.removeWaitingLauncher(taskItem.launcherUrl);
tasksExtendedManager.removeWaitingLauncher(taskItem.launcherUrl);
}
root.setGlobalDirectRender(false);

@ -51,8 +51,8 @@ SequentialAnimation {
//! When a window is removed and afterwards its launcher must be shown immediately!
if (!enabledAnimation && taskItem.isWindow && !taskItem.isSeparator
&& tasksModel.launcherPosition(taskItem.launcherUrl) !== -1
&& !root.immediateLauncherExists(taskItem.launcherUrl)){
root.addImmediateLauncher(taskItem.launcherUrl);
&& !tasksExtendedManager.immediateLauncherExists(taskItem.launcherUrl)){
tasksExtendedManager.addImmediateLauncher(taskItem.launcherUrl);
}
//trying to fix the ListView nasty behavior
@ -92,7 +92,7 @@ SequentialAnimation {
if (wrapper.mScale > 1 && !taskRealRemovalAnimation.enabledAnimation
&& !taskItem.inBouncingAnimation && Latte.WindowSystem.compositingActive) {
parabolicManager.setFrozenTask(taskItem.launcherUrl, wrapper.mScale);
tasksExtendedManager.setFrozenTask(taskItem.launcherUrl, wrapper.mScale);
}
}
}
@ -186,7 +186,7 @@ SequentialAnimation {
//send signal that the launcher is really removing
if (taskItem.inBouncingAnimation) {
root.removeWaitingLauncher(taskItem.launcherUrl);
tasksExtendedManager.removeWaitingLauncher(taskItem.launcherUrl);
root.setGlobalDirectRender(false);
}
}

@ -122,7 +122,7 @@ SequentialAnimation{
&& taskItem.isWindow
&& Latte.WindowSystem.compositingActive);
var animation3 = (!root.immediateLauncherExists(taskItem.launcherUrl)
var animation3 = (!tasksExtendedManager.immediateLauncherExists(taskItem.launcherUrl)
&& taskItem.isLauncher
&& Latte.WindowSystem.compositingActive);
@ -139,8 +139,8 @@ SequentialAnimation{
//var hideStartup = launcherExists && taskItem.isStartup; //! fix #976
var hideWindow = root.showWindowsOnlyFromLaunchers && !launcherExists && taskItem.isWindow;
if (root.immediateLauncherExists(taskItem.launcherUrl) && taskItem.isLauncher) {
root.removeImmediateLauncher(taskItem.launcherUrl);
if (tasksExtendedManager.immediateLauncherExists(taskItem.launcherUrl) && taskItem.isLauncher) {
tasksExtendedManager.removeImmediateLauncher(taskItem.launcherUrl);
}
//if (hideStartup || hideWindow) { //fix #976
@ -169,11 +169,11 @@ SequentialAnimation{
start();
} else {
isForcedHidden = false;
var frozenTask = parabolicManager.getFrozenTask(taskItem.launcherUrl);
var frozenTask = tasksExtendedManager.getFrozenTask(taskItem.launcherUrl);
if (frozenTask && frozenTask.mScale>1) {
wrapper.mScale = frozenTask.mScale;
parabolicManager.removeFrozenTask(taskItem.launcherUrl);
tasksExtendedManager.removeFrozenTask(taskItem.launcherUrl);
} else {
wrapper.tempScaleWidth = 1;
wrapper.tempScaleHeight = 1;

Loading…
Cancel
Save