Search code examples
c++chromium

Trouble with making Chromium browser window appear Topmost on initialization


I want to modify the Chromium browser source code, specifically for Windows, to make the browser window appear Topmost when the window is initialized.

I have tried quite a few solutions for making the window topmost post-initialization, and either they don't run at the right time or they have issues with dropdowns, such as the dropdowns not showing or hanging the browser. I have also found this snippet of code with no instructions as to where to place it:

HWND hwnd = GetWidget()->GetNativeView()->GetHost()->GetAcceleratedWidget();
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);

Solution

  • Solved! In the file src\chrome\browser\ui\views\frame\browser_frame.cc, add the line params.z_order = ui::ZOrderLevel::kFloatingWindow; to BrowserFrame::InitBrowserFrame()