mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-06 13:31:55 +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:
parent
83dbd257e1
commit
6bcdd3177d
@ -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];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user