Bring mac code into conformance with -Wunguarded-availability
This commit is contained in:
parent
27cee90e5e
commit
f3c00e96aa
12 changed files with 234 additions and 207 deletions
|
@ -145,9 +145,13 @@ void Browser::SetUserActivity(const std::string& type,
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Browser::GetCurrentActivityType() {
|
std::string Browser::GetCurrentActivityType() {
|
||||||
NSUserActivity* userActivity =
|
if (@available(macOS 10.10, *)) {
|
||||||
[[AtomApplication sharedApplication] getCurrentActivity];
|
NSUserActivity* userActivity =
|
||||||
return base::SysNSStringToUTF8(userActivity.activityType);
|
[[AtomApplication sharedApplication] getCurrentActivity];
|
||||||
|
return base::SysNSStringToUTF8(userActivity.activityType);
|
||||||
|
} else {
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Browser::InvalidateCurrentActivity() {
|
void Browser::InvalidateCurrentActivity() {
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
NSUserActivityDelegate> {
|
NSUserActivityDelegate> {
|
||||||
@private
|
@private
|
||||||
BOOL handlingSendEvent_;
|
BOOL handlingSendEvent_;
|
||||||
base::scoped_nsobject<NSUserActivity> currentActivity_;
|
base::scoped_nsobject<NSUserActivity> currentActivity_ API_AVAILABLE(macosx(10.10));
|
||||||
NSCondition* handoffLock_;
|
NSCondition* handoffLock_;
|
||||||
BOOL updateReceived_;
|
BOOL updateReceived_;
|
||||||
base::Callback<bool()> shouldShutdown_;
|
base::Callback<bool()> shouldShutdown_;
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
// CrAppControlProtocol:
|
// CrAppControlProtocol:
|
||||||
- (void)setHandlingSendEvent:(BOOL)handlingSendEvent;
|
- (void)setHandlingSendEvent:(BOOL)handlingSendEvent;
|
||||||
|
|
||||||
- (NSUserActivity*)getCurrentActivity;
|
- (NSUserActivity*)getCurrentActivity API_AVAILABLE(macosx(10.10));
|
||||||
- (void)setCurrentActivity:(NSString*)type
|
- (void)setCurrentActivity:(NSString*)type
|
||||||
withUserInfo:(NSDictionary*)userInfo
|
withUserInfo:(NSDictionary*)userInfo
|
||||||
withWebpageURL:(NSURL*)webpageURL;
|
withWebpageURL:(NSURL*)webpageURL;
|
||||||
|
|
|
@ -58,13 +58,15 @@ inline void dispatch_sync_main(dispatch_block_t block) {
|
||||||
- (void)setCurrentActivity:(NSString*)type
|
- (void)setCurrentActivity:(NSString*)type
|
||||||
withUserInfo:(NSDictionary*)userInfo
|
withUserInfo:(NSDictionary*)userInfo
|
||||||
withWebpageURL:(NSURL*)webpageURL {
|
withWebpageURL:(NSURL*)webpageURL {
|
||||||
currentActivity_ = base::scoped_nsobject<NSUserActivity>(
|
if (@available(macOS 10.10, *)) {
|
||||||
[[NSUserActivity alloc] initWithActivityType:type]);
|
currentActivity_ = base::scoped_nsobject<NSUserActivity>(
|
||||||
[currentActivity_ setUserInfo:userInfo];
|
[[NSUserActivity alloc] initWithActivityType:type]);
|
||||||
[currentActivity_ setWebpageURL:webpageURL];
|
[currentActivity_ setUserInfo:userInfo];
|
||||||
[currentActivity_ setDelegate:self];
|
[currentActivity_ setWebpageURL:webpageURL];
|
||||||
[currentActivity_ becomeCurrent];
|
[currentActivity_ setDelegate:self];
|
||||||
[currentActivity_ setNeedsSave:YES];
|
[currentActivity_ becomeCurrent];
|
||||||
|
[currentActivity_ setNeedsSave:YES];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSUserActivity*)getCurrentActivity {
|
- (NSUserActivity*)getCurrentActivity {
|
||||||
|
@ -90,7 +92,7 @@ inline void dispatch_sync_main(dispatch_block_t block) {
|
||||||
[handoffLock_ unlock];
|
[handoffLock_ unlock];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)userActivityWillSave:(NSUserActivity *)userActivity {
|
- (void)userActivityWillSave:(NSUserActivity *)userActivity API_AVAILABLE(macosx(10.10)) {
|
||||||
__block BOOL shouldWait = NO;
|
__block BOOL shouldWait = NO;
|
||||||
dispatch_sync_main(^{
|
dispatch_sync_main(^{
|
||||||
std::string activity_type(base::SysNSStringToUTF8(userActivity.activityType));
|
std::string activity_type(base::SysNSStringToUTF8(userActivity.activityType));
|
||||||
|
@ -114,7 +116,7 @@ inline void dispatch_sync_main(dispatch_block_t block) {
|
||||||
[userActivity setNeedsSave:YES];
|
[userActivity setNeedsSave:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)userActivityWasContinued:(NSUserActivity *)userActivity {
|
- (void)userActivityWasContinued:(NSUserActivity *)userActivity API_AVAILABLE(macosx(10.10)) {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
std::string activity_type(base::SysNSStringToUTF8(userActivity.activityType));
|
std::string activity_type(base::SysNSStringToUTF8(userActivity.activityType));
|
||||||
std::unique_ptr<base::DictionaryValue> user_info =
|
std::unique_ptr<base::DictionaryValue> user_info =
|
||||||
|
|
|
@ -96,7 +96,8 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
|
||||||
|
|
||||||
- (BOOL)application:(NSApplication*)sender
|
- (BOOL)application:(NSApplication*)sender
|
||||||
continueUserActivity:(NSUserActivity*)userActivity
|
continueUserActivity:(NSUserActivity*)userActivity
|
||||||
restorationHandler:(void (^)(NSArray*restorableObjects))restorationHandler {
|
restorationHandler:(void (^)(NSArray*restorableObjects))restorationHandler
|
||||||
|
API_AVAILABLE(macosx(10.10)) {
|
||||||
std::string activity_type(base::SysNSStringToUTF8(userActivity.activityType));
|
std::string activity_type(base::SysNSStringToUTF8(userActivity.activityType));
|
||||||
std::unique_ptr<base::DictionaryValue> user_info =
|
std::unique_ptr<base::DictionaryValue> user_info =
|
||||||
atom::NSDictionaryToDictionaryValue(userActivity.userInfo);
|
atom::NSDictionaryToDictionaryValue(userActivity.userInfo);
|
||||||
|
|
|
@ -50,7 +50,9 @@ const NSAutoresizingMaskOptions kDefaultAutoResizingMask =
|
||||||
postNotificationName:NSWindowWillMoveNotification
|
postNotificationName:NSWindowWillMoveNotification
|
||||||
object:self];
|
object:self];
|
||||||
|
|
||||||
[self.window performWindowDragWithEvent:event];
|
if (@available(macOS 10.11, *)) {
|
||||||
|
[self.window performWindowDragWithEvent:event];
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -314,59 +314,60 @@ bool ScopedDisableResize::disable_resize_ = false;
|
||||||
shell_->SetResizable(true);
|
shell_->SetResizable(true);
|
||||||
// Hide the native toolbar before entering fullscreen, so there is no visual
|
// Hide the native toolbar before entering fullscreen, so there is no visual
|
||||||
// artifacts.
|
// artifacts.
|
||||||
if (base::mac::IsAtLeastOS10_10() &&
|
if (@available(macOS 10.10, *)) {
|
||||||
shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) {
|
if (shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) {
|
||||||
NSWindow* window = shell_->GetNativeWindow();
|
NSWindow* window = shell_->GetNativeWindow();
|
||||||
[window setToolbar:nil];
|
[window setToolbar:nil];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowDidEnterFullScreen:(NSNotification*)notification {
|
- (void)windowDidEnterFullScreen:(NSNotification*)notification {
|
||||||
shell_->NotifyWindowEnterFullScreen();
|
shell_->NotifyWindowEnterFullScreen();
|
||||||
|
|
||||||
// For frameless window we don't show set title for normal mode since the
|
if (@available(macOS 10.10, *)) {
|
||||||
// titlebar is expected to be empty, but after entering fullscreen mode we
|
// For frameless window we don't show set title for normal mode since the
|
||||||
// have to set one, because title bar is visible here.
|
// titlebar is expected to be empty, but after entering fullscreen mode we
|
||||||
NSWindow* window = shell_->GetNativeWindow();
|
// have to set one, because title bar is visible here.
|
||||||
if ((shell_->transparent() || !shell_->has_frame()) &&
|
NSWindow* window = shell_->GetNativeWindow();
|
||||||
base::mac::IsAtLeastOS10_10() &&
|
if ((shell_->transparent() || !shell_->has_frame()) &&
|
||||||
// FIXME(zcbenz): Showing titlebar for hiddenInset window is weird under
|
// FIXME(zcbenz): Showing titlebar for hiddenInset window is weird under
|
||||||
|
// fullscreen mode.
|
||||||
|
// Show title if fullscreen_window_title flag is set
|
||||||
|
(shell_->title_bar_style() != atom::NativeWindowMac::HIDDEN_INSET ||
|
||||||
|
shell_->fullscreen_window_title())) {
|
||||||
|
[window setTitleVisibility:NSWindowTitleVisible];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restore the native toolbar immediately after entering fullscreen, if we do
|
||||||
|
// this before leaving fullscreen, traffic light buttons will be jumping.
|
||||||
|
if (shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) {
|
||||||
|
base::scoped_nsobject<NSToolbar> toolbar(
|
||||||
|
[[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]);
|
||||||
|
[toolbar setShowsBaselineSeparator:NO];
|
||||||
|
[window setToolbar:toolbar];
|
||||||
|
|
||||||
|
// Set window style to hide the toolbar, otherwise the toolbar will show in
|
||||||
// fullscreen mode.
|
// fullscreen mode.
|
||||||
// Show title if fullscreen_window_title flag is set
|
shell_->SetStyleMask(true, NSFullSizeContentViewWindowMask);
|
||||||
(shell_->title_bar_style() != atom::NativeWindowMac::HIDDEN_INSET ||
|
}
|
||||||
shell_->fullscreen_window_title())) {
|
|
||||||
[window setTitleVisibility:NSWindowTitleVisible];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Restore the native toolbar immediately after entering fullscreen, if we do
|
|
||||||
// this before leaving fullscreen, traffic light buttons will be jumping.
|
|
||||||
if (base::mac::IsAtLeastOS10_10() &&
|
|
||||||
shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) {
|
|
||||||
base::scoped_nsobject<NSToolbar> toolbar(
|
|
||||||
[[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]);
|
|
||||||
[toolbar setShowsBaselineSeparator:NO];
|
|
||||||
[window setToolbar:toolbar];
|
|
||||||
|
|
||||||
// Set window style to hide the toolbar, otherwise the toolbar will show in
|
|
||||||
// fullscreen mode.
|
|
||||||
shell_->SetStyleMask(true, NSFullSizeContentViewWindowMask);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowWillExitFullScreen:(NSNotification*)notification {
|
- (void)windowWillExitFullScreen:(NSNotification*)notification {
|
||||||
// Restore the titlebar visibility.
|
if (@available(macOS 10.10, *)) {
|
||||||
NSWindow* window = shell_->GetNativeWindow();
|
// Restore the titlebar visibility.
|
||||||
if ((shell_->transparent() || !shell_->has_frame()) &&
|
NSWindow* window = shell_->GetNativeWindow();
|
||||||
base::mac::IsAtLeastOS10_10() &&
|
if ((shell_->transparent() || !shell_->has_frame()) &&
|
||||||
(shell_->title_bar_style() != atom::NativeWindowMac::HIDDEN_INSET ||
|
(shell_->title_bar_style() != atom::NativeWindowMac::HIDDEN_INSET ||
|
||||||
shell_->fullscreen_window_title())) {
|
shell_->fullscreen_window_title())) {
|
||||||
[window setTitleVisibility:NSWindowTitleHidden];
|
[window setTitleVisibility:NSWindowTitleHidden];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Turn off the style for toolbar.
|
// Turn off the style for toolbar.
|
||||||
if (base::mac::IsAtLeastOS10_10() &&
|
if (shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) {
|
||||||
shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) {
|
shell_->SetStyleMask(false, NSFullSizeContentViewWindowMask);
|
||||||
shell_->SetStyleMask(false, NSFullSizeContentViewWindowMask);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -487,7 +488,8 @@ enum {
|
||||||
enable_larger_than_screen_ = enable;
|
enable_larger_than_screen_ = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)resetTouchBar:(const std::vector<mate::PersistentDictionary>&)settings {
|
- (void)resetTouchBar:(const std::vector<mate::PersistentDictionary>&)settings
|
||||||
|
API_AVAILABLE(macosx(10.12.2)) {
|
||||||
if (![self respondsToSelector:@selector(touchBar)]) return;
|
if (![self respondsToSelector:@selector(touchBar)]) return;
|
||||||
|
|
||||||
atom_touch_bar_.reset([[AtomTouchBar alloc] initWithDelegate:self
|
atom_touch_bar_.reset([[AtomTouchBar alloc] initWithDelegate:self
|
||||||
|
@ -496,12 +498,13 @@ enum {
|
||||||
self.touchBar = nil;
|
self.touchBar = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)refreshTouchBarItem:(const std::string&)item_id {
|
- (void)refreshTouchBarItem:(const std::string&)item_id
|
||||||
|
API_AVAILABLE(macosx(10.12.2)) {
|
||||||
if (atom_touch_bar_ && self.touchBar)
|
if (atom_touch_bar_ && self.touchBar)
|
||||||
[atom_touch_bar_ refreshTouchBarItem:self.touchBar id:item_id];
|
[atom_touch_bar_ refreshTouchBarItem:self.touchBar id:item_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSTouchBar*)makeTouchBar {
|
- (NSTouchBar*)makeTouchBar API_AVAILABLE(macosx(10.12.2)) {
|
||||||
if (atom_touch_bar_)
|
if (atom_touch_bar_)
|
||||||
return [atom_touch_bar_ makeTouchBar];
|
return [atom_touch_bar_ makeTouchBar];
|
||||||
else
|
else
|
||||||
|
@ -509,14 +512,15 @@ enum {
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSTouchBarItem*)touchBar:(NSTouchBar*)touchBar
|
- (NSTouchBarItem*)touchBar:(NSTouchBar*)touchBar
|
||||||
makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier {
|
makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier API_AVAILABLE(macosx(10.12.2)) {
|
||||||
if (touchBar && atom_touch_bar_)
|
if (touchBar && atom_touch_bar_)
|
||||||
return [atom_touch_bar_ makeItemForIdentifier:identifier];
|
return [atom_touch_bar_ makeItemForIdentifier:identifier];
|
||||||
else
|
else
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setEscapeTouchBarItem:(const mate::PersistentDictionary&)item {
|
- (void)setEscapeTouchBarItem:(const mate::PersistentDictionary&)item
|
||||||
|
API_AVAILABLE(macosx(10.12.2)) {
|
||||||
if (atom_touch_bar_ && self.touchBar)
|
if (atom_touch_bar_ && self.touchBar)
|
||||||
[atom_touch_bar_ setEscapeTouchBarItem:item forTouchBar:self.touchBar];
|
[atom_touch_bar_ setEscapeTouchBarItem:item forTouchBar:self.touchBar];
|
||||||
}
|
}
|
||||||
|
@ -828,10 +832,11 @@ NativeWindowMac::NativeWindowMac(const mate::Dictionary& options,
|
||||||
}
|
}
|
||||||
|
|
||||||
NSUInteger styleMask = NSTitledWindowMask;
|
NSUInteger styleMask = NSTitledWindowMask;
|
||||||
if (title_bar_style_ == CUSTOM_BUTTONS_ON_HOVER &&
|
if (@available(macOS 10.10, *)) {
|
||||||
base::mac::IsAtLeastOS10_10() &&
|
if (title_bar_style_ == CUSTOM_BUTTONS_ON_HOVER &&
|
||||||
(!useStandardWindow || transparent() || !has_frame())) {
|
(!useStandardWindow || transparent() || !has_frame())) {
|
||||||
styleMask = NSFullSizeContentViewWindowMask;
|
styleMask = NSFullSizeContentViewWindowMask;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (minimizable) {
|
if (minimizable) {
|
||||||
styleMask |= NSMiniaturizableWindowMask;
|
styleMask |= NSMiniaturizableWindowMask;
|
||||||
|
@ -885,7 +890,7 @@ NativeWindowMac::NativeWindowMac(const mate::Dictionary& options,
|
||||||
[window_ setDisableKeyOrMainWindow:YES];
|
[window_ setDisableKeyOrMainWindow:YES];
|
||||||
|
|
||||||
if (transparent() || !has_frame()) {
|
if (transparent() || !has_frame()) {
|
||||||
if (base::mac::IsAtLeastOS10_10()) {
|
if (@available(macOS 10.10, *)) {
|
||||||
// Don't show title bar.
|
// Don't show title bar.
|
||||||
[window_ setTitlebarAppearsTransparent:YES];
|
[window_ setTitlebarAppearsTransparent:YES];
|
||||||
[window_ setTitleVisibility:NSWindowTitleHidden];
|
[window_ setTitleVisibility:NSWindowTitleHidden];
|
||||||
|
@ -897,11 +902,11 @@ NativeWindowMac::NativeWindowMac(const mate::Dictionary& options,
|
||||||
// Create a tab only if tabbing identifier is specified and window has
|
// Create a tab only if tabbing identifier is specified and window has
|
||||||
// a native title bar.
|
// a native title bar.
|
||||||
if (tabbingIdentifier.empty() || transparent() || !has_frame()) {
|
if (tabbingIdentifier.empty() || transparent() || !has_frame()) {
|
||||||
if ([window_ respondsToSelector:@selector(tabbingMode)]) {
|
if (@available(macOS 10.12, *)) {
|
||||||
[window_ setTabbingMode:NSWindowTabbingModeDisallowed];
|
[window_ setTabbingMode:NSWindowTabbingModeDisallowed];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ([window_ respondsToSelector:@selector(tabbingIdentifier)]) {
|
if (@available(macOS 10.12, *)) {
|
||||||
[window_ setTabbingIdentifier:base::SysUTF8ToNSString(tabbingIdentifier)];
|
[window_ setTabbingIdentifier:base::SysUTF8ToNSString(tabbingIdentifier)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -911,14 +916,14 @@ NativeWindowMac::NativeWindowMac(const mate::Dictionary& options,
|
||||||
|
|
||||||
// Hide the title bar background
|
// Hide the title bar background
|
||||||
if (title_bar_style_ != NORMAL) {
|
if (title_bar_style_ != NORMAL) {
|
||||||
if (base::mac::IsAtLeastOS10_10()) {
|
if (@available(macOS 10.10, *)) {
|
||||||
[window_ setTitlebarAppearsTransparent:YES];
|
[window_ setTitlebarAppearsTransparent:YES];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide the title bar.
|
// Hide the title bar.
|
||||||
if (title_bar_style_ == HIDDEN_INSET) {
|
if (title_bar_style_ == HIDDEN_INSET) {
|
||||||
if (base::mac::IsAtLeastOS10_10()) {
|
if (@available(macOS 10.10, *)) {
|
||||||
base::scoped_nsobject<NSToolbar> toolbar(
|
base::scoped_nsobject<NSToolbar> toolbar(
|
||||||
[[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]);
|
[[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]);
|
||||||
[toolbar setShowsBaselineSeparator:NO];
|
[toolbar setShowsBaselineSeparator:NO];
|
||||||
|
@ -1650,31 +1655,31 @@ void NativeWindowMac::SetAutoHideCursor(bool auto_hide) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::SelectPreviousTab() {
|
void NativeWindowMac::SelectPreviousTab() {
|
||||||
if ([window_ respondsToSelector:@selector(selectPreviousTab:)]) {
|
if (@available(macOS 10.12, *)) {
|
||||||
[window_ selectPreviousTab:nil];
|
[window_ selectPreviousTab:nil];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::SelectNextTab() {
|
void NativeWindowMac::SelectNextTab() {
|
||||||
if ([window_ respondsToSelector:@selector(selectNextTab:)]) {
|
if (@available(macOS 10.12, *)) {
|
||||||
[window_ selectNextTab:nil];
|
[window_ selectNextTab:nil];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::MergeAllWindows() {
|
void NativeWindowMac::MergeAllWindows() {
|
||||||
if ([window_ respondsToSelector:@selector(mergeAllWindows:)]) {
|
if (@available(macOS 10.12, *)) {
|
||||||
[window_ mergeAllWindows:nil];
|
[window_ mergeAllWindows:nil];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::MoveTabToNewWindow() {
|
void NativeWindowMac::MoveTabToNewWindow() {
|
||||||
if ([window_ respondsToSelector:@selector(moveTabToNewWindow:)]) {
|
if (@available(macOS 10.12, *)) {
|
||||||
[window_ moveTabToNewWindow:nil];
|
[window_ moveTabToNewWindow:nil];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::ToggleTabBar() {
|
void NativeWindowMac::ToggleTabBar() {
|
||||||
if ([window_ respondsToSelector:@selector(toggleTabBar:)]) {
|
if (@available(macOS 10.12, *)) {
|
||||||
[window_ toggleTabBar:nil];
|
[window_ toggleTabBar:nil];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1683,91 +1688,91 @@ bool NativeWindowMac::AddTabbedWindow(NativeWindow* window) {
|
||||||
if (window_.get() == window->GetNativeWindow()) {
|
if (window_.get() == window->GetNativeWindow()) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if ([window_ respondsToSelector:@selector(addTabbedWindow:ordered:)])
|
if (@available(macOS 10.12, *))
|
||||||
[window_ addTabbedWindow:window->GetNativeWindow() ordered:NSWindowAbove];
|
[window_ addTabbedWindow:window->GetNativeWindow() ordered:NSWindowAbove];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::SetVibrancy(const std::string& type) {
|
void NativeWindowMac::SetVibrancy(const std::string& type) {
|
||||||
if (!base::mac::IsAtLeastOS10_10()) return;
|
if (@available(macOS 10.10, *)) {
|
||||||
|
NSView* vibrant_view = [window_ vibrantView];
|
||||||
|
|
||||||
NSView* vibrant_view = [window_ vibrantView];
|
if (type.empty()) {
|
||||||
|
if (background_color_before_vibrancy_) {
|
||||||
|
[window_ setBackgroundColor:background_color_before_vibrancy_];
|
||||||
|
[window_ setTitlebarAppearsTransparent:transparency_before_vibrancy_];
|
||||||
|
}
|
||||||
|
if (vibrant_view == nil) return;
|
||||||
|
|
||||||
if (type.empty()) {
|
[vibrant_view removeFromSuperview];
|
||||||
if (background_color_before_vibrancy_) {
|
[window_ setVibrantView:nil];
|
||||||
[window_ setBackgroundColor:background_color_before_vibrancy_];
|
ui::GpuSwitchingManager::SetTransparent(transparent());
|
||||||
[window_ setTitlebarAppearsTransparent:transparency_before_vibrancy_];
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (vibrant_view == nil) return;
|
|
||||||
|
|
||||||
[vibrant_view removeFromSuperview];
|
background_color_before_vibrancy_.reset([[window_ backgroundColor] retain]);
|
||||||
[window_ setVibrantView:nil];
|
transparency_before_vibrancy_ = [window_ titlebarAppearsTransparent];
|
||||||
ui::GpuSwitchingManager::SetTransparent(transparent());
|
ui::GpuSwitchingManager::SetTransparent(true);
|
||||||
|
|
||||||
return;
|
if (title_bar_style_ != NORMAL) {
|
||||||
}
|
[window_ setTitlebarAppearsTransparent:YES];
|
||||||
|
[window_ setBackgroundColor:[NSColor clearColor]];
|
||||||
background_color_before_vibrancy_.reset([[window_ backgroundColor] retain]);
|
|
||||||
transparency_before_vibrancy_ = [window_ titlebarAppearsTransparent];
|
|
||||||
ui::GpuSwitchingManager::SetTransparent(true);
|
|
||||||
|
|
||||||
if (title_bar_style_ != NORMAL) {
|
|
||||||
[window_ setTitlebarAppearsTransparent:YES];
|
|
||||||
[window_ setBackgroundColor:[NSColor clearColor]];
|
|
||||||
}
|
|
||||||
|
|
||||||
NSVisualEffectView* effect_view = (NSVisualEffectView*)vibrant_view;
|
|
||||||
if (effect_view == nil) {
|
|
||||||
effect_view = [[[NSVisualEffectView alloc]
|
|
||||||
initWithFrame: [[window_ contentView] bounds]] autorelease];
|
|
||||||
[window_ setVibrantView:(NSView*)effect_view];
|
|
||||||
|
|
||||||
[effect_view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
|
||||||
[effect_view setBlendingMode:NSVisualEffectBlendingModeBehindWindow];
|
|
||||||
[effect_view setState:NSVisualEffectStateActive];
|
|
||||||
[[window_ contentView] addSubview:effect_view
|
|
||||||
positioned:NSWindowBelow
|
|
||||||
relativeTo:nil];
|
|
||||||
}
|
|
||||||
|
|
||||||
NSVisualEffectMaterial vibrancyType = NSVisualEffectMaterialLight;
|
|
||||||
|
|
||||||
if (type == "appearance-based") {
|
|
||||||
vibrancyType = NSVisualEffectMaterialAppearanceBased;
|
|
||||||
} else if (type == "light") {
|
|
||||||
vibrancyType = NSVisualEffectMaterialLight;
|
|
||||||
} else if (type == "dark") {
|
|
||||||
vibrancyType = NSVisualEffectMaterialDark;
|
|
||||||
} else if (type == "titlebar") {
|
|
||||||
vibrancyType = NSVisualEffectMaterialTitlebar;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (base::mac::IsAtLeastOS10_11()) {
|
|
||||||
// TODO(kevinsawicki): Use NSVisualEffectMaterial* constants directly once
|
|
||||||
// they are available in the minimum SDK version
|
|
||||||
if (type == "selection") {
|
|
||||||
// NSVisualEffectMaterialSelection
|
|
||||||
vibrancyType = static_cast<NSVisualEffectMaterial>(4);
|
|
||||||
} else if (type == "menu") {
|
|
||||||
// NSVisualEffectMaterialMenu
|
|
||||||
vibrancyType = static_cast<NSVisualEffectMaterial>(5);
|
|
||||||
} else if (type == "popover") {
|
|
||||||
// NSVisualEffectMaterialPopover
|
|
||||||
vibrancyType = static_cast<NSVisualEffectMaterial>(6);
|
|
||||||
} else if (type == "sidebar") {
|
|
||||||
// NSVisualEffectMaterialSidebar
|
|
||||||
vibrancyType = static_cast<NSVisualEffectMaterial>(7);
|
|
||||||
} else if (type == "medium-light") {
|
|
||||||
// NSVisualEffectMaterialMediumLight
|
|
||||||
vibrancyType = static_cast<NSVisualEffectMaterial>(8);
|
|
||||||
} else if (type == "ultra-dark") {
|
|
||||||
// NSVisualEffectMaterialUltraDark
|
|
||||||
vibrancyType = static_cast<NSVisualEffectMaterial>(9);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[effect_view setMaterial:vibrancyType];
|
NSVisualEffectView* effect_view = (NSVisualEffectView*)vibrant_view;
|
||||||
|
if (effect_view == nil) {
|
||||||
|
effect_view = [[[NSVisualEffectView alloc]
|
||||||
|
initWithFrame: [[window_ contentView] bounds]] autorelease];
|
||||||
|
[window_ setVibrantView:(NSView*)effect_view];
|
||||||
|
|
||||||
|
[effect_view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
||||||
|
[effect_view setBlendingMode:NSVisualEffectBlendingModeBehindWindow];
|
||||||
|
[effect_view setState:NSVisualEffectStateActive];
|
||||||
|
[[window_ contentView] addSubview:effect_view
|
||||||
|
positioned:NSWindowBelow
|
||||||
|
relativeTo:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
NSVisualEffectMaterial vibrancyType = NSVisualEffectMaterialLight;
|
||||||
|
|
||||||
|
if (type == "appearance-based") {
|
||||||
|
vibrancyType = NSVisualEffectMaterialAppearanceBased;
|
||||||
|
} else if (type == "light") {
|
||||||
|
vibrancyType = NSVisualEffectMaterialLight;
|
||||||
|
} else if (type == "dark") {
|
||||||
|
vibrancyType = NSVisualEffectMaterialDark;
|
||||||
|
} else if (type == "titlebar") {
|
||||||
|
vibrancyType = NSVisualEffectMaterialTitlebar;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (@available(macOS 10.11, *)) {
|
||||||
|
// TODO(kevinsawicki): Use NSVisualEffectMaterial* constants directly once
|
||||||
|
// they are available in the minimum SDK version
|
||||||
|
if (type == "selection") {
|
||||||
|
// NSVisualEffectMaterialSelection
|
||||||
|
vibrancyType = static_cast<NSVisualEffectMaterial>(4);
|
||||||
|
} else if (type == "menu") {
|
||||||
|
// NSVisualEffectMaterialMenu
|
||||||
|
vibrancyType = static_cast<NSVisualEffectMaterial>(5);
|
||||||
|
} else if (type == "popover") {
|
||||||
|
// NSVisualEffectMaterialPopover
|
||||||
|
vibrancyType = static_cast<NSVisualEffectMaterial>(6);
|
||||||
|
} else if (type == "sidebar") {
|
||||||
|
// NSVisualEffectMaterialSidebar
|
||||||
|
vibrancyType = static_cast<NSVisualEffectMaterial>(7);
|
||||||
|
} else if (type == "medium-light") {
|
||||||
|
// NSVisualEffectMaterialMediumLight
|
||||||
|
vibrancyType = static_cast<NSVisualEffectMaterial>(8);
|
||||||
|
} else if (type == "ultra-dark") {
|
||||||
|
// NSVisualEffectMaterialUltraDark
|
||||||
|
vibrancyType = static_cast<NSVisualEffectMaterial>(9);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[effect_view setMaterial:vibrancyType];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::SetTouchBar(
|
void NativeWindowMac::SetTouchBar(
|
||||||
|
|
|
@ -31,16 +31,16 @@
|
||||||
window:(atom::NativeWindow*)window
|
window:(atom::NativeWindow*)window
|
||||||
settings:(const std::vector<mate::PersistentDictionary>&)settings;
|
settings:(const std::vector<mate::PersistentDictionary>&)settings;
|
||||||
|
|
||||||
- (NSTouchBar*)makeTouchBar;
|
- (NSTouchBar*)makeTouchBar API_AVAILABLE(macosx(10.12.2));
|
||||||
- (NSTouchBar*)touchBarFromItemIdentifiers:(NSMutableArray*)items;
|
- (NSTouchBar*)touchBarFromItemIdentifiers:(NSMutableArray*)items API_AVAILABLE(macosx(10.12.2));
|
||||||
- (NSMutableArray*)identifiersFromSettings:
|
- (NSMutableArray*)identifiersFromSettings:
|
||||||
(const std::vector<mate::PersistentDictionary>&)settings;
|
(const std::vector<mate::PersistentDictionary>&)settings;
|
||||||
- (void)refreshTouchBarItem:(NSTouchBar*)touchBar
|
- (void)refreshTouchBarItem:(NSTouchBar*)touchBar
|
||||||
id:(const std::string&)item_id;
|
id:(const std::string&)item_id API_AVAILABLE(macosx(10.12.2));
|
||||||
- (void)addNonDefaultTouchBarItems:
|
- (void)addNonDefaultTouchBarItems:
|
||||||
(const std::vector<mate::PersistentDictionary>&)items;
|
(const std::vector<mate::PersistentDictionary>&)items;
|
||||||
- (void)setEscapeTouchBarItem:(const mate::PersistentDictionary&)item
|
- (void)setEscapeTouchBarItem:(const mate::PersistentDictionary&)item
|
||||||
forTouchBar:(NSTouchBar*)touchBar;
|
forTouchBar:(NSTouchBar*)touchBar API_AVAILABLE(macosx(10.12.2));
|
||||||
|
|
||||||
- (NSString*)idFromIdentifier:(NSString*)identifier
|
- (NSString*)idFromIdentifier:(NSString*)identifier
|
||||||
withPrefix:(NSString*)prefix;
|
withPrefix:(NSString*)prefix;
|
||||||
|
@ -51,35 +51,36 @@
|
||||||
|
|
||||||
// Selector actions
|
// Selector actions
|
||||||
- (void)buttonAction:(id)sender;
|
- (void)buttonAction:(id)sender;
|
||||||
- (void)colorPickerAction:(id)sender;
|
- (void)colorPickerAction:(id)sender API_AVAILABLE(macosx(10.12.2));
|
||||||
- (void)sliderAction:(id)sender;
|
- (void)sliderAction:(id)sender API_AVAILABLE(macosx(10.12.2));
|
||||||
|
|
||||||
// Helpers to create touch bar items
|
// Helpers to create touch bar items
|
||||||
- (NSTouchBarItem*)makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier;
|
- (NSTouchBarItem*)makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier
|
||||||
|
API_AVAILABLE(macosx(10.12.2));
|
||||||
- (NSTouchBarItem*)makeButtonForID:(NSString*)id
|
- (NSTouchBarItem*)makeButtonForID:(NSString*)id
|
||||||
withIdentifier:(NSString*)identifier;
|
withIdentifier:(NSString*)identifier API_AVAILABLE(macosx(10.12.2));
|
||||||
- (NSTouchBarItem*)makeLabelForID:(NSString*)id
|
- (NSTouchBarItem*)makeLabelForID:(NSString*)id
|
||||||
withIdentifier:(NSString*)identifier;
|
withIdentifier:(NSString*)identifier API_AVAILABLE(macosx(10.12.2));
|
||||||
- (NSTouchBarItem*)makeColorPickerForID:(NSString*)id
|
- (NSTouchBarItem*)makeColorPickerForID:(NSString*)id
|
||||||
withIdentifier:(NSString*)identifier;
|
withIdentifier:(NSString*)identifier API_AVAILABLE(macosx(10.12.2));
|
||||||
- (NSTouchBarItem*)makeSliderForID:(NSString*)id
|
- (NSTouchBarItem*)makeSliderForID:(NSString*)id
|
||||||
withIdentifier:(NSString*)identifier;
|
withIdentifier:(NSString*)identifier API_AVAILABLE(macosx(10.12.2));
|
||||||
- (NSTouchBarItem*)makePopoverForID:(NSString*)id
|
- (NSTouchBarItem*)makePopoverForID:(NSString*)id
|
||||||
withIdentifier:(NSString*)identifier;
|
withIdentifier:(NSString*)identifier API_AVAILABLE(macosx(10.12.2));
|
||||||
- (NSTouchBarItem*)makeGroupForID:(NSString*)id
|
- (NSTouchBarItem*)makeGroupForID:(NSString*)id
|
||||||
withIdentifier:(NSString*)identifier;
|
withIdentifier:(NSString*)identifier API_AVAILABLE(macosx(10.12.2));
|
||||||
|
|
||||||
// Helpers to update touch bar items
|
// Helpers to update touch bar items
|
||||||
- (void)updateButton:(NSCustomTouchBarItem*)item
|
- (void)updateButton:(NSCustomTouchBarItem*)item
|
||||||
withSettings:(const mate::PersistentDictionary&)settings;
|
withSettings:(const mate::PersistentDictionary&)settings API_AVAILABLE(macosx(10.12.2));
|
||||||
- (void)updateLabel:(NSCustomTouchBarItem*)item
|
- (void)updateLabel:(NSCustomTouchBarItem*)item
|
||||||
withSettings:(const mate::PersistentDictionary&)settings;
|
withSettings:(const mate::PersistentDictionary&)settings API_AVAILABLE(macosx(10.12.2));
|
||||||
- (void)updateColorPicker:(NSColorPickerTouchBarItem*)item
|
- (void)updateColorPicker:(NSColorPickerTouchBarItem*)item
|
||||||
withSettings:(const mate::PersistentDictionary&)settings;
|
withSettings:(const mate::PersistentDictionary&)settings API_AVAILABLE(macosx(10.12.2));
|
||||||
- (void)updateSlider:(NSSliderTouchBarItem*)item
|
- (void)updateSlider:(NSSliderTouchBarItem*)item
|
||||||
withSettings:(const mate::PersistentDictionary&)settings;
|
withSettings:(const mate::PersistentDictionary&)settings API_AVAILABLE(macosx(10.12.2));
|
||||||
- (void)updatePopover:(NSPopoverTouchBarItem*)item
|
- (void)updatePopover:(NSPopoverTouchBarItem*)item
|
||||||
withSettings:(const mate::PersistentDictionary&)settings;
|
withSettings:(const mate::PersistentDictionary&)settings API_AVAILABLE(macosx(10.12.2));
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -51,32 +51,34 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
||||||
- (NSMutableArray*)identifiersFromSettings:(const std::vector<mate::PersistentDictionary>&)dicts {
|
- (NSMutableArray*)identifiersFromSettings:(const std::vector<mate::PersistentDictionary>&)dicts {
|
||||||
NSMutableArray* identifiers = [NSMutableArray array];
|
NSMutableArray* identifiers = [NSMutableArray array];
|
||||||
|
|
||||||
for (const auto& item : dicts) {
|
if (@available(macOS 10.12.2, *)) {
|
||||||
std::string type;
|
for (const auto& item : dicts) {
|
||||||
std::string item_id;
|
std::string type;
|
||||||
if (item.Get("type", &type) && item.Get("id", &item_id)) {
|
std::string item_id;
|
||||||
NSTouchBarItemIdentifier identifier = nil;
|
if (item.Get("type", &type) && item.Get("id", &item_id)) {
|
||||||
if (type == "spacer") {
|
NSTouchBarItemIdentifier identifier = nil;
|
||||||
std::string size;
|
if (type == "spacer") {
|
||||||
item.Get("size", &size);
|
std::string size;
|
||||||
if (size == "large") {
|
item.Get("size", &size);
|
||||||
identifier = NSTouchBarItemIdentifierFixedSpaceLarge;
|
if (size == "large") {
|
||||||
} else if (size == "flexible") {
|
identifier = NSTouchBarItemIdentifierFixedSpaceLarge;
|
||||||
identifier = NSTouchBarItemIdentifierFlexibleSpace;
|
} else if (size == "flexible") {
|
||||||
|
identifier = NSTouchBarItemIdentifierFlexibleSpace;
|
||||||
|
} else {
|
||||||
|
identifier = NSTouchBarItemIdentifierFixedSpaceSmall;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
identifier = NSTouchBarItemIdentifierFixedSpaceSmall;
|
identifier = [self identifierFromID:item_id type:type];
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
identifier = [self identifierFromID:item_id type:type];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (identifier) {
|
if (identifier) {
|
||||||
settings_[item_id] = item;
|
settings_[item_id] = item;
|
||||||
[identifiers addObject:identifier];
|
[identifiers addObject:identifier];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[identifiers addObject:NSTouchBarItemIdentifierOtherItemsProxy];
|
||||||
}
|
}
|
||||||
[identifiers addObject:NSTouchBarItemIdentifierOtherItemsProxy];
|
|
||||||
|
|
||||||
return identifiers;
|
return identifiers;
|
||||||
}
|
}
|
||||||
|
@ -116,7 +118,8 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
||||||
- (void)refreshTouchBarItem:(NSTouchBar*)touchBar
|
- (void)refreshTouchBarItem:(NSTouchBar*)touchBar
|
||||||
id:(NSTouchBarItemIdentifier)identifier
|
id:(NSTouchBarItemIdentifier)identifier
|
||||||
withType:(const std::string&)item_type
|
withType:(const std::string&)item_type
|
||||||
withSettings:(const mate::PersistentDictionary&)settings {
|
withSettings:(const mate::PersistentDictionary&)settings
|
||||||
|
API_AVAILABLE(macosx(10.12.2)) {
|
||||||
NSTouchBarItem* item = [touchBar itemForIdentifier:identifier];
|
NSTouchBarItem* item = [touchBar itemForIdentifier:identifier];
|
||||||
if (!item) return;
|
if (!item) return;
|
||||||
|
|
||||||
|
@ -245,14 +248,14 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
||||||
details);
|
details);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)scrubber:(NSScrubber*)scrubber didSelectItemAtIndex:(NSInteger)selectedIndex {
|
- (void)scrubber:(NSScrubber*)scrubber didSelectItemAtIndex:(NSInteger)selectedIndex API_AVAILABLE(macosx(10.12.2)) {
|
||||||
base::DictionaryValue details;
|
base::DictionaryValue details;
|
||||||
details.SetInteger("selectedIndex", selectedIndex);
|
details.SetInteger("selectedIndex", selectedIndex);
|
||||||
details.SetString("type", "select");
|
details.SetString("type", "select");
|
||||||
window_->NotifyTouchBarItemInteraction([scrubber.identifier UTF8String], details);
|
window_->NotifyTouchBarItemInteraction([scrubber.identifier UTF8String], details);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)scrubber:(NSScrubber*)scrubber didHighlightItemAtIndex:(NSInteger)highlightedIndex {
|
- (void)scrubber:(NSScrubber*)scrubber didHighlightItemAtIndex:(NSInteger)highlightedIndex API_AVAILABLE(macosx(10.12.2)) {
|
||||||
base::DictionaryValue details;
|
base::DictionaryValue details;
|
||||||
details.SetInteger("highlightedIndex", highlightedIndex);
|
details.SetInteger("highlightedIndex", highlightedIndex);
|
||||||
details.SetString("type", "highlight");
|
details.SetString("type", "highlight");
|
||||||
|
@ -494,7 +497,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateGroup:(NSGroupTouchBarItem*)item
|
- (void)updateGroup:(NSGroupTouchBarItem*)item
|
||||||
withSettings:(const mate::PersistentDictionary&)settings {
|
withSettings:(const mate::PersistentDictionary&)settings API_AVAILABLE(macosx(10.12.2)) {
|
||||||
|
|
||||||
mate::PersistentDictionary child;
|
mate::PersistentDictionary child;
|
||||||
if (!settings.Get("child", &child)) return;
|
if (!settings.Get("child", &child)) return;
|
||||||
|
@ -505,7 +508,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSTouchBarItem*)makeSegmentedControlForID:(NSString*)id
|
- (NSTouchBarItem*)makeSegmentedControlForID:(NSString*)id
|
||||||
withIdentifier:(NSString*)identifier {
|
withIdentifier:(NSString*)identifier API_AVAILABLE(macosx(10.12.2)) {
|
||||||
std::string s_id([id UTF8String]);
|
std::string s_id([id UTF8String]);
|
||||||
if (![self hasItemWithID:s_id]) return nil;
|
if (![self hasItemWithID:s_id]) return nil;
|
||||||
|
|
||||||
|
@ -525,7 +528,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateSegmentedControl:(NSCustomTouchBarItem*)item
|
- (void)updateSegmentedControl:(NSCustomTouchBarItem*)item
|
||||||
withSettings:(const mate::PersistentDictionary&)settings {
|
withSettings:(const mate::PersistentDictionary&)settings API_AVAILABLE(macosx(10.12.2)) {
|
||||||
|
|
||||||
NSSegmentedControl* control = item.view;
|
NSSegmentedControl* control = item.view;
|
||||||
|
|
||||||
|
@ -582,7 +585,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSTouchBarItem*)makeScrubberForID:(NSString*)id
|
- (NSTouchBarItem*)makeScrubberForID:(NSString*)id
|
||||||
withIdentifier:(NSString*)identifier {
|
withIdentifier:(NSString*)identifier API_AVAILABLE(macosx(10.12.2)) {
|
||||||
std::string s_id([id UTF8String]);
|
std::string s_id([id UTF8String]);
|
||||||
if (![self hasItemWithID:s_id]) return nil;
|
if (![self hasItemWithID:s_id]) return nil;
|
||||||
|
|
||||||
|
@ -606,7 +609,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateScrubber:(NSCustomTouchBarItem*)item
|
- (void)updateScrubber:(NSCustomTouchBarItem*)item
|
||||||
withSettings:(const mate::PersistentDictionary&)settings {
|
withSettings:(const mate::PersistentDictionary&)settings API_AVAILABLE(macosx(10.12.2)) {
|
||||||
NSScrubber* scrubber = item.view;
|
NSScrubber* scrubber = item.view;
|
||||||
|
|
||||||
bool showsArrowButtons = false;
|
bool showsArrowButtons = false;
|
||||||
|
@ -649,7 +652,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
||||||
[scrubber reloadData];
|
[scrubber reloadData];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSInteger)numberOfItemsForScrubber:(NSScrubber*)scrubber {
|
- (NSInteger)numberOfItemsForScrubber:(NSScrubber*)scrubber API_AVAILABLE(macosx(10.12.2)) {
|
||||||
std::string s_id([[scrubber identifier] UTF8String]);
|
std::string s_id([[scrubber identifier] UTF8String]);
|
||||||
if (![self hasItemWithID:s_id]) return 0;
|
if (![self hasItemWithID:s_id]) return 0;
|
||||||
|
|
||||||
|
@ -660,7 +663,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSScrubberItemView*)scrubber:(NSScrubber*)scrubber
|
- (NSScrubberItemView*)scrubber:(NSScrubber*)scrubber
|
||||||
viewForItemAtIndex:(NSInteger)index {
|
viewForItemAtIndex:(NSInteger)index API_AVAILABLE(macosx(10.12.2)) {
|
||||||
std::string s_id([[scrubber identifier] UTF8String]);
|
std::string s_id([[scrubber identifier] UTF8String]);
|
||||||
if (![self hasItemWithID:s_id]) return nil;
|
if (![self hasItemWithID:s_id]) return nil;
|
||||||
|
|
||||||
|
@ -694,7 +697,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSSize)scrubber:(NSScrubber *)scrubber layout:(NSScrubberFlowLayout *)layout sizeForItemAtIndex:(NSInteger)itemIndex
|
- (NSSize)scrubber:(NSScrubber *)scrubber layout:(NSScrubberFlowLayout *)layout sizeForItemAtIndex:(NSInteger)itemIndex
|
||||||
{
|
API_AVAILABLE(macosx(10.12.2)) {
|
||||||
NSInteger width = 50;
|
NSInteger width = 50;
|
||||||
NSInteger height = 30;
|
NSInteger height = 30;
|
||||||
NSInteger margin = 15;
|
NSInteger margin = 15;
|
||||||
|
|
|
@ -259,7 +259,7 @@ static const NSTouchBarItemIdentifier NSTouchBarItemIdentifierOtherItemsProxy =
|
||||||
@class NSTouchBarItem;
|
@class NSTouchBarItem;
|
||||||
|
|
||||||
@interface NSWindow (TouchBarSDK)
|
@interface NSWindow (TouchBarSDK)
|
||||||
@property(strong, readonly) NSTouchBar* touchBar;
|
@property(strong, readonly) NSTouchBar* touchBar API_AVAILABLE(macosx(10.12.2));
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif // MAC_OS_X_VERSION_10_12_1
|
#endif // MAC_OS_X_VERSION_10_12_1
|
||||||
|
|
|
@ -29,7 +29,8 @@ class CocoaNotification : public Notification {
|
||||||
void NotificationDisplayed();
|
void NotificationDisplayed();
|
||||||
void NotificationReplied(const std::string& reply);
|
void NotificationReplied(const std::string& reply);
|
||||||
void NotificationActivated();
|
void NotificationActivated();
|
||||||
void NotificationActivated(NSUserNotificationAction* action);
|
void NotificationActivated(NSUserNotificationAction* action)
|
||||||
|
API_AVAILABLE(macosx(10.10));
|
||||||
|
|
||||||
NSUserNotification* notification() const { return notification_; }
|
NSUserNotification* notification() const { return notification_; }
|
||||||
|
|
||||||
|
|
|
@ -69,18 +69,22 @@ void CocoaNotification::Show(const NotificationOptions& options) {
|
||||||
} else {
|
} else {
|
||||||
// All of the rest are appended to the list of additional actions
|
// All of the rest are appended to the list of additional actions
|
||||||
NSString* actionIdentifier = [NSString stringWithFormat:@"%@Action%d", identifier, i];
|
NSString* actionIdentifier = [NSString stringWithFormat:@"%@Action%d", identifier, i];
|
||||||
NSUserNotificationAction* notificationAction =
|
if (@available(macOS 10.10, *)) {
|
||||||
[NSUserNotificationAction actionWithIdentifier:actionIdentifier
|
NSUserNotificationAction* notificationAction =
|
||||||
title:base::SysUTF16ToNSString(action.text)];
|
[NSUserNotificationAction actionWithIdentifier:actionIdentifier
|
||||||
[additionalActions addObject:notificationAction];
|
title:base::SysUTF16ToNSString(action.text)];
|
||||||
additional_action_indices_.insert(std::make_pair(base::SysNSStringToUTF8(actionIdentifier), i));
|
[additionalActions addObject:notificationAction];
|
||||||
|
additional_action_indices_.insert(std::make_pair(base::SysNSStringToUTF8(actionIdentifier), i));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
if ([additionalActions count] > 0 &&
|
if ([additionalActions count] > 0 &&
|
||||||
[notification_ respondsToSelector:@selector(setAdditionalActions:)]) {
|
[notification_ respondsToSelector:@selector(setAdditionalActions:)]) {
|
||||||
[notification_ setAdditionalActions:additionalActions]; // Requires macOS 10.10
|
if (@available(macOS 10.10, *)) {
|
||||||
|
[notification_ setAdditionalActions:additionalActions];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.has_reply) {
|
if (options.has_reply) {
|
||||||
|
|
|
@ -41,8 +41,12 @@
|
||||||
notification->NotificationActivated();
|
notification->NotificationActivated();
|
||||||
} else if (notif.activationType == NSUserNotificationActivationTypeReplied) {
|
} else if (notif.activationType == NSUserNotificationActivationTypeReplied) {
|
||||||
notification->NotificationReplied([notif.response.string UTF8String]);
|
notification->NotificationReplied([notif.response.string UTF8String]);
|
||||||
} else if (notif.activationType == NSUserNotificationActivationTypeAdditionalActionClicked) {
|
} else {
|
||||||
notification->NotificationActivated([notif additionalActivationAction]);
|
if (@available(macOS 10.10, *)) {
|
||||||
|
if (notif.activationType == NSUserNotificationActivationTypeAdditionalActionClicked) {
|
||||||
|
notification->NotificationActivated([notif additionalActivationAction]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue