1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-06 16:29:20 +00:00

Ensures that a change of screen issues a reshape. Just in case.

Thereby resolves display mis-sizing when dragging from a Retina display to a regular one, or vice versa.
This commit is contained in:
Thomas Harte 2020-01-26 18:04:25 -05:00
parent 83dbd257e1
commit 6bcdd3177d

View File

@ -17,6 +17,7 @@
@implementation CSOpenGLView {
CVDisplayLinkRef _displayLink;
CGSize _backingSize;
NSScreen *_currentScreen;
NSTrackingArea *_mouseTrackingArea;
NSTimer *_mouseHideTimer;
@ -26,6 +27,9 @@
- (void)prepareOpenGL {
[super prepareOpenGL];
// Note the initial screen.
_currentScreen = self.window.screen;
// Synchronize buffer swaps with vertical refresh rate
GLint swapInt = 1;
[[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval];
@ -56,6 +60,14 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
}
- (void)drawAtTime:(const CVTimeStamp *)now frequency:(double)frequency {
if(self.window.screen != _currentScreen) {
_currentScreen = self.window.screen;
// Issue a reshape, in case a switch to/from a Retina display has
// happened, changing the results of -convertSizeToBacking:, etc.
[self reshape];
}
[self redrawWithEvent:CSOpenGLViewRedrawEventTimer];
}