Skip to content

Conversation

@michal-pichlinski-openfin
Copy link
Contributor

@michal-pichlinski-openfin michal-pichlinski-openfin commented Mar 31, 2025

bringToFront DevTools message is sent when breakpoint is triggered or inspect is called and Chromium upon this message activates DevTools via DevToolsUIBindings::Delegate::ActivateWindow:

void DevToolsWindow::ActivateWindow() {
  if (life_stage_ != kLoadCompleted)
    return;
\#if BUILDFLAG(IS_ANDROID)
  NOTIMPLEMENTED();
\#else
  if (is_docked_ && GetInspectedBrowserWindow())
    main_web_contents_->Focus();
  else if (!is_docked_ && browser_ && !browser_->window()->IsActive())
    browser_->window()->Activate();
\#endif
}

which implements: DevToolsUIBindings::Delegate::ActivateWindow.

Electron also implements this interface in:
electron::InspectableWebContents. However it was only setting a zoom level, therefore this commit extends it with activation of the DevTools.

Only supported for DevTools manged by electron::InspectableWebContents.

Closes: #37388

Description of Change

Checklist

Release Notes

Notes: Automatically focus DevTools when element is inspected or breakpoint is triggered.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label Mar 31, 2025
@codebytere
Copy link
Member

@michal-pichlinski-openfin could you please add release notes?

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened recently label Apr 7, 2025
@michal-pichlinski-openfin
Copy link
Contributor Author

ping

@codebytere codebytere added semver/patch backwards-compatible bug fixes target/35-x-y PR should also be added to the "35-x-y" branch. target/36-x-y PR should also be added to the "36-x-y" branch. target/37-x-y PR should also be added to the "37-x-y" branch. labels Jun 17, 2025
@github-actions github-actions bot added the target/38-x-y PR should also be added to the "38-x-y" branch. label Jun 24, 2025
@github-actions github-actions bot added the target/39-x-y PR should also be added to the "39-x-y" branch. label Sep 3, 2025
@jkleinsc jkleinsc removed target/35-x-y PR should also be added to the "35-x-y" branch. target/36-x-y PR should also be added to the "36-x-y" branch. labels Oct 27, 2025
`bringToFront` DevTools message is sent when breakpoint is triggered
or inspect is called and Chromium upon this message activates DevTools
via `DevToolsUIBindings::Delegate::ActivateWindow`:
```
void DevToolsWindow::ActivateWindow() {
  if (life_stage_ != kLoadCompleted)
    return;
\#if BUILDFLAG(IS_ANDROID)
  NOTIMPLEMENTED();
\#else
  if (is_docked_ && GetInspectedBrowserWindow())
    main_web_contents_->Focus();
  else if (!is_docked_ && browser_ && !browser_->window()->IsActive())
    browser_->window()->Activate();
\#endif
}
```
which implements: `DevToolsUIBindings::Delegate::ActivateWindow`.

Electron also implements this interface in:
`electron::InspectableWebContents`. However it was only setting
a zoom level, therefore this commit extends it with activation
of the DevTools.

Only supported for DevTools manged by `electron::InspectableWebContents`.

Closes: electron#37388
@jkleinsc jkleinsc force-pushed the mpichlinski/activate-devtools/main/1 branch from 1f68bad to e168292 Compare October 27, 2025 19:30
@jkleinsc jkleinsc merged commit 28f1cf1 into electron:main Oct 28, 2025
58 checks passed
@release-clerk
Copy link

release-clerk bot commented Oct 28, 2025

Release Notes Persisted

Automatically focus DevTools when element is inspected or breakpoint is triggered.

@trop
Copy link
Contributor

trop bot commented Oct 28, 2025

I have automatically backported this PR to "38-x-y", please check out #48701

@trop
Copy link
Contributor

trop bot commented Oct 28, 2025

I have automatically backported this PR to "39-x-y", please check out #48702

@trop trop bot removed the target/38-x-y PR should also be added to the "38-x-y" branch. label Oct 28, 2025
@trop
Copy link
Contributor

trop bot commented Oct 28, 2025

I have automatically backported this PR to "37-x-y", please check out #48703

