Revision: 13367
          http://sourceforge.net/p/skim-app/code/13367
Author:   hofman
Date:     2023-03-15 17:09:09 +0000 (Wed, 15 Mar 2023)
Log Message:
-----------
Include toolbar window from fullscreen window in screenshot for animation. Move 
code for screenshot from main window to windowcontroller category

Modified Paths:
--------------
    trunk/SKMainWindow.h
    trunk/SKMainWindow.m
    trunk/SKMainWindowController_FullScreen.m

Modified: trunk/SKMainWindow.h
===================================================================
--- trunk/SKMainWindow.h        2023-03-15 16:58:43 UTC (rev 13366)
+++ trunk/SKMainWindow.h        2023-03-15 17:09:09 UTC (rev 13367)
@@ -49,7 +49,6 @@
 }
 
 @property (nonatomic) BOOL disableConstrainedFrame;
-@property (nonatomic, readonly) NSImage *windowImage;
 
 - (id<SKMainWindowDelegate>)delegate;
 - (void)setDelegate:(id<SKMainWindowDelegate>)newDelegate;

Modified: trunk/SKMainWindow.m
===================================================================
--- trunk/SKMainWindow.m        2023-03-15 16:58:43 UTC (rev 13366)
+++ trunk/SKMainWindow.m        2023-03-15 17:09:09 UTC (rev 13367)
@@ -45,7 +45,6 @@
 @implementation SKMainWindow
 
 @synthesize disableConstrainedFrame;
-@dynamic windowImage;
 
 - (void)sendEvent:(NSEvent *)theEvent {
     if ([theEvent type] == NSEventTypeLeftMouseDown || [theEvent type] == 
NSEventTypeRightMouseDown || [theEvent type] == NSEventTypeKeyDown) {
@@ -107,12 +106,4 @@
     [super setDelegate:newDelegate];
 }
 
-- (NSImage *)windowImage {
-    NSRect frame = [self frame];
-    CGImageRef cgImage = CGWindowListCreateImage(CGRectNull, 
kCGWindowListOptionIncludingWindow, (CGWindowID)[self windowNumber], 
kCGWindowImageBoundsIgnoreFraming);
-    NSImage *image = [[NSImage alloc] initWithCGImage:cgImage size:frame.size];
-    CGImageRelease(cgImage);
-    return [image autorelease];
-}
-
 @end

Modified: trunk/SKMainWindowController_FullScreen.m
===================================================================
--- trunk/SKMainWindowController_FullScreen.m   2023-03-15 16:58:43 UTC (rev 
13366)
+++ trunk/SKMainWindowController_FullScreen.m   2023-03-15 17:09:09 UTC (rev 
13367)
@@ -553,6 +553,17 @@
     return 0.0;
 }
 
+static inline NSImage *imageForWindow(NSWindow *window) {
+    NSRect frame = [window frame];
+    CGWindowListOption options = kCGWindowListOptionIncludingWindow;
+    if (([window styleMask] & NSWindowStyleMaskFullScreen) != 0)
+        options |= kCGWindowListOptionOnScreenAboveWindow;
+    CGImageRef cgImage = CGWindowListCreateImage(CGRectNull, options, 
(CGWindowID)[window windowNumber], kCGWindowImageBoundsIgnoreFraming);
+    NSImage *image = [[NSImage alloc] initWithCGImage:cgImage size:frame.size];
+    CGImageRelease(cgImage);
+    return [image autorelease];
+}
+
 - (void)windowWillEnterFullScreen:(NSNotification *)notification {
     mwcFlags.isSwitchingFullScreen = 1;
     interactionMode = SKFullScreenMode;
@@ -586,7 +597,7 @@
     NSRect frame = SKShrinkRect([[window screen] frame], 
-fullScreenOffset(window), NSMaxYEdge);
     [(SKMainWindow *)window setDisableConstrainedFrame:YES];
     if (animationWindow != nil) {
-        [(SKAnimatedBorderlessWindow *)animationWindow 
setBackgroundImage:[(SKMainWindow *)window windowImage]];
+        [(SKAnimatedBorderlessWindow *)animationWindow 
setBackgroundImage:imageForWindow(window)];
         [animationWindow setHasShadow:YES];
         [animationWindow orderWindow:NSWindowBelow relativeTo:window];
         [window setAlphaValue:0.0];
@@ -680,7 +691,7 @@
 - (void)window:(NSWindow *)window 
startCustomAnimationToExitFullScreenWithDuration:(NSTimeInterval)duration {
     NSRect frame = NSRectFromString([savedNormalSetup 
objectForKey:MAINWINDOWFRAME_KEY]);
     if (animationWindow != nil) {
-        [(SKAnimatedBorderlessWindow *)animationWindow 
setBackgroundImage:[(SKMainWindow *)window windowImage]];
+        [(SKAnimatedBorderlessWindow *)animationWindow 
setBackgroundImage:imageForWindow(window)];
         [animationWindow orderWindow:NSWindowBelow relativeTo:window];
         [window setAlphaValue:0.0];
         [window setStyleMask:[window styleMask] & 
~NSWindowStyleMaskFullScreen];

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to