Skip to content

Commit fffc65c

Browse files
committed
fix: 修复任务栏位置切换时的显示异常
通过改进位置切换逻辑,实现平滑的过渡动画: 1. 在切换位置时,先保存新位置并临时恢复到旧位置 2. 在旧位置播放隐藏动画 3. 切换到新位置后,从隐藏状态播放显示动画 4. 使用状态标志精确控制动画流程,避免闪烁和显示异常 这样可以确保任务栏在位置切换时不会出现空白区域、内容溢出或突然跳变的问题。 Log: 修复任务栏位置切换时的显示异常 PMS: BUG-346777
1 parent 4f0c66e commit fffc65c

File tree

1 file changed

+90
-23
lines changed

1 file changed

+90
-23
lines changed

panels/dock/package/main.qml

Lines changed: 90 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ Window {
165165
id: dockAnimation
166166
property bool useTransformBasedAnimation: Qt.platform.pluginName === "xcb"
167167
property bool isShowing: false
168+
property bool isPositionChanging: false
168169
property var target: useTransformBasedAnimation ? dockTransform : dock
169170
property string animProperty: {
170171
if (useTransformBasedAnimation) return dock.useColumnLayout ? "x" : "y";
@@ -212,6 +213,17 @@ Window {
212213
} else {
213214
dock.visible = ((dock.useColumnLayout ? dock.width : dock.height) !== 1);
214215
}
216+
217+
// If this was a hide animation during position change, handle the position change now
218+
if (isPositionChanging && !isShowing) {
219+
isPositionChanging = false;
220+
positionChangeConnections.handlePositionChangeAfterHide();
221+
} else {
222+
// If this was a show animation and dock should be hidden, trigger auto-hide
223+
if (isShowing && Panel.hideState === Dock.Hide) {
224+
hideTimer.running = true;
225+
}
226+
}
215227
}
216228
}
217229

@@ -221,34 +233,20 @@ Window {
221233
required property int value
222234
text: name
223235

224-
property var positionChangeCallback: function() {
225-
// Disconnect any existing callback first
226-
dockAnimation.onStopped.disconnect(positionChangeCallback);
227-
// Stop any running animations first --fix bug with do not show dock
228-
dockAnimation.stop();
229-
// Reset transform before starting new animation--fix bug with change position,will have a blank area
230-
dockTransform.x = 0;
231-
dockTransform.y = 0;
236+
onTriggered: {
237+
if (Applet[prop] === value) {
238+
// Manually restore checked state since Qt already toggled it
239+
checked = true;
240+
return;
241+
}
242+
Applet[prop] = value
243+
}
232244

233-
Applet[prop] = value;
245+
Component.onCompleted: {
234246
checked = Qt.binding(function() {
235247
return Applet[prop] === value;
236248
});
237-
dockAnimation.startAnimation(true);
238-
}
239-
onTriggered: {
240-
if (prop === "position") {
241-
// Connect the callback and start the hide animation
242-
dockAnimation.onStopped.connect(positionChangeCallback);
243-
dockAnimation.startAnimation(false);
244-
} else {
245-
Applet[prop] = value
246-
checked = Qt.binding(function() {
247-
return Applet[prop] === value
248-
})
249-
}
250249
}
251-
checked: Applet[prop] === value
252250
}
253251
component MutuallyExclusiveMenu: LP.Menu {
254252
id: menu
@@ -665,9 +663,78 @@ Window {
665663
}
666664

667665
Connections {
666+
id: positionChangeConnections
667+
property int previousPosition: Panel.position
668+
property int savedNewPosition: -1
669+
property bool isRestoringPosition: false
670+
668671
function onPositionChanged() {
672+
// Ignore position changes triggered by our own restore operation
673+
if (isRestoringPosition) {
674+
return;
675+
}
676+
677+
// Save the new position
678+
savedNewPosition = Panel.position;
679+
680+
// Set flag to ignore the next position change
681+
isRestoringPosition = true;
682+
683+
// Temporarily restore to previous position for hide animation
684+
Applet.position = previousPosition;
685+
686+
// Clear the flag after restore
687+
isRestoringPosition = false;
688+
689+
// Stop any running animations first
690+
dockAnimation.stop();
691+
hideShowAnimation.stop();
692+
693+
// Mark that we're changing position
694+
dockAnimation.isPositionChanging = true;
695+
696+
// Check if dock is currently hidden
697+
if (Panel.hideState === Dock.Hide && !dock.visible) {
698+
// Directly handle position change without animation
699+
dockAnimation.isPositionChanging = false;
700+
handlePositionChangeAfterHide();
701+
} else {
702+
// Start hide animation at old position
703+
dockAnimation.startAnimation(false);
704+
}
705+
}
706+
707+
function handlePositionChangeAfterHide() {
708+
if (savedNewPosition === -1) return;
709+
710+
// Apply position change
711+
previousPosition = savedNewPosition;
712+
Applet.position = savedNewPosition;
713+
savedNewPosition = -1;
714+
669715
changeDragAreaAnchor()
670716
Panel.requestClosePopup()
717+
718+
// Set transform to hidden position before showing
719+
if (dockAnimation.useTransformBasedAnimation) {
720+
var hideOffset = (Applet.position === Dock.Left || Applet.position === Dock.Top) ? -Panel.dockSize : Panel.dockSize;
721+
if (dock.useColumnLayout) {
722+
dockTransform.x = hideOffset;
723+
dockTransform.y = 0;
724+
} else {
725+
dockTransform.x = 0;
726+
dockTransform.y = hideOffset;
727+
}
728+
} else {
729+
dockTransform.x = 0;
730+
dockTransform.y = 0;
731+
}
732+
733+
dockAnimation.startAnimation(true);
734+
}
735+
736+
Component.onCompleted: {
737+
previousPosition = Panel.position
671738
}
672739
function onDockSizeChanged() {
673740
dock.dockSize = Panel.dockSize

0 commit comments

Comments
 (0)