-/* xscreensaver, Copyright (c) 1992-2016 Jamie Zawinski <jwz@jwz.org>
+/* xscreensaver, Copyright (c) 1992-2017 Jamie Zawinski <jwz@jwz.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
use it if when being compiled against the 10.5 SDK or later.
*/
+extern float jwxyz_scale (Window); /* jwxyzI.h */
+
/* Loads an image into the Drawable, returning once the image is loaded.
*/
Bool
// Grab only the rectangle of the screen underlying this window.
//
CGRect cgrect;
+ double s = jwxyz_scale (xwindow);
cgrect.origin.x = window_x;
cgrect.origin.y = window_y;
- cgrect.size.width = xgwa.width;
- cgrect.size.height = xgwa.height;
+ cgrect.size.width = xgwa.width / s;
+ cgrect.size.height = xgwa.height / s;
/* If a password is required to unlock the screen, a large black
window will be on top of all of the desktop windows by the time
Oct 2016: Surprise, this trick no longer works on MacOS 10.12. Sigh.
*/
- // save our current level so we can restore it later
- int oldLevel = [[nsview window] level];
+ CGWindowID windowNumber = (CGWindowID) nsview.window.windowNumber;
-# if 0
{
- FILE *f = fopen("/tmp/log.txt", "w");
CFArrayRef L = CGWindowListCopyWindowInfo (kCGWindowListOptionOnScreenOnly,
kCGNullWindowID);
- fprintf(f, "# %d\n", [[nsview window] windowNumber]);
-
- int n = CFArrayGetCount(L);
+ CFIndex n = CFArrayGetCount(L);
for (int i = 0; i < n; i++) {
NSDictionary *dict = (NSDictionary *) CFArrayGetValueAtIndex(L, i);
- fprintf(f,
- "%d \"%s\"\n",
- (int) [dict objectForKey:kCGWindowNumber],
- [(NSString *) [dict objectForKey:kCGWindowOwnerName]
- cStringUsingEncoding:[NSString defaultCStringEncoding]]);
+
+ // loginwindow creates multiple toplevel windows. Grab the lowest one.
+ if(![([dict objectForKey:(NSString *)kCGWindowOwnerName])
+ compare:@"loginwindow"]) {
+ windowNumber = ((NSNumber *)[dict objectForKey:
+ (NSString *)kCGWindowNumber]).intValue;
+ }
}
- fclose(f);
}
-#endif
-
- [[nsview window] setLevel:CGWindowLevelForKey(kCGPopUpMenuWindowLevelKey)];
// Grab a screen shot of those windows below this one
// (hey, X11 can't do that!)
CGImageRef img =
CGWindowListCreateImage (cgrect,
kCGWindowListOptionOnScreenBelowWindow,
- [[nsview window] windowNumber],
+ windowNumber,
kCGWindowImageDefault);
- // put us back above the login windows so the screensaver is visible.
- [[nsview window] setLevel:oldLevel];
-
if (! img) return False;
// Render the grabbed CGImage into the Drawable.