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>
297 lines
11 KiB
Objective-C
297 lines
11 KiB
Objective-C
// Copyright (c) 2013 GitHub, Inc.
|
|
// Use of this source code is governed by the MIT license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_NATIVE_WINDOW_MAC_H_
|
|
#define ELECTRON_SHELL_BROWSER_NATIVE_WINDOW_MAC_H_
|
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "base/mac/scoped_nsobject.h"
|
|
#include "electron/shell/common/api/api.mojom.h"
|
|
#include "shell/browser/native_window.h"
|
|
#include "ui/display/display_observer.h"
|
|
#include "ui/native_theme/native_theme_observer.h"
|
|
#include "ui/views/controls/native/native_view_host.h"
|
|
|
|
@class ElectronNSWindow;
|
|
@class ElectronNSWindowDelegate;
|
|
@class ElectronPreviewItem;
|
|
@class ElectronTouchBar;
|
|
@class WindowButtonsProxy;
|
|
|
|
namespace electron {
|
|
|
|
class RootViewMac;
|
|
|
|
class NativeWindowMac : public NativeWindow,
|
|
public ui::NativeThemeObserver,
|
|
public display::DisplayObserver {
|
|
public:
|
|
NativeWindowMac(const gin_helper::Dictionary& options, NativeWindow* parent);
|
|
~NativeWindowMac() override;
|
|
|
|
// NativeWindow:
|
|
void SetContentView(views::View* view) override;
|
|
void Close() override;
|
|
void CloseImmediately() override;
|
|
void Focus(bool focus) override;
|
|
bool IsFocused() override;
|
|
void Show() override;
|
|
void ShowInactive() override;
|
|
void Hide() override;
|
|
bool IsVisible() override;
|
|
bool IsEnabled() override;
|
|
void SetEnabled(bool enable) override;
|
|
void Maximize() override;
|
|
void Unmaximize() override;
|
|
bool IsMaximized() override;
|
|
void Minimize() override;
|
|
void Restore() override;
|
|
bool IsMinimized() override;
|
|
void SetFullScreen(bool fullscreen) override;
|
|
bool IsFullscreen() const override;
|
|
void SetBounds(const gfx::Rect& bounds, bool animate = false) override;
|
|
gfx::Rect GetBounds() override;
|
|
bool IsNormal() override;
|
|
gfx::Rect GetNormalBounds() override;
|
|
void SetContentSizeConstraints(
|
|
const extensions::SizeConstraints& size_constraints) override;
|
|
void SetResizable(bool resizable) override;
|
|
bool MoveAbove(const std::string& sourceId) override;
|
|
void MoveTop() override;
|
|
bool IsResizable() override;
|
|
void SetMovable(bool movable) override;
|
|
bool IsMovable() override;
|
|
void SetMinimizable(bool minimizable) override;
|
|
bool IsMinimizable() override;
|
|
void SetMaximizable(bool maximizable) override;
|
|
bool IsMaximizable() override;
|
|
void SetFullScreenable(bool fullscreenable) override;
|
|
bool IsFullScreenable() override;
|
|
void SetClosable(bool closable) override;
|
|
bool IsClosable() override;
|
|
void SetAlwaysOnTop(ui::ZOrderLevel z_order,
|
|
const std::string& level,
|
|
int relative_level) override;
|
|
std::string GetAlwaysOnTopLevel() override;
|
|
ui::ZOrderLevel GetZOrderLevel() override;
|
|
void Center() override;
|
|
void Invalidate() override;
|
|
void SetTitle(const std::string& title) override;
|
|
std::string GetTitle() override;
|
|
void FlashFrame(bool flash) override;
|
|
void SetSkipTaskbar(bool skip) override;
|
|
void SetExcludedFromShownWindowsMenu(bool excluded) override;
|
|
bool IsExcludedFromShownWindowsMenu() override;
|
|
void SetSimpleFullScreen(bool simple_fullscreen) override;
|
|
bool IsSimpleFullScreen() override;
|
|
void SetKiosk(bool kiosk) override;
|
|
bool IsKiosk() override;
|
|
void SetBackgroundColor(SkColor color) override;
|
|
SkColor GetBackgroundColor() override;
|
|
void InvalidateShadow() override;
|
|
void SetHasShadow(bool has_shadow) override;
|
|
bool HasShadow() override;
|
|
void SetOpacity(const double opacity) override;
|
|
double GetOpacity() override;
|
|
void SetRepresentedFilename(const std::string& filename) override;
|
|
std::string GetRepresentedFilename() override;
|
|
void SetDocumentEdited(bool edited) override;
|
|
bool IsDocumentEdited() override;
|
|
void SetIgnoreMouseEvents(bool ignore, bool forward) override;
|
|
bool IsHiddenInMissionControl() override;
|
|
void SetHiddenInMissionControl(bool hidden) override;
|
|
void SetContentProtection(bool enable) override;
|
|
void SetFocusable(bool focusable) override;
|
|
bool IsFocusable() override;
|
|
void AddBrowserView(NativeBrowserView* browser_view) override;
|
|
void RemoveBrowserView(NativeBrowserView* browser_view) override;
|
|
void SetTopBrowserView(NativeBrowserView* browser_view) override;
|
|
void SetParentWindow(NativeWindow* parent) override;
|
|
content::DesktopMediaID GetDesktopMediaID() const override;
|
|
gfx::NativeView GetNativeView() const override;
|
|
gfx::NativeWindow GetNativeWindow() const override;
|
|
gfx::AcceleratedWidget GetAcceleratedWidget() const override;
|
|
NativeWindowHandle GetNativeWindowHandle() const override;
|
|
void SetProgressBar(double progress, const ProgressState state) override;
|
|
void SetOverlayIcon(const gfx::Image& overlay,
|
|
const std::string& description) override;
|
|
void SetVisibleOnAllWorkspaces(bool visible,
|
|
bool visibleOnFullScreen,
|
|
bool skipTransformProcessType) override;
|
|
bool IsVisibleOnAllWorkspaces() override;
|
|
void SetAutoHideCursor(bool auto_hide) override;
|
|
void SetVibrancy(const std::string& type) override;
|
|
void SetWindowButtonVisibility(bool visible) override;
|
|
bool GetWindowButtonVisibility() const override;
|
|
void SetWindowButtonPosition(absl::optional<gfx::Point> position) override;
|
|
absl::optional<gfx::Point> GetWindowButtonPosition() const override;
|
|
void RedrawTrafficLights() override;
|
|
void UpdateFrame() override;
|
|
void SetTouchBar(
|
|
std::vector<gin_helper::PersistentDictionary> items) override;
|
|
void RefreshTouchBarItem(const std::string& item_id) override;
|
|
void SetEscapeTouchBarItem(gin_helper::PersistentDictionary item) override;
|
|
void SelectPreviousTab() override;
|
|
void SelectNextTab() override;
|
|
void ShowAllTabs() override;
|
|
void MergeAllWindows() override;
|
|
void MoveTabToNewWindow() override;
|
|
void ToggleTabBar() override;
|
|
bool AddTabbedWindow(NativeWindow* window) override;
|
|
void SetAspectRatio(double aspect_ratio,
|
|
const gfx::Size& extra_size) override;
|
|
void PreviewFile(const std::string& path,
|
|
const std::string& display_name) override;
|
|
void CloseFilePreview() override;
|
|
gfx::Rect ContentBoundsToWindowBounds(const gfx::Rect& bounds) const override;
|
|
gfx::Rect WindowBoundsToContentBounds(const gfx::Rect& bounds) const override;
|
|
gfx::Rect GetWindowControlsOverlayRect() override;
|
|
void NotifyWindowEnterFullScreen() override;
|
|
void NotifyWindowLeaveFullScreen() override;
|
|
void SetActive(bool is_key) override;
|
|
bool IsActive() const override;
|
|
// Remove the specified child window without closing it.
|
|
void RemoveChildWindow(NativeWindow* child) override;
|
|
void RemoveChildFromParentWindow(NativeWindow* child);
|
|
// Attach child windows, if the window is visible.
|
|
void AttachChildren() override;
|
|
// Detach window from parent without destroying it.
|
|
void DetachChildren() override;
|
|
|
|
void NotifyWindowWillEnterFullScreen();
|
|
void NotifyWindowWillLeaveFullScreen();
|
|
|
|
// Cleanup observers when window is getting closed. Note that the destructor
|
|
// can be called much later after window gets closed, so we should not do
|
|
// cleanup in destructor.
|
|
void Cleanup();
|
|
|
|
void UpdateVibrancyRadii(bool fullscreen);
|
|
|
|
void UpdateWindowOriginalFrame();
|
|
|
|
// Set the attribute of NSWindow while work around a bug of zoom button.
|
|
bool HasStyleMask(NSUInteger flag) const;
|
|
void SetStyleMask(bool on, NSUInteger flag);
|
|
void SetCollectionBehavior(bool on, NSUInteger flag);
|
|
void SetWindowLevel(int level);
|
|
|
|
bool HandleDeferredClose();
|
|
void SetHasDeferredWindowClose(bool defer_close) {
|
|
has_deferred_window_close_ = defer_close;
|
|
}
|
|
|
|
enum class VisualEffectState {
|
|
kFollowWindow,
|
|
kActive,
|
|
kInactive,
|
|
};
|
|
|
|
ElectronPreviewItem* preview_item() const { return preview_item_.get(); }
|
|
ElectronTouchBar* touch_bar() const { return touch_bar_.get(); }
|
|
bool zoom_to_page_width() const { return zoom_to_page_width_; }
|
|
bool always_simple_fullscreen() const { return always_simple_fullscreen_; }
|
|
|
|
// We need to save the result of windowWillUseStandardFrame:defaultFrame
|
|
// because macOS calls it with what it refers to as the "best fit" frame for a
|
|
// zoom. This means that even if an aspect ratio is set, macOS might adjust it
|
|
// to better fit the screen.
|
|
//
|
|
// Thus, we can't just calculate the maximized aspect ratio'd sizing from
|
|
// the current visible screen and compare that to the current window's frame
|
|
// to determine whether a window is maximized.
|
|
NSRect default_frame_for_zoom() const { return default_frame_for_zoom_; }
|
|
void set_default_frame_for_zoom(NSRect frame) {
|
|
default_frame_for_zoom_ = frame;
|
|
}
|
|
|
|
protected:
|
|
// views::WidgetDelegate:
|
|
views::View* GetContentsView() override;
|
|
bool CanMaximize() const override;
|
|
std::unique_ptr<views::NonClientFrameView> CreateNonClientFrameView(
|
|
views::Widget* widget) override;
|
|
|
|
// ui::NativeThemeObserver:
|
|
void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;
|
|
|
|
// display::DisplayObserver:
|
|
void OnDisplayMetricsChanged(const display::Display& display,
|
|
uint32_t changed_metrics) override;
|
|
|
|
private:
|
|
// Add custom layers to the content view.
|
|
void AddContentViewLayers();
|
|
|
|
void InternalSetWindowButtonVisibility(bool visible);
|
|
void InternalSetParentWindow(NativeWindow* parent, bool attach);
|
|
void SetForwardMouseMessages(bool forward);
|
|
|
|
ElectronNSWindow* window_; // Weak ref, managed by widget_.
|
|
|
|
base::scoped_nsobject<ElectronNSWindowDelegate> window_delegate_;
|
|
base::scoped_nsobject<ElectronPreviewItem> preview_item_;
|
|
base::scoped_nsobject<ElectronTouchBar> touch_bar_;
|
|
|
|
// The views::View that fills the client area.
|
|
std::unique_ptr<RootViewMac> root_view_;
|
|
|
|
bool fullscreen_before_kiosk_ = false;
|
|
bool is_kiosk_ = false;
|
|
bool zoom_to_page_width_ = false;
|
|
absl::optional<gfx::Point> traffic_light_position_;
|
|
|
|
// Trying to close an NSWindow during a fullscreen transition will cause the
|
|
// window to lock up. Use this to track if CloseWindow was called during a
|
|
// fullscreen transition, to defer the -[NSWindow close] call until the
|
|
// transition is complete.
|
|
bool has_deferred_window_close_ = false;
|
|
|
|
NSInteger attention_request_id_ = 0; // identifier from requestUserAttention
|
|
|
|
// The presentation options before entering kiosk mode.
|
|
NSApplicationPresentationOptions kiosk_options_;
|
|
|
|
// The "visualEffectState" option.
|
|
VisualEffectState visual_effect_state_ = VisualEffectState::kFollowWindow;
|
|
|
|
// The visibility mode of window button controls when explicitly set through
|
|
// setWindowButtonVisibility().
|
|
absl::optional<bool> window_button_visibility_;
|
|
|
|
// Controls the position and visibility of window buttons.
|
|
base::scoped_nsobject<WindowButtonsProxy> buttons_proxy_;
|
|
|
|
std::unique_ptr<SkRegion> draggable_region_;
|
|
|
|
// Maximizable window state; necessary for persistence through redraws.
|
|
bool maximizable_ = true;
|
|
|
|
bool user_set_bounds_maximized_ = false;
|
|
|
|
// Simple (pre-Lion) Fullscreen Settings
|
|
bool always_simple_fullscreen_ = false;
|
|
bool is_simple_fullscreen_ = false;
|
|
bool was_maximizable_ = false;
|
|
bool was_movable_ = false;
|
|
bool is_active_ = false;
|
|
NSRect original_frame_;
|
|
NSInteger original_level_;
|
|
NSUInteger simple_fullscreen_mask_;
|
|
NSRect default_frame_for_zoom_;
|
|
|
|
std::string vibrancy_type_;
|
|
|
|
// The presentation options before entering simple fullscreen mode.
|
|
NSApplicationPresentationOptions simple_fullscreen_options_;
|
|
};
|
|
|
|
} // namespace electron
|
|
|
|
#endif // ELECTRON_SHELL_BROWSER_NATIVE_WINDOW_MAC_H_
|