Revision: 15214 http://sourceforge.net/p/skim-app/code/15214 Author: hofman Date: 2025-05-15 21:20:00 +0000 (Thu, 15 May 2025) Log Message: ----------- Set contentsScale of page layer ourselves, update if needed when moving to a window or the windoww changes screen. Also redisplay when contentsScale changes.
Modified Paths: -------------- trunk/SKPresentationView.m Modified: trunk/SKPresentationView.m =================================================================== --- trunk/SKPresentationView.m 2025-05-15 09:29:50 UTC (rev 15213) +++ trunk/SKPresentationView.m 2025-05-15 21:20:00 UTC (rev 15214) @@ -79,7 +79,7 @@ static NSInteger navigationMode = SKNavigationBottom; -@interface SKPDFPageView () <CALayerDelegate> +@interface SKPDFPageView () - (void)displayPage:(void (^)(void))completionHandler; @end @@ -108,7 +108,7 @@ [pageLayer setAutoresizingMask:kCALayerWidthSizable | kCALayerHeightSizable]; [pageLayer setActions:@{@"contents": [NSNull null]}]; [pageLayer setFilters:SKColorEffectFilters()]; - [pageLayer setDelegate:self]; + [pageLayer setContentsScale:[[self layer] contentsScale]]; [[self layer] addSublayer:pageLayer]; [self setTranslatesAutoresizingMaskIntoConstraints:NO]; @@ -142,6 +142,32 @@ [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; } +- (void)handleWindoWillChangeBackingProperties:(NSNotification *)notifcation { + CGFloat scale = [[self window] backingScaleFactor]; + if (fabs([pageLayer contentsScale] - scale) > 0.0) { + [pageLayer setContentsScale:scale]; + if (page) + [self displayPage:nil]; + } +} + +- (void)viewWillMoveToWindow:(NSWindow *)newWindow { + [super viewWillMoveToWindow:newWindow]; + NSWindow *window = [self window]; + if (window) { + [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidChangeBackingPropertiesNotification object:window]; + } +} + +- (void)viewDidMoveToWindow { + [super viewDidMoveToWindow]; + NSWindow *window = [self window]; + if (window) { + [self handleWindoWillChangeBackingProperties:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleWindowWillChangeBackingProperties:) name:NSWindowDidChangeBackingPropertiesNotification object:window]; + } +} + #pragma mark Transitions - (void)displayPage:(PDFPage *)newPage completionHandler:(void (^)(void))completionHandler { @@ -327,10 +353,6 @@ return [super bitmapImageRepCachingDisplay]; } -- (BOOL)layer:(CALayer *)layer shouldInheritContentsScale:(CGFloat)newScale fromWindow:(NSWindow *)window { - return YES; -} - @end #pragma mark - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit