1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-03-21 22:50:14 +03:00

orchestrate better directRender for plasmoid

--use same techniques with the containment in order
to activate/deactivate the directRender through
the latte plasmoid
This commit is contained in:
Michail Vourlakos 2018-02-19 01:44:42 +02:00
parent 14ffc70088
commit b12cf1446a
5 changed files with 79 additions and 74 deletions

View File

@ -425,10 +425,10 @@ DragDrop.DropArea {
if (editMode) {
visibilityManager.updateMaskArea();
updateAutomaticIconSize();
clearZoom();
} else {
updateAutomaticIconSize();
layoutsContainer.updateSizeForAppletsInFill();
// setGlobalDirectRender(false);
}
updateLayouts();

View File

@ -57,7 +57,6 @@ Item {
//it is used to check both the applet and the containment for direct render
property bool globalDirectRender: latteDock ? latteDock.globalDirectRender : icList.directRender
property bool directRenderTimerIsRunning: latteDock ? latteDock.directRenderTimerIsRunning : enableDirectRenderTimer.running
property bool editMode: latteDock ? latteDock.editMode : plasmoid.userConfiguring
property bool disableRestoreZoom: false //blocks restore animation in rightClick
@ -831,14 +830,9 @@ Item {
if(root.latteDock)
console.log("Plasmoid, checkListHoveredTimer was called, even though it shouldnt...");
if ((latteDock && !latteDock.dockContainsMouse) || !root.containsMouse()) {
if (enableDirectRenderTimer.running)
enableDirectRenderTimer.stop();
if (!root.containsMouse()) {
icList.directRender = false;
if(root.latteDock) {
root.latteDock.startEnableDirectRenderTimer();
}
root.clearZoom();
}
@ -863,29 +857,6 @@ Item {
}
}
//this timer adds a delay into enabling direct rendering...
//it gives the time to neighbour tasks to complete their animation
//during first hovering phase
//IMPORTANT ::: This timer should be used only when the Latte plasmoid
//is not inside a Latte dock
Timer {
id: enableDirectRenderTimer
interval: 4 * root.durationTime * units.shortDuration
onTriggered: {
if(root.latteDock)
console.log("Plasmoid, enableDirectRenderTimer was called, even though it shouldnt...");
if (waitingLaunchers.length > 0)
restart();
else
icList.directRender = true;
if (latteDock && latteDock.debugModeTimers) {
console.log("plasmoid timer: enableDirectRenderTimer called...");
}
}
}
//this timer restores the draggingPhase flag to false
//after a dragging has finished... This delay is needed
//in order to not animate any tasks are added after a
@ -1573,7 +1544,7 @@ Item {
}
//if (previewContainsMouse())
// windowsPreviewDlg.hide(4);
// windowsPreviewDlg.hide(4);
if (previewContainsMouse())
return true;
@ -1631,12 +1602,22 @@ Item {
dragSource = null;
}
function startEnableDirectRenderTimer() {
function setGlobalDirectRender(value) {
if (waitingLaunchers.length > 0)
return;
if (latteDock) {
// latteDock.setGlobalDirectRender(true);
latteDock.startEnableDirectRenderTimer();
latteDock.setGlobalDirectRender(value);
} else {
enableDirectRenderTimer.start();
if (value === true) {
if (root.containsMouse()) {
icList.directRender = true;
} else {
// console.log("direct render true ignored...");
}
} else {
icList.directRender = false;
}
}
}

View File

@ -87,6 +87,7 @@ MouseArea{
property bool buffersAreReady: false
property bool fastEnteringFlag: false //!flag to check if the mouse entered the dock very fast
property bool delayingRemove: ListView.delayRemove
property bool scalesUpdatedOnce: false
//states that exist in windows in a Group of windows
property bool hasActive: isActive
property bool hasMinimized: (IsGroupParent === true) ? tasksWindows.hasMinimized : isMinimized
@ -503,12 +504,16 @@ MouseArea{
if (root.editMode)
return;
if (restoreAnimation.running) {
restoreAnimation.stop();
}
// console.log("entered task:" + icList.hoveredIndex);
if (fastEnteringFlag) {
fastEnteringFlag = false;
}
if (icList.hoveredIndex!==-1 && !root.directRenderTimerIsRunning && !root.globalDirectRender) {
if (icList.hoveredIndex!==-1 && !root.globalDirectRender) {
fastEnteringFlag = true;
}
@ -531,7 +536,7 @@ MouseArea{
return;
}
/* if((!inAnimation)&&(root.dragSource == null)&&(!root.taskInAnimation) && hoverEnabled){
/* if((!inAnimation)&&(root.dragSource == null)&&(!root.taskInAnimation) && hoverEnabled){
if (inAttentionAnimation) {
var subSpacerScale = (root.zoomFactor-1)/2;
hiddenSpacerLeft.nScale = subSpacerScale;
@ -553,6 +558,12 @@ MouseArea{
// IMPORTANT: This must be improved ! even for small miliseconds it reduces performance
onExited: {
mainItemContainer.scalesUpdatedOnce = false;
if (fastEnteringFlag) {
fastEnteringFlag = false;
}
if (root.latteDock && (!root.showPreviews || (root.showPreviews && isLauncher))){
root.latteDock.hideTooltipLabel();
}
@ -584,33 +595,34 @@ MouseArea{
return;
}
if (fastEnteringFlag) {
var lengthPos;
if (root.vertical) {
lengthPos = mouse.x;
} else {
lengthPos = mouse.y;
}
//! check if the mouse enters a second task and it is near the center
//! this way the directRendering isnt activated too fast or when the
//! mouse enters between two tasks at start
if (lengthPos >= (wrapper.center - root.iconSize/2)
&& lengthPos <= (wrapper.center + root.iconSize/2)) {
if (!root.directRenderTimerIsRunning && !root.globalDirectRender) {
root.startEnableDirectRenderTimer();
}
fastEnteringFlag = false;
}
}
if((inAnimation == false)&&(!root.taskInAnimation)&&(!root.disableRestoreZoom) && hoverEnabled){
if (!latteDock || (latteDock && !(latteDock.dockIsHidden || latteDock.inSlidingIn || latteDock.inSlidingOut))){
icList.hoveredIndex = index;
}
if( ((wrapper.mScale == 1 || wrapper.mScale === root.zoomFactor) && !root.globalDirectRender) || root.globalDirectRender) {
if (fastEnteringFlag) {
var lengthPos;
if (root.vertical) {
lengthPos = mouse.x;
} else {
lengthPos = mouse.y;
}
//! check if the mouse enters a second task and it is near the center
//! this way the directRendering isnt activated too fast or when the
//! mouse enters between two tasks at start
if (lengthPos >= (wrapper.center - root.iconSize/2)
&& lengthPos <= (wrapper.center + root.iconSize/2)) {
if (!root.globalDirectRender) {
root.setGlobalDirectRender(true);
}
fastEnteringFlag = false;
}
}
if( ((wrapper.mScale == 1 || wrapper.mScale === root.zoomFactor) && !root.globalDirectRender)
|| root.globalDirectRender || !scalesUpdatedOnce) {
if(root.dragSource == null){
if (icList.orientation == Qt.Horizontal){
var step = Math.abs(icList.currentSpot-mouse.x);
@ -840,15 +852,7 @@ MouseArea{
if(!root)
return;
if (root.globalDirectRender)
wrapper.mScale = 1;
else if (!inAttentionAnimation && !inFastRestoreAnimation && !inMimicParabolicAnimation){
if (icList.hoveredIndex === -1) {
restoreAnimation.start();
} else {
console.log("Clear zoom signal ignored...");
}
}
restoreAnimation.start();
}
function handlerDraggingFinished(){
@ -1213,6 +1217,23 @@ MouseArea{
onDragSourceChanged: mainItemContainer.updateAudioStreams()
onIndicateAudioStreamsChanged: mainItemContainer.updateAudioStreams()
}
Connections {
target: root
onHoveredIndexChanged: {
if ((restoreAnimation.running) && (root.hoveredIndex !== -1)) {
restoreAnimation.stop();
}
}
onDockHoveredIndexChanged: {
if ((restoreAnimation.running) && (root.dockHoveredIndex !== -1)) {
restoreAnimation.stop();
}
}
}
///// End of Helper functions ////
Component.onCompleted: {

View File

@ -171,7 +171,7 @@ Item{
width: root.vertical ? wrapper.maxThickness-wrapper.width : 1
height: !root.vertical ? wrapper.maxThickness-wrapper.height : 1
/* Rectangle{
/* Rectangle{
width: !root.vertical ? 1 : parent.width
height: !root.vertical ? parent.height : 1
x: !root.vertical ? wrapper.width /2 : 0
@ -256,6 +256,8 @@ Item{
if (!mainItemContainer.inAttentionAnimation)
mScale = root.zoomFactor;
mainItemContainer.scalesUpdatedOnce = false;
}
} //nScale
@ -295,7 +297,7 @@ Item{
onMScaleChanged: {
if ((mScale === root.zoomFactor) && !root.directRenderTimerIsRunning && !root.globalDirectRender) {
root.startEnableDirectRenderTimer();
root.setGlobalDirectRender(true);
}
if (inMimicParabolicAnimation){

View File

@ -68,9 +68,10 @@ SequentialAnimation{
onStopped: {
//! VERY IMPORTANT CODE, fixes a bug when cycling the mouse very fast inside
//! and outside the dock, in some rare cases the restoreAnimation didnt end!!
if (latteDock && (!latteDock.dockContainsMouse || icList.hoveredIndex === -1)) {
wrapper.mScale = 1;
}
//if (latteDock && (!latteDock.dockContainsMouse || icList.hoveredIndex === -1)) {
// wrapper.mScale = 1;
//}
// if (index === 2)
// console.log("restore animation stopped... ind:"+index+" zoom:"+wrapper.mScale);
}