Skip to content

Commit 794fe74

Browse files
committed
fix: Drop support for OS X Mavericks (version 10.9)
1 parent bcbcb4c commit 794fe74

15 files changed

+152
-286
lines changed

atom/browser/browser_mac.mm

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,9 @@
142142
}
143143

144144
std::string Browser::GetCurrentActivityType() {
145-
if (@available(macOS 10.10, *)) {
146-
NSUserActivity* userActivity =
147-
[[AtomApplication sharedApplication] getCurrentActivity];
148-
return base::SysNSStringToUTF8(userActivity.activityType);
149-
} else {
150-
return std::string();
151-
}
145+
NSUserActivity* userActivity =
146+
[[AtomApplication sharedApplication] getCurrentActivity];
147+
return base::SysNSStringToUTF8(userActivity.activityType);
152148
}
153149

154150
void Browser::InvalidateCurrentActivity() {

atom/browser/mac/atom_application.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
NSUserActivityDelegate> {
1212
@private
1313
BOOL handlingSendEvent_;
14-
base::scoped_nsobject<NSUserActivity> currentActivity_ API_AVAILABLE(macosx(10.10));
14+
base::scoped_nsobject<NSUserActivity> currentActivity_;
1515
NSCondition* handoffLock_;
1616
BOOL updateReceived_;
1717
base::Callback<bool()> shouldShutdown_;
@@ -27,7 +27,7 @@
2727
// CrAppControlProtocol:
2828
- (void)setHandlingSendEvent:(BOOL)handlingSendEvent;
2929

30-
- (NSUserActivity*)getCurrentActivity API_AVAILABLE(macosx(10.10));
30+
- (NSUserActivity*)getCurrentActivity;
3131
- (void)setCurrentActivity:(NSString*)type
3232
withUserInfo:(NSDictionary*)userInfo
3333
withWebpageURL:(NSURL*)webpageURL;

atom/browser/mac/atom_application.mm

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,13 @@ - (void)setHandlingSendEvent:(BOOL)handlingSendEvent {
5858
- (void)setCurrentActivity:(NSString*)type
5959
withUserInfo:(NSDictionary*)userInfo
6060
withWebpageURL:(NSURL*)webpageURL {
61-
if (@available(macOS 10.10, *)) {
62-
currentActivity_ = base::scoped_nsobject<NSUserActivity>(
63-
[[NSUserActivity alloc] initWithActivityType:type]);
64-
[currentActivity_ setUserInfo:userInfo];
65-
[currentActivity_ setWebpageURL:webpageURL];
66-
[currentActivity_ setDelegate:self];
67-
[currentActivity_ becomeCurrent];
68-
[currentActivity_ setNeedsSave:YES];
69-
}
61+
currentActivity_ = base::scoped_nsobject<NSUserActivity>(
62+
[[NSUserActivity alloc] initWithActivityType:type]);
63+
[currentActivity_ setUserInfo:userInfo];
64+
[currentActivity_ setWebpageURL:webpageURL];
65+
[currentActivity_ setDelegate:self];
66+
[currentActivity_ becomeCurrent];
67+
[currentActivity_ setNeedsSave:YES];
7068
}
7169

7270
- (NSUserActivity*)getCurrentActivity {
@@ -92,8 +90,7 @@ - (void)updateCurrentActivity:(NSString*)type
9290
[handoffLock_ unlock];
9391
}
9492

95-
- (void)userActivityWillSave:(NSUserActivity*)userActivity
96-
API_AVAILABLE(macosx(10.10)) {
93+
- (void)userActivityWillSave:(NSUserActivity*)userActivity {
9794
__block BOOL shouldWait = NO;
9895
dispatch_sync_main(^{
9996
std::string activity_type(
@@ -121,8 +118,7 @@ - (void)userActivityWillSave:(NSUserActivity*)userActivity
121118
[userActivity setNeedsSave:YES];
122119
}
123120

124-
- (void)userActivityWasContinued:(NSUserActivity*)userActivity
125-
API_AVAILABLE(macosx(10.10)) {
121+
- (void)userActivityWasContinued:(NSUserActivity*)userActivity {
126122
dispatch_async(dispatch_get_main_queue(), ^{
127123
std::string activity_type(
128124
base::SysNSStringToUTF8(userActivity.activityType));

atom/browser/mac/atom_application_delegate.mm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ - (BOOL)applicationShouldHandleReopen:(NSApplication*)theApplication
9898
- (BOOL)application:(NSApplication*)sender
9999
continueUserActivity:(NSUserActivity*)userActivity
100100
restorationHandler:
101-
(void (^)(NSArray* restorableObjects))restorationHandler
102-
API_AVAILABLE(macosx(10.10)) {
101+
(void (^)(NSArray* restorableObjects))restorationHandler {
103102
std::string activity_type(base::SysNSStringToUTF8(userActivity.activityType));
104103
std::unique_ptr<base::DictionaryValue> user_info =
105104
atom::NSDictionaryToDictionaryValue(userActivity.userInfo);

atom/browser/native_window_mac.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ class NativeWindowMac : public NativeWindow {
153153

154154
private:
155155
void InternalSetParentWindow(NativeWindow* parent, bool attach);
156-
void ShowWindowButton(NSWindowButton button);
157-
158156
void SetForwardMouseMessages(bool forward);
159157

160158
AtomNSWindow* window_; // Weak ref, managed by widget_.

atom/browser/native_window_mac.mm

Lines changed: 80 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,9 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
295295
}
296296

297297
NSUInteger styleMask = NSTitledWindowMask;
298-
if (@available(macOS 10.10, *)) {
299-
if (title_bar_style_ == CUSTOM_BUTTONS_ON_HOVER &&
300-
(!useStandardWindow || transparent() || !has_frame())) {
301-
styleMask = NSFullSizeContentViewWindowMask;
302-
}
298+
if (title_bar_style_ == CUSTOM_BUTTONS_ON_HOVER &&
299+
(!useStandardWindow || transparent() || !has_frame())) {
300+
styleMask = NSFullSizeContentViewWindowMask;
303301
}
304302
if (minimizable) {
305303
styleMask |= NSMiniaturizableWindowMask;
@@ -354,11 +352,10 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
354352
[window_ setDisableKeyOrMainWindow:YES];
355353

356354
if (transparent() || !has_frame()) {
357-
if (@available(macOS 10.10, *)) {
358-
// Don't show title bar.
359-
[window_ setTitlebarAppearsTransparent:YES];
360-
[window_ setTitleVisibility:NSWindowTitleHidden];
361-
}
355+
// Don't show title bar.
356+
[window_ setTitlebarAppearsTransparent:YES];
357+
[window_ setTitleVisibility:NSWindowTitleHidden];
358+
362359
// Remove non-transparent corners, see http://git.io/vfonD.
363360
[window_ setOpaque:NO];
364361
}
@@ -377,22 +374,15 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
377374

378375
// Hide the title bar background
379376
if (title_bar_style_ != NORMAL) {
380-
if (@available(macOS 10.10, *)) {
381-
[window_ setTitlebarAppearsTransparent:YES];
382-
}
377+
[window_ setTitlebarAppearsTransparent:YES];
383378
}
384379

385380
// Hide the title bar.
386381
if (title_bar_style_ == HIDDEN_INSET) {
387-
if (@available(macOS 10.10, *)) {
388-
base::scoped_nsobject<NSToolbar> toolbar(
389-
[[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]);
390-
[toolbar setShowsBaselineSeparator:NO];
391-
[window_ setToolbar:toolbar];
392-
} else {
393-
[window_ enableWindowButtonsOffset];
394-
[window_ setWindowButtonsOffset:NSMakePoint(12, 10)];
395-
}
382+
base::scoped_nsobject<NSToolbar> toolbar(
383+
[[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]);
384+
[toolbar setShowsBaselineSeparator:NO];
385+
[window_ setToolbar:toolbar];
396386
}
397387

398388
// Resize to content bounds.
@@ -445,9 +435,8 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
445435
SetContentView(new views::View());
446436

447437
// Make sure the bottom corner is rounded for non-modal windows:
448-
// http://crbug.com/396264. But do not enable it on OS X 10.9 for transparent
449-
// window, otherwise a semi-transparent frame would show.
450-
if (!(transparent() && base::mac::IsOS10_9()) && !is_modal()) {
438+
// http://crbug.com/396264.
439+
if (!is_modal()) {
451440
base::scoped_nsobject<CALayer> background_layer([[CALayer alloc] init]);
452441
[background_layer
453442
setAutoresizingMask:kCALayerWidthSizable | kCALayerHeightSizable];
@@ -479,11 +468,6 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
479468
[[window_ contentView] addSubview:buttons_view_];
480469
} else {
481470
if (title_bar_style_ != NORMAL) {
482-
if (base::mac::IsOS10_9()) {
483-
ShowWindowButton(NSWindowZoomButton);
484-
ShowWindowButton(NSWindowMiniaturizeButton);
485-
ShowWindowButton(NSWindowCloseButton);
486-
}
487471
return;
488472
}
489473

@@ -858,17 +842,11 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
858842
}
859843

860844
void NativeWindowMac::SetTitle(const std::string& title) {
861-
// For macOS <= 10.9, the setTitleVisibility API is not available, we have
862-
// to avoid calling setTitle for frameless window.
863-
if (!base::mac::IsAtLeastOS10_10() && (transparent() || !has_frame()))
864-
return;
865-
866845
[window_ setTitle:base::SysUTF8ToNSString(title)];
867846
}
868847

869848
std::string NativeWindowMac::GetTitle() {
870849
return base::SysNSStringToUTF8([window_ title]);
871-
;
872850
}
873851

874852
void NativeWindowMac::FlashFrame(bool flash) {
@@ -1178,86 +1156,83 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
11781156
}
11791157

11801158
void NativeWindowMac::SetVibrancy(const std::string& type) {
1181-
if (@available(macOS 10.10, *)) {
1182-
NSView* vibrant_view = [window_ vibrantView];
1159+
NSView* vibrant_view = [window_ vibrantView];
11831160

1184-
if (type.empty()) {
1185-
if (background_color_before_vibrancy_) {
1186-
[window_ setBackgroundColor:background_color_before_vibrancy_];
1187-
[window_ setTitlebarAppearsTransparent:transparency_before_vibrancy_];
1188-
}
1189-
if (vibrant_view == nil)
1190-
return;
1161+
if (type.empty()) {
1162+
if (background_color_before_vibrancy_) {
1163+
[window_ setBackgroundColor:background_color_before_vibrancy_];
1164+
[window_ setTitlebarAppearsTransparent:transparency_before_vibrancy_];
1165+
}
1166+
if (vibrant_view == nil)
1167+
return;
11911168

1192-
[vibrant_view removeFromSuperview];
1193-
[window_ setVibrantView:nil];
1194-
ui::GpuSwitchingManager::SetTransparent(transparent());
1169+
[vibrant_view removeFromSuperview];
1170+
[window_ setVibrantView:nil];
1171+
ui::GpuSwitchingManager::SetTransparent(transparent());
11951172

1196-
return;
1197-
}
1173+
return;
1174+
}
11981175

1199-
background_color_before_vibrancy_.reset([[window_ backgroundColor] retain]);
1200-
transparency_before_vibrancy_ = [window_ titlebarAppearsTransparent];
1201-
ui::GpuSwitchingManager::SetTransparent(true);
1176+
background_color_before_vibrancy_.reset([[window_ backgroundColor] retain]);
1177+
transparency_before_vibrancy_ = [window_ titlebarAppearsTransparent];
1178+
ui::GpuSwitchingManager::SetTransparent(true);
12021179

1203-
if (title_bar_style_ != NORMAL) {
1204-
[window_ setTitlebarAppearsTransparent:YES];
1205-
[window_ setBackgroundColor:[NSColor clearColor]];
1206-
}
1180+
if (title_bar_style_ != NORMAL) {
1181+
[window_ setTitlebarAppearsTransparent:YES];
1182+
[window_ setBackgroundColor:[NSColor clearColor]];
1183+
}
12071184

1208-
NSVisualEffectView* effect_view = (NSVisualEffectView*)vibrant_view;
1209-
if (effect_view == nil) {
1210-
effect_view = [[[NSVisualEffectView alloc]
1211-
initWithFrame:[[window_ contentView] bounds]] autorelease];
1212-
[window_ setVibrantView:(NSView*)effect_view];
1213-
1214-
[effect_view
1215-
setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
1216-
[effect_view setBlendingMode:NSVisualEffectBlendingModeBehindWindow];
1217-
[effect_view setState:NSVisualEffectStateActive];
1218-
[[window_ contentView] addSubview:effect_view
1219-
positioned:NSWindowBelow
1220-
relativeTo:nil];
1221-
}
1185+
NSVisualEffectView* effect_view = (NSVisualEffectView*)vibrant_view;
1186+
if (effect_view == nil) {
1187+
effect_view = [[[NSVisualEffectView alloc]
1188+
initWithFrame:[[window_ contentView] bounds]] autorelease];
1189+
[window_ setVibrantView:(NSView*)effect_view];
1190+
1191+
[effect_view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
1192+
[effect_view setBlendingMode:NSVisualEffectBlendingModeBehindWindow];
1193+
[effect_view setState:NSVisualEffectStateActive];
1194+
[[window_ contentView] addSubview:effect_view
1195+
positioned:NSWindowBelow
1196+
relativeTo:nil];
1197+
}
12221198

1223-
NSVisualEffectMaterial vibrancyType = NSVisualEffectMaterialLight;
1199+
NSVisualEffectMaterial vibrancyType = NSVisualEffectMaterialLight;
12241200

1225-
if (type == "appearance-based") {
1226-
vibrancyType = NSVisualEffectMaterialAppearanceBased;
1227-
} else if (type == "light") {
1228-
vibrancyType = NSVisualEffectMaterialLight;
1229-
} else if (type == "dark") {
1230-
vibrancyType = NSVisualEffectMaterialDark;
1231-
} else if (type == "titlebar") {
1232-
vibrancyType = NSVisualEffectMaterialTitlebar;
1233-
}
1201+
if (type == "appearance-based") {
1202+
vibrancyType = NSVisualEffectMaterialAppearanceBased;
1203+
} else if (type == "light") {
1204+
vibrancyType = NSVisualEffectMaterialLight;
1205+
} else if (type == "dark") {
1206+
vibrancyType = NSVisualEffectMaterialDark;
1207+
} else if (type == "titlebar") {
1208+
vibrancyType = NSVisualEffectMaterialTitlebar;
1209+
}
12341210

1235-
if (@available(macOS 10.11, *)) {
1236-
// TODO(kevinsawicki): Use NSVisualEffectMaterial* constants directly once
1237-
// they are available in the minimum SDK version
1238-
if (type == "selection") {
1239-
// NSVisualEffectMaterialSelection
1240-
vibrancyType = static_cast<NSVisualEffectMaterial>(4);
1241-
} else if (type == "menu") {
1242-
// NSVisualEffectMaterialMenu
1243-
vibrancyType = static_cast<NSVisualEffectMaterial>(5);
1244-
} else if (type == "popover") {
1245-
// NSVisualEffectMaterialPopover
1246-
vibrancyType = static_cast<NSVisualEffectMaterial>(6);
1247-
} else if (type == "sidebar") {
1248-
// NSVisualEffectMaterialSidebar
1249-
vibrancyType = static_cast<NSVisualEffectMaterial>(7);
1250-
} else if (type == "medium-light") {
1251-
// NSVisualEffectMaterialMediumLight
1252-
vibrancyType = static_cast<NSVisualEffectMaterial>(8);
1253-
} else if (type == "ultra-dark") {
1254-
// NSVisualEffectMaterialUltraDark
1255-
vibrancyType = static_cast<NSVisualEffectMaterial>(9);
1256-
}
1211+
if (@available(macOS 10.11, *)) {
1212+
// TODO(kevinsawicki): Use NSVisualEffectMaterial* constants directly once
1213+
// they are available in the minimum SDK version
1214+
if (type == "selection") {
1215+
// NSVisualEffectMaterialSelection
1216+
vibrancyType = static_cast<NSVisualEffectMaterial>(4);
1217+
} else if (type == "menu") {
1218+
// NSVisualEffectMaterialMenu
1219+
vibrancyType = static_cast<NSVisualEffectMaterial>(5);
1220+
} else if (type == "popover") {
1221+
// NSVisualEffectMaterialPopover
1222+
vibrancyType = static_cast<NSVisualEffectMaterial>(6);
1223+
} else if (type == "sidebar") {
1224+
// NSVisualEffectMaterialSidebar
1225+
vibrancyType = static_cast<NSVisualEffectMaterial>(7);
1226+
} else if (type == "medium-light") {
1227+
// NSVisualEffectMaterialMediumLight
1228+
vibrancyType = static_cast<NSVisualEffectMaterial>(8);
1229+
} else if (type == "ultra-dark") {
1230+
// NSVisualEffectMaterialUltraDark
1231+
vibrancyType = static_cast<NSVisualEffectMaterial>(9);
12571232
}
1258-
1259-
[effect_view setMaterial:vibrancyType];
12601233
}
1234+
1235+
[effect_view setMaterial:vibrancyType];
12611236
}
12621237

12631238
void NativeWindowMac::SetTouchBar(
@@ -1341,11 +1316,6 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
13411316
[parent->GetNativeWindow() addChildWindow:window_ ordered:NSWindowAbove];
13421317
}
13431318

1344-
void NativeWindowMac::ShowWindowButton(NSWindowButton button) {
1345-
auto view = [window_ standardWindowButton:button];
1346-
[view.superview addSubview:view positioned:NSWindowAbove relativeTo:nil];
1347-
}
1348-
13491319
void NativeWindowMac::SetForwardMouseMessages(bool forward) {
13501320
[window_ setAcceptsMouseMovedEvents:forward];
13511321
}

atom/browser/ui/cocoa/atom_ns_window.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,16 @@ class ScopedDisableResize {
2929
@interface AtomNSWindow : NativeWidgetMacNSWindow {
3030
@private
3131
atom::NativeWindowMac* shell_;
32-
CGFloat windowButtonsInterButtonSpacing_;
3332
}
3433
@property BOOL acceptsFirstMouse;
3534
@property BOOL enableLargerThanScreen;
3635
@property BOOL disableAutoHideCursor;
3736
@property BOOL disableKeyOrMainWindow;
38-
@property NSPoint windowButtonsOffset;
3937
@property(nonatomic, retain) NSView* vibrantView;
4038
- (id)initWithShell:(atom::NativeWindowMac*)shell
4139
styleMask:(NSUInteger)styleMask;
4240
- (atom::NativeWindowMac*)shell;
4341
- (NSRect)originalContentRectForFrameRect:(NSRect)frameRect;
44-
- (void)enableWindowButtonsOffset;
4542
- (void)toggleFullScreenMode:(id)sender;
4643
@end
4744

0 commit comments

Comments
 (0)