From cbf5843c9a9455d2320040ba1a6387d929e88fc4 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 15 Sep 2022 19:06:18 +0200 Subject: [PATCH] fix: WCO occlusion of DevTools (#35688) Co-authored-by: Shelley Vohr --- docs/api/web-contents.md | 2 ++ shell/browser/api/electron_api_web_contents.cc | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 71f223081bdd6..0c7f18d55cd0e 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -1626,6 +1626,8 @@ Opens the devtools. When `contents` is a `` tag, the `mode` would be `detach` by default, explicitly passing an empty `mode` can force using last used dock state. +On Windows, if Windows Control Overlay is enabled, Devtools will be opened with `mode: 'detach'`. + #### `contents.closeDevTools()` Closes the devtools. diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index e6cd258588445..e74f2523d5d5e 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -175,6 +175,7 @@ #if BUILDFLAG(IS_WIN) #include "printing/backend/win_helper.h" +#include "shell/browser/native_window_views.h" #endif #endif @@ -2415,6 +2416,14 @@ void WebContents::OpenDevTools(gin::Arguments* args) { } } +#if BUILDFLAG(IS_WIN) + auto* win = static_cast(owner_window()); + // Force a detached state when WCO is enabled to match Chrome + // behavior and prevent occlusion of DevTools. + if (win && win->IsWindowControlsOverlayEnabled()) + state = "detach"; +#endif + DCHECK(inspectable_web_contents_); inspectable_web_contents_->SetDockState(state); inspectable_web_contents_->ShowDevTools(activate);