@@ -59,7 +59,7 @@ ContainmentItem {
5959 required property list< string> windows
6060 keys: [" text/x-dde-dock-dnd-appid" ]
6161 z: attention ? - 1 : 0
62- property bool visibility: itemId !== launcherDndDropArea .launcherDndDesktopId
62+ property bool visibility: itemId !== taskmanager . Applet . desktopIdToAppId ( launcherDndDropArea .launcherDndDesktopId )
6363
6464 states: [
6565 State {
@@ -100,13 +100,12 @@ ContainmentItem {
100100 menus: delegateRoot .menus
101101 windows: delegateRoot .windows
102102 visualIndex: delegateRoot .visualIndex
103+ ListView .delayRemove : Drag .active
103104 Component .onCompleted : {
104105 clickItem .connect (taskmanager .Applet .clickItem )
105106 }
106-
107107 onDragFinished : function () {
108- // 就算在非法区域松开也更新 Model
109- taskmanager .Applet .dataModel .moveTo (itemId, visualIndex)
108+ launcherDndDropArea .resetDndState ()
110109 }
111110 anchors .fill : parent // This is mandatory for draggable item center in drop area
112111 }
@@ -118,11 +117,19 @@ ContainmentItem {
118117 anchors .fill : parent
119118 keys: [" text/x-dde-dock-dnd-appid" ]
120119 property string launcherDndDesktopId: " "
120+ property string launcherDndDragSource: " "
121+
122+ function resetDndState () {
123+ launcherDndDesktopId = " "
124+ launcherDndDragSource = " "
125+ }
126+
121127 onEntered : function (drag ) {
122128 let desktopId = drag .getDataAsString (" text/x-dde-dock-dnd-appid" )
123- launcherDndDesktopId = taskmanager .Applet .desktopIdToAppId (desktopId)
129+ launcherDndDragSource = drag .getDataAsString (" text/x-dde-dock-dnd-source" )
130+ launcherDndDesktopId = desktopId
124131 if (taskmanager .Applet .requestDockByDesktopId (desktopId) === false ) {
125- launcherDndDesktopId = " "
132+ resetDndState ()
126133 }
127134 }
128135
@@ -132,8 +139,8 @@ ContainmentItem {
132139 curX *= Screen .devicePixelRatio
133140 let cellWidth = Panel .rootObject .dockItemMaxSize
134141 let curCell = curX / cellWidth
135- let left = (curX % cellWidth) < (cellWidth / 2 )
136- taskmanager .Applet .dataModel .moveTo (launcherDndDesktopId , curCell)
142+ let appId = taskmanager . Applet . desktopIdToAppId (launcherDndDesktopId )
143+ taskmanager .Applet .dataModel .moveTo (appId , curCell)
137144 }
138145
139146 onDropped : function (drop ) {
@@ -142,13 +149,16 @@ ContainmentItem {
142149 curX *= Screen .devicePixelRatio
143150 let cellWidth = Panel .rootObject .dockItemMaxSize
144151 let curCell = curX / cellWidth
145- let left = (curX % cellWidth) < (cellWidth / 2 )
146- taskmanager .Applet .dataModel .moveTo (launcherDndDesktopId , curCell)
147- launcherDndDesktopId = " "
152+ let appId = taskmanager . Applet . desktopIdToAppId (launcherDndDesktopId )
153+ taskmanager .Applet .dataModel .moveTo (appId , curCell)
154+ resetDndState ()
148155 }
149156
150157 onExited : function () {
151- launcherDndDesktopId = " "
158+ if (launcherDndDesktopId !== " " && launcherDndDragSource !== " taskbar" ) {
159+ taskmanager .Applet .requestUndockByDesktopId (launcherDndDesktopId)
160+ }
161+ resetDndState ()
152162 }
153163 }
154164 }
0 commit comments