9645f7f6d8
* chore: bump chromium in DEPS to 117.0.5866.0 * chore: bump chromium in DEPS to 117.0.5868.0 * chore: update mas_no_private_api.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4634925 Minor manual patch syncing due to upstream code shear * chore: update mas_disable_remote_layer.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4647191 Manually sync patch to minor upstream code shear * chore: update mas_disable_remote_accessibility.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4641746 No manual changes; patch applied with fuzz * chore: update mas_avoid_usage_of_private_macos_apis.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4634925 Manually sync base/process/launch_mac.cc to minor upstream shear Manually sync base/mac/foundation_util.mm to upstream changes: _CFIsObjC use has been removed upstream, so we no longer need to remove it 🎉 * chore: update printing.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4658496 Manually sync patch to minor upstream code shear * chore: update disable_color_correct_rendering.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4625254 Manually sync patch to minor upstream code shear * chore: update feat_expose_raw_response_headers_from_urlloader.patch Xref: services/network/public/cpp/resource_request.cc No manual changes; patch applied with fuzz * chore: update add_electron_deps_to_license_credits_file.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4634961 No manual changes; patch applied with fuzz * chore: update build_only_use_the_mas_build_config_in_the_required_components.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4648411 No manual changes; patch applied with fuzz * chore: update patches * fixup! chore: update add_electron_deps_to_license_credits_file.patch chore: license files must be an array * chore: bump chromium in DEPS to 117.0.5870.0 * chore: update patches * chore: run ./script/gen-libc++-filenames.js * chore: update json_parse_errors_made_user-friendly.patch Xref: https://chromium-review.googlesource.com/c/v8/v8/+/4652014 v8 error message changed upstream; update Node test to match it * chore: bump chromium in DEPS to 117.0.5872.0 * chore: update patches * chore: explicitly cast x11::Window to unsigned int Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4661049 This is an `enum class Window : uint32_t` defined in ui/gfx/x/xproto.h. Previous versions of clang let this implicit cast happen, but it generates a warning in the new clang roll. * chore: remove unused #include Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4650453 header was removed upstream, so FTBFS unless removed here * chore: add include guard patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4628373 h/t @jkleinsc * chore: bump chromium in DEPS to 117.0.5874.0 * chore: update render_widget_host_view_mac.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4661244 Manually sync patch to minor upstream code * chore: update mas_disable_remote_accessibility.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4653209 Manually sync patch to upstream code shear * chore: update build_only_use_the_mas_build_config_in_the_required_components.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4653209 Manually sync patch to minor upstream code shear * chore: update GetInitiatorProcessId() Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4641991 trivial upstream naming change: s/ProcessID/ProcessId/ * chore: sync to upstream SetInputRegion() changes Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4665245 Simple upstream chang: SetInputRegion() used to take a gfx::Rect* where `nullptr` meant "no opaque region". The function signature changed to absl::optional<gfx::Rect> w/the same meaning. * chore: sync to upstream SetOpaqueRegion() changes Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4656738 Simple upstream chang: SetOpaqueRegion() used to take a vector<Rect>* where `nullptr` meant "no opaque region". The function signature changed to absl::optional<std::vector<gfx::Rect>> w/the same meaning. * chore: update patches * chore: bump chromium in DEPS to 117.0.5876.0 * chore: update mas_disable_remote_accessibility.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4658375 We no longer need to patch out a field that's now removed upstream. RenderWidgetHostNSViewBridgeOwner.remote_accessibility_element_ * chore: update feat_filter_out_non-shareable_windows_in_the_current_application_in.patch Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4658680 Manually sync patch to upstream code shear (ARC adoption). * chore: update patches * fix: -Werror,-Wshadow error in Node.js * chore: bump chromium in DEPS to 117.0.5878.0 * chore: bump chromium in DEPS to 117.0.5880.0 * chore: bump chromium in DEPS to 117.0.5880.4 * chore: update patches * 4658680: Convert /content/browser to use ARC https://chromium-review.googlesource.com/c/chromium/src/+/4658680 * 4669995: Remove CFToNSCast and NSToCFCast https://chromium-review.googlesource.com/c/chromium/src/+/4669995 * WIP: 4658680: Convert /content/browser to use ARC https://chromium-review.googlesource.com/c/chromium/src/+/4658680 * chore: update printing patch after rebase * chore: bump chromium in DEPS to 117.0.5882.0 * Revert "WIP: 4658680: Convert /content/browser to use ARC" This reverts commit c8559ea448ad93123865a6fa8af6fe2767e43396. * Revert "4669995: Remove CFToNSCast and NSToCFCast" This reverts commit 38e145f33d844e077b09e1fb119fae9d5d7bbc3e. * chore: bump chromium in DEPS to 117.0.5874.0 * 4661244: Convert /content/browser/renderer_host to use ARC https://chromium-review.googlesource.com/c/chromium/src/+/4661244 * 4653209: Convert /ui/views:views to use ARC https://chromium-review.googlesource.com/c/chromium/src/+/4653209 * chore: fixup mas_disable_remote_accessibility.patch * chore: fixup render_widget_host_view_mac.patch * chore: update to newer clang * chore: bump chromium in DEPS to 117.0.5884.1 (cherry picked from commit a3879acfde8f3d962d58d6ad0632164ccb88ee63) * 4669995: Remove CFToNSCast and NSToCFCast https://chromium-review.googlesource.com/c/chromium/src/+/4669995 (cherry picked from commit 38e145f33d844e077b09e1fb119fae9d5d7bbc3e) (cherry picked from commit b1224ab7e00aedbd0e5dc78ebb3c6162573b28c4) * 4658680: Convert /content/browser to use ARC https://chromium-review.googlesource.com/c/chromium/src/+/4658680 (cherry picked from commit 77039a323b9ebb3e8edb3a92a3b94a8d7d026a32) * Rename and cleanup ExtensionsBrowserClient functions | https://chromium-review.googlesource.com/c/chromium/src/+/4665670 (cherry picked from commit 677a2e646a8d82da60dc252b08b320c3ddff6be6) * chore: bump chromium in DEPS to 117.0.5886.0 * chore: update patches * Revert "chore: update patches" This reverts commit db9294f9446492d4a3d63f5f3ecc551aeeeb2e26. * Revert "chore: bump chromium in DEPS to 117.0.5886.0" This reverts commit a7de0276e6e0eeecfdbb17f9bbc27c01b4bbfc24. * build: use built toolchains instead of locally installed VSCode * fixup: build: use built toolchains instead of locally installed VSCode * chore: add missing mojo dep --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr <charles@charleskerr.com> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
394 lines
13 KiB
Text
394 lines
13 KiB
Text
// Copyright (c) 2018 GitHub, Inc.
|
|
// Use of this source code is governed by the MIT license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "shell/browser/ui/cocoa/electron_ns_window_delegate.h"
|
|
|
|
#include <algorithm>
|
|
|
|
#include "base/mac/mac_util.h"
|
|
#include "components/remote_cocoa/app_shim/native_widget_ns_window_bridge.h"
|
|
#include "shell/browser/browser.h"
|
|
#include "shell/browser/native_window_mac.h"
|
|
#include "shell/browser/ui/cocoa/electron_preview_item.h"
|
|
#include "shell/browser/ui/cocoa/electron_touch_bar.h"
|
|
#include "ui/gfx/geometry/resize_utils.h"
|
|
#include "ui/gfx/mac/coordinate_conversion.h"
|
|
#include "ui/views/cocoa/native_widget_mac_ns_window_host.h"
|
|
#include "ui/views/widget/native_widget_mac.h"
|
|
|
|
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
|
#error "This file requires ARC support."
|
|
#endif
|
|
|
|
using TitleBarStyle = electron::NativeWindowMac::TitleBarStyle;
|
|
using FullScreenTransitionState =
|
|
electron::NativeWindow::FullScreenTransitionState;
|
|
|
|
@implementation ElectronNSWindowDelegate
|
|
|
|
- (id)initWithShell:(electron::NativeWindowMac*)shell {
|
|
// The views library assumes the window delegate must be an instance of
|
|
// ViewsNSWindowDelegate, since we don't have a way to override the creation
|
|
// of NSWindowDelegate, we have to dynamically replace the window delegate
|
|
// on the fly.
|
|
// TODO(zcbenz): Add interface in NativeWidgetMac to allow overriding creating
|
|
// window delegate.
|
|
auto* bridge_host = views::NativeWidgetMacNSWindowHost::GetFromNativeWindow(
|
|
shell->GetNativeWindow());
|
|
auto* bridged_view = bridge_host->GetInProcessNSWindowBridge();
|
|
if ((self = [super initWithBridgedNativeWidget:bridged_view])) {
|
|
shell_ = shell;
|
|
is_zooming_ = false;
|
|
level_ = [shell_->GetNativeWindow().GetNativeNSWindow() level];
|
|
}
|
|
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
|
|
NSWindow* window = notification.object;
|
|
|
|
// check occlusion binary flag
|
|
if (window.occlusionState & NSWindowOcclusionStateVisible) {
|
|
// The app is visible
|
|
shell_->NotifyWindowShow();
|
|
} else {
|
|
// The app is not visible
|
|
shell_->NotifyWindowHide();
|
|
}
|
|
}
|
|
|
|
// Called when the user clicks the zoom button or selects it from the Window
|
|
// menu to determine the "standard size" of the window.
|
|
- (NSRect)windowWillUseStandardFrame:(NSWindow*)window
|
|
defaultFrame:(NSRect)frame {
|
|
if (!shell_->zoom_to_page_width()) {
|
|
if (shell_->GetAspectRatio() > 0.0)
|
|
shell_->set_default_frame_for_zoom(frame);
|
|
return frame;
|
|
}
|
|
|
|
// If the shift key is down, maximize.
|
|
if ([[NSApp currentEvent] modifierFlags] & NSEventModifierFlagShift)
|
|
return frame;
|
|
|
|
// Get preferred width from observers. Usually the page width.
|
|
int preferred_width = 0;
|
|
shell_->NotifyWindowRequestPreferredWidth(&preferred_width);
|
|
|
|
// Never shrink from the current size on zoom.
|
|
NSRect window_frame = [window frame];
|
|
CGFloat zoomed_width =
|
|
std::max(static_cast<CGFloat>(preferred_width), NSWidth(window_frame));
|
|
|
|
// |frame| determines our maximum extents. We need to set the origin of the
|
|
// frame -- and only move it left if necessary.
|
|
if (window_frame.origin.x + zoomed_width > NSMaxX(frame))
|
|
frame.origin.x = NSMaxX(frame) - zoomed_width;
|
|
else
|
|
frame.origin.x = window_frame.origin.x;
|
|
|
|
// Set the width. Don't touch y or height.
|
|
frame.size.width = zoomed_width;
|
|
|
|
if (shell_->GetAspectRatio() > 0.0)
|
|
shell_->set_default_frame_for_zoom(frame);
|
|
|
|
return frame;
|
|
}
|
|
|
|
- (void)windowDidBecomeMain:(NSNotification*)notification {
|
|
shell_->NotifyWindowFocus();
|
|
shell_->RedrawTrafficLights();
|
|
}
|
|
|
|
- (void)windowDidResignMain:(NSNotification*)notification {
|
|
shell_->NotifyWindowBlur();
|
|
shell_->RedrawTrafficLights();
|
|
}
|
|
|
|
- (void)windowDidBecomeKey:(NSNotification*)notification {
|
|
shell_->NotifyWindowIsKeyChanged(true);
|
|
shell_->RedrawTrafficLights();
|
|
}
|
|
|
|
- (void)windowDidResignKey:(NSNotification*)notification {
|
|
// If our app is still active and we're still the key window, ignore this
|
|
// message, since it just means that a menu extra (on the "system status bar")
|
|
// was activated; we'll get another |-windowDidResignKey| if we ever really
|
|
// lose key window status.
|
|
if ([NSApp isActive] && ([NSApp keyWindow] == [notification object]))
|
|
return;
|
|
|
|
shell_->NotifyWindowIsKeyChanged(false);
|
|
shell_->RedrawTrafficLights();
|
|
}
|
|
|
|
- (NSSize)windowWillResize:(NSWindow*)sender toSize:(NSSize)frameSize {
|
|
NSSize newSize = frameSize;
|
|
double aspectRatio = shell_->GetAspectRatio();
|
|
NSWindow* window = shell_->GetNativeWindow().GetNativeNSWindow();
|
|
|
|
if (aspectRatio > 0.0) {
|
|
gfx::Size windowSize = shell_->GetSize();
|
|
gfx::Size contentSize = shell_->GetContentSize();
|
|
gfx::Size extraSize = shell_->GetAspectRatioExtraSize();
|
|
|
|
double titleBarHeight = windowSize.height() - contentSize.height();
|
|
double extraWidthPlusFrame =
|
|
windowSize.width() - contentSize.width() + extraSize.width();
|
|
double extraHeightPlusFrame = titleBarHeight + extraSize.height();
|
|
|
|
newSize.width =
|
|
roundf((frameSize.height - extraHeightPlusFrame) * aspectRatio +
|
|
extraWidthPlusFrame);
|
|
newSize.height =
|
|
roundf((newSize.width - extraWidthPlusFrame) / aspectRatio +
|
|
extraHeightPlusFrame);
|
|
|
|
// Clamp to minimum width/height while ensuring aspect ratio remains.
|
|
NSSize minSize = [window minSize];
|
|
NSSize zeroSize =
|
|
shell_->has_frame() ? NSMakeSize(0, titleBarHeight) : NSZeroSize;
|
|
if (!NSEqualSizes(minSize, zeroSize)) {
|
|
double minWidthForAspectRatio =
|
|
(minSize.height - titleBarHeight) * aspectRatio;
|
|
bool atMinHeight =
|
|
minSize.height > zeroSize.height && newSize.height <= minSize.height;
|
|
newSize.width = atMinHeight ? minWidthForAspectRatio
|
|
: std::max(newSize.width, minSize.width);
|
|
|
|
double minHeightForAspectRatio = minSize.width / aspectRatio;
|
|
bool atMinWidth =
|
|
minSize.width > zeroSize.width && newSize.width <= minSize.width;
|
|
newSize.height = atMinWidth ? minHeightForAspectRatio
|
|
: std::max(newSize.height, minSize.height);
|
|
}
|
|
|
|
// Clamp to maximum width/height while ensuring aspect ratio remains.
|
|
NSSize maxSize = [window maxSize];
|
|
if (!NSEqualSizes(maxSize, NSMakeSize(FLT_MAX, FLT_MAX))) {
|
|
double maxWidthForAspectRatio = maxSize.height * aspectRatio;
|
|
bool atMaxHeight =
|
|
maxSize.height < FLT_MAX && newSize.height >= maxSize.height;
|
|
newSize.width = atMaxHeight ? maxWidthForAspectRatio
|
|
: std::min(newSize.width, maxSize.width);
|
|
|
|
double maxHeightForAspectRatio = maxSize.width / aspectRatio;
|
|
bool atMaxWidth =
|
|
maxSize.width < FLT_MAX && newSize.width >= maxSize.width;
|
|
newSize.height = atMaxWidth ? maxHeightForAspectRatio
|
|
: std::min(newSize.height, maxSize.height);
|
|
}
|
|
}
|
|
|
|
if (!resizingHorizontally_) {
|
|
const auto widthDelta = frameSize.width - [window frame].size.width;
|
|
const auto heightDelta = frameSize.height - [window frame].size.height;
|
|
resizingHorizontally_ = std::abs(widthDelta) > std::abs(heightDelta);
|
|
}
|
|
|
|
{
|
|
bool prevent_default = false;
|
|
NSRect new_bounds = NSMakeRect(sender.frame.origin.x, sender.frame.origin.y,
|
|
newSize.width, newSize.height);
|
|
shell_->NotifyWindowWillResize(gfx::ScreenRectFromNSRect(new_bounds),
|
|
*resizingHorizontally_
|
|
? gfx::ResizeEdge::kRight
|
|
: gfx::ResizeEdge::kBottom,
|
|
&prevent_default);
|
|
if (prevent_default) {
|
|
return sender.frame.size;
|
|
}
|
|
}
|
|
|
|
return newSize;
|
|
}
|
|
|
|
- (void)windowDidResize:(NSNotification*)notification {
|
|
[super windowDidResize:notification];
|
|
shell_->NotifyWindowResize();
|
|
shell_->RedrawTrafficLights();
|
|
}
|
|
|
|
- (void)windowWillMove:(NSNotification*)notification {
|
|
NSWindow* window = [notification object];
|
|
NSSize size = [[window contentView] frame].size;
|
|
NSRect new_bounds = NSMakeRect(window.frame.origin.x, window.frame.origin.y,
|
|
size.width, size.height);
|
|
bool prevent_default = false;
|
|
|
|
// prevent_default has no effect
|
|
shell_->NotifyWindowWillMove(gfx::ScreenRectFromNSRect(new_bounds),
|
|
&prevent_default);
|
|
}
|
|
|
|
- (void)windowDidMove:(NSNotification*)notification {
|
|
[super windowDidMove:notification];
|
|
// TODO(zcbenz): Remove the alias after figuring out a proper
|
|
// way to dispatch move.
|
|
shell_->NotifyWindowMove();
|
|
shell_->NotifyWindowMoved();
|
|
}
|
|
|
|
- (void)windowWillMiniaturize:(NSNotification*)notification {
|
|
NSWindow* window = shell_->GetNativeWindow().GetNativeNSWindow();
|
|
// store the current status window level to be restored in
|
|
// windowDidDeminiaturize
|
|
level_ = [window level];
|
|
shell_->SetWindowLevel(NSNormalWindowLevel);
|
|
shell_->UpdateWindowOriginalFrame();
|
|
shell_->DetachChildren();
|
|
}
|
|
|
|
- (void)windowDidMiniaturize:(NSNotification*)notification {
|
|
[super windowDidMiniaturize:notification];
|
|
shell_->NotifyWindowMinimize();
|
|
}
|
|
|
|
- (void)windowDidDeminiaturize:(NSNotification*)notification {
|
|
[super windowDidDeminiaturize:notification];
|
|
shell_->AttachChildren();
|
|
shell_->SetWindowLevel(level_);
|
|
shell_->NotifyWindowRestore();
|
|
}
|
|
|
|
- (BOOL)windowShouldZoom:(NSWindow*)window toFrame:(NSRect)newFrame {
|
|
is_zooming_ = true;
|
|
return YES;
|
|
}
|
|
|
|
- (void)windowDidEndLiveResize:(NSNotification*)notification {
|
|
resizingHorizontally_.reset();
|
|
shell_->NotifyWindowResized();
|
|
if (is_zooming_) {
|
|
if (shell_->IsMaximized())
|
|
shell_->NotifyWindowMaximize();
|
|
else
|
|
shell_->NotifyWindowUnmaximize();
|
|
is_zooming_ = false;
|
|
}
|
|
}
|
|
|
|
- (void)windowWillEnterFullScreen:(NSNotification*)notification {
|
|
// Store resizable mask so it can be restored after exiting fullscreen.
|
|
is_resizable_ = shell_->HasStyleMask(NSWindowStyleMaskResizable);
|
|
|
|
shell_->set_fullscreen_transition_state(FullScreenTransitionState::kEntering);
|
|
|
|
shell_->NotifyWindowWillEnterFullScreen();
|
|
|
|
// Set resizable to true before entering fullscreen.
|
|
shell_->SetResizable(true);
|
|
}
|
|
|
|
- (void)windowDidEnterFullScreen:(NSNotification*)notification {
|
|
shell_->set_fullscreen_transition_state(FullScreenTransitionState::kNone);
|
|
|
|
shell_->NotifyWindowEnterFullScreen();
|
|
|
|
if (shell_->HandleDeferredClose())
|
|
return;
|
|
|
|
shell_->HandlePendingFullscreenTransitions();
|
|
}
|
|
|
|
- (void)windowWillExitFullScreen:(NSNotification*)notification {
|
|
shell_->set_fullscreen_transition_state(FullScreenTransitionState::kExiting);
|
|
|
|
shell_->NotifyWindowWillLeaveFullScreen();
|
|
}
|
|
|
|
- (void)windowDidExitFullScreen:(NSNotification*)notification {
|
|
shell_->set_fullscreen_transition_state(FullScreenTransitionState::kNone);
|
|
|
|
shell_->SetResizable(is_resizable_);
|
|
shell_->NotifyWindowLeaveFullScreen();
|
|
|
|
if (shell_->HandleDeferredClose())
|
|
return;
|
|
|
|
shell_->HandlePendingFullscreenTransitions();
|
|
}
|
|
|
|
- (void)windowWillClose:(NSNotification*)notification {
|
|
shell_->Cleanup();
|
|
shell_->NotifyWindowClosed();
|
|
|
|
// Something called -[NSWindow close] on a sheet rather than calling
|
|
// -[NSWindow endSheet:] on its parent. If the modal session is not ended
|
|
// then the parent will never be able to show another sheet. But calling
|
|
// -endSheet: here will block the thread with an animation, so post a task.
|
|
if (shell_->is_modal() && shell_->parent() && shell_->IsVisible()) {
|
|
NSWindow* window = shell_->GetNativeWindow().GetNativeNSWindow();
|
|
NSWindow* sheetParent = [window sheetParent];
|
|
base::SingleThreadTaskRunner::GetCurrentDefault()->PostTask(
|
|
FROM_HERE, base::BindOnce(^{
|
|
[sheetParent endSheet:window];
|
|
}));
|
|
}
|
|
|
|
// Clears the delegate when window is going to be closed, since EL Capitan it
|
|
// is possible that the methods of delegate would get called after the window
|
|
// has been closed.
|
|
auto* bridge_host = views::NativeWidgetMacNSWindowHost::GetFromNativeWindow(
|
|
shell_->GetNativeWindow());
|
|
auto* bridged_view = bridge_host->GetInProcessNSWindowBridge();
|
|
bridged_view->OnWindowWillClose();
|
|
}
|
|
|
|
- (BOOL)windowShouldClose:(id)window {
|
|
shell_->NotifyWindowCloseButtonClicked();
|
|
return NO;
|
|
}
|
|
|
|
- (NSRect)window:(NSWindow*)window
|
|
willPositionSheet:(NSWindow*)sheet
|
|
usingRect:(NSRect)rect {
|
|
NSView* view = window.contentView;
|
|
|
|
rect.origin.x = shell_->GetSheetOffsetX();
|
|
rect.origin.y = view.frame.size.height - shell_->GetSheetOffsetY();
|
|
return rect;
|
|
}
|
|
|
|
- (void)windowWillBeginSheet:(NSNotification*)notification {
|
|
shell_->NotifyWindowSheetBegin();
|
|
}
|
|
|
|
- (void)windowDidEndSheet:(NSNotification*)notification {
|
|
shell_->NotifyWindowSheetEnd();
|
|
}
|
|
|
|
- (IBAction)newWindowForTab:(id)sender {
|
|
shell_->NotifyNewWindowForTab();
|
|
electron::Browser::Get()->NewWindowForTab();
|
|
}
|
|
|
|
#pragma mark - NSTouchBarDelegate
|
|
|
|
- (NSTouchBarItem*)touchBar:(NSTouchBar*)touchBar
|
|
makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier {
|
|
if (touchBar && shell_->touch_bar())
|
|
return [shell_->touch_bar() makeItemForIdentifier:identifier];
|
|
else
|
|
return nil;
|
|
}
|
|
|
|
#pragma mark - QLPreviewPanelDataSource
|
|
|
|
- (NSInteger)numberOfPreviewItemsInPreviewPanel:(QLPreviewPanel*)panel {
|
|
return 1;
|
|
}
|
|
|
|
- (id<QLPreviewItem>)previewPanel:(QLPreviewPanel*)panel
|
|
previewItemAtIndex:(NSInteger)index {
|
|
return shell_->preview_item();
|
|
}
|
|
|
|
@end
|