OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ui/base/cocoa/appkit_utils.h" | 5 #import "ui/base/cocoa/appkit_utils.h" |
6 | 6 |
7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
8 #include "ui/base/resource/resource_bundle.h" | 8 #include "ui/base/resource/resource_bundle.h" |
9 | 9 |
10 namespace { | 10 namespace { |
(...skipping 11 matching lines...) Expand all Loading... | |
22 // NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; | 22 // NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; |
23 // return ![defaults objectForKey:@"AppleMiniaturizeOnDoubleClick"] || | 23 // return ![defaults objectForKey:@"AppleMiniaturizeOnDoubleClick"] || |
24 // [defaults boolForKey:@"AppleMiniaturizeOnDoubleClick"]; | 24 // [defaults boolForKey:@"AppleMiniaturizeOnDoubleClick"]; |
25 BOOL methodImplemented = | 25 BOOL methodImplemented = |
26 [NSWindow respondsToSelector:@selector(_shouldMiniaturizeOnDoubleClick)]; | 26 [NSWindow respondsToSelector:@selector(_shouldMiniaturizeOnDoubleClick)]; |
27 DCHECK(methodImplemented); | 27 DCHECK(methodImplemented); |
28 return !methodImplemented || | 28 return !methodImplemented || |
29 [NSWindow performSelector:@selector(_shouldMiniaturizeOnDoubleClick)]; | 29 [NSWindow performSelector:@selector(_shouldMiniaturizeOnDoubleClick)]; |
30 } | 30 } |
31 | 31 |
32 // Whether windows should maximize on a double-click on the title bar. | |
33 bool ShouldWindowsMaximizeOnDoubleClick() { | |
34 // Pre-Yosmite the answer was "no." | |
35 if (!base::mac::IsOSYosemiteOrLater()) { | |
tapted
2016/01/17 23:53:18
nit: IsOSMavericksOrEarlier() ?
shrike
2016/01/19 19:34:23
I guess I like !IsOSYosemiteOrLater() because the
tapted
2016/01/19 22:16:34
Makes sense, and I agree with your point. (and I'm
shrike
2016/01/20 17:23:54
Yeah, that makes a lot of sense, and has nice symm
| |
36 return false; | |
37 } else if (base::mac::IsOSYosemite()) { | |
38 return true; | |
39 } | |
40 | |
41 // In El Capitan there's a Dock setting that governs the action. | |
tapted
2016/01/17 23:53:18
nit: Maybe something like "El Capitan introduced a
shrike
2016/01/19 19:34:23
Good point. I added your comment language, and als
| |
42 NSString* doubleClickAction = [[NSUserDefaults standardUserDefaults] | |
43 objectForKey:@"AppleActionOnDoubleClick"]; | |
44 | |
45 return [doubleClickAction isEqualToString:@"Maximize"]; | |
46 } | |
47 | |
32 } // namespace | 48 } // namespace |
33 | 49 |
34 namespace ui { | 50 namespace ui { |
35 | 51 |
36 void DrawNinePartImage(NSRect frame, | 52 void DrawNinePartImage(NSRect frame, |
37 const NinePartImageIds& image_ids, | 53 const NinePartImageIds& image_ids, |
38 NSCompositingOperation operation, | 54 NSCompositingOperation operation, |
39 CGFloat alpha, | 55 CGFloat alpha, |
40 BOOL flipped) { | 56 BOOL flipped) { |
41 NSDrawNinePartImage(frame, | 57 NSDrawNinePartImage(frame, |
42 GetImage(image_ids.top_left), | 58 GetImage(image_ids.top_left), |
43 GetImage(image_ids.top), | 59 GetImage(image_ids.top), |
44 GetImage(image_ids.top_right), | 60 GetImage(image_ids.top_right), |
45 GetImage(image_ids.left), | 61 GetImage(image_ids.left), |
46 GetImage(image_ids.center), | 62 GetImage(image_ids.center), |
47 GetImage(image_ids.right), | 63 GetImage(image_ids.right), |
48 GetImage(image_ids.bottom_left), | 64 GetImage(image_ids.bottom_left), |
49 GetImage(image_ids.bottom), | 65 GetImage(image_ids.bottom), |
50 GetImage(image_ids.bottom_right), | 66 GetImage(image_ids.bottom_right), |
51 operation, | 67 operation, |
52 alpha, | 68 alpha, |
53 flipped); | 69 flipped); |
54 } | 70 } |
55 | 71 |
56 void WindowTitlebarReceivedDoubleClick(NSWindow* window, id sender) { | 72 void WindowTitlebarReceivedDoubleClick(NSWindow* window, id sender) { |
57 if (ShouldWindowsMiniaturizeOnDoubleClick()) { | 73 if (ShouldWindowsMiniaturizeOnDoubleClick()) { |
58 [window performMiniaturize:sender]; | 74 [window performMiniaturize:sender]; |
59 } else if (base::mac::IsOSYosemiteOrLater()) { | 75 } else if (ShouldWindowsMaximizeOnDoubleClick()) { |
60 [window performZoom:sender]; | 76 [window performZoom:sender]; |
61 } | 77 } |
62 } | 78 } |
63 | 79 |
64 } // namespace ui | 80 } // namespace ui |
OLD | NEW |