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 #endif
@interface AtomNSWindow : EventDispatchingWindow<QLPreviewPanelDataSource, QLPreviewPanelDelegate, NSTouchBarDelegate> { @interface AtomNSWindow : EventDispatchingWindow<QLPreviewPanelDataSource, QLPreviewPanelDelegate> {
@private @private
atom::NativeWindowMac* shell_; atom::NativeWindowMac* shell_;
bool enable_larger_than_screen_; bool enable_larger_than_screen_;
@ -252,14 +252,6 @@ enum {
return nil; 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. // NSWindow overrides.
- (void)swipeWithEvent:(NSEvent *)event { - (void)swipeWithEvent:(NSEvent *)event {
@ -1515,9 +1507,10 @@ void NativeWindowMac::SetTouchBar(
if (![window_ respondsToSelector:@selector(touchBar)]) if (![window_ respondsToSelector:@selector(touchBar)])
return; return;
atom_touch_bar_.reset([[AtomTouchBar alloc] initWithDelegate:window_.get() atom_touch_bar_.reset([[AtomTouchBar alloc]
window:this initWithDelegate:window_delegate_.get()
settings:items]); window:this
settings:items]);
[window_ setTouchBar:nil]; [window_ setTouchBar:nil];
} }

View file

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

View file

@ -6,6 +6,7 @@
#include "atom/browser/browser.h" #include "atom/browser/browser.h"
#include "atom/browser/native_window_mac.h" #include "atom/browser/native_window_mac.h"
#include "atom/browser/ui/cocoa/atom_touch_bar.h"
#include "base/mac/mac_util.h" #include "base/mac/mac_util.h"
@implementation AtomNSWindowDelegate @implementation AtomNSWindowDelegate
@ -19,6 +20,8 @@
return self; return self;
} }
#pragma mark - NSWindowDelegate
- (void)windowDidChangeOcclusionState:(NSNotification *)notification { - (void)windowDidChangeOcclusionState:(NSNotification *)notification {
// notification.object is the window that changed its state. // 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 // 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(); 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 @end