From 37a422d05b8ff4b7ef74d6e5dc1e7a23aae439d8 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Tue, 31 May 2022 07:08:45 +0200 Subject: [PATCH] fix: esc not working on Windows during fullscreen (#34361) * fix: esc not working on Windows during fullscreen * chore: fix lint --- patches/chromium/.patches | 2 +- ...exclusive_access_for_electron_needs.patch} | 30 +++++++++++++++---- .../browser/api/electron_api_web_contents.cc | 5 ++-- 3 files changed, 28 insertions(+), 9 deletions(-) rename patches/chromium/{fix_patch_out_permissions_checks_in_exclusive_access.patch => fix_adapt_exclusive_access_for_electron_needs.patch} (62%) diff --git a/patches/chromium/.patches b/patches/chromium/.patches index f25ddf6273601..0a396f5bf1265 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -105,7 +105,7 @@ add_ui_scopedcliboardwriter_writeunsaferawdata.patch feat_add_data_parameter_to_processsingleton.patch mas_gate_private_enterprise_APIs.patch load_v8_snapshot_in_browser_process.patch -fix_patch_out_permissions_checks_in_exclusive_access.patch +fix_adapt_exclusive_access_for_electron_needs.patch fix_aspect_ratio_with_max_size.patch fix_dont_delete_SerialPortManager_on_main_thread.patch fix_crash_when_saving_edited_pdf_files.patch diff --git a/patches/chromium/fix_patch_out_permissions_checks_in_exclusive_access.patch b/patches/chromium/fix_adapt_exclusive_access_for_electron_needs.patch similarity index 62% rename from patches/chromium/fix_patch_out_permissions_checks_in_exclusive_access.patch rename to patches/chromium/fix_adapt_exclusive_access_for_electron_needs.patch index f957509ddd87c..91a5eaf50bc1a 100644 --- a/patches/chromium/fix_patch_out_permissions_checks_in_exclusive_access.patch +++ b/patches/chromium/fix_adapt_exclusive_access_for_electron_needs.patch @@ -1,20 +1,22 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Mon, 25 Oct 2021 21:45:57 +0200 -Subject: fix: patch out permissions checks in exclusive_access +Subject: fix: adapt exclusive_access for electron needs This patch is necessary in order to properly enable navigator.keyboard.{(un)?lock}() functionality. We don't have a concept of PermissionManager nor of a Profile, so this would not affect usage of the API. -We might consider potentially using our own permissions handler, -but it's not strictly necessary for this API to work to spec. - -Profile check has been upstreamed at https://chromium-review.googlesource.com/c/chromium/src/+/3247196 +We also need to ensure that NotifyExclusiveTabAccessLost is called +on all platforms in FullscreenController::ExitFullscreenModeInternal() +and not just macOS, since Electron's native window impls report state +change fairly instantly as well, and so pressing escape won't work on +Linux or Windows to un-fullscreen in some circumstances without this +change. diff --git a/chrome/browser/ui/exclusive_access/fullscreen_controller.cc b/chrome/browser/ui/exclusive_access/fullscreen_controller.cc -index 9b2c91d39324b61afa49ccea6be2eda8308473ff..1652b52c5c752809348b3ab44d3703ac343c829d 100644 +index 9b2c91d39324b61afa49ccea6be2eda8308473ff..6817a9cd22ebb8adba2118a1bd8a32cfc065e8ea 100644 --- a/chrome/browser/ui/exclusive_access/fullscreen_controller.cc +++ b/chrome/browser/ui/exclusive_access/fullscreen_controller.cc @@ -382,13 +382,9 @@ void FullscreenController::EnterFullscreenModeInternal( @@ -49,3 +51,19 @@ index 9b2c91d39324b61afa49ccea6be2eda8308473ff..1652b52c5c752809348b3ab44d3703ac if (option == BROWSER) base::RecordAction(base::UserMetricsAction("ToggleFullscreen")); +@@ -439,12 +437,12 @@ void FullscreenController::ExitFullscreenModeInternal() { + + RecordExitingUMA(); + toggled_into_fullscreen_ = false; +-#if BUILDFLAG(IS_MAC) +- // Mac windows report a state change instantly, and so we must also clear ++ ++ // Electron native windows report a state change instantly, and so we must also clear + // state_prior_to_tab_fullscreen_ to match them else other logic using + // state_prior_to_tab_fullscreen_ will be incorrect. + NotifyTabExclusiveAccessLost(); +-#endif ++ + exclusive_access_manager()->context()->ExitFullscreen(); + extension_caused_fullscreen_ = GURL(); + diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index 91957ba7ea9b6..bb15a507961ff 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -1312,8 +1312,6 @@ void WebContents::EnterFullscreenModeForTab( base::BindRepeating(&WebContents::OnEnterFullscreenModeForTab, base::Unretained(this), requesting_frame, options); permission_helper->RequestFullscreenPermission(callback); - exclusive_access_manager_->fullscreen_controller()->EnterFullscreenModeForTab( - requesting_frame, options.display_id); } void WebContents::OnEnterFullscreenModeForTab( @@ -1329,6 +1327,9 @@ void WebContents::OnEnterFullscreenModeForTab( return; } + exclusive_access_manager_->fullscreen_controller()->EnterFullscreenModeForTab( + requesting_frame, options.display_id); + SetHtmlApiFullscreen(true); if (native_fullscreen_) {