yatli / fvim

Cross platform Neovim front-end UI, built with F# + Avalonia
MIT License
1.34k stars 30 forks source link

fvim doesn't remember window position height #64

Closed nree closed 5 years ago

nree commented 5 years ago

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.

yatli commented 5 years ago

thanks @nree! I've been refactoring the viewmodels these days and I may accidently broke that. Looking into it.

nree commented 5 years ago

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.

yatli commented 5 years ago

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)

nree commented 5 years ago

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.

yatli commented 5 years ago

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 :)

nree commented 5 years ago

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.

yatli commented 5 years ago

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!

nree commented 5 years ago

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:

  1. Load cfg , initialize Window -- OK
  2. OnDataContextChanged trigger (from initialize?) -- OK
  3. PositionChanged triggered (from ondata?) -- BAD
  4. Window init finished, renders to screen and I see the bad position then..... few seconds later see another PositionChanged trigger (same bad position) but why? I still have not touched the window.

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.

yatli commented 5 years ago

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

yatli commented 5 years ago

the fix is to measure the miscalculation on first event, and then compensate. works pretty well on my side. :)

nree commented 5 years ago

Ok wasn't sure if you also saw the same thing Pulled master, looks good