mirror of
https://github.com/TomHarte/CLK.git
synced 2024-10-11 23:24:28 +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 {
|
@implementation CSOpenGLView {
|
||||||
CVDisplayLinkRef _displayLink;
|
CVDisplayLinkRef _displayLink;
|
||||||
CGSize _backingSize;
|
CGSize _backingSize;
|
||||||
|
NSScreen *_currentScreen;
|
||||||
|
|
||||||
NSTrackingArea *_mouseTrackingArea;
|
NSTrackingArea *_mouseTrackingArea;
|
||||||
NSTimer *_mouseHideTimer;
|
NSTimer *_mouseHideTimer;
|
||||||
@ -26,6 +27,9 @@
|
|||||||
- (void)prepareOpenGL {
|
- (void)prepareOpenGL {
|
||||||
[super prepareOpenGL];
|
[super prepareOpenGL];
|
||||||
|
|
||||||
|
// Note the initial screen.
|
||||||
|
_currentScreen = self.window.screen;
|
||||||
|
|
||||||
// Synchronize buffer swaps with vertical refresh rate
|
// Synchronize buffer swaps with vertical refresh rate
|
||||||
GLint swapInt = 1;
|
GLint swapInt = 1;
|
||||||
[[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval];
|
[[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 {
|
- (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];
|
[self redrawWithEvent:CSOpenGLViewRedrawEventTimer];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user