rogual / neovim-dot-app

Mac OS X GUI for Neovim
1.13k stars 62 forks source link

Incorrect view area on iMac display #269

Closed ray-x closed 8 years ago

ray-x commented 8 years ago

I have a 5K display. But sadly, neovim.app can not display area larger than 58 lines of buffer in vertically. Is that because of neovim or neovim.app ?

screen shot uploaded:

screen shot 2016-06-22 at 9 26 12 am
rogual commented 8 years ago

Are 5K screens denser than Retina screens? Right now we just allocate a screen buffer big enough for the whole screen at Retina density: https://github.com/rogual/neovim-dot-app/blob/master/src/view.mm#L64

bambu commented 8 years ago

@ray-x,

Not sure if this work or not since I dont have a 5k screen, but does this fix the problem?

diff --git a/src/view.mm b/src/view.mm
index 49dd79f..c46a277 100644
--- a/src/view.mm
+++ b/src/view.mm
@@ -63,9 +63,15 @@

     /* Allocate a canvas big enough to fill the entire screen at Retina
        resolution. TODO: Detect screen size changes */
-    CGSize screenSize = [[NSScreen mainScreen] frame].size;
+    NSScreen *screen = [NSScreen mainScreen];
+    NSDictionary *description = [screen deviceDescription];
+    NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue];
+    CGSize displayPhysicalSize = CGDisplayScreenSize(
+                [[description objectForKey:@"NSScreenNumber"] unsignedIntValue]);
+    float dpi = displayPixelSize.width / displayPhysicalSize.width;
+
     CGSize sizeInPixels = CGSizeMake(
-        screenSize.width * 2, screenSize.height * 2
+        displayPixelSize.width * dpi, displayPixelSize.height * dpi
     );

     /* A CGBitmapContext is basically a mutable buffer of bytes in a given
ray-x commented 8 years ago

Yeah! It is working perfect now, Cheers!

JackCA commented 8 years ago

fwiw, even with this fix out I get strange behavior when the window is a certain size (my monitor is 2560x1440) so I'm not sure this is actually fixed or if it's another issue (that I can only reproduce on large screens)

Attached is some of this behavior: neovim-dot-app-issue

I'm basically creating splits that don't appear most of the time, and when I resize the screen smaller nothing renders