Closed nree closed 5 years ago
thanks @nree! I've been refactoring the viewmodels these days and I may accidently broke that. Looking into it.
ok thank you. I spoke too soon, x & y both are not ok. It increases by a little bit every launch for both.
Example: close fvim at -> x: 100, y: 100 next launch -> x: 110, y: 110
+10 is example number, but showing it remembers position but adds to it for some reason.
What DPI are you running? I'd suspect the error coming from DPI-related miscalculations (e.g. recorded "pixels" but restored "points", where a point is 1.75 pixels)
Ah, not sure what you mean / how to check what DPI I am running.
My monitor is native 4k. But I run at 1920 x 1080 resolution with 100% scaling option set.
I just checked, changed resolution to 4k and still same thing, fvim position moves every relaunch.
hmm if you're running 100% then it's not caused by DPI. but generally speaking the cause of this should be that, the coordinates captured at program exit are not compatible with the set window position coordinates. Windows 10 has a lot of these quirks. Definitely worth looking into :)
I’m not sure how to look into it, windows is new platform to me; would need help.
But I can say other programs don’t do this, like Chrome, Discord, ConEmu etc.
take a look at ~/AppData/Local/fvim/config.json -- the coordinates are kept in there. could you examine the shift that's done on each startup? like, is it a constant value (so we can simply compensate), or a proportional value related to window position.
thanks!
Ok I try to debug this... but don't know F# or Avalonia at all 😅 x +13 , y + 58 Seems consistent
PositionChanged event immediately triggers after MainWindow.xaml.fs initialization (this is where +13, +58 come from). Anyway I am not sure why, does not seem right for event to trigger so fast. Window initializes with correct values, but it happens so fast that by the time the window is rendered, you see the wrong values on screen.
So looks like this:
Could it be possible during load need to set Window.X,Y as PixelPoint? Looks like X,Y is set as int -> float and then converted at PositionChanged to PixelPoint? But again I'm not familiar with F# / avalonia.
thanks @nree! that's a comprehensive run!
I'm looking into this with the "Window Spy" utility from ahk.
this.Position
correctly sets the screen coordinates in PIXELS.
PositionChanged
events are also PIXELS, but always report offset'ed coordinates -- (12, 52) in my case
the fix is to measure the miscalculation on first event, and then compensate. works pretty well on my side. :)
Ok wasn't sure if you also saw the same thing Pulled master, looks good
For Windows 10, fvim does not remember last window position Y (or maybe it does but it adds to Y).
X is ok.Not a big deal but figure to report the issue.