Advertisement
Guest User

Untitled

a guest
May 24th, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. - (void)applicationDidFinishLaunching:(NSNotification *)notification
  2. {
  3.  
  4. self.windows = [NSMutableArray new];
  5.  
  6. #ifndef DEBUG
  7. for (NSScreen *screen in [NSScreen screens]) {
  8. NSWindow *blockingWindow = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, [screen frame].size.width, [screen frame].size.height)
  9. styleMask:NSBorderlessWindowMask
  10. backing:NSBackingStoreBuffered
  11. defer:YES
  12. screen:screen];
  13. blockingWindow.alphaValue = 0.75;
  14. blockingWindow.backgroundColor = [NSColor blackColor];
  15. blockingWindow.level = kCGPopUpMenuWindowLevel + 100;
  16. [blockingWindow makeKeyAndOrderFront:self];
  17.  
  18. [self.windows addObject:blockingWindow];
  19. }
  20.  
  21. // Capture displays (really black it out)
  22. if (CGCaptureAllDisplays() != kCGErrorSuccess) {
  23. NSLog(@"Couldn't capture displays!");
  24. // Note: you'll probably want to display a proper error dialog here
  25. }
  26. #endif
  27.  
  28. // Create the usage agreement window
  29. NSRect rect = [agreementView bounds];
  30. unsigned int stylemask = NSBorderlessWindowMask;
  31.  
  32. agreementWindow = [[UsageAgreementWindow alloc] initWithContentRect:rect
  33. styleMask:stylemask
  34. backing:NSBackingStoreBuffered
  35. defer:NO ];
  36.  
  37. [agreementWindow setLevel:CGShieldingWindowLevel()];
  38. [agreementWindow setHasShadow:YES];
  39. [agreementWindow center];
  40. [agreementWindow makeKeyAndOrderFront:nil];
  41. [NSApp activateIgnoringOtherApps:YES];
  42.  
  43. }
  44.  
  45. - (void)applicationWillTerminate:(NSNotification *)notification
  46. {
  47. CGReleaseAllDisplays();
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement