Drag to reorder the clock, battery, volume, wifi and hidden icons arrow

This commit is contained in:
2026-11-06 11:49:19 +00:00
parent cab30fb5d3
commit ed8a7cf275
2 changed files with 128 additions and 10 deletions
+29 -2
View File
@@ -1000,10 +1000,14 @@ func wndProc(hwnd, m, wparam, lparam uintptr) (result uintptr) {
} else if idx := appIndexAt(hwnd, x); idx >= 0 {
dragSeq, dragIsStart, dragStart, dragActive = seqOfApp(idx), false, x, false
pSetCapture.Call(hwnd)
} else if k := trayAt(hwnd, x); k != 0 {
dragTray, dragTrayStart, dragTrayActive = k, x, false
pSetCapture.Call(hwnd)
}
return 0
case wmCaptureChanged:
endIconDrag()
dragTray, dragTrayActive = 0, false
return 0
case wmMouseMove:
x := alongClient(lparam)
@@ -1025,6 +1029,19 @@ func wndProc(hwnd, m, wparam, lparam uintptr) (result uintptr) {
return 0
}
}
if dragTray != 0 {
if !dragTrayActive && abs32(x-dragTrayStart) > px(5) {
dragTrayActive = true
}
if dragTrayActive {
if t := trayKindAt(hwnd, x); t != 0 && t != dragTray {
moveTray(dragTray, t)
}
hoverStart, hoverApp, hoverTray = false, -1, dragTray
redraw(hwnd)
return 0
}
}
overStart := inStart(hwnd, x)
overApp := appIndexAt(hwnd, x)
overTray := trayAt(hwnd, x)
@@ -1064,10 +1081,19 @@ func wndProc(hwnd, m, wparam, lparam uintptr) (result uintptr) {
activateApp(idx)
}
redraw(hwnd)
} else if dragTray != 0 {
// A press on a tray item: a click if it never moved, otherwise the drag ends here.
k, wasDrag := dragTray, dragTrayActive
dragTray, dragTrayActive = 0, false
pReleaseCapture.Call()
if wasDrag {
saveTrayOrder()
} else {
trayClick(k)
}
redraw(hwnd)
} else if inStart(hwnd, x) {
tapWinKey()
} else if k := trayAt(hwnd, x); k != 0 {
trayClick(k)
}
return 0
case wmRButtonUp:
@@ -1176,6 +1202,7 @@ func main() {
loadAlpha()
loadPos()
loadStartSlot()
loadTrayOrder()
loadOrient()
hdc, _, _ := pGetDC.Call(0)