2014-10-31 18:17:05 +00:00
|
|
|
|
// Copyright (c) 2013 GitHub, Inc.
|
2014-04-25 09:49:37 +00:00
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
2013-04-12 07:04:46 +00:00
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
2019-06-19 20:46:59 +00:00
|
|
|
|
#include "shell/browser/native_window_mac.h"
|
2013-04-12 07:04:46 +00:00
|
|
|
|
|
2017-10-05 22:57:27 +00:00
|
|
|
|
#include <AvailabilityMacros.h>
|
2018-05-02 11:43:45 +00:00
|
|
|
|
#include <objc/objc-runtime.h>
|
2018-04-19 07:41:36 +00:00
|
|
|
|
|
2020-01-29 17:03:53 +00:00
|
|
|
|
#include <algorithm>
|
2022-10-12 16:05:45 +00:00
|
|
|
|
#include <memory>
|
2016-10-26 00:55:34 +00:00
|
|
|
|
#include <string>
|
2020-01-29 17:03:53 +00:00
|
|
|
|
#include <utility>
|
2019-05-02 12:05:37 +00:00
|
|
|
|
#include <vector>
|
2013-04-15 16:25:08 +00:00
|
|
|
|
|
chore: bump chromium to 118.0.5975.0 (main) (#39531)
* chore: bump chromium in DEPS to 118.0.5951.0
* chore: update printing.patch
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4727894
No logic changes, but patch needed to be manually re-applied due to upstream code shear
* chore: update port_autofill_colors_to_the_color_pipeline.patch
No manual changes; patch applied with fuzz
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5953.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5955.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5957.0
* chore: update patches
* chore: include path of native_web_keyboard_event.h
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4758689
* chore: remove reference to eextensions/browser/notification-types.h
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4771627
* chore: update references to renamed upstream field NativeWebKeyboardEvent.skip_if_unhandled (formerly known as skip_in_browser
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4758689
Need a second pair of eyes on this commit. In particular the reference in content_converter.cc, skipInBrowser, seems to not be set or documented anywhere? Is this unused/vestigal code?
* chore: sync signature of ElectronExtensionsBrowserClient::IsValidContext() to upstream change
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4784198
* chore: add auto_pip_setting_helper.[cc,h] to chromium_src build
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4688277
Exiting upstream code used by chromium_src now depends on this new upstream class
* chore: bump chromium in DEPS to 118.0.5959.0
* chore: update add_maximized_parameter_to_linuxui_getwindowframeprovider.patch
Xref: add_maximized_parameter_to_linuxui_getwindowframeprovider.patch
manually adjust patch to minor upstream chagnes
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5961.0
* chore: bump chromium in DEPS to 118.0.5963.0
* chore: update patches
* 4780994: Rename various base files to "apple" since iOS uses them too
https://chromium-review.googlesource.com/c/chromium/src/+/4780994
* Many files moved from `mac` -> `apple`
This commit follows a handful of CLs that simply rename files/symbols to change `mac`
to `apple`
to signify their use across both macOS and iOS:
- 4784010: Move scoped_nsautorelease_pool to base/apple, leave a forwarding header
- 4790744: Move foundation_util to base/apple, leave a forwarding header
- 4790741: Move scoped_cftypreref to base/apple, leave a forwarding header
- 4787627: Move and rename macOS+iOS base/ files in PA to "apple"
- 4780399: Move OSStatus logging to base/apple
- 4787387: Remove forwarding headers
- 4781113: Rename message_pump_mac to "apple" because iOS uses it too
* fixup minor patch update error
A function param got dropped from this patch somewhere earlier
* chore: bump chromium in DEPS to 118.0.5965.2
* chore: update patches
* 4799213: Move ScopedTypeRef and ScopedCFTypeRef into base::apple::
https://chromium-review.googlesource.com/c/chromium/src/+/4799213
* Fix removed include to BrowserContext
In crrev.com/c/4767962 an include to BrowserContext was removed,
which was necessary for compilation. This broke only for us because
"chrome/browser/profiles/profile.h" includes that class, but we remove
all references to profiles.
* chore: bump chromium in DEPS to 118.0.5967.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5969.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5971.0
* chore: bump chromium in DEPS to 118.0.5973.0
* chore: update patches
* 4772121: [OOPIF PDF] Replace PDFWebContentsHelper with PDFDocumentHelper
https://chromium-review.googlesource.com/c/chromium/src/+/4772121
* 4811164: [Extensions] Do some cleanup in ChromeManagementAPIDelegate.
https://chromium-review.googlesource.com/c/chromium/src/+/4811164
* 4809488: Remove duplicate dnd functionality between Web and Renderer prefs
https://chromium-review.googlesource.com/c/chromium/src/+/4809488
Given that this is no longer an option of web preferences, we should
consider deprecating this option and then removing it.
* chore: bump chromium in DEPS to 118.0.5975.0
* chore: update patches
* fixup! chore: add auto_pip_settings_helper.{cc|h} to chromium_src build
* Reland "[windows] Remove RegKey::DeleteEmptyKey"
Refs https://chromium-review.googlesource.com/c/chromium/src/+/4813255
* Ensure StrCat means StrCat
Refs https://chromium-review.googlesource.com/c/chromium/src/+/1117180
* fixup! Remove RegKey::DeleteEmptyKey
* Consistently reject large p and large q in DH
Refs https://boringssl-review.googlesource.com/c/boringssl/+/62226
---------
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: clavin <clavin@electronjs.org>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
2023-09-01 06:54:59 +00:00
|
|
|
|
#include "base/apple/scoped_cftyperef.h"
|
2014-05-15 07:19:02 +00:00
|
|
|
|
#include "base/mac/mac_util.h"
|
|
|
|
|
#include "base/strings/sys_string_conversions.h"
|
2019-06-05 00:27:07 +00:00
|
|
|
|
#include "components/remote_cocoa/app_shim/native_widget_ns_window_bridge.h"
|
chore: bump chromium to 92.0.4475.0 (master) (#28462)
* chore: bump chromium in DEPS to 91.0.4464.0
* chore: rebuild chromium/dcheck.patch with import-patches -3
Mechanical only; no code changes
* chore: remove content_browser_main_loop.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2725153
The function being patched (BrowserMainLoop::MainMessageLoopRun()) no
longer exists.
NB: if removing this introduces regressions the likely fix will be to
add a similar patch for ShellBrowserMainParts::WillRunMainMessageLoop()
which has similar code and was added at the same time this was removed.
* chore: rebuild chromium/put_back_deleted_colors_for_autofill.patch with import-patches -3
Mechanical only; no code changes
* chore: rebuild chromium/disable_color_correct_rendering.patch with import-patches -3
Mechanical only; no code changes
* chore: rebuild chromium/eat_allow_disabling_blink_scheduler_throttling_per_renderview.patch with patch
Mechanical only; no code changes
* chore: rebuild chromium/gpu_notify_when_dxdiag_request_fails.patch with import-patches -3
Mechanical only; no code changes
* chore: rebuild chromium/ui_gtk_public_header.patch manually
no code changes
* chore: rebuild chromium/web_contents.patch with import-patches -3
Mechanical only; no code changes
* chore: remove v8/skip_global_registration_of_shared_arraybuffer_backing_stores.patch
Refs: https://chromium-review.googlesource.com/c/v8/v8/+/2763874
This patch has been merged upstream
* chore: export patches
* chore: update add_trustedauthclient_to_urlloaderfactory.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2757969
Sync with removal of render_frame_id_
* chore: sync chromium/put_back_deleted_colors_for_autofill.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2785841
SkColorFromColorId() no longer takes theme, scheme args
* chore: sync chromium/put_back_deleted_colors_for_autofill.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2772143
Change new calls to GetDarkSchemeColor to fit our patched call signature
* chore: update add_trustedauthclient_to_urlloaderfactory.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2757969
Sync with removal of render_frame_id_ in our mojom
* chore: update chromium/frame_host_manager.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2740008
UrlInfo ctor now takes UrlInfo::OriginIsolationRequest instead of a bool
* chore: update chromium/revert_remove_contentrendererclient_shouldfork.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2755314
Upstream has removed `history_list_length_` which we were comparing to 0
to calculate our `is_initial_navigation` bool when calling ShouldFork().
ShouldFork() is ours and none of the code paths actually use that param,
so this commit removes it altogether.
* chore: update permissions_to_register
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2789074
Replace all uses of APIPermission::ID enum with Mojo type
* refactor: update return type of PreMainMessageLoopRun()
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2725153
Used to return void; now returns an int errorcode.
Note: 2725153 also has some nice doc updates about Browser's "stages"
* refactor: sync ElectronBrowserMainParts to MainParts changes
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2725153
RunMainMessageLoopParts has been replaced with WillRunMainMessageLoop
so `BrowserMainLoop::result_code_` is no longer available to us for our
exit_code_ pointer.
This variable held a dual role: (1) of course, hold the exit code, but
also (2) was a nullptr before the message loop was ready, indicating to
anyone calling SetExitCode() that we were still in startup and could
just exit() without any extra steps. exit_code_ still fulfills these two
roles but is now a base::Optional.
* chore: update ElectronBrowserMainParts::PreDefaultMainMessageLoopRun
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2725153
BrowserMainParts::BrowsePreDefaultMainMesssageLoopRun() has been
removed; move that work to the new WillRunMainMessageLoop().
* refactor: stop using CallbackList; it has been removed.
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2785973
* refactor: update use of threadpools.
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2773408
The upstream code is still in flux (e.g. reverts and re-lands) but the
tl;dr for this commit is (1) include thread_pool.h if you're using it
and (2) don't instantiate pools directly.
* refactor: remove routing_id from CreateLoaderAndStart
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2762858
NB: One logic branch in ProxyingURLLoaderFactory::CreateLoaderAndStart
calls std::make_unique<InProgressRequest>, which needs a routing_id.
This PR uses the member field `routing_id_` since there's no longer one
being passed into CreateLoaderAndStart.
* refactor: sync to upstream ParittionOptions churn
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2771318
PartitionOptions' enums have changed.
* refactor: update Manifest::Location usage
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2771320
tldr: s/Manifest::FOO/ManifestLocation::kFoo/
* chore: bump chromium in DEPS to 91.0.4465.0
* update patches
* refactor: update extensions::Manifest to upstream
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2771320
- extensions::Manifest::COMPONENT
+ extensions::mojom::ManifestLocation::kExternalComponent
* refactor: sync with upstream UrlInfo ctor changes
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2740008
UrlInfo ctor now takes UrlInfo::OriginIsolationRequest instead of a bool
* chore: update invocation of convert_protocol_to_json.py
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2792623
python3 is being used in parts of the upstream build, but the copy of
convert_protocol_to_json.py invoked in v8/third_party/inspector_protocol
is not python3-friendly. Node has a py2+3-friendly version of it in its
tools directory, so call it instead.
* chore: use extensions::mojom::APIPermissionID
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2791122
tldr:
- extensions::APIPermission::kFoo
+ extensions::mojom::APIPermissionID::kFoo
* chore: Remove support for TLS1.0/1.1 in SSLVersionMin policy
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2765737
Remove TLS v1.0 & 1.1 from our SSLProtocolVersionFromString() function.
This is the same change made upstream at
https://chromium-review.googlesource.com/c/chromium/src/+/2765737/8/chrome/browser/ssl/ssl_config_service_manager_pref.cc
* fixup! chore: update ElectronBrowserMainParts::PreDefaultMainMessageLoopRun
* chore: Use IDType for permission change subscriptions.
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2791431
tldr: {Subscribe,Unsubscribe}PermissionStatusChange's tag type used to
be an int; now it's the new SubscriptionId type (which is an IdType64).
* chore: sync PowerMonitor code to upstream refactor
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2752635
tldr: PowerMonitor has been split into PowerStateObserver,
PowerSuspendObserver, and PowerThermalObserver to reduce number of tasks
posted to consumers who only need notifications for one of those things
instead of all of them.
* chore: use PartitionOptions's new Cookies field
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2771318
* Revert "refactor: remove routing_id from CreateLoaderAndStart"
This reverts commit 8c9773b87a3c84f9073a47089eb2b6889d745245.
8c9773b was only a partial fix; reverting to start & try again.
* update patches
* chore: bump chromium in DEPS to 91.0.4466.0
* chore: update chromium/accelerator.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2795472
tldr: sync patch with upstream renamed variable & macro names.
* chore: update chromium/gtk_visibility.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2796200
tldr: no code changes; just updating the diff to apply cleanly.
note: ooh upstream Wayland hacking!
* chore: update chromium/picture-in-picture.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2710023
tldr: no code changes; just updating the diff to apply cleanly.
* chore: update chromium/worker_feat_add_hook_to_notify_script_ready.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2775573
tldr: no code changes; just updating the diff to apply cleanly.
* chore: export_all_patches
* chore: update chromium/feat_add_set_theme_source_to_allow_apps_to.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2796511
tldr: NotifyObservers has been renamed to NotifyOnNativeThemeUpdated,
so update the invocation in our patch.
* chore: update ElectronBrowserClient w/upstream API
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2797454
tldr: GetDevToolsManagerDelegate() was returning an owned raw pointer.
Replaced it with CreateDevToolsManagerDelegate() which uses unique_ptr<>.
* chore: handle new content::PermissionType::FILE_HANDLING in toV8()
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2762201
`file-handling` string confirmed in https://chromium-review.googlesource.com/c/chromium/src/+/2762201/18/chrome/browser/ui/webui/settings/site_settings_helper.cc
* refactor: remove routing_id from CreateLoaderAndStart pt 1
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2762858
Part 1: the easiest ones
* 2796724: Support Python3
https://chromium-review.googlesource.com/c/infra/luci/python-adb/+/2796724
* chore: bump chromium in DEPS to 91.0.4468.0
* 2668974: WebShare: Implement SharingServicePicker
https://chromium-review.googlesource.com/c/chromium/src/+/2668974
* 2802766: Apply modernize-make-unique to media/
https://chromium-review.googlesource.com/c/chromium/src/+/2802766
* 2802823: Apply modernize-make-unique to gpu/
https://chromium-review.googlesource.com/c/chromium/src/+/2802823
* 2803041: Apply modernize-make-unique to remaining files
https://chromium-review.googlesource.com/c/chromium/src/+/2803041
* 2798873: Convert GtkKeyBindingsHandler build checks to runtime checks
https://chromium-review.googlesource.com/c/chromium/src/+/2798873
* 2733595: [ch-r] Parse ACCEPT_CH H2/3 frame and restart with new headers if needed
https://chromium-review.googlesource.com/c/chromium/src/+/2733595
* chore: update patch indices
* 2795107: Remove unused PermissionRequest IDs.
https://chromium-review.googlesource.com/c/chromium/src/+/2795107
* chore: bump chromium in DEPS to 91.0.4469.0
* chore: fixup patch indices
* chore: bump chromium in DEPS to 91.0.4469.5
* PiP 1.5: Add microphone, camera, and hang up buttons to the PiP window
https://chromium-review.googlesource.com/c/chromium/src/+/2710023
* fixup! refactor: remove routing_id from CreateLoaderAndStart
* refactor: use URLLoaderNetworkServiceObserver for auth requests from SimpleURLLoader
* fixup! chore: fixup patch indices
* 2724817: Expand scope of wasm-eval to all URLs
https://chromium-review.googlesource.com/c/chromium/src/+/2724817
* Fixup patch after rebase
* chore: bump chromium in DEPS to 91.0.4472.0
* 2797341: [ozone/x11] Enabled the global shortcut listener.
https://chromium-review.googlesource.com/c/chromium/src/+/2797341
* 2805553: Reland Add GTK ColorMixers to ColorPipeline P1
https://chromium-review.googlesource.com/c/chromium/src/+/2805553
* 2804366: PiP 1.5: Label back to tab button with origin and center it
https://chromium-review.googlesource.com/c/chromium/src/+/2804366
* 2784730: Fix crash on AX mode change in NativeViewHost without a Widget
https://chromium-review.googlesource.com/c/chromium/src/+/2784730
* chore: update patch indices
* 2810174: Add PdfAnnotationsEnabled policy.
https://chromium-review.googlesource.com/c/chromium/src/+/2810174
* 2807829: Allow capturers to indicate if they want a WakeLock or not.
https://chromium-review.googlesource.com/c/chromium/src/+/2807829
* chore: bump chromium in DEPS to 92.0.4473.0
* chore: bump chromium in DEPS to 92.0.4474.0
* chore: bump chromium in DEPS to 92.0.4475.0
* chore: update patches
* chore: updates patches
* chore: update is_media_key patch to handle new ozone impl
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2797341
* fix: ExecuteJavascript requests now need to be flagged as non-bf-aware
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2787195
* chore: icon_util_x11 is now icon_util_linux
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2791362
* build: update sysroots
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2628496
* build: fix missing symbols on linux build
* use_ozone and use_x11 are not exclusive
* new button view to build for pip
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2797341
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2804366
* chore: fix broken gtk_util color patch
* chore: remove patch conflict
* build: update linux manifests
* chore: build bttlb on all platforms for pip
* chore: add thread_pool include for views delegate win
* chore: fix lint
* chore: add node patches for V8 changes
* build: add missing base include on windows
* fix: update frame host manager patch for new state transitions
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2714464
* chore: update windows zip manifests
* chore: update mac zip manifests
* chore: fix patch linting
* refactor: implement missing URLLoaderNetworkServiceObserver methods
It is against The Mojo Rules to leave hanging callbacks. These always
have to be called.
Refs: https://github.com/electron/electron/commit/186528aab9f8e29d658f07d220bb7f627980edda
* spec: fix locale test on local linux
* fix: pass the exit code correctly in new PreMainMessageLoopRun
Refs: https://github.com/electron/electron/commit/2622e91c4493ceb032e2f80cb484885bb8f97475
* fix: ensure we early-exit when request_handler_ is not provided
Refs: https://github.com/electron/electron/commit/93077afbfb6db248a0c0cc447d7ad2c9ccfda1d5
* fix: strongly set result_code in the BrowserMainLoop
* fix: invalid usage of non-targetted PostTask
You must always either use a host threadpool or specify a target
thread. In this case we did neither after this refactor.
Refs: https://github.com/electron/electron/pull/28462/commits/4e33ee0ad35a710bd34641cb0376bdee6aea2d1f
* chore: fix gn check
* chore: remove stray .rej files in patch
* chore: add mojo error code to url loader failure
* build: ensure CI is truthy in arm test env
* fix: handle windowCaptureMacV2 being enabled when fetching media source id
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2709931
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>
Co-authored-by: Samuel Attard <sattard@slack-corp.com>
2021-04-15 17:44:35 +00:00
|
|
|
|
#include "components/remote_cocoa/browser/scoped_cg_window_id.h"
|
2015-04-13 12:10:51 +00:00
|
|
|
|
#include "content/public/browser/browser_accessibility_state.h"
|
2020-03-05 20:19:05 +00:00
|
|
|
|
#include "content/public/browser/browser_task_traits.h"
|
|
|
|
|
#include "content/public/browser/browser_thread.h"
|
2019-08-15 06:51:15 +00:00
|
|
|
|
#include "content/public/browser/desktop_media_id.h"
|
2023-03-20 14:30:49 +00:00
|
|
|
|
#include "shell/browser/browser.h"
|
2021-03-29 10:45:08 +00:00
|
|
|
|
#include "shell/browser/javascript_environment.h"
|
2019-06-19 20:46:59 +00:00
|
|
|
|
#include "shell/browser/ui/cocoa/electron_native_widget_mac.h"
|
2024-04-12 12:27:59 +00:00
|
|
|
|
#include "shell/browser/ui/cocoa/electron_ns_panel.h"
|
2019-06-19 20:46:59 +00:00
|
|
|
|
#include "shell/browser/ui/cocoa/electron_ns_window.h"
|
|
|
|
|
#include "shell/browser/ui/cocoa/electron_ns_window_delegate.h"
|
|
|
|
|
#include "shell/browser/ui/cocoa/electron_preview_item.h"
|
|
|
|
|
#include "shell/browser/ui/cocoa/electron_touch_bar.h"
|
|
|
|
|
#include "shell/browser/ui/cocoa/root_view_mac.h"
|
2021-08-04 00:31:12 +00:00
|
|
|
|
#include "shell/browser/ui/cocoa/window_buttons_proxy.h"
|
2022-10-12 16:05:45 +00:00
|
|
|
|
#include "shell/browser/ui/drag_util.h"
|
2019-06-19 20:46:59 +00:00
|
|
|
|
#include "shell/browser/window_list.h"
|
2020-01-23 18:13:08 +00:00
|
|
|
|
#include "shell/common/gin_converters/gfx_converter.h"
|
2019-10-25 13:03:28 +00:00
|
|
|
|
#include "shell/common/gin_helper/dictionary.h"
|
2024-09-16 20:53:04 +00:00
|
|
|
|
#include "shell/common/node_util.h"
|
2019-06-19 20:46:59 +00:00
|
|
|
|
#include "shell/common/options_switches.h"
|
2016-04-02 12:17:38 +00:00
|
|
|
|
#include "skia/ext/skia_utils_mac.h"
|
2019-08-15 06:51:15 +00:00
|
|
|
|
#include "third_party/webrtc/modules/desktop_capture/mac/window_list_utils.h"
|
2022-10-12 16:05:45 +00:00
|
|
|
|
#include "ui/base/hit_test.h"
|
2021-03-16 09:41:59 +00:00
|
|
|
|
#include "ui/display/screen.h"
|
2018-03-07 16:40:36 +00:00
|
|
|
|
#include "ui/gl/gpu_switching_manager.h"
|
2018-04-24 10:00:44 +00:00
|
|
|
|
#include "ui/views/background.h"
|
2019-08-22 21:16:56 +00:00
|
|
|
|
#include "ui/views/cocoa/native_widget_mac_ns_window_host.h"
|
2018-04-19 06:26:34 +00:00
|
|
|
|
#include "ui/views/widget/widget.h"
|
2022-10-12 16:05:45 +00:00
|
|
|
|
#include "ui/views/window/native_frame_view_mac.h"
|
2018-07-10 01:43:42 +00:00
|
|
|
|
|
2014-09-17 07:58:08 +00:00
|
|
|
|
@interface ElectronProgressBar : NSProgressIndicator
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation ElectronProgressBar
|
|
|
|
|
|
|
|
|
|
- (void)drawRect:(NSRect)dirtyRect {
|
2023-07-01 20:22:55 +00:00
|
|
|
|
if (self.style != NSProgressIndicatorStyleBar)
|
2014-09-17 07:58:08 +00:00
|
|
|
|
return;
|
|
|
|
|
// Draw edges of rounded rect.
|
|
|
|
|
NSRect rect = NSInsetRect([self bounds], 1.0, 1.0);
|
2014-09-18 08:17:49 +00:00
|
|
|
|
CGFloat radius = rect.size.height / 2;
|
2018-04-20 18:47:04 +00:00
|
|
|
|
NSBezierPath* bezier_path = [NSBezierPath bezierPathWithRoundedRect:rect
|
|
|
|
|
xRadius:radius
|
|
|
|
|
yRadius:radius];
|
2014-09-18 08:17:49 +00:00
|
|
|
|
[bezier_path setLineWidth:2.0];
|
|
|
|
|
[[NSColor grayColor] set];
|
|
|
|
|
[bezier_path stroke];
|
2014-09-17 07:58:08 +00:00
|
|
|
|
|
|
|
|
|
// Fill the rounded rect.
|
2014-09-18 08:17:49 +00:00
|
|
|
|
rect = NSInsetRect(rect, 2.0, 2.0);
|
|
|
|
|
radius = rect.size.height / 2;
|
2018-04-20 18:47:04 +00:00
|
|
|
|
bezier_path = [NSBezierPath bezierPathWithRoundedRect:rect
|
|
|
|
|
xRadius:radius
|
|
|
|
|
yRadius:radius];
|
2014-09-18 08:17:49 +00:00
|
|
|
|
[bezier_path setLineWidth:1.0];
|
|
|
|
|
[bezier_path addClip];
|
2014-09-17 07:58:08 +00:00
|
|
|
|
|
|
|
|
|
// Calculate the progress width.
|
2018-04-20 18:47:04 +00:00
|
|
|
|
rect.size.width =
|
|
|
|
|
floor(rect.size.width * ([self doubleValue] / [self maxValue]));
|
2014-09-17 07:58:08 +00:00
|
|
|
|
|
|
|
|
|
// Fill the progress bar with color blue.
|
|
|
|
|
[[NSColor colorWithSRGBRed:0.2 green:0.6 blue:1 alpha:1] set];
|
|
|
|
|
NSRectFill(rect);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
2019-10-25 13:03:28 +00:00
|
|
|
|
namespace gin {
|
2016-06-17 01:54:50 +00:00
|
|
|
|
|
2020-08-24 15:44:48 +00:00
|
|
|
|
template <>
|
|
|
|
|
struct Converter<electron::NativeWindowMac::VisualEffectState> {
|
|
|
|
|
static bool FromV8(v8::Isolate* isolate,
|
2024-07-24 23:24:07 +00:00
|
|
|
|
v8::Local<v8::Value> val,
|
2020-08-24 15:44:48 +00:00
|
|
|
|
electron::NativeWindowMac::VisualEffectState* out) {
|
|
|
|
|
using VisualEffectState = electron::NativeWindowMac::VisualEffectState;
|
|
|
|
|
std::string visual_effect_state;
|
|
|
|
|
if (!ConvertFromV8(isolate, val, &visual_effect_state))
|
|
|
|
|
return false;
|
|
|
|
|
if (visual_effect_state == "followWindow") {
|
2020-10-27 17:51:45 +00:00
|
|
|
|
*out = VisualEffectState::kFollowWindow;
|
2020-08-24 15:44:48 +00:00
|
|
|
|
} else if (visual_effect_state == "active") {
|
2020-10-27 17:51:45 +00:00
|
|
|
|
*out = VisualEffectState::kActive;
|
2020-08-24 15:44:48 +00:00
|
|
|
|
} else if (visual_effect_state == "inactive") {
|
2020-10-27 17:51:45 +00:00
|
|
|
|
*out = VisualEffectState::kInactive;
|
2020-08-24 15:44:48 +00:00
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2019-10-25 13:03:28 +00:00
|
|
|
|
} // namespace gin
|
2016-06-17 01:54:50 +00:00
|
|
|
|
|
2013-04-12 07:04:46 +00:00
|
|
|
|
namespace electron {
|
|
|
|
|
|
2019-10-25 13:03:28 +00:00
|
|
|
|
NativeWindowMac::NativeWindowMac(const gin_helper::Dictionary& options,
|
2018-04-08 11:20:43 +00:00
|
|
|
|
NativeWindow* parent)
|
2018-05-21 22:18:38 +00:00
|
|
|
|
: NativeWindow(options, parent), root_view_(new RootViewMac(this)) {
|
2020-03-05 20:19:05 +00:00
|
|
|
|
ui::NativeTheme::GetInstanceForNativeUi()->AddObserver(this);
|
2021-03-16 09:41:59 +00:00
|
|
|
|
display::Screen::GetScreen()->AddObserver(this);
|
2020-03-05 20:19:05 +00:00
|
|
|
|
|
2014-01-06 10:58:30 +00:00
|
|
|
|
int width = 800, height = 600;
|
2015-11-13 05:58:31 +00:00
|
|
|
|
options.Get(options::kWidth, &width);
|
|
|
|
|
options.Get(options::kHeight, &height);
|
2013-04-12 07:04:46 +00:00
|
|
|
|
|
2016-12-20 21:49:35 +00:00
|
|
|
|
NSRect main_screen_rect = [[[NSScreen screens] firstObject] frame];
|
2018-04-24 08:23:08 +00:00
|
|
|
|
gfx::Rect bounds(round((NSWidth(main_screen_rect) - width) / 2),
|
2018-05-01 04:58:42 +00:00
|
|
|
|
round((NSHeight(main_screen_rect) - height) / 2), width,
|
2018-04-24 08:23:08 +00:00
|
|
|
|
height);
|
2013-09-11 10:10:28 +00:00
|
|
|
|
|
2021-06-03 08:05:04 +00:00
|
|
|
|
bool resizable = true;
|
|
|
|
|
options.Get(options::kResizable, &resizable);
|
2018-04-24 10:00:44 +00:00
|
|
|
|
options.Get(options::kZoomToPageWidth, &zoom_to_page_width_);
|
|
|
|
|
options.Get(options::kSimpleFullScreen, &always_simple_fullscreen_);
|
2020-12-16 05:30:39 +00:00
|
|
|
|
options.GetOptional(options::kTrafficLightPosition, &traffic_light_position_);
|
2020-08-24 15:44:48 +00:00
|
|
|
|
options.Get(options::kVisualEffectState, &visual_effect_state_);
|
2015-05-06 14:08:24 +00:00
|
|
|
|
|
2016-01-18 22:46:35 +00:00
|
|
|
|
bool minimizable = true;
|
|
|
|
|
options.Get(options::kMinimizable, &minimizable);
|
2016-01-23 07:51:52 +00:00
|
|
|
|
|
2016-01-22 21:24:33 +00:00
|
|
|
|
bool maximizable = true;
|
|
|
|
|
options.Get(options::kMaximizable, &maximizable);
|
|
|
|
|
|
2016-01-18 22:46:35 +00:00
|
|
|
|
bool closable = true;
|
|
|
|
|
options.Get(options::kClosable, &closable);
|
|
|
|
|
|
2017-03-30 20:47:11 +00:00
|
|
|
|
std::string tabbingIdentifier;
|
|
|
|
|
options.Get(options::kTabbingIdentifier, &tabbingIdentifier);
|
2017-03-27 14:15:17 +00:00
|
|
|
|
|
2015-11-19 08:39:45 +00:00
|
|
|
|
std::string windowType;
|
|
|
|
|
options.Get(options::kType, &windowType);
|
|
|
|
|
|
2022-11-01 20:43:42 +00:00
|
|
|
|
bool hiddenInMissionControl = false;
|
|
|
|
|
options.Get(options::kHiddenInMissionControl, &hiddenInMissionControl);
|
|
|
|
|
|
2021-02-09 16:38:35 +00:00
|
|
|
|
// The window without titlebar is treated the same with frameless window.
|
|
|
|
|
if (title_bar_style_ != TitleBarStyle::kNormal)
|
|
|
|
|
set_has_frame(false);
|
|
|
|
|
|
2018-09-26 23:00:57 +00:00
|
|
|
|
NSUInteger styleMask = NSWindowStyleMaskTitled;
|
2021-02-09 16:38:35 +00:00
|
|
|
|
|
2022-12-01 18:24:44 +00:00
|
|
|
|
// The NSWindowStyleMaskFullSizeContentView style removes rounded corners
|
|
|
|
|
// for frameless window.
|
2021-02-09 16:38:35 +00:00
|
|
|
|
bool rounded_corner = true;
|
|
|
|
|
options.Get(options::kRoundedCorners, &rounded_corner);
|
|
|
|
|
if (!rounded_corner && !has_frame())
|
2022-08-25 11:39:01 +00:00
|
|
|
|
styleMask = NSWindowStyleMaskBorderless;
|
2021-02-09 16:38:35 +00:00
|
|
|
|
|
2024-08-02 14:02:11 +00:00
|
|
|
|
// TODO: remove NSWindowStyleMaskTexturedBackground.
|
|
|
|
|
// https://github.com/electron/electron/issues/43125
|
|
|
|
|
#pragma clang diagnostic push
|
|
|
|
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
|
|
|
|
|
2019-05-28 17:23:16 +00:00
|
|
|
|
if (minimizable)
|
2022-06-01 06:12:47 +00:00
|
|
|
|
styleMask |= NSWindowStyleMaskMiniaturizable;
|
2019-05-28 17:23:16 +00:00
|
|
|
|
if (closable)
|
2018-09-26 23:00:57 +00:00
|
|
|
|
styleMask |= NSWindowStyleMaskClosable;
|
2021-06-03 08:05:04 +00:00
|
|
|
|
if (resizable)
|
2022-06-01 06:12:47 +00:00
|
|
|
|
styleMask |= NSWindowStyleMaskResizable;
|
2024-08-12 08:32:35 +00:00
|
|
|
|
|
|
|
|
|
#pragma clang diagnostic push
|
|
|
|
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
|
|
|
|
if (windowType == "textured" || transparent() || !has_frame()) {
|
2024-09-16 20:53:04 +00:00
|
|
|
|
util::EmitWarning(
|
|
|
|
|
"The 'textured' window type is deprecated and will be removed",
|
|
|
|
|
"DeprecationWarning");
|
2022-06-01 06:12:47 +00:00
|
|
|
|
styleMask |= NSWindowStyleMaskTexturedBackground;
|
2024-08-12 08:32:35 +00:00
|
|
|
|
}
|
|
|
|
|
#pragma clang diagnostic pop
|
2015-12-21 18:55:23 +00:00
|
|
|
|
|
2024-08-02 14:02:11 +00:00
|
|
|
|
// -Wdeprecated-declarations
|
|
|
|
|
#pragma clang diagnostic pop
|
|
|
|
|
|
2018-04-24 08:23:08 +00:00
|
|
|
|
// Create views::Widget and assign window_ with it.
|
|
|
|
|
// TODO(zcbenz): Get rid of the window_ in future.
|
2024-06-07 21:18:35 +00:00
|
|
|
|
views::Widget::InitParams params(
|
|
|
|
|
views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET,
|
|
|
|
|
views::Widget::InitParams::TYPE_WINDOW);
|
2018-04-24 08:23:08 +00:00
|
|
|
|
params.bounds = bounds;
|
|
|
|
|
params.delegate = this;
|
2024-07-27 16:44:22 +00:00
|
|
|
|
params.type = views::Widget::InitParams::TYPE_WINDOW;
|
2022-06-14 16:24:52 +00:00
|
|
|
|
params.native_widget =
|
|
|
|
|
new ElectronNativeWidgetMac(this, windowType, styleMask, widget());
|
2019-08-15 20:50:58 +00:00
|
|
|
|
widget()->Init(std::move(params));
|
2023-12-13 21:01:03 +00:00
|
|
|
|
widget()->SetNativeWindowProperty(kElectronNativeWindowKey, this);
|
2021-06-03 08:05:04 +00:00
|
|
|
|
SetCanResize(resizable);
|
2019-01-09 20:25:19 +00:00
|
|
|
|
window_ = static_cast<ElectronNSWindow*>(
|
|
|
|
|
widget()->GetNativeWindow().GetNativeNSWindow());
|
2018-04-24 08:23:08 +00:00
|
|
|
|
|
2021-10-14 17:36:32 +00:00
|
|
|
|
RegisterDeleteDelegateCallback(base::BindOnce(
|
|
|
|
|
[](NativeWindowMac* window) {
|
|
|
|
|
if (window->window_)
|
|
|
|
|
window->window_ = nil;
|
2022-03-29 03:02:44 +00:00
|
|
|
|
if (window->buttons_proxy_)
|
2023-07-18 22:26:27 +00:00
|
|
|
|
window->buttons_proxy_ = nil;
|
2021-10-14 17:36:32 +00:00
|
|
|
|
},
|
|
|
|
|
this));
|
|
|
|
|
|
2015-08-05 04:46:32 +00:00
|
|
|
|
[window_ setEnableLargerThanScreen:enable_larger_than_screen()];
|
2013-09-11 10:10:28 +00:00
|
|
|
|
|
2023-07-18 22:26:27 +00:00
|
|
|
|
window_delegate_ = [[ElectronNSWindowDelegate alloc] initWithShell:this];
|
2015-03-25 10:51:29 +00:00
|
|
|
|
[window_ setDelegate:window_delegate_];
|
2014-03-15 11:28:23 +00:00
|
|
|
|
|
2016-06-20 05:49:24 +00:00
|
|
|
|
// Only use native parent window for non-modal windows.
|
|
|
|
|
if (parent && !is_modal()) {
|
2017-05-01 20:21:05 +00:00
|
|
|
|
SetParentWindow(parent);
|
2016-06-19 03:06:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-05 04:46:32 +00:00
|
|
|
|
if (transparent()) {
|
2016-01-19 23:24:16 +00:00
|
|
|
|
// Setting the background color to clear will also hide the shadow.
|
2014-12-23 19:17:56 +00:00
|
|
|
|
[window_ setBackgroundColor:[NSColor clearColor]];
|
|
|
|
|
}
|
2015-04-25 02:35:28 +00:00
|
|
|
|
|
2015-11-19 08:39:45 +00:00
|
|
|
|
if (windowType == "desktop") {
|
|
|
|
|
[window_ setLevel:kCGDesktopWindowLevel - 1];
|
2015-11-20 05:06:42 +00:00
|
|
|
|
[window_ setDisableKeyOrMainWindow:YES];
|
2018-04-20 18:47:04 +00:00
|
|
|
|
[window_ setCollectionBehavior:(NSWindowCollectionBehaviorCanJoinAllSpaces |
|
|
|
|
|
NSWindowCollectionBehaviorStationary |
|
|
|
|
|
NSWindowCollectionBehaviorIgnoresCycle)];
|
2015-11-19 08:39:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-14 16:24:52 +00:00
|
|
|
|
if (windowType == "panel") {
|
|
|
|
|
[window_ setLevel:NSFloatingWindowLevel];
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-13 08:10:28 +00:00
|
|
|
|
bool focusable;
|
|
|
|
|
if (options.Get(options::kFocusable, &focusable) && !focusable)
|
|
|
|
|
[window_ setDisableKeyOrMainWindow:YES];
|
|
|
|
|
|
2016-06-17 02:02:37 +00:00
|
|
|
|
if (transparent() || !has_frame()) {
|
2019-02-25 17:21:57 +00:00
|
|
|
|
// Don't show title bar.
|
|
|
|
|
[window_ setTitlebarAppearsTransparent:YES];
|
|
|
|
|
[window_ setTitleVisibility:NSWindowTitleHidden];
|
2022-04-27 19:56:01 +00:00
|
|
|
|
// Remove non-transparent corners, see
|
|
|
|
|
// https://github.com/electron/electron/issues/517.
|
2015-04-18 12:08:22 +00:00
|
|
|
|
[window_ setOpaque:NO];
|
2021-08-04 00:31:12 +00:00
|
|
|
|
// Show window buttons if titleBarStyle is not "normal".
|
|
|
|
|
if (title_bar_style_ == TitleBarStyle::kNormal) {
|
|
|
|
|
InternalSetWindowButtonVisibility(false);
|
|
|
|
|
} else {
|
2023-07-18 22:26:27 +00:00
|
|
|
|
buttons_proxy_ = [[WindowButtonsProxy alloc] initWithWindow:window_];
|
2022-01-24 22:09:21 +00:00
|
|
|
|
[buttons_proxy_ setHeight:titlebar_overlay_height()];
|
2021-08-04 00:31:12 +00:00
|
|
|
|
if (traffic_light_position_) {
|
|
|
|
|
[buttons_proxy_ setMargin:*traffic_light_position_];
|
|
|
|
|
} else if (title_bar_style_ == TitleBarStyle::kHiddenInset) {
|
2022-02-21 09:27:45 +00:00
|
|
|
|
// For macOS >= 11, while this value does not match official macOS apps
|
2021-08-04 00:31:12 +00:00
|
|
|
|
// like Safari or Notes, it matches titleBarStyle's old implementation
|
|
|
|
|
// before Electron <= 12.
|
|
|
|
|
[buttons_proxy_ setMargin:gfx::Point(12, 11)];
|
|
|
|
|
}
|
|
|
|
|
if (title_bar_style_ == TitleBarStyle::kCustomButtonsOnHover) {
|
|
|
|
|
[buttons_proxy_ setShowOnHover:YES];
|
|
|
|
|
} else {
|
2022-02-21 09:27:45 +00:00
|
|
|
|
// customButtonsOnHover does not show buttons initially.
|
2021-08-04 00:31:12 +00:00
|
|
|
|
InternalSetWindowButtonVisibility(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-06-17 01:54:50 +00:00
|
|
|
|
}
|
2014-12-23 19:17:56 +00:00
|
|
|
|
|
2017-03-30 20:46:34 +00:00
|
|
|
|
// Create a tab only if tabbing identifier is specified and window has
|
|
|
|
|
// a native title bar.
|
2017-03-30 20:47:11 +00:00
|
|
|
|
if (tabbingIdentifier.empty() || transparent() || !has_frame()) {
|
2022-06-02 18:43:40 +00:00
|
|
|
|
[window_ setTabbingMode:NSWindowTabbingModeDisallowed];
|
2017-03-30 20:46:34 +00:00
|
|
|
|
} else {
|
2022-06-02 18:43:40 +00:00
|
|
|
|
[window_ setTabbingIdentifier:base::SysUTF8ToNSString(tabbingIdentifier)];
|
2017-03-27 14:15:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-24 10:00:44 +00:00
|
|
|
|
// Resize to content bounds.
|
2014-05-15 07:19:02 +00:00
|
|
|
|
bool use_content_size = false;
|
2015-11-13 05:58:31 +00:00
|
|
|
|
options.Get(options::kUseContentSize, &use_content_size);
|
2018-04-24 10:00:44 +00:00
|
|
|
|
if (!has_frame() || use_content_size)
|
|
|
|
|
SetContentSize(gfx::Size(width, height));
|
2017-08-13 06:28:33 +00:00
|
|
|
|
|
2014-03-15 11:28:23 +00:00
|
|
|
|
// Enable the NSView to accept first mouse event.
|
|
|
|
|
bool acceptsFirstMouse = false;
|
2015-11-13 05:58:31 +00:00
|
|
|
|
options.Get(options::kAcceptFirstMouse, &acceptsFirstMouse);
|
2015-04-27 03:47:26 +00:00
|
|
|
|
[window_ setAcceptsFirstMouse:acceptsFirstMouse];
|
2013-04-12 07:04:46 +00:00
|
|
|
|
|
2015-04-27 04:08:22 +00:00
|
|
|
|
// Disable auto-hiding cursor.
|
|
|
|
|
bool disableAutoHideCursor = false;
|
2015-11-13 05:58:31 +00:00
|
|
|
|
options.Get(options::kDisableAutoHideCursor, &disableAutoHideCursor);
|
2015-04-27 04:08:22 +00:00
|
|
|
|
[window_ setDisableAutoHideCursor:disableAutoHideCursor];
|
|
|
|
|
|
2022-11-01 20:43:42 +00:00
|
|
|
|
SetHiddenInMissionControl(hiddenInMissionControl);
|
|
|
|
|
|
2016-06-08 20:56:45 +00:00
|
|
|
|
// Set maximizable state last to ensure zoom button does not get reset
|
|
|
|
|
// by calls to other APIs.
|
2016-08-04 23:47:03 +00:00
|
|
|
|
SetMaximizable(maximizable);
|
2018-04-10 08:30:46 +00:00
|
|
|
|
|
2018-05-08 07:02:57 +00:00
|
|
|
|
// Default content view.
|
|
|
|
|
SetContentView(new views::View());
|
2021-01-30 23:15:10 +00:00
|
|
|
|
AddContentViewLayers();
|
2018-08-24 21:33:27 +00:00
|
|
|
|
|
2022-06-09 08:48:50 +00:00
|
|
|
|
UpdateWindowOriginalFrame();
|
2018-10-10 05:38:52 +00:00
|
|
|
|
original_level_ = [window_ level];
|
2018-04-08 11:20:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-04 04:16:13 +00:00
|
|
|
|
NativeWindowMac::~NativeWindowMac() = default;
|
2020-09-23 01:53:32 +00:00
|
|
|
|
|
2018-05-08 03:51:27 +00:00
|
|
|
|
void NativeWindowMac::SetContentView(views::View* view) {
|
2018-05-02 06:39:43 +00:00
|
|
|
|
views::View* root_view = GetContentsView();
|
2018-05-08 03:51:27 +00:00
|
|
|
|
if (content_view())
|
|
|
|
|
root_view->RemoveChildView(content_view());
|
2018-05-01 04:58:42 +00:00
|
|
|
|
|
2018-05-08 03:51:27 +00:00
|
|
|
|
set_content_view(view);
|
|
|
|
|
root_view->AddChildView(content_view());
|
2018-05-01 04:58:42 +00:00
|
|
|
|
|
2024-02-14 17:33:32 +00:00
|
|
|
|
root_view->DeprecatedLayoutImmediately();
|
2018-05-01 04:58:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 07:04:46 +00:00
|
|
|
|
void NativeWindowMac::Close() {
|
2016-05-25 23:25:51 +00:00
|
|
|
|
if (!IsClosable()) {
|
|
|
|
|
WindowList::WindowCloseCancelled(this);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-12 13:24:01 +00:00
|
|
|
|
if (fullscreen_transition_state() != FullScreenTransitionState::kNone) {
|
2022-05-31 08:43:42 +00:00
|
|
|
|
SetHasDeferredWindowClose(true);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-08 10:18:37 +00:00
|
|
|
|
// Ensure we're detached from the parent window before closing.
|
2023-07-26 14:47:32 +00:00
|
|
|
|
RemoveChildFromParentWindow();
|
|
|
|
|
|
|
|
|
|
while (!child_windows_.empty()) {
|
|
|
|
|
auto* child = child_windows_.back();
|
|
|
|
|
child->RemoveChildFromParentWindow();
|
|
|
|
|
}
|
2023-06-08 10:18:37 +00:00
|
|
|
|
|
2021-05-04 10:11:16 +00:00
|
|
|
|
// If a sheet is attached to the window when we call
|
|
|
|
|
// [window_ performClose:nil], the window won't close properly
|
|
|
|
|
// even after the user has ended the sheet.
|
|
|
|
|
// Ensure it's closed before calling [window_ performClose:nil].
|
2022-07-19 10:31:49 +00:00
|
|
|
|
if ([window_ attachedSheet])
|
|
|
|
|
[window_ endSheet:[window_ attachedSheet]];
|
2021-05-04 10:11:16 +00:00
|
|
|
|
|
2024-02-09 21:44:24 +00:00
|
|
|
|
// window_ could be nil after performClose.
|
|
|
|
|
bool should_notify = is_modal() && parent() && IsVisible();
|
|
|
|
|
|
2014-04-11 04:45:48 +00:00
|
|
|
|
[window_ performClose:nil];
|
2020-03-30 16:48:20 +00:00
|
|
|
|
|
|
|
|
|
// Closing a sheet doesn't trigger windowShouldClose,
|
|
|
|
|
// so we need to manually call it ourselves here.
|
2024-02-09 21:44:24 +00:00
|
|
|
|
if (should_notify) {
|
2020-03-30 16:48:20 +00:00
|
|
|
|
NotifyWindowCloseButtonClicked();
|
|
|
|
|
}
|
2013-04-12 07:04:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-05-01 08:12:00 +00:00
|
|
|
|
void NativeWindowMac::CloseImmediately() {
|
2023-07-26 14:47:32 +00:00
|
|
|
|
// Ensure we're detached from the parent window before closing.
|
|
|
|
|
RemoveChildFromParentWindow();
|
|
|
|
|
|
|
|
|
|
while (!child_windows_.empty()) {
|
|
|
|
|
auto* child = child_windows_.back();
|
|
|
|
|
child->RemoveChildFromParentWindow();
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-11 04:45:48 +00:00
|
|
|
|
[window_ close];
|
2013-05-01 08:12:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 07:04:46 +00:00
|
|
|
|
void NativeWindowMac::Focus(bool focus) {
|
2013-10-03 01:39:17 +00:00
|
|
|
|
if (!IsVisible())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (focus) {
|
2023-11-27 17:58:46 +00:00
|
|
|
|
// If we're a panel window, we do not want to activate the app,
|
|
|
|
|
// which enables Electron-apps to build Spotlight-like experiences.
|
2024-04-12 12:27:59 +00:00
|
|
|
|
if (!IsPanel()) {
|
2024-05-14 22:52:08 +00:00
|
|
|
|
[[NSApplication sharedApplication] activateIgnoringOtherApps:NO];
|
2023-11-06 21:38:12 +00:00
|
|
|
|
}
|
2014-04-11 04:45:48 +00:00
|
|
|
|
[window_ makeKeyAndOrderFront:nil];
|
2013-05-25 07:08:58 +00:00
|
|
|
|
} else {
|
2022-05-03 07:39:18 +00:00
|
|
|
|
[window_ orderOut:nil];
|
2014-04-11 04:45:48 +00:00
|
|
|
|
[window_ orderBack:nil];
|
2013-05-25 07:08:58 +00:00
|
|
|
|
}
|
2013-04-12 07:04:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
bool NativeWindowMac::IsFocused() const {
|
2014-04-11 04:45:48 +00:00
|
|
|
|
return [window_ isKeyWindow];
|
2013-05-16 14:56:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 07:04:46 +00:00
|
|
|
|
void NativeWindowMac::Show() {
|
2016-06-20 05:49:24 +00:00
|
|
|
|
if (is_modal() && parent()) {
|
2020-03-30 16:48:20 +00:00
|
|
|
|
NSWindow* window = parent()->GetNativeWindow().GetNativeNSWindow();
|
2016-09-29 18:49:24 +00:00
|
|
|
|
if ([window_ sheetParent] == nil)
|
2020-03-30 16:48:20 +00:00
|
|
|
|
[window beginSheet:window_
|
2019-01-09 20:25:19 +00:00
|
|
|
|
completionHandler:^(NSModalResponse){
|
|
|
|
|
}];
|
2016-06-20 05:49:24 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2017-09-14 05:43:22 +00:00
|
|
|
|
|
2023-10-05 13:19:57 +00:00
|
|
|
|
set_wants_to_be_visible(true);
|
|
|
|
|
|
2017-05-01 20:10:48 +00:00
|
|
|
|
// Reattach the window to the parent to actually show it.
|
|
|
|
|
if (parent())
|
|
|
|
|
InternalSetParentWindow(parent(), true);
|
2016-06-20 05:49:24 +00:00
|
|
|
|
|
2024-04-12 12:27:59 +00:00
|
|
|
|
// Panels receive key focus when shown but should not activate the app.
|
|
|
|
|
if (!IsPanel()) {
|
2024-05-29 06:31:11 +00:00
|
|
|
|
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
|
2024-04-12 12:27:59 +00:00
|
|
|
|
}
|
2014-10-17 14:51:20 +00:00
|
|
|
|
[window_ makeKeyAndOrderFront:nil];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NativeWindowMac::ShowInactive() {
|
2023-11-30 11:43:22 +00:00
|
|
|
|
set_wants_to_be_visible(true);
|
|
|
|
|
|
2017-05-01 21:01:48 +00:00
|
|
|
|
// Reattach the window to the parent to actually show it.
|
|
|
|
|
if (parent())
|
|
|
|
|
InternalSetParentWindow(parent(), true);
|
2017-09-14 05:43:22 +00:00
|
|
|
|
|
2024-07-30 10:37:27 +00:00
|
|
|
|
[window_ orderFrontRegardless];
|
2013-04-12 07:04:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NativeWindowMac::Hide() {
|
2021-04-16 15:42:09 +00:00
|
|
|
|
// If a sheet is attached to the window when we call [window_ orderOut:nil],
|
|
|
|
|
// the sheet won't be able to show again on the same window.
|
|
|
|
|
// Ensure it's closed before calling [window_ orderOut:nil].
|
2022-07-19 10:31:49 +00:00
|
|
|
|
if ([window_ attachedSheet])
|
|
|
|
|
[window_ endSheet:[window_ attachedSheet]];
|
2021-04-16 15:42:09 +00:00
|
|
|
|
|
2016-06-20 05:49:24 +00:00
|
|
|
|
if (is_modal() && parent()) {
|
|
|
|
|
[window_ orderOut:nil];
|
2019-01-09 20:25:19 +00:00
|
|
|
|
[parent()->GetNativeWindow().GetNativeNSWindow() endSheet:window_];
|
2016-06-20 05:49:24 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2017-09-14 05:43:22 +00:00
|
|
|
|
|
2023-10-05 13:19:57 +00:00
|
|
|
|
// If the window wants to be visible and has a parent, then the parent may
|
|
|
|
|
// order it back in (in the period between orderOut: and close).
|
|
|
|
|
set_wants_to_be_visible(false);
|
|
|
|
|
|
2023-05-31 09:57:44 +00:00
|
|
|
|
DetachChildren();
|
2021-06-24 18:43:28 +00:00
|
|
|
|
|
2022-02-21 09:27:45 +00:00
|
|
|
|
// Detach the window from the parent before.
|
2017-05-01 20:10:48 +00:00
|
|
|
|
if (parent())
|
|
|
|
|
InternalSetParentWindow(parent(), false);
|
2016-06-20 05:49:24 +00:00
|
|
|
|
|
2014-04-11 04:45:48 +00:00
|
|
|
|
[window_ orderOut:nil];
|
2013-04-12 07:04:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
bool NativeWindowMac::IsVisible() const {
|
2024-02-12 08:35:34 +00:00
|
|
|
|
bool occluded = [window_ occlusionState] == NSWindowOcclusionStateVisible;
|
|
|
|
|
return [window_ isVisible] && !occluded && !IsMinimized();
|
2013-10-03 00:27:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
bool NativeWindowMac::IsEnabled() const {
|
2016-06-20 05:49:24 +00:00
|
|
|
|
return [window_ attachedSheet] == nil;
|
2016-06-17 08:38:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-02-06 13:21:53 +00:00
|
|
|
|
void NativeWindowMac::SetEnabled(bool enable) {
|
2021-05-04 10:11:16 +00:00
|
|
|
|
if (!enable) {
|
2022-07-19 10:31:49 +00:00
|
|
|
|
NSRect frame = [window_ frame];
|
|
|
|
|
NSWindow* window =
|
|
|
|
|
[[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, frame.size.width,
|
|
|
|
|
frame.size.height)
|
|
|
|
|
styleMask:NSWindowStyleMaskTitled
|
|
|
|
|
backing:NSBackingStoreBuffered
|
|
|
|
|
defer:NO];
|
|
|
|
|
[window setAlphaValue:0.5];
|
|
|
|
|
|
|
|
|
|
[window_ beginSheet:window
|
2018-04-20 18:47:04 +00:00
|
|
|
|
completionHandler:^(NSModalResponse returnCode) {
|
2022-07-19 10:31:49 +00:00
|
|
|
|
NSLog(@"main window disabled");
|
2018-04-20 18:47:04 +00:00
|
|
|
|
return;
|
|
|
|
|
}];
|
2021-05-04 10:11:16 +00:00
|
|
|
|
} else if ([window_ attachedSheet]) {
|
|
|
|
|
[window_ endSheet:[window_ attachedSheet]];
|
2018-02-06 13:21:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 07:04:46 +00:00
|
|
|
|
void NativeWindowMac::Maximize() {
|
2022-03-29 23:08:34 +00:00
|
|
|
|
const bool is_visible = [window_ isVisible];
|
|
|
|
|
|
|
|
|
|
if (IsMaximized()) {
|
|
|
|
|
if (!is_visible)
|
|
|
|
|
ShowInactive();
|
2016-04-22 23:15:00 +00:00
|
|
|
|
return;
|
2022-03-29 23:08:34 +00:00
|
|
|
|
}
|
2016-04-22 23:15:00 +00:00
|
|
|
|
|
2018-08-24 21:33:27 +00:00
|
|
|
|
// Take note of the current window size
|
|
|
|
|
if (IsNormal())
|
2022-06-09 08:48:50 +00:00
|
|
|
|
UpdateWindowOriginalFrame();
|
2014-04-11 04:45:48 +00:00
|
|
|
|
[window_ zoom:nil];
|
2022-03-29 23:08:34 +00:00
|
|
|
|
|
|
|
|
|
if (!is_visible) {
|
|
|
|
|
ShowInactive();
|
|
|
|
|
NotifyWindowMaximize();
|
|
|
|
|
}
|
2013-04-12 07:04:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NativeWindowMac::Unmaximize() {
|
2022-03-30 22:29:02 +00:00
|
|
|
|
// Bail if the last user set bounds were the same size as the window
|
|
|
|
|
// screen (e.g. the user set the window to maximized via setBounds)
|
|
|
|
|
//
|
|
|
|
|
// Per docs during zoom:
|
|
|
|
|
// > If there’s no saved user state because there has been no previous
|
|
|
|
|
// > zoom,the size and location of the window don’t change.
|
|
|
|
|
//
|
|
|
|
|
// However, in classic Apple fashion, this is not the case in practice,
|
|
|
|
|
// and the frame inexplicably becomes very tiny. We should prevent
|
|
|
|
|
// zoom from being called if the window is being unmaximized and its
|
|
|
|
|
// unmaximized window bounds are themselves functionally maximized.
|
|
|
|
|
if (!IsMaximized() || user_set_bounds_maximized_)
|
2016-04-22 23:15:00 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2014-04-11 04:45:48 +00:00
|
|
|
|
[window_ zoom:nil];
|
2013-04-12 07:04:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
bool NativeWindowMac::IsMaximized() const {
|
2023-05-16 07:26:41 +00:00
|
|
|
|
// It's possible for [window_ isZoomed] to be true
|
|
|
|
|
// when the window is minimized or fullscreened.
|
|
|
|
|
if (IsMinimized() || IsFullscreen())
|
|
|
|
|
return false;
|
|
|
|
|
|
2022-06-03 07:47:19 +00:00
|
|
|
|
if (HasStyleMask(NSWindowStyleMaskResizable) != 0)
|
2016-03-05 06:39:13 +00:00
|
|
|
|
return [window_ isZoomed];
|
2021-09-21 10:04:32 +00:00
|
|
|
|
|
2024-02-09 09:29:14 +00:00
|
|
|
|
NSRect rectScreen = aspect_ratio() > 0.0
|
2021-09-21 10:04:32 +00:00
|
|
|
|
? default_frame_for_zoom()
|
|
|
|
|
: [[NSScreen mainScreen] visibleFrame];
|
|
|
|
|
|
|
|
|
|
return NSEqualRects([window_ frame], rectScreen);
|
2014-05-14 21:58:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 07:04:46 +00:00
|
|
|
|
void NativeWindowMac::Minimize() {
|
2018-08-24 21:33:27 +00:00
|
|
|
|
if (IsMinimized())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Take note of the current window size
|
|
|
|
|
if (IsNormal())
|
2022-06-09 08:48:50 +00:00
|
|
|
|
UpdateWindowOriginalFrame();
|
2014-04-11 04:45:48 +00:00
|
|
|
|
[window_ miniaturize:nil];
|
2013-04-12 07:04:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NativeWindowMac::Restore() {
|
2014-04-11 04:45:48 +00:00
|
|
|
|
[window_ deminiaturize:nil];
|
2013-04-12 07:04:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
bool NativeWindowMac::IsMinimized() const {
|
2014-07-26 05:58:26 +00:00
|
|
|
|
return [window_ isMiniaturized];
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-12 12:27:59 +00:00
|
|
|
|
bool NativeWindowMac::IsPanel() {
|
|
|
|
|
return [window_ isKindOfClass:[ElectronNSPanel class]];
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-31 08:43:42 +00:00
|
|
|
|
bool NativeWindowMac::HandleDeferredClose() {
|
|
|
|
|
if (has_deferred_window_close_) {
|
|
|
|
|
SetHasDeferredWindowClose(false);
|
|
|
|
|
Close();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-31 09:57:44 +00:00
|
|
|
|
void NativeWindowMac::RemoveChildWindow(NativeWindow* child) {
|
|
|
|
|
child_windows_.remove_if([&child](NativeWindow* w) { return (w == child); });
|
|
|
|
|
|
|
|
|
|
[window_ removeChildWindow:child->GetNativeWindow().GetNativeNSWindow()];
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-26 14:47:32 +00:00
|
|
|
|
void NativeWindowMac::RemoveChildFromParentWindow() {
|
|
|
|
|
if (parent() && !is_modal()) {
|
|
|
|
|
parent()->RemoveChildWindow(this);
|
|
|
|
|
NativeWindow::SetParentWindow(nullptr);
|
|
|
|
|
}
|
2023-06-08 10:18:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-31 09:57:44 +00:00
|
|
|
|
void NativeWindowMac::AttachChildren() {
|
|
|
|
|
for (auto* child : child_windows_) {
|
2023-10-05 13:19:57 +00:00
|
|
|
|
if (!static_cast<NativeWindowMac*>(child)->wants_to_be_visible())
|
|
|
|
|
continue;
|
|
|
|
|
|
2023-05-31 09:57:44 +00:00
|
|
|
|
auto* child_nswindow = child->GetNativeWindow().GetNativeNSWindow();
|
|
|
|
|
if ([child_nswindow parentWindow] == window_)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// Attaching a window as a child window resets its window level, so
|
|
|
|
|
// save and restore it afterwards.
|
|
|
|
|
NSInteger level = window_.level;
|
|
|
|
|
[window_ addChildWindow:child_nswindow ordered:NSWindowAbove];
|
|
|
|
|
[window_ setLevel:level];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NativeWindowMac::DetachChildren() {
|
|
|
|
|
// Hide all children before hiding/minimizing the window.
|
|
|
|
|
// NativeWidgetNSWindowBridge::NotifyVisibilityChangeDown()
|
|
|
|
|
// will DCHECK otherwise.
|
|
|
|
|
for (auto* child : child_windows_) {
|
|
|
|
|
[child->GetNativeWindow().GetNativeNSWindow() orderOut:nil];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-25 06:34:14 +00:00
|
|
|
|
void NativeWindowMac::SetFullScreen(bool fullscreen) {
|
2021-04-21 14:56:25 +00:00
|
|
|
|
// [NSWindow -toggleFullScreen] is an asynchronous operation, which means
|
|
|
|
|
// that it's possible to call it while a fullscreen transition is currently
|
|
|
|
|
// in process. This can create weird behavior (incl. phantom windows),
|
|
|
|
|
// so we want to schedule a transition for when the current one has completed.
|
2023-05-12 13:24:01 +00:00
|
|
|
|
if (fullscreen_transition_state() != FullScreenTransitionState::kNone) {
|
2021-04-21 14:56:25 +00:00
|
|
|
|
if (!pending_transitions_.empty()) {
|
|
|
|
|
bool last_pending = pending_transitions_.back();
|
|
|
|
|
// Only push new transitions if they're different than the last transition
|
|
|
|
|
// in the queue.
|
|
|
|
|
if (last_pending != fullscreen)
|
|
|
|
|
pending_transitions_.push(fullscreen);
|
|
|
|
|
} else {
|
|
|
|
|
pending_transitions_.push(fullscreen);
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-21 11:11:34 +00:00
|
|
|
|
if (fullscreen == IsFullscreen() || !IsFullScreenable())
|
2013-04-12 07:04:46 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2018-08-24 21:33:27 +00:00
|
|
|
|
// Take note of the current window size
|
|
|
|
|
if (IsNormal())
|
2022-06-09 08:48:50 +00:00
|
|
|
|
UpdateWindowOriginalFrame();
|
2021-04-21 14:56:25 +00:00
|
|
|
|
|
|
|
|
|
// This needs to be set here because it can be the case that
|
|
|
|
|
// SetFullScreen is called by a user before windowWillEnterFullScreen
|
|
|
|
|
// or windowWillExitFullScreen are invoked, and so a potential transition
|
|
|
|
|
// could be dropped.
|
|
|
|
|
fullscreen_transition_state_ = fullscreen
|
2023-05-12 13:24:01 +00:00
|
|
|
|
? FullScreenTransitionState::kEntering
|
|
|
|
|
: FullScreenTransitionState::kExiting;
|
2021-04-21 14:56:25 +00:00
|
|
|
|
|
2023-09-11 07:38:10 +00:00
|
|
|
|
if (![window_ toggleFullScreenMode:nil])
|
|
|
|
|
fullscreen_transition_state_ = FullScreenTransitionState::kNone;
|
2013-04-12 07:04:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-04-21 13:35:36 +00:00
|
|
|
|
bool NativeWindowMac::IsFullscreen() const {
|
2022-06-03 07:47:19 +00:00
|
|
|
|
return HasStyleMask(NSWindowStyleMaskFullScreen);
|
2013-04-12 07:04:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-01-15 04:54:12 +00:00
|
|
|
|
void NativeWindowMac::SetBounds(const gfx::Rect& bounds, bool animate) {
|
2016-07-11 07:44:42 +00:00
|
|
|
|
// Do nothing if in fullscreen mode.
|
|
|
|
|
if (IsFullscreen())
|
|
|
|
|
return;
|
|
|
|
|
|
2016-07-07 11:02:18 +00:00
|
|
|
|
// Check size constraints since setFrame does not check it.
|
|
|
|
|
gfx::Size size = bounds.size();
|
|
|
|
|
size.SetToMax(GetMinimumSize());
|
|
|
|
|
gfx::Size max_size = GetMaximumSize();
|
|
|
|
|
if (!max_size.IsEmpty())
|
|
|
|
|
size.SetToMin(max_size);
|
|
|
|
|
|
|
|
|
|
NSRect cocoa_bounds = NSMakeRect(bounds.x(), 0, size.width(), size.height());
|
2015-05-01 14:40:46 +00:00
|
|
|
|
// Flip coordinates based on the primary screen.
|
2016-12-20 21:49:35 +00:00
|
|
|
|
NSScreen* screen = [[NSScreen screens] firstObject];
|
2018-04-20 18:47:04 +00:00
|
|
|
|
cocoa_bounds.origin.y = NSHeight([screen frame]) - size.height() - bounds.y();
|
2015-05-01 14:40:46 +00:00
|
|
|
|
|
2016-01-15 04:54:12 +00:00
|
|
|
|
[window_ setFrame:cocoa_bounds display:YES animate:animate];
|
2022-03-30 22:29:02 +00:00
|
|
|
|
user_set_bounds_maximized_ = IsMaximized() ? true : false;
|
2022-06-09 08:48:50 +00:00
|
|
|
|
UpdateWindowOriginalFrame();
|
2015-05-01 10:50:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
gfx::Rect NativeWindowMac::GetBounds() const {
|
2015-05-01 14:40:46 +00:00
|
|
|
|
NSRect frame = [window_ frame];
|
2015-05-04 04:06:03 +00:00
|
|
|
|
gfx::Rect bounds(frame.origin.x, 0, NSWidth(frame), NSHeight(frame));
|
2016-12-20 21:49:35 +00:00
|
|
|
|
NSScreen* screen = [[NSScreen screens] firstObject];
|
2015-05-04 04:06:03 +00:00
|
|
|
|
bounds.set_y(NSHeight([screen frame]) - NSMaxY(frame));
|
|
|
|
|
return bounds;
|
2015-05-01 10:50:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
bool NativeWindowMac::IsNormal() const {
|
2018-08-24 21:33:27 +00:00
|
|
|
|
return NativeWindow::IsNormal() && !IsSimpleFullScreen();
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
gfx::Rect NativeWindowMac::GetNormalBounds() const {
|
2018-08-24 21:33:27 +00:00
|
|
|
|
if (IsNormal()) {
|
2018-09-26 23:00:57 +00:00
|
|
|
|
return GetBounds();
|
2018-08-24 21:33:27 +00:00
|
|
|
|
}
|
|
|
|
|
NSRect frame = original_frame_;
|
|
|
|
|
gfx::Rect bounds(frame.origin.x, 0, NSWidth(frame), NSHeight(frame));
|
|
|
|
|
NSScreen* screen = [[NSScreen screens] firstObject];
|
|
|
|
|
bounds.set_y(NSHeight([screen frame]) - NSMaxY(frame));
|
|
|
|
|
return bounds;
|
|
|
|
|
// Works on OS_WIN !
|
|
|
|
|
// return widget()->GetRestoredBounds();
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-27 09:11:24 +00:00
|
|
|
|
void NativeWindowMac::SetSizeConstraints(
|
|
|
|
|
const extensions::SizeConstraints& window_constraints) {
|
|
|
|
|
// Apply the size constraints to NSWindow.
|
|
|
|
|
if (window_constraints.HasMinimumSize())
|
|
|
|
|
[window_ setMinSize:window_constraints.GetMinimumSize().ToCGSize()];
|
|
|
|
|
if (window_constraints.HasMaximumSize())
|
|
|
|
|
[window_ setMaxSize:window_constraints.GetMaximumSize().ToCGSize()];
|
|
|
|
|
NativeWindow::SetSizeConstraints(window_constraints);
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-05 08:19:01 +00:00
|
|
|
|
void NativeWindowMac::SetContentSizeConstraints(
|
|
|
|
|
const extensions::SizeConstraints& size_constraints) {
|
2015-10-06 07:15:23 +00:00
|
|
|
|
auto convertSize = [this](const gfx::Size& size) {
|
|
|
|
|
// Our frameless window still has titlebar attached, so setting contentSize
|
|
|
|
|
// will result in actual content size being larger.
|
|
|
|
|
if (!has_frame()) {
|
|
|
|
|
NSRect frame = NSMakeRect(0, 0, size.width(), size.height());
|
2018-05-02 12:28:28 +00:00
|
|
|
|
NSRect content = [window_ originalContentRectForFrameRect:frame];
|
2015-10-06 07:15:23 +00:00
|
|
|
|
return content.size;
|
|
|
|
|
} else {
|
|
|
|
|
return NSMakeSize(size.width(), size.height());
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2023-09-27 09:11:24 +00:00
|
|
|
|
// Apply the size constraints to NSWindow.
|
2014-04-11 04:45:48 +00:00
|
|
|
|
NSView* content = [window_ contentView];
|
2015-10-05 08:19:01 +00:00
|
|
|
|
if (size_constraints.HasMinimumSize()) {
|
2015-10-06 07:15:23 +00:00
|
|
|
|
NSSize min_size = convertSize(size_constraints.GetMinimumSize());
|
2015-10-05 12:09:29 +00:00
|
|
|
|
[window_ setContentMinSize:[content convertSize:min_size toView:nil]];
|
2015-10-05 08:19:01 +00:00
|
|
|
|
}
|
|
|
|
|
if (size_constraints.HasMaximumSize()) {
|
2015-10-06 07:15:23 +00:00
|
|
|
|
NSSize max_size = convertSize(size_constraints.GetMaximumSize());
|
2015-10-05 12:09:29 +00:00
|
|
|
|
[window_ setContentMaxSize:[content convertSize:max_size toView:nil]];
|
2015-10-05 08:19:01 +00:00
|
|
|
|
}
|
|
|
|
|
NativeWindow::SetContentSizeConstraints(size_constraints);
|
2013-04-18 07:38:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-15 06:51:15 +00:00
|
|
|
|
bool NativeWindowMac::MoveAbove(const std::string& sourceId) {
|
|
|
|
|
const content::DesktopMediaID id = content::DesktopMediaID::Parse(sourceId);
|
|
|
|
|
if (id.type != content::DesktopMediaID::TYPE_WINDOW)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// Check if the window source is valid.
|
|
|
|
|
const CGWindowID window_id = id.id;
|
|
|
|
|
if (!webrtc::GetWindowOwnerPid(window_id))
|
|
|
|
|
return false;
|
|
|
|
|
|
2024-08-05 07:57:16 +00:00
|
|
|
|
[window_ orderWindowByShuffling:NSWindowAbove relativeTo:window_id];
|
2019-08-15 06:51:15 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-20 18:47:04 +00:00
|
|
|
|
void NativeWindowMac::MoveTop() {
|
2024-08-05 07:57:16 +00:00
|
|
|
|
[window_ orderWindowByShuffling:NSWindowAbove relativeTo:0];
|
2018-04-03 13:04:32 +00:00
|
|
|
|
}
|
2018-04-24 10:00:44 +00:00
|
|
|
|
|
2013-04-12 07:04:46 +00:00
|
|
|
|
void NativeWindowMac::SetResizable(bool resizable) {
|
2022-06-14 16:24:52 +00:00
|
|
|
|
ScopedDisableResize disable_resize;
|
2018-09-26 23:00:57 +00:00
|
|
|
|
SetStyleMask(resizable, NSWindowStyleMaskResizable);
|
2023-07-25 16:18:36 +00:00
|
|
|
|
|
2023-08-24 20:54:08 +00:00
|
|
|
|
bool was_fullscreenable = IsFullScreenable();
|
|
|
|
|
|
2023-07-25 16:18:36 +00:00
|
|
|
|
// Right now, resizable and fullscreenable are decoupled in
|
|
|
|
|
// documentation and on Windows/Linux. Chromium disables
|
2023-08-24 20:54:08 +00:00
|
|
|
|
// fullscreen collection behavior as well as the maximize traffic
|
|
|
|
|
// light in SetCanResize if resizability is false on macOS unless
|
|
|
|
|
// the window is both resizable and maximizable. We want consistent
|
|
|
|
|
// cross-platform behavior, so if resizability is disabled we disable
|
|
|
|
|
// the maximize button and ensure fullscreenability matches user setting.
|
2021-06-03 08:05:04 +00:00
|
|
|
|
SetCanResize(resizable);
|
2023-08-24 20:54:08 +00:00
|
|
|
|
SetFullScreenable(was_fullscreenable);
|
2024-01-05 17:15:35 +00:00
|
|
|
|
UpdateZoomButton();
|
2013-04-12 07:04:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
bool NativeWindowMac::IsResizable() const {
|
2022-06-03 07:47:19 +00:00
|
|
|
|
bool in_fs_transition =
|
2023-05-12 13:24:01 +00:00
|
|
|
|
fullscreen_transition_state() != FullScreenTransitionState::kNone;
|
2022-06-03 07:47:19 +00:00
|
|
|
|
bool has_rs_mask = HasStyleMask(NSWindowStyleMaskResizable);
|
|
|
|
|
return has_rs_mask && !IsFullscreen() && !in_fs_transition;
|
2013-04-18 07:38:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-01-18 22:46:35 +00:00
|
|
|
|
void NativeWindowMac::SetMovable(bool movable) {
|
|
|
|
|
[window_ setMovable:movable];
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
bool NativeWindowMac::IsMovable() const {
|
2016-01-18 22:46:35 +00:00
|
|
|
|
return [window_ isMovable];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NativeWindowMac::SetMinimizable(bool minimizable) {
|
2022-06-01 06:12:47 +00:00
|
|
|
|
SetStyleMask(minimizable, NSWindowStyleMaskMiniaturizable);
|
2016-01-18 22:46:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
bool NativeWindowMac::IsMinimizable() const {
|
2022-06-03 07:47:19 +00:00
|
|
|
|
return HasStyleMask(NSWindowStyleMaskMiniaturizable);
|
2016-01-18 22:46:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-01-22 21:24:33 +00:00
|
|
|
|
void NativeWindowMac::SetMaximizable(bool maximizable) {
|
2020-03-17 17:58:57 +00:00
|
|
|
|
maximizable_ = maximizable;
|
2024-01-05 17:15:35 +00:00
|
|
|
|
UpdateZoomButton();
|
2016-01-22 21:24:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
bool NativeWindowMac::IsMaximizable() const {
|
2016-01-22 21:24:33 +00:00
|
|
|
|
return [[window_ standardWindowButton:NSWindowZoomButton] isEnabled];
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-05 17:15:35 +00:00
|
|
|
|
void NativeWindowMac::UpdateZoomButton() {
|
|
|
|
|
[[window_ standardWindowButton:NSWindowZoomButton]
|
2024-01-17 17:23:41 +00:00
|
|
|
|
setEnabled:HasStyleMask(NSWindowStyleMaskResizable) &&
|
|
|
|
|
(CanMaximize() || IsFullScreenable())];
|
2024-01-05 17:15:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-01-23 07:47:37 +00:00
|
|
|
|
void NativeWindowMac::SetFullScreenable(bool fullscreenable) {
|
2018-04-20 18:47:04 +00:00
|
|
|
|
SetCollectionBehavior(fullscreenable,
|
|
|
|
|
NSWindowCollectionBehaviorFullScreenPrimary);
|
2016-01-23 11:12:19 +00:00
|
|
|
|
// On EL Capitan this flag is required to hide fullscreen button.
|
2018-04-20 18:47:04 +00:00
|
|
|
|
SetCollectionBehavior(!fullscreenable,
|
|
|
|
|
NSWindowCollectionBehaviorFullScreenAuxiliary);
|
2024-01-05 17:15:35 +00:00
|
|
|
|
|
|
|
|
|
UpdateZoomButton();
|
2016-01-22 21:24:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
bool NativeWindowMac::IsFullScreenable() const {
|
2016-01-23 11:12:19 +00:00
|
|
|
|
NSUInteger collectionBehavior = [window_ collectionBehavior];
|
|
|
|
|
return collectionBehavior & NSWindowCollectionBehaviorFullScreenPrimary;
|
2016-01-22 21:24:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-01-18 22:46:35 +00:00
|
|
|
|
void NativeWindowMac::SetClosable(bool closable) {
|
2018-09-26 23:00:57 +00:00
|
|
|
|
SetStyleMask(closable, NSWindowStyleMaskClosable);
|
2016-01-18 22:46:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
bool NativeWindowMac::IsClosable() const {
|
2022-06-03 07:47:19 +00:00
|
|
|
|
return HasStyleMask(NSWindowStyleMaskClosable);
|
2016-01-18 22:46:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-24 22:58:51 +00:00
|
|
|
|
void NativeWindowMac::SetAlwaysOnTop(ui::ZOrderLevel z_order,
|
2019-10-18 19:57:34 +00:00
|
|
|
|
const std::string& level_name,
|
|
|
|
|
int relative_level) {
|
|
|
|
|
if (z_order == ui::ZOrderLevel::kNormal) {
|
|
|
|
|
SetWindowLevel(NSNormalWindowLevel);
|
|
|
|
|
return;
|
2016-09-22 16:22:28 +00:00
|
|
|
|
}
|
2017-01-24 04:36:09 +00:00
|
|
|
|
|
2019-10-18 19:57:34 +00:00
|
|
|
|
int level = NSNormalWindowLevel;
|
|
|
|
|
if (level_name == "floating") {
|
|
|
|
|
level = NSFloatingWindowLevel;
|
|
|
|
|
} else if (level_name == "torn-off-menu") {
|
|
|
|
|
level = NSTornOffMenuWindowLevel;
|
|
|
|
|
} else if (level_name == "modal-panel") {
|
|
|
|
|
level = NSModalPanelWindowLevel;
|
|
|
|
|
} else if (level_name == "main-menu") {
|
|
|
|
|
level = NSMainMenuWindowLevel;
|
|
|
|
|
} else if (level_name == "status") {
|
|
|
|
|
level = NSStatusWindowLevel;
|
|
|
|
|
} else if (level_name == "pop-up-menu") {
|
|
|
|
|
level = NSPopUpMenuWindowLevel;
|
|
|
|
|
} else if (level_name == "screen-saver") {
|
|
|
|
|
level = NSScreenSaverWindowLevel;
|
2017-01-24 04:36:09 +00:00
|
|
|
|
}
|
2019-07-27 05:25:51 +00:00
|
|
|
|
|
2019-10-18 19:57:34 +00:00
|
|
|
|
SetWindowLevel(level + relative_level);
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
std::string NativeWindowMac::GetAlwaysOnTopLevel() const {
|
2021-06-23 06:09:09 +00:00
|
|
|
|
std::string level_name = "normal";
|
|
|
|
|
|
|
|
|
|
int level = [window_ level];
|
|
|
|
|
if (level == NSFloatingWindowLevel) {
|
|
|
|
|
level_name = "floating";
|
|
|
|
|
} else if (level == NSTornOffMenuWindowLevel) {
|
|
|
|
|
level_name = "torn-off-menu";
|
|
|
|
|
} else if (level == NSModalPanelWindowLevel) {
|
|
|
|
|
level_name = "modal-panel";
|
|
|
|
|
} else if (level == NSMainMenuWindowLevel) {
|
|
|
|
|
level_name = "main-menu";
|
|
|
|
|
} else if (level == NSStatusWindowLevel) {
|
|
|
|
|
level_name = "status";
|
|
|
|
|
} else if (level == NSPopUpMenuWindowLevel) {
|
|
|
|
|
level_name = "pop-up-menu";
|
|
|
|
|
} else if (level == NSScreenSaverWindowLevel) {
|
|
|
|
|
level_name = "screen-saver";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return level_name;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-18 19:57:34 +00:00
|
|
|
|
void NativeWindowMac::SetWindowLevel(int unbounded_level) {
|
|
|
|
|
int level = std::min(
|
|
|
|
|
std::max(unbounded_level, CGWindowLevelForKey(kCGMinimumWindowLevelKey)),
|
|
|
|
|
CGWindowLevelForKey(kCGMaximumWindowLevelKey));
|
|
|
|
|
ui::ZOrderLevel z_order_level = level == NSNormalWindowLevel
|
|
|
|
|
? ui::ZOrderLevel::kNormal
|
|
|
|
|
: ui::ZOrderLevel::kFloatingWindow;
|
|
|
|
|
bool did_z_order_level_change = z_order_level != GetZOrderLevel();
|
|
|
|
|
|
|
|
|
|
was_maximizable_ = IsMaximizable();
|
|
|
|
|
|
|
|
|
|
// We need to explicitly keep the NativeWidget up to date, since it stores the
|
|
|
|
|
// window level in a local variable, rather than reading it from the NSWindow.
|
|
|
|
|
// Unfortunately, it results in a second setLevel call. It's not ideal, but we
|
|
|
|
|
// don't expect this to cause any user-visible jank.
|
|
|
|
|
widget()->SetZOrderLevel(z_order_level);
|
|
|
|
|
[window_ setLevel:level];
|
|
|
|
|
|
|
|
|
|
// Set level will make the zoom button revert to default, probably
|
|
|
|
|
// a bug of Cocoa or macOS.
|
2020-03-17 17:58:57 +00:00
|
|
|
|
SetMaximizable(was_maximizable_);
|
2019-10-18 19:57:34 +00:00
|
|
|
|
|
2019-07-27 05:25:51 +00:00
|
|
|
|
// This must be notified at the very end or IsAlwaysOnTop
|
|
|
|
|
// will not yet have been updated to reflect the new status
|
2019-10-18 19:57:34 +00:00
|
|
|
|
if (did_z_order_level_change)
|
2019-07-27 05:25:51 +00:00
|
|
|
|
NativeWindow::NotifyWindowAlwaysOnTopChanged();
|
2013-04-12 07:04:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
ui::ZOrderLevel NativeWindowMac::GetZOrderLevel() const {
|
2019-07-24 22:58:51 +00:00
|
|
|
|
return widget()->GetZOrderLevel();
|
2013-04-18 07:38:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-05-10 12:34:05 +00:00
|
|
|
|
void NativeWindowMac::Center() {
|
2014-04-11 04:45:48 +00:00
|
|
|
|
[window_ center];
|
2013-04-12 07:04:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-14 03:41:24 +00:00
|
|
|
|
void NativeWindowMac::Invalidate() {
|
2017-02-14 19:09:15 +00:00
|
|
|
|
[[window_ contentView] setNeedsDisplay:YES];
|
2017-02-14 03:41:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 07:04:46 +00:00
|
|
|
|
void NativeWindowMac::SetTitle(const std::string& title) {
|
2016-06-17 01:54:50 +00:00
|
|
|
|
[window_ setTitle:base::SysUTF8ToNSString(title)];
|
2021-08-04 00:31:12 +00:00
|
|
|
|
if (buttons_proxy_)
|
|
|
|
|
[buttons_proxy_ redraw];
|
2013-04-12 07:04:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
std::string NativeWindowMac::GetTitle() const {
|
2018-04-20 18:47:04 +00:00
|
|
|
|
return base::SysNSStringToUTF8([window_ title]);
|
2013-04-18 06:30:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 07:04:46 +00:00
|
|
|
|
void NativeWindowMac::FlashFrame(bool flash) {
|
|
|
|
|
if (flash) {
|
2024-04-17 16:42:34 +00:00
|
|
|
|
attention_request_id_ = [NSApp requestUserAttention:NSCriticalRequest];
|
2013-04-12 07:04:46 +00:00
|
|
|
|
} else {
|
|
|
|
|
[NSApp cancelUserAttentionRequest:attention_request_id_];
|
|
|
|
|
attention_request_id_ = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-20 18:47:04 +00:00
|
|
|
|
void NativeWindowMac::SetSkipTaskbar(bool skip) {}
|
2014-06-16 02:29:51 +00:00
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
bool NativeWindowMac::IsExcludedFromShownWindowsMenu() const {
|
2019-03-27 12:10:23 +00:00
|
|
|
|
NSWindow* window = GetNativeWindow().GetNativeNSWindow();
|
|
|
|
|
return [window isExcludedFromWindowsMenu];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NativeWindowMac::SetExcludedFromShownWindowsMenu(bool excluded) {
|
|
|
|
|
NSWindow* window = GetNativeWindow().GetNativeNSWindow();
|
|
|
|
|
[window setExcludedFromWindowsMenu:excluded];
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-16 09:41:59 +00:00
|
|
|
|
void NativeWindowMac::OnDisplayMetricsChanged(const display::Display& display,
|
|
|
|
|
uint32_t changed_metrics) {
|
|
|
|
|
// We only want to force screen recalibration if we're in simpleFullscreen
|
|
|
|
|
// mode.
|
|
|
|
|
if (!is_simple_fullscreen_)
|
|
|
|
|
return;
|
|
|
|
|
|
2022-05-17 16:48:40 +00:00
|
|
|
|
content::GetUIThreadTaskRunner({})->PostTask(
|
|
|
|
|
FROM_HERE, base::BindOnce(&NativeWindow::UpdateFrame, GetWeakPtr()));
|
2021-03-16 09:41:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-13 06:28:33 +00:00
|
|
|
|
void NativeWindowMac::SetSimpleFullScreen(bool simple_fullscreen) {
|
2019-01-09 20:25:19 +00:00
|
|
|
|
NSWindow* window = GetNativeWindow().GetNativeNSWindow();
|
2017-08-13 06:28:33 +00:00
|
|
|
|
|
|
|
|
|
if (simple_fullscreen && !is_simple_fullscreen_) {
|
|
|
|
|
is_simple_fullscreen_ = true;
|
|
|
|
|
|
2018-10-10 05:38:52 +00:00
|
|
|
|
// Take note of the current window size and level
|
|
|
|
|
if (IsNormal()) {
|
2022-06-09 08:48:50 +00:00
|
|
|
|
UpdateWindowOriginalFrame();
|
2018-10-10 05:38:52 +00:00
|
|
|
|
original_level_ = [window_ level];
|
|
|
|
|
}
|
2017-08-13 06:28:33 +00:00
|
|
|
|
|
|
|
|
|
simple_fullscreen_options_ = [NSApp currentSystemPresentationOptions];
|
2017-09-12 18:27:30 +00:00
|
|
|
|
simple_fullscreen_mask_ = [window styleMask];
|
2017-08-13 06:28:33 +00:00
|
|
|
|
|
2018-04-20 18:47:04 +00:00
|
|
|
|
// We can simulate the pre-Lion fullscreen by auto-hiding the dock and menu
|
|
|
|
|
// bar
|
2017-08-13 06:28:33 +00:00
|
|
|
|
NSApplicationPresentationOptions options =
|
2019-05-14 15:49:46 +00:00
|
|
|
|
NSApplicationPresentationAutoHideDock |
|
2017-08-13 06:28:33 +00:00
|
|
|
|
NSApplicationPresentationAutoHideMenuBar;
|
|
|
|
|
[NSApp setPresentationOptions:options];
|
|
|
|
|
|
|
|
|
|
was_maximizable_ = IsMaximizable();
|
|
|
|
|
was_movable_ = IsMovable();
|
|
|
|
|
|
|
|
|
|
NSRect fullscreenFrame = [window.screen frame];
|
|
|
|
|
|
2018-10-10 05:38:52 +00:00
|
|
|
|
// If our app has dock hidden, set the window level higher so another app's
|
|
|
|
|
// menu bar doesn't appear on top of our fullscreen app.
|
|
|
|
|
if ([[NSRunningApplication currentApplication] activationPolicy] !=
|
|
|
|
|
NSApplicationActivationPolicyRegular) {
|
|
|
|
|
window.level = NSPopUpMenuWindowLevel;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-25 23:29:34 +00:00
|
|
|
|
// Always hide the titlebar in simple fullscreen mode.
|
|
|
|
|
//
|
|
|
|
|
// Note that we must remove the NSWindowStyleMaskTitled style instead of
|
|
|
|
|
// using the [window_ setTitleVisibility:], as the latter would leave the
|
|
|
|
|
// window with rounded corners.
|
|
|
|
|
SetStyleMask(false, NSWindowStyleMaskTitled);
|
|
|
|
|
|
2021-01-30 23:15:10 +00:00
|
|
|
|
if (!window_button_visibility_.has_value()) {
|
2018-07-03 08:20:56 +00:00
|
|
|
|
// Lets keep previous behaviour - hide window controls in titled
|
|
|
|
|
// fullscreen mode when not specified otherwise.
|
2021-01-19 10:12:09 +00:00
|
|
|
|
InternalSetWindowButtonVisibility(false);
|
2017-08-13 06:28:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-20 18:47:04 +00:00
|
|
|
|
[window setFrame:fullscreenFrame display:YES animate:YES];
|
2017-08-13 06:28:33 +00:00
|
|
|
|
|
2017-09-12 18:27:30 +00:00
|
|
|
|
// Fullscreen windows can't be resized, minimized, maximized, or moved
|
|
|
|
|
SetMinimizable(false);
|
|
|
|
|
SetResizable(false);
|
|
|
|
|
SetMaximizable(false);
|
|
|
|
|
SetMovable(false);
|
2017-08-13 06:28:33 +00:00
|
|
|
|
} else if (!simple_fullscreen && is_simple_fullscreen_) {
|
|
|
|
|
is_simple_fullscreen_ = false;
|
|
|
|
|
|
2018-04-20 18:47:04 +00:00
|
|
|
|
[window setFrame:original_frame_ display:YES animate:YES];
|
2018-10-10 05:38:52 +00:00
|
|
|
|
window.level = original_level_;
|
2017-08-13 06:28:33 +00:00
|
|
|
|
|
|
|
|
|
[NSApp setPresentationOptions:simple_fullscreen_options_];
|
2017-09-12 18:27:30 +00:00
|
|
|
|
|
|
|
|
|
// Restore original style mask
|
|
|
|
|
ScopedDisableResize disable_resize;
|
|
|
|
|
[window_ setStyleMask:simple_fullscreen_mask_];
|
|
|
|
|
|
2017-08-13 06:28:33 +00:00
|
|
|
|
// Restore window manipulation abilities
|
2017-09-12 18:27:30 +00:00
|
|
|
|
SetMaximizable(was_maximizable_);
|
|
|
|
|
SetMovable(was_movable_);
|
2021-08-25 23:29:34 +00:00
|
|
|
|
|
|
|
|
|
// Restore default window controls visibility state.
|
|
|
|
|
if (!window_button_visibility_.has_value()) {
|
|
|
|
|
bool visibility;
|
|
|
|
|
if (has_frame())
|
|
|
|
|
visibility = true;
|
|
|
|
|
else
|
|
|
|
|
visibility = title_bar_style_ != TitleBarStyle::kNormal;
|
|
|
|
|
InternalSetWindowButtonVisibility(visibility);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (buttons_proxy_)
|
|
|
|
|
[buttons_proxy_ redraw];
|
2017-08-13 06:28:33 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
bool NativeWindowMac::IsSimpleFullScreen() const {
|
2017-08-13 06:28:33 +00:00
|
|
|
|
return is_simple_fullscreen_;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 07:04:46 +00:00
|
|
|
|
void NativeWindowMac::SetKiosk(bool kiosk) {
|
2014-06-09 05:04:59 +00:00
|
|
|
|
if (kiosk && !is_kiosk_) {
|
|
|
|
|
kiosk_options_ = [NSApp currentSystemPresentationOptions];
|
2013-04-12 07:04:46 +00:00
|
|
|
|
NSApplicationPresentationOptions options =
|
2019-05-14 15:49:46 +00:00
|
|
|
|
NSApplicationPresentationHideDock |
|
|
|
|
|
NSApplicationPresentationHideMenuBar |
|
|
|
|
|
NSApplicationPresentationDisableAppleMenu |
|
|
|
|
|
NSApplicationPresentationDisableProcessSwitching |
|
|
|
|
|
NSApplicationPresentationDisableForceQuit |
|
|
|
|
|
NSApplicationPresentationDisableSessionTermination |
|
2013-04-12 07:04:46 +00:00
|
|
|
|
NSApplicationPresentationDisableHideApplication;
|
|
|
|
|
[NSApp setPresentationOptions:options];
|
|
|
|
|
is_kiosk_ = true;
|
2023-05-09 16:28:37 +00:00
|
|
|
|
fullscreen_before_kiosk_ = IsFullscreen();
|
|
|
|
|
if (!fullscreen_before_kiosk_)
|
|
|
|
|
SetFullScreen(true);
|
2014-06-09 05:04:59 +00:00
|
|
|
|
} else if (!kiosk && is_kiosk_) {
|
2021-04-21 14:56:25 +00:00
|
|
|
|
is_kiosk_ = false;
|
2023-05-09 16:28:37 +00:00
|
|
|
|
if (!fullscreen_before_kiosk_)
|
|
|
|
|
SetFullScreen(false);
|
2023-01-16 09:06:43 +00:00
|
|
|
|
|
|
|
|
|
// Set presentation options *after* asynchronously exiting
|
|
|
|
|
// fullscreen to ensure they take effect.
|
|
|
|
|
[NSApp setPresentationOptions:kiosk_options_];
|
2013-04-12 07:04:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
bool NativeWindowMac::IsKiosk() const {
|
2013-04-12 07:04:46 +00:00
|
|
|
|
return is_kiosk_;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-06 04:21:47 +00:00
|
|
|
|
void NativeWindowMac::SetBackgroundColor(SkColor color) {
|
chore: bump chromium to 118.0.5975.0 (main) (#39531)
* chore: bump chromium in DEPS to 118.0.5951.0
* chore: update printing.patch
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4727894
No logic changes, but patch needed to be manually re-applied due to upstream code shear
* chore: update port_autofill_colors_to_the_color_pipeline.patch
No manual changes; patch applied with fuzz
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5953.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5955.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5957.0
* chore: update patches
* chore: include path of native_web_keyboard_event.h
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4758689
* chore: remove reference to eextensions/browser/notification-types.h
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4771627
* chore: update references to renamed upstream field NativeWebKeyboardEvent.skip_if_unhandled (formerly known as skip_in_browser
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4758689
Need a second pair of eyes on this commit. In particular the reference in content_converter.cc, skipInBrowser, seems to not be set or documented anywhere? Is this unused/vestigal code?
* chore: sync signature of ElectronExtensionsBrowserClient::IsValidContext() to upstream change
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4784198
* chore: add auto_pip_setting_helper.[cc,h] to chromium_src build
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4688277
Exiting upstream code used by chromium_src now depends on this new upstream class
* chore: bump chromium in DEPS to 118.0.5959.0
* chore: update add_maximized_parameter_to_linuxui_getwindowframeprovider.patch
Xref: add_maximized_parameter_to_linuxui_getwindowframeprovider.patch
manually adjust patch to minor upstream chagnes
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5961.0
* chore: bump chromium in DEPS to 118.0.5963.0
* chore: update patches
* 4780994: Rename various base files to "apple" since iOS uses them too
https://chromium-review.googlesource.com/c/chromium/src/+/4780994
* Many files moved from `mac` -> `apple`
This commit follows a handful of CLs that simply rename files/symbols to change `mac`
to `apple`
to signify their use across both macOS and iOS:
- 4784010: Move scoped_nsautorelease_pool to base/apple, leave a forwarding header
- 4790744: Move foundation_util to base/apple, leave a forwarding header
- 4790741: Move scoped_cftypreref to base/apple, leave a forwarding header
- 4787627: Move and rename macOS+iOS base/ files in PA to "apple"
- 4780399: Move OSStatus logging to base/apple
- 4787387: Remove forwarding headers
- 4781113: Rename message_pump_mac to "apple" because iOS uses it too
* fixup minor patch update error
A function param got dropped from this patch somewhere earlier
* chore: bump chromium in DEPS to 118.0.5965.2
* chore: update patches
* 4799213: Move ScopedTypeRef and ScopedCFTypeRef into base::apple::
https://chromium-review.googlesource.com/c/chromium/src/+/4799213
* Fix removed include to BrowserContext
In crrev.com/c/4767962 an include to BrowserContext was removed,
which was necessary for compilation. This broke only for us because
"chrome/browser/profiles/profile.h" includes that class, but we remove
all references to profiles.
* chore: bump chromium in DEPS to 118.0.5967.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5969.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5971.0
* chore: bump chromium in DEPS to 118.0.5973.0
* chore: update patches
* 4772121: [OOPIF PDF] Replace PDFWebContentsHelper with PDFDocumentHelper
https://chromium-review.googlesource.com/c/chromium/src/+/4772121
* 4811164: [Extensions] Do some cleanup in ChromeManagementAPIDelegate.
https://chromium-review.googlesource.com/c/chromium/src/+/4811164
* 4809488: Remove duplicate dnd functionality between Web and Renderer prefs
https://chromium-review.googlesource.com/c/chromium/src/+/4809488
Given that this is no longer an option of web preferences, we should
consider deprecating this option and then removing it.
* chore: bump chromium in DEPS to 118.0.5975.0
* chore: update patches
* fixup! chore: add auto_pip_settings_helper.{cc|h} to chromium_src build
* Reland "[windows] Remove RegKey::DeleteEmptyKey"
Refs https://chromium-review.googlesource.com/c/chromium/src/+/4813255
* Ensure StrCat means StrCat
Refs https://chromium-review.googlesource.com/c/chromium/src/+/1117180
* fixup! Remove RegKey::DeleteEmptyKey
* Consistently reject large p and large q in DH
Refs https://boringssl-review.googlesource.com/c/boringssl/+/62226
---------
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: clavin <clavin@electronjs.org>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
2023-09-01 06:54:59 +00:00
|
|
|
|
base::apple::ScopedCFTypeRef<CGColorRef> cgcolor(
|
2018-04-24 11:08:14 +00:00
|
|
|
|
skia::CGColorCreateFromSkColor(color));
|
2023-11-14 21:21:32 +00:00
|
|
|
|
[[[window_ contentView] layer] setBackgroundColor:cgcolor.get()];
|
2015-10-23 03:35:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
SkColor NativeWindowMac::GetBackgroundColor() const {
|
2021-03-15 00:26:47 +00:00
|
|
|
|
CGColorRef color = [[[window_ contentView] layer] backgroundColor];
|
|
|
|
|
if (!color)
|
|
|
|
|
return SK_ColorTRANSPARENT;
|
|
|
|
|
return skia::CGColorRefToSkColor(color);
|
2019-12-13 16:08:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-01-23 00:15:49 +00:00
|
|
|
|
void NativeWindowMac::SetHasShadow(bool has_shadow) {
|
|
|
|
|
[window_ setHasShadow:has_shadow];
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
bool NativeWindowMac::HasShadow() const {
|
2016-01-23 00:15:49 +00:00
|
|
|
|
return [window_ hasShadow];
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-01 18:24:44 +00:00
|
|
|
|
void NativeWindowMac::InvalidateShadow() {
|
|
|
|
|
[window_ invalidateShadow];
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-29 02:26:02 +00:00
|
|
|
|
void NativeWindowMac::SetOpacity(const double opacity) {
|
2023-05-23 19:58:58 +00:00
|
|
|
|
const double boundedOpacity = std::clamp(opacity, 0.0, 1.0);
|
2019-08-07 07:17:32 +00:00
|
|
|
|
[window_ setAlphaValue:boundedOpacity];
|
2017-09-29 02:26:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
double NativeWindowMac::GetOpacity() const {
|
2017-10-02 15:08:10 +00:00
|
|
|
|
return [window_ alphaValue];
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-27 06:15:34 +00:00
|
|
|
|
void NativeWindowMac::SetRepresentedFilename(const std::string& filename) {
|
|
|
|
|
[window_ setRepresentedFilename:base::SysUTF8ToNSString(filename)];
|
2022-07-08 06:33:42 +00:00
|
|
|
|
if (buttons_proxy_)
|
|
|
|
|
[buttons_proxy_ redraw];
|
2014-05-27 06:15:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
std::string NativeWindowMac::GetRepresentedFilename() const {
|
2014-07-18 13:42:26 +00:00
|
|
|
|
return base::SysNSStringToUTF8([window_ representedFilename]);
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-27 06:15:34 +00:00
|
|
|
|
void NativeWindowMac::SetDocumentEdited(bool edited) {
|
|
|
|
|
[window_ setDocumentEdited:edited];
|
2021-08-18 19:09:57 +00:00
|
|
|
|
if (buttons_proxy_)
|
|
|
|
|
[buttons_proxy_ redraw];
|
2014-05-27 06:15:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
bool NativeWindowMac::IsDocumentEdited() const {
|
2014-07-24 07:48:33 +00:00
|
|
|
|
return [window_ isDocumentEdited];
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
bool NativeWindowMac::IsHiddenInMissionControl() const {
|
2022-11-01 20:43:42 +00:00
|
|
|
|
NSUInteger collectionBehavior = [window_ collectionBehavior];
|
|
|
|
|
return collectionBehavior & NSWindowCollectionBehaviorTransient;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NativeWindowMac::SetHiddenInMissionControl(bool hidden) {
|
|
|
|
|
SetCollectionBehavior(hidden, NSWindowCollectionBehaviorTransient);
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-09 10:35:05 +00:00
|
|
|
|
void NativeWindowMac::SetIgnoreMouseEvents(bool ignore, bool forward) {
|
2015-12-06 02:14:54 +00:00
|
|
|
|
[window_ setIgnoresMouseEvents:ignore];
|
2018-04-09 10:35:05 +00:00
|
|
|
|
if (!ignore) {
|
|
|
|
|
SetForwardMouseMessages(NO);
|
|
|
|
|
} else {
|
|
|
|
|
SetForwardMouseMessages(forward);
|
|
|
|
|
}
|
2015-12-06 02:14:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-22 08:40:01 +00:00
|
|
|
|
void NativeWindowMac::SetContentProtection(bool enable) {
|
2018-04-20 18:47:04 +00:00
|
|
|
|
[window_
|
|
|
|
|
setSharingType:enable ? NSWindowSharingNone : NSWindowSharingReadOnly];
|
2016-06-22 08:40:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-08 02:34:18 +00:00
|
|
|
|
void NativeWindowMac::SetFocusable(bool focusable) {
|
|
|
|
|
// No known way to unfocus the window if it had the focus. Here we do not
|
|
|
|
|
// want to call Focus(false) because it moves the window to the back, i.e.
|
|
|
|
|
// at the bottom in term of z-order.
|
|
|
|
|
[window_ setDisableKeyOrMainWindow:!focusable];
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
bool NativeWindowMac::IsFocusable() const {
|
2021-04-21 10:32:19 +00:00
|
|
|
|
return ![window_ disableKeyOrMainWindow];
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-01 20:10:48 +00:00
|
|
|
|
void NativeWindowMac::SetParentWindow(NativeWindow* parent) {
|
2017-05-01 20:21:05 +00:00
|
|
|
|
InternalSetParentWindow(parent, IsVisible());
|
2017-05-01 20:10:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-23 09:41:59 +00:00
|
|
|
|
gfx::NativeView NativeWindowMac::GetNativeView() const {
|
2018-03-06 04:31:12 +00:00
|
|
|
|
return [window_ contentView];
|
2017-03-14 11:56:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-14 05:43:22 +00:00
|
|
|
|
gfx::NativeWindow NativeWindowMac::GetNativeWindow() const {
|
2014-04-11 04:45:48 +00:00
|
|
|
|
return window_;
|
2013-05-03 11:31:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-23 09:41:59 +00:00
|
|
|
|
gfx::AcceleratedWidget NativeWindowMac::GetAcceleratedWidget() const {
|
2019-08-15 06:51:15 +00:00
|
|
|
|
return [window_ windowNumber];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
content::DesktopMediaID NativeWindowMac::GetDesktopMediaID() const {
|
chore: bump chromium to 92.0.4475.0 (master) (#28462)
* chore: bump chromium in DEPS to 91.0.4464.0
* chore: rebuild chromium/dcheck.patch with import-patches -3
Mechanical only; no code changes
* chore: remove content_browser_main_loop.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2725153
The function being patched (BrowserMainLoop::MainMessageLoopRun()) no
longer exists.
NB: if removing this introduces regressions the likely fix will be to
add a similar patch for ShellBrowserMainParts::WillRunMainMessageLoop()
which has similar code and was added at the same time this was removed.
* chore: rebuild chromium/put_back_deleted_colors_for_autofill.patch with import-patches -3
Mechanical only; no code changes
* chore: rebuild chromium/disable_color_correct_rendering.patch with import-patches -3
Mechanical only; no code changes
* chore: rebuild chromium/eat_allow_disabling_blink_scheduler_throttling_per_renderview.patch with patch
Mechanical only; no code changes
* chore: rebuild chromium/gpu_notify_when_dxdiag_request_fails.patch with import-patches -3
Mechanical only; no code changes
* chore: rebuild chromium/ui_gtk_public_header.patch manually
no code changes
* chore: rebuild chromium/web_contents.patch with import-patches -3
Mechanical only; no code changes
* chore: remove v8/skip_global_registration_of_shared_arraybuffer_backing_stores.patch
Refs: https://chromium-review.googlesource.com/c/v8/v8/+/2763874
This patch has been merged upstream
* chore: export patches
* chore: update add_trustedauthclient_to_urlloaderfactory.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2757969
Sync with removal of render_frame_id_
* chore: sync chromium/put_back_deleted_colors_for_autofill.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2785841
SkColorFromColorId() no longer takes theme, scheme args
* chore: sync chromium/put_back_deleted_colors_for_autofill.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2772143
Change new calls to GetDarkSchemeColor to fit our patched call signature
* chore: update add_trustedauthclient_to_urlloaderfactory.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2757969
Sync with removal of render_frame_id_ in our mojom
* chore: update chromium/frame_host_manager.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2740008
UrlInfo ctor now takes UrlInfo::OriginIsolationRequest instead of a bool
* chore: update chromium/revert_remove_contentrendererclient_shouldfork.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2755314
Upstream has removed `history_list_length_` which we were comparing to 0
to calculate our `is_initial_navigation` bool when calling ShouldFork().
ShouldFork() is ours and none of the code paths actually use that param,
so this commit removes it altogether.
* chore: update permissions_to_register
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2789074
Replace all uses of APIPermission::ID enum with Mojo type
* refactor: update return type of PreMainMessageLoopRun()
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2725153
Used to return void; now returns an int errorcode.
Note: 2725153 also has some nice doc updates about Browser's "stages"
* refactor: sync ElectronBrowserMainParts to MainParts changes
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2725153
RunMainMessageLoopParts has been replaced with WillRunMainMessageLoop
so `BrowserMainLoop::result_code_` is no longer available to us for our
exit_code_ pointer.
This variable held a dual role: (1) of course, hold the exit code, but
also (2) was a nullptr before the message loop was ready, indicating to
anyone calling SetExitCode() that we were still in startup and could
just exit() without any extra steps. exit_code_ still fulfills these two
roles but is now a base::Optional.
* chore: update ElectronBrowserMainParts::PreDefaultMainMessageLoopRun
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2725153
BrowserMainParts::BrowsePreDefaultMainMesssageLoopRun() has been
removed; move that work to the new WillRunMainMessageLoop().
* refactor: stop using CallbackList; it has been removed.
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2785973
* refactor: update use of threadpools.
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2773408
The upstream code is still in flux (e.g. reverts and re-lands) but the
tl;dr for this commit is (1) include thread_pool.h if you're using it
and (2) don't instantiate pools directly.
* refactor: remove routing_id from CreateLoaderAndStart
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2762858
NB: One logic branch in ProxyingURLLoaderFactory::CreateLoaderAndStart
calls std::make_unique<InProgressRequest>, which needs a routing_id.
This PR uses the member field `routing_id_` since there's no longer one
being passed into CreateLoaderAndStart.
* refactor: sync to upstream ParittionOptions churn
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2771318
PartitionOptions' enums have changed.
* refactor: update Manifest::Location usage
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2771320
tldr: s/Manifest::FOO/ManifestLocation::kFoo/
* chore: bump chromium in DEPS to 91.0.4465.0
* update patches
* refactor: update extensions::Manifest to upstream
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2771320
- extensions::Manifest::COMPONENT
+ extensions::mojom::ManifestLocation::kExternalComponent
* refactor: sync with upstream UrlInfo ctor changes
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2740008
UrlInfo ctor now takes UrlInfo::OriginIsolationRequest instead of a bool
* chore: update invocation of convert_protocol_to_json.py
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2792623
python3 is being used in parts of the upstream build, but the copy of
convert_protocol_to_json.py invoked in v8/third_party/inspector_protocol
is not python3-friendly. Node has a py2+3-friendly version of it in its
tools directory, so call it instead.
* chore: use extensions::mojom::APIPermissionID
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2791122
tldr:
- extensions::APIPermission::kFoo
+ extensions::mojom::APIPermissionID::kFoo
* chore: Remove support for TLS1.0/1.1 in SSLVersionMin policy
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2765737
Remove TLS v1.0 & 1.1 from our SSLProtocolVersionFromString() function.
This is the same change made upstream at
https://chromium-review.googlesource.com/c/chromium/src/+/2765737/8/chrome/browser/ssl/ssl_config_service_manager_pref.cc
* fixup! chore: update ElectronBrowserMainParts::PreDefaultMainMessageLoopRun
* chore: Use IDType for permission change subscriptions.
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2791431
tldr: {Subscribe,Unsubscribe}PermissionStatusChange's tag type used to
be an int; now it's the new SubscriptionId type (which is an IdType64).
* chore: sync PowerMonitor code to upstream refactor
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2752635
tldr: PowerMonitor has been split into PowerStateObserver,
PowerSuspendObserver, and PowerThermalObserver to reduce number of tasks
posted to consumers who only need notifications for one of those things
instead of all of them.
* chore: use PartitionOptions's new Cookies field
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2771318
* Revert "refactor: remove routing_id from CreateLoaderAndStart"
This reverts commit 8c9773b87a3c84f9073a47089eb2b6889d745245.
8c9773b was only a partial fix; reverting to start & try again.
* update patches
* chore: bump chromium in DEPS to 91.0.4466.0
* chore: update chromium/accelerator.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2795472
tldr: sync patch with upstream renamed variable & macro names.
* chore: update chromium/gtk_visibility.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2796200
tldr: no code changes; just updating the diff to apply cleanly.
note: ooh upstream Wayland hacking!
* chore: update chromium/picture-in-picture.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2710023
tldr: no code changes; just updating the diff to apply cleanly.
* chore: update chromium/worker_feat_add_hook_to_notify_script_ready.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2775573
tldr: no code changes; just updating the diff to apply cleanly.
* chore: export_all_patches
* chore: update chromium/feat_add_set_theme_source_to_allow_apps_to.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2796511
tldr: NotifyObservers has been renamed to NotifyOnNativeThemeUpdated,
so update the invocation in our patch.
* chore: update ElectronBrowserClient w/upstream API
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2797454
tldr: GetDevToolsManagerDelegate() was returning an owned raw pointer.
Replaced it with CreateDevToolsManagerDelegate() which uses unique_ptr<>.
* chore: handle new content::PermissionType::FILE_HANDLING in toV8()
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2762201
`file-handling` string confirmed in https://chromium-review.googlesource.com/c/chromium/src/+/2762201/18/chrome/browser/ui/webui/settings/site_settings_helper.cc
* refactor: remove routing_id from CreateLoaderAndStart pt 1
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2762858
Part 1: the easiest ones
* 2796724: Support Python3
https://chromium-review.googlesource.com/c/infra/luci/python-adb/+/2796724
* chore: bump chromium in DEPS to 91.0.4468.0
* 2668974: WebShare: Implement SharingServicePicker
https://chromium-review.googlesource.com/c/chromium/src/+/2668974
* 2802766: Apply modernize-make-unique to media/
https://chromium-review.googlesource.com/c/chromium/src/+/2802766
* 2802823: Apply modernize-make-unique to gpu/
https://chromium-review.googlesource.com/c/chromium/src/+/2802823
* 2803041: Apply modernize-make-unique to remaining files
https://chromium-review.googlesource.com/c/chromium/src/+/2803041
* 2798873: Convert GtkKeyBindingsHandler build checks to runtime checks
https://chromium-review.googlesource.com/c/chromium/src/+/2798873
* 2733595: [ch-r] Parse ACCEPT_CH H2/3 frame and restart with new headers if needed
https://chromium-review.googlesource.com/c/chromium/src/+/2733595
* chore: update patch indices
* 2795107: Remove unused PermissionRequest IDs.
https://chromium-review.googlesource.com/c/chromium/src/+/2795107
* chore: bump chromium in DEPS to 91.0.4469.0
* chore: fixup patch indices
* chore: bump chromium in DEPS to 91.0.4469.5
* PiP 1.5: Add microphone, camera, and hang up buttons to the PiP window
https://chromium-review.googlesource.com/c/chromium/src/+/2710023
* fixup! refactor: remove routing_id from CreateLoaderAndStart
* refactor: use URLLoaderNetworkServiceObserver for auth requests from SimpleURLLoader
* fixup! chore: fixup patch indices
* 2724817: Expand scope of wasm-eval to all URLs
https://chromium-review.googlesource.com/c/chromium/src/+/2724817
* Fixup patch after rebase
* chore: bump chromium in DEPS to 91.0.4472.0
* 2797341: [ozone/x11] Enabled the global shortcut listener.
https://chromium-review.googlesource.com/c/chromium/src/+/2797341
* 2805553: Reland Add GTK ColorMixers to ColorPipeline P1
https://chromium-review.googlesource.com/c/chromium/src/+/2805553
* 2804366: PiP 1.5: Label back to tab button with origin and center it
https://chromium-review.googlesource.com/c/chromium/src/+/2804366
* 2784730: Fix crash on AX mode change in NativeViewHost without a Widget
https://chromium-review.googlesource.com/c/chromium/src/+/2784730
* chore: update patch indices
* 2810174: Add PdfAnnotationsEnabled policy.
https://chromium-review.googlesource.com/c/chromium/src/+/2810174
* 2807829: Allow capturers to indicate if they want a WakeLock or not.
https://chromium-review.googlesource.com/c/chromium/src/+/2807829
* chore: bump chromium in DEPS to 92.0.4473.0
* chore: bump chromium in DEPS to 92.0.4474.0
* chore: bump chromium in DEPS to 92.0.4475.0
* chore: update patches
* chore: updates patches
* chore: update is_media_key patch to handle new ozone impl
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2797341
* fix: ExecuteJavascript requests now need to be flagged as non-bf-aware
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2787195
* chore: icon_util_x11 is now icon_util_linux
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2791362
* build: update sysroots
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2628496
* build: fix missing symbols on linux build
* use_ozone and use_x11 are not exclusive
* new button view to build for pip
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2797341
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2804366
* chore: fix broken gtk_util color patch
* chore: remove patch conflict
* build: update linux manifests
* chore: build bttlb on all platforms for pip
* chore: add thread_pool include for views delegate win
* chore: fix lint
* chore: add node patches for V8 changes
* build: add missing base include on windows
* fix: update frame host manager patch for new state transitions
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2714464
* chore: update windows zip manifests
* chore: update mac zip manifests
* chore: fix patch linting
* refactor: implement missing URLLoaderNetworkServiceObserver methods
It is against The Mojo Rules to leave hanging callbacks. These always
have to be called.
Refs: https://github.com/electron/electron/commit/186528aab9f8e29d658f07d220bb7f627980edda
* spec: fix locale test on local linux
* fix: pass the exit code correctly in new PreMainMessageLoopRun
Refs: https://github.com/electron/electron/commit/2622e91c4493ceb032e2f80cb484885bb8f97475
* fix: ensure we early-exit when request_handler_ is not provided
Refs: https://github.com/electron/electron/commit/93077afbfb6db248a0c0cc447d7ad2c9ccfda1d5
* fix: strongly set result_code in the BrowserMainLoop
* fix: invalid usage of non-targetted PostTask
You must always either use a host threadpool or specify a target
thread. In this case we did neither after this refactor.
Refs: https://github.com/electron/electron/pull/28462/commits/4e33ee0ad35a710bd34641cb0376bdee6aea2d1f
* chore: fix gn check
* chore: remove stray .rej files in patch
* chore: add mojo error code to url loader failure
* build: ensure CI is truthy in arm test env
* fix: handle windowCaptureMacV2 being enabled when fetching media source id
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2709931
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>
Co-authored-by: Samuel Attard <sattard@slack-corp.com>
2021-04-15 17:44:35 +00:00
|
|
|
|
auto desktop_media_id = content::DesktopMediaID(
|
|
|
|
|
content::DesktopMediaID::TYPE_WINDOW, GetAcceleratedWidget());
|
|
|
|
|
// c.f.
|
2023-02-12 02:52:54 +00:00
|
|
|
|
// https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/media/webrtc/native_desktop_media_list.cc;l=775-780;drc=79502ab47f61bff351426f57f576daef02b1a8dc
|
2021-08-24 00:52:17 +00:00
|
|
|
|
// Refs https://github.com/electron/electron/pull/30507
|
|
|
|
|
// TODO(deepak1556): Match upstream for `kWindowCaptureMacV2`
|
|
|
|
|
#if 0
|
chore: bump chromium to 92.0.4475.0 (master) (#28462)
* chore: bump chromium in DEPS to 91.0.4464.0
* chore: rebuild chromium/dcheck.patch with import-patches -3
Mechanical only; no code changes
* chore: remove content_browser_main_loop.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2725153
The function being patched (BrowserMainLoop::MainMessageLoopRun()) no
longer exists.
NB: if removing this introduces regressions the likely fix will be to
add a similar patch for ShellBrowserMainParts::WillRunMainMessageLoop()
which has similar code and was added at the same time this was removed.
* chore: rebuild chromium/put_back_deleted_colors_for_autofill.patch with import-patches -3
Mechanical only; no code changes
* chore: rebuild chromium/disable_color_correct_rendering.patch with import-patches -3
Mechanical only; no code changes
* chore: rebuild chromium/eat_allow_disabling_blink_scheduler_throttling_per_renderview.patch with patch
Mechanical only; no code changes
* chore: rebuild chromium/gpu_notify_when_dxdiag_request_fails.patch with import-patches -3
Mechanical only; no code changes
* chore: rebuild chromium/ui_gtk_public_header.patch manually
no code changes
* chore: rebuild chromium/web_contents.patch with import-patches -3
Mechanical only; no code changes
* chore: remove v8/skip_global_registration_of_shared_arraybuffer_backing_stores.patch
Refs: https://chromium-review.googlesource.com/c/v8/v8/+/2763874
This patch has been merged upstream
* chore: export patches
* chore: update add_trustedauthclient_to_urlloaderfactory.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2757969
Sync with removal of render_frame_id_
* chore: sync chromium/put_back_deleted_colors_for_autofill.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2785841
SkColorFromColorId() no longer takes theme, scheme args
* chore: sync chromium/put_back_deleted_colors_for_autofill.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2772143
Change new calls to GetDarkSchemeColor to fit our patched call signature
* chore: update add_trustedauthclient_to_urlloaderfactory.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2757969
Sync with removal of render_frame_id_ in our mojom
* chore: update chromium/frame_host_manager.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2740008
UrlInfo ctor now takes UrlInfo::OriginIsolationRequest instead of a bool
* chore: update chromium/revert_remove_contentrendererclient_shouldfork.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2755314
Upstream has removed `history_list_length_` which we were comparing to 0
to calculate our `is_initial_navigation` bool when calling ShouldFork().
ShouldFork() is ours and none of the code paths actually use that param,
so this commit removes it altogether.
* chore: update permissions_to_register
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2789074
Replace all uses of APIPermission::ID enum with Mojo type
* refactor: update return type of PreMainMessageLoopRun()
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2725153
Used to return void; now returns an int errorcode.
Note: 2725153 also has some nice doc updates about Browser's "stages"
* refactor: sync ElectronBrowserMainParts to MainParts changes
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2725153
RunMainMessageLoopParts has been replaced with WillRunMainMessageLoop
so `BrowserMainLoop::result_code_` is no longer available to us for our
exit_code_ pointer.
This variable held a dual role: (1) of course, hold the exit code, but
also (2) was a nullptr before the message loop was ready, indicating to
anyone calling SetExitCode() that we were still in startup and could
just exit() without any extra steps. exit_code_ still fulfills these two
roles but is now a base::Optional.
* chore: update ElectronBrowserMainParts::PreDefaultMainMessageLoopRun
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2725153
BrowserMainParts::BrowsePreDefaultMainMesssageLoopRun() has been
removed; move that work to the new WillRunMainMessageLoop().
* refactor: stop using CallbackList; it has been removed.
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2785973
* refactor: update use of threadpools.
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2773408
The upstream code is still in flux (e.g. reverts and re-lands) but the
tl;dr for this commit is (1) include thread_pool.h if you're using it
and (2) don't instantiate pools directly.
* refactor: remove routing_id from CreateLoaderAndStart
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2762858
NB: One logic branch in ProxyingURLLoaderFactory::CreateLoaderAndStart
calls std::make_unique<InProgressRequest>, which needs a routing_id.
This PR uses the member field `routing_id_` since there's no longer one
being passed into CreateLoaderAndStart.
* refactor: sync to upstream ParittionOptions churn
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2771318
PartitionOptions' enums have changed.
* refactor: update Manifest::Location usage
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2771320
tldr: s/Manifest::FOO/ManifestLocation::kFoo/
* chore: bump chromium in DEPS to 91.0.4465.0
* update patches
* refactor: update extensions::Manifest to upstream
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2771320
- extensions::Manifest::COMPONENT
+ extensions::mojom::ManifestLocation::kExternalComponent
* refactor: sync with upstream UrlInfo ctor changes
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2740008
UrlInfo ctor now takes UrlInfo::OriginIsolationRequest instead of a bool
* chore: update invocation of convert_protocol_to_json.py
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2792623
python3 is being used in parts of the upstream build, but the copy of
convert_protocol_to_json.py invoked in v8/third_party/inspector_protocol
is not python3-friendly. Node has a py2+3-friendly version of it in its
tools directory, so call it instead.
* chore: use extensions::mojom::APIPermissionID
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2791122
tldr:
- extensions::APIPermission::kFoo
+ extensions::mojom::APIPermissionID::kFoo
* chore: Remove support for TLS1.0/1.1 in SSLVersionMin policy
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2765737
Remove TLS v1.0 & 1.1 from our SSLProtocolVersionFromString() function.
This is the same change made upstream at
https://chromium-review.googlesource.com/c/chromium/src/+/2765737/8/chrome/browser/ssl/ssl_config_service_manager_pref.cc
* fixup! chore: update ElectronBrowserMainParts::PreDefaultMainMessageLoopRun
* chore: Use IDType for permission change subscriptions.
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2791431
tldr: {Subscribe,Unsubscribe}PermissionStatusChange's tag type used to
be an int; now it's the new SubscriptionId type (which is an IdType64).
* chore: sync PowerMonitor code to upstream refactor
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2752635
tldr: PowerMonitor has been split into PowerStateObserver,
PowerSuspendObserver, and PowerThermalObserver to reduce number of tasks
posted to consumers who only need notifications for one of those things
instead of all of them.
* chore: use PartitionOptions's new Cookies field
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2771318
* Revert "refactor: remove routing_id from CreateLoaderAndStart"
This reverts commit 8c9773b87a3c84f9073a47089eb2b6889d745245.
8c9773b was only a partial fix; reverting to start & try again.
* update patches
* chore: bump chromium in DEPS to 91.0.4466.0
* chore: update chromium/accelerator.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2795472
tldr: sync patch with upstream renamed variable & macro names.
* chore: update chromium/gtk_visibility.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2796200
tldr: no code changes; just updating the diff to apply cleanly.
note: ooh upstream Wayland hacking!
* chore: update chromium/picture-in-picture.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2710023
tldr: no code changes; just updating the diff to apply cleanly.
* chore: update chromium/worker_feat_add_hook_to_notify_script_ready.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2775573
tldr: no code changes; just updating the diff to apply cleanly.
* chore: export_all_patches
* chore: update chromium/feat_add_set_theme_source_to_allow_apps_to.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2796511
tldr: NotifyObservers has been renamed to NotifyOnNativeThemeUpdated,
so update the invocation in our patch.
* chore: update ElectronBrowserClient w/upstream API
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2797454
tldr: GetDevToolsManagerDelegate() was returning an owned raw pointer.
Replaced it with CreateDevToolsManagerDelegate() which uses unique_ptr<>.
* chore: handle new content::PermissionType::FILE_HANDLING in toV8()
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2762201
`file-handling` string confirmed in https://chromium-review.googlesource.com/c/chromium/src/+/2762201/18/chrome/browser/ui/webui/settings/site_settings_helper.cc
* refactor: remove routing_id from CreateLoaderAndStart pt 1
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2762858
Part 1: the easiest ones
* 2796724: Support Python3
https://chromium-review.googlesource.com/c/infra/luci/python-adb/+/2796724
* chore: bump chromium in DEPS to 91.0.4468.0
* 2668974: WebShare: Implement SharingServicePicker
https://chromium-review.googlesource.com/c/chromium/src/+/2668974
* 2802766: Apply modernize-make-unique to media/
https://chromium-review.googlesource.com/c/chromium/src/+/2802766
* 2802823: Apply modernize-make-unique to gpu/
https://chromium-review.googlesource.com/c/chromium/src/+/2802823
* 2803041: Apply modernize-make-unique to remaining files
https://chromium-review.googlesource.com/c/chromium/src/+/2803041
* 2798873: Convert GtkKeyBindingsHandler build checks to runtime checks
https://chromium-review.googlesource.com/c/chromium/src/+/2798873
* 2733595: [ch-r] Parse ACCEPT_CH H2/3 frame and restart with new headers if needed
https://chromium-review.googlesource.com/c/chromium/src/+/2733595
* chore: update patch indices
* 2795107: Remove unused PermissionRequest IDs.
https://chromium-review.googlesource.com/c/chromium/src/+/2795107
* chore: bump chromium in DEPS to 91.0.4469.0
* chore: fixup patch indices
* chore: bump chromium in DEPS to 91.0.4469.5
* PiP 1.5: Add microphone, camera, and hang up buttons to the PiP window
https://chromium-review.googlesource.com/c/chromium/src/+/2710023
* fixup! refactor: remove routing_id from CreateLoaderAndStart
* refactor: use URLLoaderNetworkServiceObserver for auth requests from SimpleURLLoader
* fixup! chore: fixup patch indices
* 2724817: Expand scope of wasm-eval to all URLs
https://chromium-review.googlesource.com/c/chromium/src/+/2724817
* Fixup patch after rebase
* chore: bump chromium in DEPS to 91.0.4472.0
* 2797341: [ozone/x11] Enabled the global shortcut listener.
https://chromium-review.googlesource.com/c/chromium/src/+/2797341
* 2805553: Reland Add GTK ColorMixers to ColorPipeline P1
https://chromium-review.googlesource.com/c/chromium/src/+/2805553
* 2804366: PiP 1.5: Label back to tab button with origin and center it
https://chromium-review.googlesource.com/c/chromium/src/+/2804366
* 2784730: Fix crash on AX mode change in NativeViewHost without a Widget
https://chromium-review.googlesource.com/c/chromium/src/+/2784730
* chore: update patch indices
* 2810174: Add PdfAnnotationsEnabled policy.
https://chromium-review.googlesource.com/c/chromium/src/+/2810174
* 2807829: Allow capturers to indicate if they want a WakeLock or not.
https://chromium-review.googlesource.com/c/chromium/src/+/2807829
* chore: bump chromium in DEPS to 92.0.4473.0
* chore: bump chromium in DEPS to 92.0.4474.0
* chore: bump chromium in DEPS to 92.0.4475.0
* chore: update patches
* chore: updates patches
* chore: update is_media_key patch to handle new ozone impl
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2797341
* fix: ExecuteJavascript requests now need to be flagged as non-bf-aware
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2787195
* chore: icon_util_x11 is now icon_util_linux
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2791362
* build: update sysroots
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2628496
* build: fix missing symbols on linux build
* use_ozone and use_x11 are not exclusive
* new button view to build for pip
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2797341
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2804366
* chore: fix broken gtk_util color patch
* chore: remove patch conflict
* build: update linux manifests
* chore: build bttlb on all platforms for pip
* chore: add thread_pool include for views delegate win
* chore: fix lint
* chore: add node patches for V8 changes
* build: add missing base include on windows
* fix: update frame host manager patch for new state transitions
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2714464
* chore: update windows zip manifests
* chore: update mac zip manifests
* chore: fix patch linting
* refactor: implement missing URLLoaderNetworkServiceObserver methods
It is against The Mojo Rules to leave hanging callbacks. These always
have to be called.
Refs: https://github.com/electron/electron/commit/186528aab9f8e29d658f07d220bb7f627980edda
* spec: fix locale test on local linux
* fix: pass the exit code correctly in new PreMainMessageLoopRun
Refs: https://github.com/electron/electron/commit/2622e91c4493ceb032e2f80cb484885bb8f97475
* fix: ensure we early-exit when request_handler_ is not provided
Refs: https://github.com/electron/electron/commit/93077afbfb6db248a0c0cc447d7ad2c9ccfda1d5
* fix: strongly set result_code in the BrowserMainLoop
* fix: invalid usage of non-targetted PostTask
You must always either use a host threadpool or specify a target
thread. In this case we did neither after this refactor.
Refs: https://github.com/electron/electron/pull/28462/commits/4e33ee0ad35a710bd34641cb0376bdee6aea2d1f
* chore: fix gn check
* chore: remove stray .rej files in patch
* chore: add mojo error code to url loader failure
* build: ensure CI is truthy in arm test env
* fix: handle windowCaptureMacV2 being enabled when fetching media source id
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2709931
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>
Co-authored-by: Samuel Attard <sattard@slack-corp.com>
2021-04-15 17:44:35 +00:00
|
|
|
|
if (remote_cocoa::ScopedCGWindowID::Get(desktop_media_id.id)) {
|
|
|
|
|
desktop_media_id.window_id = desktop_media_id.id;
|
|
|
|
|
}
|
2021-08-24 00:52:17 +00:00
|
|
|
|
#endif
|
chore: bump chromium to 92.0.4475.0 (master) (#28462)
* chore: bump chromium in DEPS to 91.0.4464.0
* chore: rebuild chromium/dcheck.patch with import-patches -3
Mechanical only; no code changes
* chore: remove content_browser_main_loop.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2725153
The function being patched (BrowserMainLoop::MainMessageLoopRun()) no
longer exists.
NB: if removing this introduces regressions the likely fix will be to
add a similar patch for ShellBrowserMainParts::WillRunMainMessageLoop()
which has similar code and was added at the same time this was removed.
* chore: rebuild chromium/put_back_deleted_colors_for_autofill.patch with import-patches -3
Mechanical only; no code changes
* chore: rebuild chromium/disable_color_correct_rendering.patch with import-patches -3
Mechanical only; no code changes
* chore: rebuild chromium/eat_allow_disabling_blink_scheduler_throttling_per_renderview.patch with patch
Mechanical only; no code changes
* chore: rebuild chromium/gpu_notify_when_dxdiag_request_fails.patch with import-patches -3
Mechanical only; no code changes
* chore: rebuild chromium/ui_gtk_public_header.patch manually
no code changes
* chore: rebuild chromium/web_contents.patch with import-patches -3
Mechanical only; no code changes
* chore: remove v8/skip_global_registration_of_shared_arraybuffer_backing_stores.patch
Refs: https://chromium-review.googlesource.com/c/v8/v8/+/2763874
This patch has been merged upstream
* chore: export patches
* chore: update add_trustedauthclient_to_urlloaderfactory.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2757969
Sync with removal of render_frame_id_
* chore: sync chromium/put_back_deleted_colors_for_autofill.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2785841
SkColorFromColorId() no longer takes theme, scheme args
* chore: sync chromium/put_back_deleted_colors_for_autofill.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2772143
Change new calls to GetDarkSchemeColor to fit our patched call signature
* chore: update add_trustedauthclient_to_urlloaderfactory.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2757969
Sync with removal of render_frame_id_ in our mojom
* chore: update chromium/frame_host_manager.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2740008
UrlInfo ctor now takes UrlInfo::OriginIsolationRequest instead of a bool
* chore: update chromium/revert_remove_contentrendererclient_shouldfork.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2755314
Upstream has removed `history_list_length_` which we were comparing to 0
to calculate our `is_initial_navigation` bool when calling ShouldFork().
ShouldFork() is ours and none of the code paths actually use that param,
so this commit removes it altogether.
* chore: update permissions_to_register
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2789074
Replace all uses of APIPermission::ID enum with Mojo type
* refactor: update return type of PreMainMessageLoopRun()
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2725153
Used to return void; now returns an int errorcode.
Note: 2725153 also has some nice doc updates about Browser's "stages"
* refactor: sync ElectronBrowserMainParts to MainParts changes
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2725153
RunMainMessageLoopParts has been replaced with WillRunMainMessageLoop
so `BrowserMainLoop::result_code_` is no longer available to us for our
exit_code_ pointer.
This variable held a dual role: (1) of course, hold the exit code, but
also (2) was a nullptr before the message loop was ready, indicating to
anyone calling SetExitCode() that we were still in startup and could
just exit() without any extra steps. exit_code_ still fulfills these two
roles but is now a base::Optional.
* chore: update ElectronBrowserMainParts::PreDefaultMainMessageLoopRun
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2725153
BrowserMainParts::BrowsePreDefaultMainMesssageLoopRun() has been
removed; move that work to the new WillRunMainMessageLoop().
* refactor: stop using CallbackList; it has been removed.
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2785973
* refactor: update use of threadpools.
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2773408
The upstream code is still in flux (e.g. reverts and re-lands) but the
tl;dr for this commit is (1) include thread_pool.h if you're using it
and (2) don't instantiate pools directly.
* refactor: remove routing_id from CreateLoaderAndStart
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2762858
NB: One logic branch in ProxyingURLLoaderFactory::CreateLoaderAndStart
calls std::make_unique<InProgressRequest>, which needs a routing_id.
This PR uses the member field `routing_id_` since there's no longer one
being passed into CreateLoaderAndStart.
* refactor: sync to upstream ParittionOptions churn
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2771318
PartitionOptions' enums have changed.
* refactor: update Manifest::Location usage
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2771320
tldr: s/Manifest::FOO/ManifestLocation::kFoo/
* chore: bump chromium in DEPS to 91.0.4465.0
* update patches
* refactor: update extensions::Manifest to upstream
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2771320
- extensions::Manifest::COMPONENT
+ extensions::mojom::ManifestLocation::kExternalComponent
* refactor: sync with upstream UrlInfo ctor changes
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2740008
UrlInfo ctor now takes UrlInfo::OriginIsolationRequest instead of a bool
* chore: update invocation of convert_protocol_to_json.py
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2792623
python3 is being used in parts of the upstream build, but the copy of
convert_protocol_to_json.py invoked in v8/third_party/inspector_protocol
is not python3-friendly. Node has a py2+3-friendly version of it in its
tools directory, so call it instead.
* chore: use extensions::mojom::APIPermissionID
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2791122
tldr:
- extensions::APIPermission::kFoo
+ extensions::mojom::APIPermissionID::kFoo
* chore: Remove support for TLS1.0/1.1 in SSLVersionMin policy
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2765737
Remove TLS v1.0 & 1.1 from our SSLProtocolVersionFromString() function.
This is the same change made upstream at
https://chromium-review.googlesource.com/c/chromium/src/+/2765737/8/chrome/browser/ssl/ssl_config_service_manager_pref.cc
* fixup! chore: update ElectronBrowserMainParts::PreDefaultMainMessageLoopRun
* chore: Use IDType for permission change subscriptions.
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2791431
tldr: {Subscribe,Unsubscribe}PermissionStatusChange's tag type used to
be an int; now it's the new SubscriptionId type (which is an IdType64).
* chore: sync PowerMonitor code to upstream refactor
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2752635
tldr: PowerMonitor has been split into PowerStateObserver,
PowerSuspendObserver, and PowerThermalObserver to reduce number of tasks
posted to consumers who only need notifications for one of those things
instead of all of them.
* chore: use PartitionOptions's new Cookies field
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2771318
* Revert "refactor: remove routing_id from CreateLoaderAndStart"
This reverts commit 8c9773b87a3c84f9073a47089eb2b6889d745245.
8c9773b was only a partial fix; reverting to start & try again.
* update patches
* chore: bump chromium in DEPS to 91.0.4466.0
* chore: update chromium/accelerator.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2795472
tldr: sync patch with upstream renamed variable & macro names.
* chore: update chromium/gtk_visibility.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2796200
tldr: no code changes; just updating the diff to apply cleanly.
note: ooh upstream Wayland hacking!
* chore: update chromium/picture-in-picture.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2710023
tldr: no code changes; just updating the diff to apply cleanly.
* chore: update chromium/worker_feat_add_hook_to_notify_script_ready.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2775573
tldr: no code changes; just updating the diff to apply cleanly.
* chore: export_all_patches
* chore: update chromium/feat_add_set_theme_source_to_allow_apps_to.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2796511
tldr: NotifyObservers has been renamed to NotifyOnNativeThemeUpdated,
so update the invocation in our patch.
* chore: update ElectronBrowserClient w/upstream API
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2797454
tldr: GetDevToolsManagerDelegate() was returning an owned raw pointer.
Replaced it with CreateDevToolsManagerDelegate() which uses unique_ptr<>.
* chore: handle new content::PermissionType::FILE_HANDLING in toV8()
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2762201
`file-handling` string confirmed in https://chromium-review.googlesource.com/c/chromium/src/+/2762201/18/chrome/browser/ui/webui/settings/site_settings_helper.cc
* refactor: remove routing_id from CreateLoaderAndStart pt 1
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2762858
Part 1: the easiest ones
* 2796724: Support Python3
https://chromium-review.googlesource.com/c/infra/luci/python-adb/+/2796724
* chore: bump chromium in DEPS to 91.0.4468.0
* 2668974: WebShare: Implement SharingServicePicker
https://chromium-review.googlesource.com/c/chromium/src/+/2668974
* 2802766: Apply modernize-make-unique to media/
https://chromium-review.googlesource.com/c/chromium/src/+/2802766
* 2802823: Apply modernize-make-unique to gpu/
https://chromium-review.googlesource.com/c/chromium/src/+/2802823
* 2803041: Apply modernize-make-unique to remaining files
https://chromium-review.googlesource.com/c/chromium/src/+/2803041
* 2798873: Convert GtkKeyBindingsHandler build checks to runtime checks
https://chromium-review.googlesource.com/c/chromium/src/+/2798873
* 2733595: [ch-r] Parse ACCEPT_CH H2/3 frame and restart with new headers if needed
https://chromium-review.googlesource.com/c/chromium/src/+/2733595
* chore: update patch indices
* 2795107: Remove unused PermissionRequest IDs.
https://chromium-review.googlesource.com/c/chromium/src/+/2795107
* chore: bump chromium in DEPS to 91.0.4469.0
* chore: fixup patch indices
* chore: bump chromium in DEPS to 91.0.4469.5
* PiP 1.5: Add microphone, camera, and hang up buttons to the PiP window
https://chromium-review.googlesource.com/c/chromium/src/+/2710023
* fixup! refactor: remove routing_id from CreateLoaderAndStart
* refactor: use URLLoaderNetworkServiceObserver for auth requests from SimpleURLLoader
* fixup! chore: fixup patch indices
* 2724817: Expand scope of wasm-eval to all URLs
https://chromium-review.googlesource.com/c/chromium/src/+/2724817
* Fixup patch after rebase
* chore: bump chromium in DEPS to 91.0.4472.0
* 2797341: [ozone/x11] Enabled the global shortcut listener.
https://chromium-review.googlesource.com/c/chromium/src/+/2797341
* 2805553: Reland Add GTK ColorMixers to ColorPipeline P1
https://chromium-review.googlesource.com/c/chromium/src/+/2805553
* 2804366: PiP 1.5: Label back to tab button with origin and center it
https://chromium-review.googlesource.com/c/chromium/src/+/2804366
* 2784730: Fix crash on AX mode change in NativeViewHost without a Widget
https://chromium-review.googlesource.com/c/chromium/src/+/2784730
* chore: update patch indices
* 2810174: Add PdfAnnotationsEnabled policy.
https://chromium-review.googlesource.com/c/chromium/src/+/2810174
* 2807829: Allow capturers to indicate if they want a WakeLock or not.
https://chromium-review.googlesource.com/c/chromium/src/+/2807829
* chore: bump chromium in DEPS to 92.0.4473.0
* chore: bump chromium in DEPS to 92.0.4474.0
* chore: bump chromium in DEPS to 92.0.4475.0
* chore: update patches
* chore: updates patches
* chore: update is_media_key patch to handle new ozone impl
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2797341
* fix: ExecuteJavascript requests now need to be flagged as non-bf-aware
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2787195
* chore: icon_util_x11 is now icon_util_linux
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2791362
* build: update sysroots
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2628496
* build: fix missing symbols on linux build
* use_ozone and use_x11 are not exclusive
* new button view to build for pip
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2797341
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2804366
* chore: fix broken gtk_util color patch
* chore: remove patch conflict
* build: update linux manifests
* chore: build bttlb on all platforms for pip
* chore: add thread_pool include for views delegate win
* chore: fix lint
* chore: add node patches for V8 changes
* build: add missing base include on windows
* fix: update frame host manager patch for new state transitions
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2714464
* chore: update windows zip manifests
* chore: update mac zip manifests
* chore: fix patch linting
* refactor: implement missing URLLoaderNetworkServiceObserver methods
It is against The Mojo Rules to leave hanging callbacks. These always
have to be called.
Refs: https://github.com/electron/electron/commit/186528aab9f8e29d658f07d220bb7f627980edda
* spec: fix locale test on local linux
* fix: pass the exit code correctly in new PreMainMessageLoopRun
Refs: https://github.com/electron/electron/commit/2622e91c4493ceb032e2f80cb484885bb8f97475
* fix: ensure we early-exit when request_handler_ is not provided
Refs: https://github.com/electron/electron/commit/93077afbfb6db248a0c0cc447d7ad2c9ccfda1d5
* fix: strongly set result_code in the BrowserMainLoop
* fix: invalid usage of non-targetted PostTask
You must always either use a host threadpool or specify a target
thread. In this case we did neither after this refactor.
Refs: https://github.com/electron/electron/pull/28462/commits/4e33ee0ad35a710bd34641cb0376bdee6aea2d1f
* chore: fix gn check
* chore: remove stray .rej files in patch
* chore: add mojo error code to url loader failure
* build: ensure CI is truthy in arm test env
* fix: handle windowCaptureMacV2 being enabled when fetching media source id
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2709931
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>
Co-authored-by: Samuel Attard <sattard@slack-corp.com>
2021-04-15 17:44:35 +00:00
|
|
|
|
return desktop_media_id;
|
2016-01-07 20:38:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-11 17:45:55 +00:00
|
|
|
|
NativeWindowHandle NativeWindowMac::GetNativeWindowHandle() const {
|
|
|
|
|
return [window_ contentView];
|
2018-11-08 17:03:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-20 18:47:04 +00:00
|
|
|
|
void NativeWindowMac::SetProgressBar(double progress,
|
|
|
|
|
const NativeWindow::ProgressState state) {
|
2014-09-17 07:58:08 +00:00
|
|
|
|
NSDockTile* dock_tile = [NSApp dockTile];
|
|
|
|
|
|
2019-02-04 23:59:06 +00:00
|
|
|
|
// Sometimes macOS would install a default contentView for dock, we must
|
|
|
|
|
// verify whether NSProgressIndicator has been installed.
|
|
|
|
|
bool first_time = !dock_tile.contentView ||
|
|
|
|
|
[[dock_tile.contentView subviews] count] == 0 ||
|
|
|
|
|
![[[dock_tile.contentView subviews] lastObject]
|
|
|
|
|
isKindOfClass:[NSProgressIndicator class]];
|
|
|
|
|
|
2018-04-20 18:47:04 +00:00
|
|
|
|
// For the first time API invoked, we need to create a ContentView in
|
|
|
|
|
// DockTile.
|
2019-02-04 23:59:06 +00:00
|
|
|
|
if (first_time) {
|
2023-07-16 14:14:43 +00:00
|
|
|
|
NSImageView* image_view = [[NSImageView alloc] init];
|
2014-09-17 07:58:08 +00:00
|
|
|
|
[image_view setImage:[NSApp applicationIconImage]];
|
|
|
|
|
[dock_tile setContentView:image_view];
|
|
|
|
|
|
2019-02-04 23:59:06 +00:00
|
|
|
|
NSRect frame = NSMakeRect(0.0f, 0.0f, dock_tile.size.width, 15.0);
|
|
|
|
|
NSProgressIndicator* progress_indicator =
|
2023-07-16 14:14:43 +00:00
|
|
|
|
[[ElectronProgressBar alloc] initWithFrame:frame];
|
2023-07-01 20:22:55 +00:00
|
|
|
|
[progress_indicator setStyle:NSProgressIndicatorStyleBar];
|
2014-09-17 07:58:08 +00:00
|
|
|
|
[progress_indicator setIndeterminate:NO];
|
|
|
|
|
[progress_indicator setBezeled:YES];
|
|
|
|
|
[progress_indicator setMinValue:0];
|
|
|
|
|
[progress_indicator setMaxValue:1];
|
|
|
|
|
[progress_indicator setHidden:NO];
|
2016-06-16 21:57:23 +00:00
|
|
|
|
[dock_tile.contentView addSubview:progress_indicator];
|
2014-09-17 07:58:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-20 18:47:04 +00:00
|
|
|
|
NSProgressIndicator* progress_indicator = static_cast<NSProgressIndicator*>(
|
2019-02-04 23:59:06 +00:00
|
|
|
|
[[[dock_tile contentView] subviews] lastObject]);
|
2014-09-17 07:58:08 +00:00
|
|
|
|
if (progress < 0) {
|
|
|
|
|
[progress_indicator setHidden:YES];
|
|
|
|
|
} else if (progress > 1) {
|
2014-09-21 10:56:03 +00:00
|
|
|
|
[progress_indicator setHidden:NO];
|
2014-09-17 07:58:08 +00:00
|
|
|
|
[progress_indicator setIndeterminate:YES];
|
2014-09-21 10:56:03 +00:00
|
|
|
|
[progress_indicator setDoubleValue:1];
|
2014-09-17 07:58:08 +00:00
|
|
|
|
} else {
|
2014-09-21 10:56:03 +00:00
|
|
|
|
[progress_indicator setHidden:NO];
|
2014-09-17 07:58:08 +00:00
|
|
|
|
[progress_indicator setDoubleValue:progress];
|
|
|
|
|
}
|
|
|
|
|
[dock_tile display];
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-11 01:14:26 +00:00
|
|
|
|
void NativeWindowMac::SetOverlayIcon(const gfx::Image& overlay,
|
2018-04-20 18:47:04 +00:00
|
|
|
|
const std::string& description) {}
|
2015-02-07 19:56:03 +00:00
|
|
|
|
|
2020-08-19 20:31:25 +00:00
|
|
|
|
void NativeWindowMac::SetVisibleOnAllWorkspaces(bool visible,
|
2021-02-02 12:24:04 +00:00
|
|
|
|
bool visibleOnFullScreen,
|
|
|
|
|
bool skipTransformProcessType) {
|
2023-03-20 14:30:49 +00:00
|
|
|
|
// In order for NSWindows to be visible on fullscreen we need to invoke
|
|
|
|
|
// app.dock.hide() since Apple changed the underlying functionality of
|
2020-08-19 20:31:25 +00:00
|
|
|
|
// NSWindows starting with 10.14 to disallow NSWindows from floating on top of
|
|
|
|
|
// fullscreen apps.
|
2021-02-02 12:24:04 +00:00
|
|
|
|
if (!skipTransformProcessType) {
|
|
|
|
|
if (visibleOnFullScreen) {
|
2023-03-20 14:30:49 +00:00
|
|
|
|
Browser::Get()->DockHide();
|
2021-02-02 12:24:04 +00:00
|
|
|
|
} else {
|
2023-03-20 14:30:49 +00:00
|
|
|
|
Browser::Get()->DockShow(JavascriptEnvironment::GetIsolate());
|
2021-02-02 12:24:04 +00:00
|
|
|
|
}
|
2020-08-19 20:31:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-01-23 11:12:19 +00:00
|
|
|
|
SetCollectionBehavior(visible, NSWindowCollectionBehaviorCanJoinAllSpaces);
|
2020-08-19 20:31:25 +00:00
|
|
|
|
SetCollectionBehavior(visibleOnFullScreen,
|
|
|
|
|
NSWindowCollectionBehaviorFullScreenAuxiliary);
|
2015-03-26 06:18:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 15:51:59 +00:00
|
|
|
|
bool NativeWindowMac::IsVisibleOnAllWorkspaces() const {
|
2015-03-27 11:41:07 +00:00
|
|
|
|
NSUInteger collectionBehavior = [window_ collectionBehavior];
|
|
|
|
|
return collectionBehavior & NSWindowCollectionBehaviorCanJoinAllSpaces;
|
2015-03-26 06:18:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-28 19:38:40 +00:00
|
|
|
|
void NativeWindowMac::SetAutoHideCursor(bool auto_hide) {
|
|
|
|
|
[window_ setDisableAutoHideCursor:!auto_hide];
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-11 07:45:21 +00:00
|
|
|
|
void NativeWindowMac::UpdateVibrancyRadii(bool fullscreen) {
|
2021-06-16 17:13:42 +00:00
|
|
|
|
NSVisualEffectView* vibrantView = [window_ vibrantView];
|
2021-05-11 07:45:21 +00:00
|
|
|
|
|
2021-06-16 17:13:42 +00:00
|
|
|
|
if (vibrantView != nil && !vibrancy_type_.empty()) {
|
2022-06-03 07:47:19 +00:00
|
|
|
|
const bool no_rounded_corner = !HasStyleMask(NSWindowStyleMaskTitled);
|
2023-09-27 13:12:37 +00:00
|
|
|
|
const int macos_version = base::mac::MacOSMajorVersion();
|
2024-01-18 08:59:54 +00:00
|
|
|
|
const bool modal = is_modal();
|
2023-09-27 13:12:37 +00:00
|
|
|
|
|
2024-01-18 08:59:54 +00:00
|
|
|
|
// If the window is modal, its corners are rounded on macOS >= 11 or higher
|
|
|
|
|
// unless the user has explicitly passed noRoundedCorners.
|
2023-09-27 13:12:37 +00:00
|
|
|
|
bool should_round_modal =
|
2024-01-18 08:59:54 +00:00
|
|
|
|
!no_rounded_corner && macos_version >= 11 && modal;
|
|
|
|
|
// If the window is nonmodal, its corners are rounded if it is frameless and
|
|
|
|
|
// the user hasn't passed noRoundedCorners.
|
|
|
|
|
bool should_round_nonmodal = !no_rounded_corner && !modal && !has_frame();
|
2023-09-27 13:12:37 +00:00
|
|
|
|
|
|
|
|
|
if (should_round_nonmodal || should_round_modal) {
|
2021-05-11 07:45:21 +00:00
|
|
|
|
CGFloat radius;
|
|
|
|
|
if (fullscreen) {
|
|
|
|
|
radius = 0.0f;
|
2023-09-27 13:12:37 +00:00
|
|
|
|
} else if (macos_version >= 11) {
|
2021-05-11 07:45:21 +00:00
|
|
|
|
radius = 9.0f;
|
|
|
|
|
} else {
|
|
|
|
|
// Smaller corner radius on versions prior to Big Sur.
|
|
|
|
|
radius = 5.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CGFloat dimension = 2 * radius + 1;
|
|
|
|
|
NSSize size = NSMakeSize(dimension, dimension);
|
|
|
|
|
NSImage* maskImage = [NSImage imageWithSize:size
|
|
|
|
|
flipped:NO
|
|
|
|
|
drawingHandler:^BOOL(NSRect rect) {
|
|
|
|
|
NSBezierPath* bezierPath = [NSBezierPath
|
|
|
|
|
bezierPathWithRoundedRect:rect
|
|
|
|
|
xRadius:radius
|
|
|
|
|
yRadius:radius];
|
|
|
|
|
[[NSColor blackColor] set];
|
|
|
|
|
[bezierPath fill];
|
|
|
|
|
return YES;
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[maskImage setCapInsets:NSEdgeInsetsMake(radius, radius, radius, radius)];
|
|
|
|
|
[maskImage setResizingMode:NSImageResizingModeStretch];
|
2021-06-16 17:13:42 +00:00
|
|
|
|
[vibrantView setMaskImage:maskImage];
|
2021-05-14 09:05:34 +00:00
|
|
|
|
[window_ setCornerMask:maskImage];
|
2021-05-11 07:45:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-09 08:48:50 +00:00
|
|
|
|
void NativeWindowMac::UpdateWindowOriginalFrame() {
|
|
|
|
|
original_frame_ = [window_ frame];
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-07 20:22:41 +00:00
|
|
|
|
void NativeWindowMac::SetVibrancy(const std::string& type) {
|
2023-09-11 12:51:54 +00:00
|
|
|
|
NativeWindow::SetVibrancy(type);
|
|
|
|
|
|
2021-06-16 17:13:42 +00:00
|
|
|
|
NSVisualEffectView* vibrantView = [window_ vibrantView];
|
2024-07-30 23:21:20 +00:00
|
|
|
|
views::View* rootView = GetContentsView();
|
2016-11-10 10:59:25 +00:00
|
|
|
|
|
2019-02-25 17:21:57 +00:00
|
|
|
|
if (type.empty()) {
|
2024-07-30 23:21:20 +00:00
|
|
|
|
if (vibrant_native_view_host_ != nullptr) {
|
|
|
|
|
// Transfers ownership back to caller in the form of a unique_ptr which is
|
|
|
|
|
// subsequently deleted.
|
|
|
|
|
rootView->RemoveChildViewT(vibrant_native_view_host_);
|
|
|
|
|
vibrant_native_view_host_ = nullptr;
|
|
|
|
|
}
|
2016-11-10 10:59:25 +00:00
|
|
|
|
|
2024-07-30 23:21:20 +00:00
|
|
|
|
if (vibrantView != nil) {
|
|
|
|
|
[window_ setVibrantView:nil];
|
|
|
|
|
}
|
2018-02-12 18:38:37 +00:00
|
|
|
|
|
2019-02-25 17:21:57 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2018-02-12 18:38:37 +00:00
|
|
|
|
|
2021-06-16 06:39:20 +00:00
|
|
|
|
NSVisualEffectMaterial vibrancyType{};
|
2023-07-01 20:22:55 +00:00
|
|
|
|
if (type == "titlebar") {
|
2019-02-25 17:21:57 +00:00
|
|
|
|
vibrancyType = NSVisualEffectMaterialTitlebar;
|
2023-07-01 20:22:55 +00:00
|
|
|
|
} else if (type == "selection") {
|
2021-09-30 09:41:28 +00:00
|
|
|
|
vibrancyType = NSVisualEffectMaterialSelection;
|
|
|
|
|
} else if (type == "menu") {
|
|
|
|
|
vibrancyType = NSVisualEffectMaterialMenu;
|
|
|
|
|
} else if (type == "popover") {
|
|
|
|
|
vibrancyType = NSVisualEffectMaterialPopover;
|
|
|
|
|
} else if (type == "sidebar") {
|
|
|
|
|
vibrancyType = NSVisualEffectMaterialSidebar;
|
2023-07-01 20:22:55 +00:00
|
|
|
|
} else if (type == "header") {
|
|
|
|
|
vibrancyType = NSVisualEffectMaterialHeaderView;
|
|
|
|
|
} else if (type == "sheet") {
|
|
|
|
|
vibrancyType = NSVisualEffectMaterialSheet;
|
|
|
|
|
} else if (type == "window") {
|
|
|
|
|
vibrancyType = NSVisualEffectMaterialWindowBackground;
|
|
|
|
|
} else if (type == "hud") {
|
|
|
|
|
vibrancyType = NSVisualEffectMaterialHUDWindow;
|
|
|
|
|
} else if (type == "fullscreen-ui") {
|
|
|
|
|
vibrancyType = NSVisualEffectMaterialFullScreenUI;
|
|
|
|
|
} else if (type == "tooltip") {
|
|
|
|
|
vibrancyType = NSVisualEffectMaterialToolTip;
|
|
|
|
|
} else if (type == "content") {
|
|
|
|
|
vibrancyType = NSVisualEffectMaterialContentBackground;
|
|
|
|
|
} else if (type == "under-window") {
|
|
|
|
|
vibrancyType = NSVisualEffectMaterialUnderWindowBackground;
|
|
|
|
|
} else if (type == "under-page") {
|
|
|
|
|
vibrancyType = NSVisualEffectMaterialUnderPageBackground;
|
2019-07-11 19:10:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-16 06:39:20 +00:00
|
|
|
|
if (vibrancyType) {
|
|
|
|
|
vibrancy_type_ = type;
|
2021-06-23 06:09:42 +00:00
|
|
|
|
|
|
|
|
|
if (vibrantView == nil) {
|
2023-07-16 14:14:43 +00:00
|
|
|
|
vibrantView = [[NSVisualEffectView alloc]
|
|
|
|
|
initWithFrame:[[window_ contentView] bounds]];
|
2021-06-23 06:09:42 +00:00
|
|
|
|
[window_ setVibrantView:vibrantView];
|
|
|
|
|
|
|
|
|
|
[vibrantView
|
|
|
|
|
setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
|
|
|
|
[vibrantView setBlendingMode:NSVisualEffectBlendingModeBehindWindow];
|
|
|
|
|
|
|
|
|
|
if (visual_effect_state_ == VisualEffectState::kActive) {
|
|
|
|
|
[vibrantView setState:NSVisualEffectStateActive];
|
|
|
|
|
} else if (visual_effect_state_ == VisualEffectState::kInactive) {
|
|
|
|
|
[vibrantView setState:NSVisualEffectStateInactive];
|
|
|
|
|
} else {
|
|
|
|
|
[vibrantView setState:NSVisualEffectStateFollowsWindowActiveState];
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-30 23:21:20 +00:00
|
|
|
|
// Vibrant view is inserted into the root view hierarchy underneath all
|
|
|
|
|
// other views.
|
|
|
|
|
vibrant_native_view_host_ = rootView->AddChildViewAt(
|
|
|
|
|
std::make_unique<views::NativeViewHost>(), 0);
|
|
|
|
|
vibrant_native_view_host_->Attach(vibrantView);
|
|
|
|
|
|
|
|
|
|
rootView->DeprecatedLayoutImmediately();
|
2021-06-23 06:09:42 +00:00
|
|
|
|
|
|
|
|
|
UpdateVibrancyRadii(IsFullscreen());
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-16 17:13:42 +00:00
|
|
|
|
[vibrantView setMaterial:vibrancyType];
|
2021-06-16 06:39:20 +00:00
|
|
|
|
}
|
2016-11-07 20:22:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-01-19 10:12:09 +00:00
|
|
|
|
void NativeWindowMac::SetWindowButtonVisibility(bool visible) {
|
|
|
|
|
window_button_visibility_ = visible;
|
2022-06-21 07:35:53 +00:00
|
|
|
|
if (buttons_proxy_) {
|
|
|
|
|
if (visible)
|
|
|
|
|
[buttons_proxy_ redraw];
|
2021-08-04 00:31:12 +00:00
|
|
|
|
[buttons_proxy_ setVisible:visible];
|
2022-06-21 07:35:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (title_bar_style_ != TitleBarStyle::kCustomButtonsOnHover)
|
2021-08-04 00:31:12 +00:00
|
|
|
|
InternalSetWindowButtonVisibility(visible);
|
2022-06-21 07:35:53 +00:00
|
|
|
|
|
2021-07-01 19:25:40 +00:00
|
|
|
|
NotifyLayoutWindowControlsOverlay();
|
2021-01-19 10:12:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool NativeWindowMac::GetWindowButtonVisibility() const {
|
2021-08-04 00:31:12 +00:00
|
|
|
|
return ![window_ standardWindowButton:NSWindowZoomButton].hidden ||
|
|
|
|
|
![window_ standardWindowButton:NSWindowMiniaturizeButton].hidden ||
|
|
|
|
|
![window_ standardWindowButton:NSWindowCloseButton].hidden;
|
2021-01-19 10:12:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-17 10:06:32 +00:00
|
|
|
|
void NativeWindowMac::SetWindowButtonPosition(
|
2024-01-10 22:23:35 +00:00
|
|
|
|
std::optional<gfx::Point> position) {
|
2020-12-16 05:30:39 +00:00
|
|
|
|
traffic_light_position_ = std::move(position);
|
2021-08-04 00:31:12 +00:00
|
|
|
|
if (buttons_proxy_) {
|
|
|
|
|
[buttons_proxy_ setMargin:traffic_light_position_];
|
2021-07-01 19:25:40 +00:00
|
|
|
|
NotifyLayoutWindowControlsOverlay();
|
2020-12-16 05:30:39 +00:00
|
|
|
|
}
|
2020-03-05 22:22:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-10 22:23:35 +00:00
|
|
|
|
std::optional<gfx::Point> NativeWindowMac::GetWindowButtonPosition() const {
|
2020-03-05 22:22:12 +00:00
|
|
|
|
return traffic_light_position_;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-18 00:50:51 +00:00
|
|
|
|
void NativeWindowMac::RedrawTrafficLights() {
|
2021-08-04 00:31:12 +00:00
|
|
|
|
if (buttons_proxy_ && !IsFullscreen())
|
|
|
|
|
[buttons_proxy_ redraw];
|
2020-12-18 00:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-03-16 09:41:59 +00:00
|
|
|
|
// In simpleFullScreen mode, update the frame for new bounds.
|
|
|
|
|
void NativeWindowMac::UpdateFrame() {
|
|
|
|
|
NSWindow* window = GetNativeWindow().GetNativeNSWindow();
|
|
|
|
|
NSRect fullscreenFrame = [window.screen frame];
|
|
|
|
|
[window setFrame:fullscreenFrame display:YES animate:YES];
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-01 00:14:02 +00:00
|
|
|
|
void NativeWindowMac::SetTouchBar(
|
2019-10-31 07:56:00 +00:00
|
|
|
|
std::vector<gin_helper::PersistentDictionary> items) {
|
2023-07-18 22:26:27 +00:00
|
|
|
|
touch_bar_ = [[ElectronTouchBar alloc] initWithDelegate:window_delegate_
|
|
|
|
|
window:this
|
|
|
|
|
settings:std::move(items)];
|
2022-06-02 18:43:40 +00:00
|
|
|
|
[window_ setTouchBar:nil];
|
2016-11-27 11:54:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-01 00:08:12 +00:00
|
|
|
|
void NativeWindowMac::RefreshTouchBarItem(const std::string& item_id) {
|
2022-06-02 18:43:40 +00:00
|
|
|
|
if (touch_bar_ && [window_ touchBar])
|
|
|
|
|
[touch_bar_ refreshTouchBarItem:[window_ touchBar] id:item_id];
|
2016-12-16 06:24:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-19 07:12:11 +00:00
|
|
|
|
void NativeWindowMac::SetEscapeTouchBarItem(
|
2019-10-31 07:56:00 +00:00
|
|
|
|
gin_helper::PersistentDictionary item) {
|
2022-06-02 18:43:40 +00:00
|
|
|
|
if (touch_bar_ && [window_ touchBar])
|
|
|
|
|
[touch_bar_ setEscapeTouchBarItem:std::move(item)
|
|
|
|
|
forTouchBar:[window_ touchBar]];
|
2017-03-27 00:22:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-18 00:50:51 +00:00
|
|
|
|
void NativeWindowMac::SelectPreviousTab() {
|
2022-06-02 18:43:40 +00:00
|
|
|
|
[window_ selectPreviousTab:nil];
|
2020-12-18 00:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NativeWindowMac::SelectNextTab() {
|
2022-06-02 18:43:40 +00:00
|
|
|
|
[window_ selectNextTab:nil];
|
2020-12-18 00:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-10 08:43:37 +00:00
|
|
|
|
void NativeWindowMac::ShowAllTabs() {
|
|
|
|
|
[window_ toggleTabOverview:nil];
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-18 00:50:51 +00:00
|
|
|
|
void NativeWindowMac::MergeAllWindows() {
|
2022-06-02 18:43:40 +00:00
|
|
|
|
[window_ mergeAllWindows:nil];
|
2020-12-18 00:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NativeWindowMac::MoveTabToNewWindow() {
|
2022-06-02 18:43:40 +00:00
|
|
|
|
[window_ moveTabToNewWindow:nil];
|
2020-12-18 00:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NativeWindowMac::ToggleTabBar() {
|
2022-06-02 18:43:40 +00:00
|
|
|
|
[window_ toggleTabBar:nil];
|
2020-12-18 00:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool NativeWindowMac::AddTabbedWindow(NativeWindow* window) {
|
|
|
|
|
if (window_ == window->GetNativeWindow().GetNativeNSWindow()) {
|
|
|
|
|
return false;
|
|
|
|
|
} else {
|
2022-06-02 18:43:40 +00:00
|
|
|
|
[window_ addTabbedWindow:window->GetNativeWindow().GetNativeNSWindow()
|
|
|
|
|
ordered:NSWindowAbove];
|
2020-12-18 00:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-10 22:23:35 +00:00
|
|
|
|
std::optional<std::string> NativeWindowMac::GetTabbingIdentifier() const {
|
2023-10-03 19:27:40 +00:00
|
|
|
|
if ([window_ tabbingMode] == NSWindowTabbingModeDisallowed)
|
2024-01-10 22:23:35 +00:00
|
|
|
|
return std::nullopt;
|
2023-10-03 19:27:40 +00:00
|
|
|
|
|
|
|
|
|
return base::SysNSStringToUTF8([window_ tabbingIdentifier]);
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-18 00:50:51 +00:00
|
|
|
|
void NativeWindowMac::SetAspectRatio(double aspect_ratio,
|
|
|
|
|
const gfx::Size& extra_size) {
|
|
|
|
|
NativeWindow::SetAspectRatio(aspect_ratio, extra_size);
|
|
|
|
|
|
|
|
|
|
// Reset the behaviour to default if aspect_ratio is set to 0 or less.
|
2022-01-13 00:42:42 +00:00
|
|
|
|
if (aspect_ratio > 0.0) {
|
|
|
|
|
NSSize aspect_ratio_size = NSMakeSize(aspect_ratio, 1.0);
|
|
|
|
|
if (has_frame())
|
|
|
|
|
[window_ setContentAspectRatio:aspect_ratio_size];
|
|
|
|
|
else
|
|
|
|
|
[window_ setAspectRatio:aspect_ratio_size];
|
|
|
|
|
} else {
|
2020-12-18 00:50:51 +00:00
|
|
|
|
[window_ setResizeIncrements:NSMakeSize(1.0, 1.0)];
|
2022-01-13 00:42:42 +00:00
|
|
|
|
}
|
2020-12-18 00:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NativeWindowMac::PreviewFile(const std::string& path,
|
|
|
|
|
const std::string& display_name) {
|
2023-07-18 22:26:27 +00:00
|
|
|
|
preview_item_ = [[ElectronPreviewItem alloc]
|
2020-12-18 00:50:51 +00:00
|
|
|
|
initWithURL:[NSURL fileURLWithPath:base::SysUTF8ToNSString(path)]
|
2023-07-18 22:26:27 +00:00
|
|
|
|
title:base::SysUTF8ToNSString(display_name)];
|
2020-12-18 00:50:51 +00:00
|
|
|
|
[[QLPreviewPanel sharedPreviewPanel] makeKeyAndOrderFront:nil];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NativeWindowMac::CloseFilePreview() {
|
|
|
|
|
if ([QLPreviewPanel sharedPreviewPanelExists]) {
|
|
|
|
|
[[QLPreviewPanel sharedPreviewPanel] close];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-22 06:09:38 +00:00
|
|
|
|
gfx::Rect NativeWindowMac::ContentBoundsToWindowBounds(
|
|
|
|
|
const gfx::Rect& bounds) const {
|
|
|
|
|
if (has_frame()) {
|
|
|
|
|
gfx::Rect window_bounds(
|
|
|
|
|
[window_ frameRectForContentRect:bounds.ToCGRect()]);
|
|
|
|
|
int frame_height = window_bounds.height() - bounds.height();
|
|
|
|
|
window_bounds.set_y(window_bounds.y() - frame_height);
|
|
|
|
|
return window_bounds;
|
|
|
|
|
} else {
|
|
|
|
|
return bounds;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gfx::Rect NativeWindowMac::WindowBoundsToContentBounds(
|
|
|
|
|
const gfx::Rect& bounds) const {
|
|
|
|
|
if (has_frame()) {
|
|
|
|
|
gfx::Rect content_bounds(
|
|
|
|
|
[window_ contentRectForFrameRect:bounds.ToCGRect()]);
|
|
|
|
|
int frame_height = bounds.height() - content_bounds.height();
|
|
|
|
|
content_bounds.set_y(content_bounds.y() + frame_height);
|
|
|
|
|
return content_bounds;
|
|
|
|
|
} else {
|
|
|
|
|
return bounds;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-30 23:15:10 +00:00
|
|
|
|
void NativeWindowMac::NotifyWindowEnterFullScreen() {
|
|
|
|
|
NativeWindow::NotifyWindowEnterFullScreen();
|
|
|
|
|
// Restore the window title under fullscreen mode.
|
2021-08-04 00:31:12 +00:00
|
|
|
|
if (buttons_proxy_)
|
2021-01-30 23:15:10 +00:00
|
|
|
|
[window_ setTitleVisibility:NSWindowTitleVisible];
|
2023-09-07 22:55:17 +00:00
|
|
|
|
|
|
|
|
|
if (transparent() || !has_frame())
|
|
|
|
|
[window_ setTitlebarAppearsTransparent:NO];
|
2021-01-30 23:15:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NativeWindowMac::NotifyWindowLeaveFullScreen() {
|
|
|
|
|
NativeWindow::NotifyWindowLeaveFullScreen();
|
2021-08-04 00:31:12 +00:00
|
|
|
|
// Restore window buttons.
|
|
|
|
|
if (buttons_proxy_ && window_button_visibility_.value_or(true)) {
|
|
|
|
|
[buttons_proxy_ redraw];
|
|
|
|
|
[buttons_proxy_ setVisible:YES];
|
|
|
|
|
}
|
2023-09-07 22:55:17 +00:00
|
|
|
|
|
|
|
|
|
if (transparent() || !has_frame())
|
|
|
|
|
[window_ setTitlebarAppearsTransparent:YES];
|
2021-01-30 23:15:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NativeWindowMac::NotifyWindowWillEnterFullScreen() {
|
2021-05-11 07:45:21 +00:00
|
|
|
|
UpdateVibrancyRadii(true);
|
2021-01-30 23:15:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-01 10:13:13 +00:00
|
|
|
|
void NativeWindowMac::NotifyWindowDidFailToEnterFullScreen() {
|
|
|
|
|
UpdateVibrancyRadii(false);
|
|
|
|
|
|
|
|
|
|
if (buttons_proxy_)
|
|
|
|
|
[buttons_proxy_ redraw];
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-30 23:15:10 +00:00
|
|
|
|
void NativeWindowMac::NotifyWindowWillLeaveFullScreen() {
|
2021-08-04 00:31:12 +00:00
|
|
|
|
if (buttons_proxy_) {
|
|
|
|
|
// Hide window title when leaving fullscreen.
|
2021-01-30 23:15:10 +00:00
|
|
|
|
[window_ setTitleVisibility:NSWindowTitleHidden];
|
2021-08-04 00:31:12 +00:00
|
|
|
|
// Hide the container otherwise traffic light buttons jump.
|
|
|
|
|
[buttons_proxy_ setVisible:NO];
|
2021-02-05 01:03:12 +00:00
|
|
|
|
}
|
2021-05-11 07:45:21 +00:00
|
|
|
|
UpdateVibrancyRadii(false);
|
2021-01-30 23:15:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-19 09:27:35 +00:00
|
|
|
|
void NativeWindowMac::SetActive(bool is_key) {
|
|
|
|
|
is_active_ = is_key;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool NativeWindowMac::IsActive() const {
|
|
|
|
|
return is_active_;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-18 00:50:51 +00:00
|
|
|
|
void NativeWindowMac::Cleanup() {
|
|
|
|
|
DCHECK(!IsClosed());
|
|
|
|
|
ui::NativeTheme::GetInstanceForNativeUi()->RemoveObserver(this);
|
2021-03-16 09:41:59 +00:00
|
|
|
|
display::Screen::GetScreen()->RemoveObserver(this);
|
2020-12-18 00:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-10-12 16:05:45 +00:00
|
|
|
|
class NativeAppWindowFrameViewMac : public views::NativeFrameViewMac {
|
|
|
|
|
public:
|
|
|
|
|
NativeAppWindowFrameViewMac(views::Widget* frame, NativeWindowMac* window)
|
|
|
|
|
: views::NativeFrameViewMac(frame), native_window_(window) {}
|
|
|
|
|
|
|
|
|
|
NativeAppWindowFrameViewMac(const NativeAppWindowFrameViewMac&) = delete;
|
|
|
|
|
NativeAppWindowFrameViewMac& operator=(const NativeAppWindowFrameViewMac&) =
|
|
|
|
|
delete;
|
|
|
|
|
|
|
|
|
|
~NativeAppWindowFrameViewMac() override = default;
|
|
|
|
|
|
|
|
|
|
// NonClientFrameView:
|
|
|
|
|
int NonClientHitTest(const gfx::Point& point) override {
|
|
|
|
|
if (!bounds().Contains(point))
|
|
|
|
|
return HTNOWHERE;
|
|
|
|
|
|
|
|
|
|
if (GetWidget()->IsFullscreen())
|
|
|
|
|
return HTCLIENT;
|
|
|
|
|
|
|
|
|
|
// Check for possible draggable region in the client area for the frameless
|
|
|
|
|
// window.
|
2022-11-07 18:15:57 +00:00
|
|
|
|
int contents_hit_test = native_window_->NonClientHitTest(point);
|
|
|
|
|
if (contents_hit_test != HTNOWHERE)
|
|
|
|
|
return contents_hit_test;
|
2022-10-12 16:05:45 +00:00
|
|
|
|
|
|
|
|
|
return HTCLIENT;
|
2020-12-18 00:50:51 +00:00
|
|
|
|
}
|
2022-10-12 16:05:45 +00:00
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// Weak.
|
|
|
|
|
raw_ptr<NativeWindowMac> const native_window_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<views::NonClientFrameView>
|
|
|
|
|
NativeWindowMac::CreateNonClientFrameView(views::Widget* widget) {
|
|
|
|
|
return std::make_unique<NativeAppWindowFrameViewMac>(widget, this);
|
2020-12-18 00:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-03 07:47:19 +00:00
|
|
|
|
bool NativeWindowMac::HasStyleMask(NSUInteger flag) const {
|
|
|
|
|
return [window_ styleMask] & flag;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-18 00:50:51 +00:00
|
|
|
|
void NativeWindowMac::SetStyleMask(bool on, NSUInteger flag) {
|
|
|
|
|
// Changing the styleMask of a frameless windows causes it to change size so
|
|
|
|
|
// we explicitly disable resizing while setting it.
|
|
|
|
|
ScopedDisableResize disable_resize;
|
|
|
|
|
|
|
|
|
|
if (on)
|
|
|
|
|
[window_ setStyleMask:[window_ styleMask] | flag];
|
|
|
|
|
else
|
|
|
|
|
[window_ setStyleMask:[window_ styleMask] & (~flag)];
|
2021-09-17 13:54:15 +00:00
|
|
|
|
|
2020-12-18 00:50:51 +00:00
|
|
|
|
// Change style mask will make the zoom button revert to default, probably
|
|
|
|
|
// a bug of Cocoa or macOS.
|
2021-09-17 13:54:15 +00:00
|
|
|
|
SetMaximizable(maximizable_);
|
2020-12-18 00:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NativeWindowMac::SetCollectionBehavior(bool on, NSUInteger flag) {
|
|
|
|
|
if (on)
|
|
|
|
|
[window_ setCollectionBehavior:[window_ collectionBehavior] | flag];
|
|
|
|
|
else
|
|
|
|
|
[window_ setCollectionBehavior:[window_ collectionBehavior] & (~flag)];
|
2021-09-17 13:54:15 +00:00
|
|
|
|
|
2020-12-18 00:50:51 +00:00
|
|
|
|
// Change collectionBehavior will make the zoom button revert to default,
|
|
|
|
|
// probably a bug of Cocoa or macOS.
|
2021-09-17 13:54:15 +00:00
|
|
|
|
SetMaximizable(maximizable_);
|
2020-12-18 00:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-02 06:39:43 +00:00
|
|
|
|
views::View* NativeWindowMac::GetContentsView() {
|
|
|
|
|
return root_view_.get();
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-17 13:54:15 +00:00
|
|
|
|
bool NativeWindowMac::CanMaximize() const {
|
|
|
|
|
return maximizable_;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-18 00:50:51 +00:00
|
|
|
|
void NativeWindowMac::OnNativeThemeUpdated(ui::NativeTheme* observed_theme) {
|
2022-05-17 16:48:40 +00:00
|
|
|
|
content::GetUIThreadTaskRunner({})->PostTask(
|
|
|
|
|
FROM_HERE,
|
2020-12-18 00:50:51 +00:00
|
|
|
|
base::BindOnce(&NativeWindow::RedrawTrafficLights, GetWeakPtr()));
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-30 23:15:10 +00:00
|
|
|
|
void NativeWindowMac::AddContentViewLayers() {
|
2018-07-10 01:43:42 +00:00
|
|
|
|
// Make sure the bottom corner is rounded for non-modal windows:
|
2018-11-06 04:42:19 +00:00
|
|
|
|
// http://crbug.com/396264.
|
|
|
|
|
if (!is_modal()) {
|
2018-09-20 17:24:55 +00:00
|
|
|
|
// For normal window, we need to explicitly set layer for contentView to
|
|
|
|
|
// make setBackgroundColor work correctly.
|
|
|
|
|
// There is no need to do so for frameless window, and doing so would make
|
|
|
|
|
// titleBarStyle stop working.
|
|
|
|
|
if (has_frame()) {
|
2023-07-18 22:26:27 +00:00
|
|
|
|
CALayer* background_layer = [[CALayer alloc] init];
|
2018-09-20 17:24:55 +00:00
|
|
|
|
[background_layer
|
|
|
|
|
setAutoresizingMask:kCALayerWidthSizable | kCALayerHeightSizable];
|
|
|
|
|
[[window_ contentView] setLayer:background_layer];
|
|
|
|
|
}
|
2018-07-10 01:43:42 +00:00
|
|
|
|
[[window_ contentView] setWantsLayer:YES];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-19 10:12:09 +00:00
|
|
|
|
void NativeWindowMac::InternalSetWindowButtonVisibility(bool visible) {
|
2021-01-30 23:15:10 +00:00
|
|
|
|
[[window_ standardWindowButton:NSWindowCloseButton] setHidden:!visible];
|
|
|
|
|
[[window_ standardWindowButton:NSWindowMiniaturizeButton] setHidden:!visible];
|
|
|
|
|
[[window_ standardWindowButton:NSWindowZoomButton] setHidden:!visible];
|
2021-01-19 10:12:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-08 10:18:37 +00:00
|
|
|
|
void NativeWindowMac::InternalSetParentWindow(NativeWindow* new_parent,
|
2018-04-20 18:47:04 +00:00
|
|
|
|
bool attach) {
|
2017-09-14 05:43:22 +00:00
|
|
|
|
if (is_modal())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Do not remove/add if we are already properly attached.
|
2023-06-08 10:18:37 +00:00
|
|
|
|
if (attach && new_parent &&
|
|
|
|
|
[window_ parentWindow] ==
|
|
|
|
|
new_parent->GetNativeWindow().GetNativeNSWindow())
|
2017-09-14 05:43:22 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Remove current parent window.
|
2023-07-26 14:47:32 +00:00
|
|
|
|
RemoveChildFromParentWindow();
|
2017-09-14 05:43:22 +00:00
|
|
|
|
|
|
|
|
|
// Set new parent window.
|
2023-07-26 14:47:32 +00:00
|
|
|
|
if (new_parent) {
|
2023-06-08 10:18:37 +00:00
|
|
|
|
new_parent->add_child_window(this);
|
2023-07-26 14:47:32 +00:00
|
|
|
|
if (attach)
|
|
|
|
|
new_parent->AttachChildren();
|
2021-06-23 06:09:09 +00:00
|
|
|
|
}
|
2023-06-08 10:18:37 +00:00
|
|
|
|
|
|
|
|
|
NativeWindow::SetParentWindow(new_parent);
|
2017-09-14 05:43:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-09 10:35:05 +00:00
|
|
|
|
void NativeWindowMac::SetForwardMouseMessages(bool forward) {
|
|
|
|
|
[window_ setAcceptsMouseMovedEvents:forward];
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-10 22:23:35 +00:00
|
|
|
|
std::optional<gfx::Rect> NativeWindowMac::GetWindowControlsOverlayRect() {
|
2023-10-16 09:18:31 +00:00
|
|
|
|
if (!titlebar_overlay_)
|
2024-01-10 22:23:35 +00:00
|
|
|
|
return std::nullopt;
|
2023-10-16 09:18:31 +00:00
|
|
|
|
|
|
|
|
|
// On macOS, when in fullscreen mode, window controls (the menu bar, title
|
|
|
|
|
// bar, and toolbar) are attached to a separate NSView that slides down from
|
|
|
|
|
// the top of the screen, independent of, and overlapping the WebContents.
|
|
|
|
|
// Disable WCO when in fullscreen, because this space is inaccessible to
|
|
|
|
|
// WebContents. https://crbug.com/915110.
|
|
|
|
|
if (IsFullscreen())
|
|
|
|
|
return gfx::Rect();
|
|
|
|
|
|
|
|
|
|
if (buttons_proxy_ && window_button_visibility_.value_or(true)) {
|
2021-08-04 00:31:12 +00:00
|
|
|
|
NSRect buttons = [buttons_proxy_ getButtonsContainerBounds];
|
|
|
|
|
gfx::Rect overlay;
|
|
|
|
|
overlay.set_width(GetContentSize().width() - NSWidth(buttons));
|
2023-10-16 09:18:31 +00:00
|
|
|
|
overlay.set_height([buttons_proxy_ useCustomHeight]
|
|
|
|
|
? titlebar_overlay_height()
|
|
|
|
|
: NSHeight(buttons));
|
2022-01-24 22:09:21 +00:00
|
|
|
|
|
2021-08-04 00:31:12 +00:00
|
|
|
|
if (!base::i18n::IsRTL())
|
|
|
|
|
overlay.set_x(NSMaxX(buttons));
|
2023-10-16 09:18:31 +00:00
|
|
|
|
|
2021-08-04 00:31:12 +00:00
|
|
|
|
return overlay;
|
|
|
|
|
}
|
2023-10-16 09:18:31 +00:00
|
|
|
|
|
2024-01-10 22:23:35 +00:00
|
|
|
|
return std::nullopt;
|
2021-07-01 19:25:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 07:04:46 +00:00
|
|
|
|
// static
|
2024-09-06 16:59:32 +00:00
|
|
|
|
std::unique_ptr<NativeWindow> NativeWindow::Create(
|
|
|
|
|
const gin_helper::Dictionary& options,
|
|
|
|
|
NativeWindow* parent) {
|
|
|
|
|
return std::make_unique<NativeWindowMac>(options, parent);
|
2013-04-12 07:04:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace electron
|