@trop trop bot added in-flight/39-x-y in-flight/37-x-y and removed target/39-x-y PR should also be added to the "39-x-y" branch. target/37-x-y PR should also be added to the "37-x-y" branch. labels Oct 28, 2025
TheCommieAxolotl pushed a commit to TheCommieAxolotl/electron that referenced this pull request Nov 2, 2025
`bringToFront` DevTools message is sent when breakpoint is triggered
or inspect is called and Chromium upon this message activates DevTools
via `DevToolsUIBindings::Delegate::ActivateWindow`:
```
void DevToolsWindow::ActivateWindow() {
  if (life_stage_ != kLoadCompleted)
    return;
\#if BUILDFLAG(IS_ANDROID)
  NOTIMPLEMENTED();
\#else
  if (is_docked_ && GetInspectedBrowserWindow())
    main_web_contents_->Focus();
  else if (!is_docked_ && browser_ && !browser_->window()->IsActive())
    browser_->window()->Activate();
\#endif
}
```
which implements: `DevToolsUIBindings::Delegate::ActivateWindow`.

Electron also implements this interface in:
`electron::InspectableWebContents`. However it was only setting
a zoom level, therefore this commit extends it with activation
of the DevTools.

Only supported for DevTools manged by `electron::InspectableWebContents`.

Closes: electron#37388
@trop trop bot added merged/37-x-y PR was merged to the "37-x-y" branch. merged/38-x-y PR was merged to the "38-x-y" branch. merged/39-x-y PR was merged to the "39-x-y" branch. and removed in-flight/37-x-y in-flight/38-x-y in-flight/39-x-y labels Nov 10, 2025
nilayarya pushed a commit to nilayarya/electron that referenced this pull request Nov 21, 2025
`bringToFront` DevTools message is sent when breakpoint is triggered
or inspect is called and Chromium upon this message activates DevTools
via `DevToolsUIBindings::Delegate::ActivateWindow`:
```
void DevToolsWindow::ActivateWindow() {
  if (life_stage_ != kLoadCompleted)
    return;
\#if BUILDFLAG(IS_ANDROID)
  NOTIMPLEMENTED();
\#else
  if (is_docked_ && GetInspectedBrowserWindow())
    main_web_contents_->Focus();
  else if (!is_docked_ && browser_ && !browser_->window()->IsActive())
    browser_->window()->Activate();
\#endif
}
```
which implements: `DevToolsUIBindings::Delegate::ActivateWindow`.

Electron also implements this interface in:
`electron::InspectableWebContents`. However it was only setting
a zoom level, therefore this commit extends it with activation
of the DevTools.

Only supported for DevTools manged by `electron::InspectableWebContents`.

Closes: electron#37388
nilayarya added a commit to nilayarya/electron that referenced this pull request Nov 21, 2025
`bringToFront` DevTools message is sent when breakpoint is triggered
or inspect is called and Chromium upon this message activates DevTools
via `DevToolsUIBindings::Delegate::ActivateWindow`:
```
void DevToolsWindow::ActivateWindow() {
  if (life_stage_ != kLoadCompleted)
    return;
\#if BUILDFLAG(IS_ANDROID)
  NOTIMPLEMENTED();
\#else
  if (is_docked_ && GetInspectedBrowserWindow())
    main_web_contents_->Focus();
  else if (!is_docked_ && browser_ && !browser_->window()->IsActive())
    browser_->window()->Activate();
\#endif
}
```
which implements: `DevToolsUIBindings::Delegate::ActivateWindow`.

Electron also implements this interface in:
`electron::InspectableWebContents`. However it was only setting
a zoom level, therefore this commit extends it with activation
of the DevTools.

Only supported for DevTools manged by `electron::InspectableWebContents`.

Closes: electron#37388
nilayarya added a commit to nilayarya/electron that referenced this pull request Nov 21, 2025
`bringToFront` DevTools message is sent when breakpoint is triggered
or inspect is called and Chromium upon this message activates DevTools
via `DevToolsUIBindings::Delegate::ActivateWindow`:
```
void DevToolsWindow::ActivateWindow() {
  if (life_stage_ != kLoadCompleted)
    return;
\#if BUILDFLAG(IS_ANDROID)
  NOTIMPLEMENTED();
\#else
  if (is_docked_ && GetInspectedBrowserWindow())
    main_web_contents_->Focus();
  else if (!is_docked_ && browser_ && !browser_->window()->IsActive())
    browser_->window()->Activate();
\#endif
}
```
which implements: `DevToolsUIBindings::Delegate::ActivateWindow`.

Electron also implements this interface in:
`electron::InspectableWebContents`. However it was only setting
a zoom level, therefore this commit extends it with activation
of the DevTools.

Only supported for DevTools manged by `electron::InspectableWebContents`.

Closes: electron#37388
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged/37-x-y PR was merged to the "37-x-y" branch. merged/38-x-y PR was merged to the "38-x-y" branch. merged/39-x-y PR was merged to the "39-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Auto focus to devtoools webcontents when a devtools breakpoint is triggered

3 participants