Skip to content

Commit bda77ec

Browse files
committed
fix: add diagnostic logging for window position drift on Windows multi-monitor
Temporary diagnostic logging to understand the exact coordinate behavior during show/hide/resize cycles on Windows with mixed DPI monitors. Logs tagged [PI-DIAG] and [NL-DIAG] show: - Saved position vs getBounds() at each step - Position changes after setBounds, show, setAlwaysOnTop, focus - Display info including scaleFactor
1 parent 62c2a8d commit bda77ec

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

src/main/classes/controllers/PhoneIslandController.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ export class PhoneIslandController {
2424
if (window) {
2525
const bounds = window.getBounds()
2626
if (bounds.height !== h || bounds.width !== w) {
27+
Log.info('[PI-DIAG] resize: before setBounds getBounds=', JSON.stringify(bounds), 'requestedSize=', JSON.stringify({ w, h }))
2728
window.setBounds({ width: w, height: h })
29+
const afterBounds = window.getBounds()
30+
Log.info('[PI-DIAG] resize: after setBounds({w,h}) getBounds=', JSON.stringify(afterBounds))
2831
PhoneIslandWindow.currentSize = { width: w, height: h }
2932
}
3033
//make sure the size is equal to [0,0] when you want to close the phone island, otherwise the size will not close and will generate slowness problems.
@@ -33,8 +36,12 @@ export class PhoneIslandController {
3336
} else {
3437
// Don't show window during warm-up
3538
if (!window.isVisible() && !this.isWarmingUp) {
39+
const beforeShow = window.getBounds()
3640
window.show()
41+
const afterShow = window.getBounds()
3742
window.setAlwaysOnTop(true, 'screen-saver')
43+
const afterAlwaysOnTop = window.getBounds()
44+
Log.info('[PI-DIAG] resize show: beforeShow=', JSON.stringify(beforeShow), 'afterShow=', JSON.stringify(afterShow), 'afterAlwaysOnTop=', JSON.stringify(afterAlwaysOnTop))
3845
}
3946
}
4047
}
@@ -48,8 +55,16 @@ export class PhoneIslandController {
4855
try {
4956
const window = this.window.getWindow()
5057
if (window) {
58+
const savedPosition = AccountController.instance.getAccountPhoneIslandPosition()
59+
Log.info('[PI-DIAG] showPhoneIsland: savedPosition=', JSON.stringify(savedPosition), 'size=', JSON.stringify(size), 'getBounds_before=', JSON.stringify(window.getBounds()))
60+
61+
const displays = screen.getAllDisplays()
62+
Log.info('[PI-DIAG] showPhoneIsland: displays=', JSON.stringify(displays.map(d => ({ id: d.id, bounds: d.bounds, workArea: d.workArea, scaleFactor: d.scaleFactor }))))
5163

5264
this.resize(size)
65+
const afterResize = window.getBounds()
66+
Log.info('[PI-DIAG] showPhoneIsland: afterResize getBounds=', JSON.stringify(afterResize))
67+
5368
if (process.platform !== 'linux') {
5469
const phoneIslandPosition = AccountController.instance.getAccountPhoneIslandPosition()
5570
if (phoneIslandPosition) {
@@ -63,8 +78,11 @@ export class PhoneIslandController {
6378
(phoneIslandPosition.y + size.h) < (area.y + area.height))
6479
)
6580
}, false)
81+
Log.info('[PI-DIAG] showPhoneIsland: isOnDisplay=', isPhoneIslandOnDisplay)
6682
if (isPhoneIslandOnDisplay) {
6783
window?.setBounds({ x: phoneIslandPosition.x, y: phoneIslandPosition.y }, false)
84+
const afterSetPos = window.getBounds()
85+
Log.info('[PI-DIAG] showPhoneIsland: after setBounds({x,y}) getBounds=', JSON.stringify(afterSetPos))
6886
} else {
6987
window?.center()
7088
}
@@ -85,6 +103,8 @@ export class PhoneIslandController {
85103
try {
86104
const window = this.window.getWindow()
87105
const phoneIslandBounds = window?.getBounds()
106+
const previousSaved = AccountController.instance.getAccountPhoneIslandPosition()
107+
Log.info('[PI-DIAG] hidePhoneIsland: getBounds=', JSON.stringify(phoneIslandBounds), 'previousSaved=', JSON.stringify(previousSaved))
88108
if (phoneIslandBounds) {
89109
AccountController.instance.setAccountPhoneIslandPosition({
90110
x: phoneIslandBounds.x,

src/main/classes/windows/NethLinkWindow.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export class NethLinkWindow extends BaseWindow {
7171
show(): void {
7272
try {
7373
const accountBounds = AccountController.instance.getAccountNethLinkBounds()
74+
Log.info('[NL-DIAG] show: savedBounds=', JSON.stringify(accountBounds), 'getBounds_before=', JSON.stringify(this._window?.getBounds()))
7475
if (accountBounds) {
7576
const isAccountBoundsOnDisplay = screen.getAllDisplays().reduce((result, display) => {
7677
const area = display.workArea
@@ -84,16 +85,20 @@ export class NethLinkWindow extends BaseWindow {
8485
}, false)
8586
if (isAccountBoundsOnDisplay) {
8687
this._window?.setBounds(accountBounds, false)
88+
Log.info('[NL-DIAG] show: after setBounds getBounds=', JSON.stringify(this._window?.getBounds()))
8789
} else {
8890
this._setBounds()
8991
}
9092
} else {
9193
this._setBounds()
9294
}
9395
super.show()
96+
const afterShow = this._window?.getBounds()
9497
this._window?.setVisibleOnAllWorkspaces(true)
9598
this._window?.focus()
9699
this._window?.setVisibleOnAllWorkspaces(false)
100+
const afterFocus = this._window?.getBounds()
101+
Log.info('[NL-DIAG] show: afterShow=', JSON.stringify(afterShow), 'afterFocus=', JSON.stringify(afterFocus))
97102
}
98103
catch (e: any) {
99104
if (e.message === 'Object has been destroyed') {
@@ -107,6 +112,9 @@ export class NethLinkWindow extends BaseWindow {
107112

108113
hide(..._args: any): void {
109114
try {
115+
const boundsAtHide = this._window?.getBounds()
116+
const previousSaved = AccountController.instance.getAccountNethLinkBounds()
117+
Log.info('[NL-DIAG] hide: getBounds=', JSON.stringify(boundsAtHide), 'previousSaved=', JSON.stringify(previousSaved))
110118
this.saveBounds()
111119
this._window?.hide()
112120
} catch (e) {

0 commit comments

Comments
 (0)