Move NSTouchBarDelegate to AtomNSWindowDelegate

This commit is contained in:
Cheng Zhao 2018-04-19 16:18:50 +09:00
parent 8e9667d86c
commit f6a7e5ea23
3 changed files with 20 additions and 13 deletions

View file

@ -209,7 +209,7 @@ enum {
#endif
@interface AtomNSWindow : EventDispatchingWindow<QLPreviewPanelDataSource, QLPreviewPanelDelegate, NSTouchBarDelegate> {
@interface AtomNSWindow : EventDispatchingWindow<QLPreviewPanelDataSource, QLPreviewPanelDelegate> {
@private
atom::NativeWindowMac* shell_;
bool enable_larger_than_screen_;
@ -252,14 +252,6 @@ enum {
return nil;
}
- (NSTouchBarItem*)touchBar:(NSTouchBar*)touchBar
makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier API_AVAILABLE(macosx(10.12.2)) {
if (touchBar && shell_->atom_touch_bar())
return [shell_->atom_touch_bar() makeItemForIdentifier:identifier];
else
return nil;
}
// NSWindow overrides.
- (void)swipeWithEvent:(NSEvent *)event {
@ -1515,7 +1507,8 @@ void NativeWindowMac::SetTouchBar(
if (![window_ respondsToSelector:@selector(touchBar)])
return;
atom_touch_bar_.reset([[AtomTouchBar alloc] initWithDelegate:window_.get()
atom_touch_bar_.reset([[AtomTouchBar alloc]
initWithDelegate:window_delegate_.get()
window:this
settings:items]);
[window_ setTouchBar:nil];

View file

@ -11,7 +11,8 @@ namespace atom {
class NativeWindowMac;
}
@interface AtomNSWindowDelegate : NSObject<NSWindowDelegate> {
@interface AtomNSWindowDelegate : NSObject<NSWindowDelegate,
NSTouchBarDelegate> {
@private
atom::NativeWindowMac* shell_;
bool is_zooming_;

View file

@ -6,6 +6,7 @@
#include "atom/browser/browser.h"
#include "atom/browser/native_window_mac.h"
#include "atom/browser/ui/cocoa/atom_touch_bar.h"
#include "base/mac/mac_util.h"
@implementation AtomNSWindowDelegate
@ -19,6 +20,8 @@
return self;
}
#pragma mark - NSWindowDelegate
- (void)windowDidChangeOcclusionState:(NSNotification *)notification {
// notification.object is the window that changed its state.
// It's safe to use self.window instead if you don't assign one delegate to many windows
@ -246,4 +249,14 @@
atom::Browser::Get()->NewWindowForTab();
}
#pragma mark - NSTouchBarDelegate
- (NSTouchBarItem*)touchBar:(NSTouchBar*)touchBar
makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier API_AVAILABLE(macosx(10.12.2)) {
if (touchBar && shell_->atom_touch_bar())
return [shell_->atom_touch_bar() makeItemForIdentifier:identifier];
else
return nil;
}
@end