~ubuntu-branches/ubuntu/saucy/xdaliclock/saucy-proposed

« back to all changes in this revision

Viewing changes to OSX/AppController.m

  • Committer: Package Import Robot
  • Author(s): Kartik Mistry
  • Date: 2013-07-16 10:01:14 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20130716100114-zgaclt1rkj4y71g3
Tags: 2.38-1
* New upstream release.
* debian/control:
  + Added VCS-* fields.
  + Updated to Standards-Version 3.9.4
* debian/rules:
  + Rewrote to use dh.
* Added debian/docs file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* xdaliclock - a melting digital clock
2
 
 * Copyright (c) 1991-2007 Jamie Zawinski <jwz@jwz.org>
 
2
 * Copyright (c) 1991-2013 Jamie Zawinski <jwz@jwz.org>
3
3
 *
4
4
 * Permission to use, copy, modify, distribute, and sell this software and its
5
5
 * documentation for any purpose is hereby granted without fee, provided that
30
30
 
31
31
  NSUserDefaultsController *controller =
32
32
    [NSUserDefaultsController sharedUserDefaultsController];
 
33
  NSUserDefaults *defs = [controller defaults];
33
34
 
34
 
  /* Tell the DaliClockView class to initialize its preferences.
35
 
     This can't just happen in [DaliClockView:initialize], because
36
 
     we have to ensure that DaliClockView is using the same
37
 
     NSUserDefaultsController object that we are using here.
 
35
  /* Tell the DaliClockView class to initialize its default preferences.
38
36
   */
39
 
  [DaliClockView initializeDefaults:controller];
 
37
  [DaliClockView registerDefaults:defs];
40
38
 
41
39
 
42
40
  /* Now that the DaliClockView class has initialized its preferences,
43
41
     set the defaults for those preferences handled by AppController
44
42
     rather than by DaliClockView.
45
43
   */
46
 
  NSDictionary* defaults = [NSDictionary dictionaryWithObjectsAndKeys:
 
44
  NSDictionary *extras = [NSDictionary dictionaryWithObjectsAndKeys:
47
45
    @"NO", @"windowTitlebarIsHidden",
48
46
    @"NO", @"dockIconIsHidden",
49
47
    @"0", @"windowLevel",  // default to "normal window"
50
48
    nil];
51
 
 
52
49
  NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:100];
53
 
  [dict addEntriesFromDictionary: [controller initialValues]];
54
 
  [dict addEntriesFromDictionary:defaults];
55
 
  [controller setInitialValues:dict];
56
 
  [[controller defaults] registerDefaults:dict];
 
50
  [dict addEntriesFromDictionary:[defs dictionaryRepresentation]];
 
51
  [dict addEntriesFromDictionary:extras];
 
52
  [defs registerDefaults:dict];
 
53
 
 
54
  [DaliClockView setUserDefaultsController: controller];
57
55
}
58
56
 
59
57
 
77
75
 
78
76
  int level = real_window_level ([prefs integerForKey:@"windowLevel"]);
79
77
 
 
78
  /* CGDisplayCaptureWithOptions (kCGDirectMainDisplay, kCGCaptureNoFill)
 
79
     is supposed to grab the screen without blanking it, but it blanks anyway.
 
80
     As of 10.7, the new way to do full-screen is
 
81
     [app setPresentationOptions:NSApplicationPresentationFullScreen]
 
82
     but that doesn't seem to do anything.  E.g., it doesn't grab the mouse.
 
83
     So let's just not do anything.
 
84
   */
 
85
 
 
86
# if 0
 
87
  NSApplication *app = [NSApplication sharedApplication];
80
88
  if (was_fullscreen_p) {
81
 
    [NSCursor unhide];
82
 
    if (CGDisplayRelease (kCGDirectMainDisplay) != kCGErrorSuccess)
83
 
      NSLog ( @"Couldn't release the display!");
 
89
    if ([app respondsToSelector:@selector(setPresentationOptions:)]) { // 10.7
 
90
      [app setPresentationOptions: NSApplicationPresentationDefault];
 
91
    } else {
 
92
      if (CGDisplayRelease (kCGDirectMainDisplay) != kCGErrorSuccess)
 
93
        NSLog ( @"Couldn't release the display!");
 
94
    }
84
95
  }
85
96
 
86
97
  if (fullscreen_p) {
87
 
    if (CGDisplayCapture (kCGDirectMainDisplay) != kCGErrorSuccess) {
 
98
    if ([app respondsToSelector:@selector(setPresentationOptions:)]) { // 10.7
 
99
      [app setPresentationOptions:(NSApplicationPresentationHideDock|
 
100
                                   NSApplicationPresentationHideMenuBar|
 
101
                                   NSApplicationPresentationFullScreen)];
 
102
    } else {
 
103
      if (CGDisplayCaptureWithOptions (kCGDirectMainDisplay, kCGCaptureNoFill)
 
104
          != kCGErrorSuccess) {
88
105
        NSLog(@"Couldn't capture the main display!");
89
 
      fullscreen_p = NO;
 
106
        fullscreen_p = NO;
 
107
      }
90
108
    }
91
109
  }
 
110
# endif // 0
92
111
 
93
112
  if (fullscreen_p) {
94
113
    level = CGShieldingWindowLevel();
95
114
    fullscreen_window_level = level;
96
115
    title_p = NO;
97
116
    [NSCursor hide];
 
117
    CGAssociateMouseAndMouseCursorPosition (false); // locks mouse position
 
118
  } else {
 
119
    [NSCursor unhide];
 
120
    CGAssociateMouseAndMouseCursorPosition (true);  // normal mouse
98
121
  }
99
122
 
100
123
  NSScreen *screen = [NSScreen mainScreen];
165
188
  if (! view)
166
189
    view = [[DaliClockView alloc] initWithFrame:[window frame]];
167
190
 
 
191
  // Without this, toggling the title bar kills transparency until restart.
 
192
  [window setBackgroundColor:[NSColor clearColor]];
 
193
 
168
194
  [window setContentView:view];
169
195
}
170
196