pi-win-notify 1.0.9 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -157,10 +157,14 @@ function Focus-PiTerminal($hwndNum, $winTitle) {
157
157
  }
158
158
 
159
159
  $stackFile = "$env:TEMP\pi-notify-stack.txt"
160
+ # 每次宿主启动重置计数器,避免崩溃残留导致窗口位置漂移
161
+ if (Test-Path $stackFile) { Remove-Item $stackFile -Force }
160
162
 
161
163
  function inc-stack {
162
164
  $count = 0
163
165
  if (Test-Path $stackFile) { try { $count = [int](Get-Content $stackFile -Raw).Trim() } catch {} }
166
+ # 保护:超过 10 层说明 dec-stack 泄露,重置
167
+ if ($count -gt 10) { $count = 0; l '[stack-reset] overflow' }
164
168
  $count++
165
169
  $count | Out-File -Encoding ascii $stackFile
166
170
  return $count
@@ -241,12 +245,15 @@ function Show-Notify($data) {
241
245
  $win.FindName('MuteBtn').Add_Click({ $popup.IsOpen = $true })
242
246
 
243
247
  $cursor = [System.Windows.Forms.Cursor]::Position
244
- $waW = [System.Windows.SystemParameters]::WorkArea.Width
245
- $waH = [System.Windows.SystemParameters]::WorkArea.Height
248
+ $screen = [System.Windows.Forms.Screen]::FromPoint($cursor)
249
+ $waL = $screen.WorkingArea.Left
250
+ $waT = $screen.WorkingArea.Top
251
+ $waW = $screen.WorkingArea.Width
252
+ $waH = $screen.WorkingArea.Height
246
253
  $count = inc-stack
247
254
  $offset = ($count - 1) * 128
248
- $win.Left = $waW - $win.Width - 20
249
- $win.Top = $waH - $win.Height - 10 - $offset
255
+ $win.Left = $waL + $waW - $win.Width - 20
256
+ $win.Top = $waT + $waH - $win.Height - 10 - $offset
250
257
  l "[ps-stack] count=$count offset=$offset"
251
258
 
252
259
  $timer = New-Object System.Windows.Threading.DispatcherTimer
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-win-notify",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "type": "module",
5
5
  "description": "A Windows notification tool for pi — fast focus, response preview, elapsed time, mute, multi-language",
6
6
  "keywords": [