From e21c3cb801622095b19c4ead8fa9d15fc5c6ea17 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 16:19:27 -0400 Subject: [PATCH] fix: respect setAlwaysOnTop before showInactive on Linux under X11 (#44322) fix: respect setAlwaysOnTop before showInactive on Linux under X11 (#44078) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: John Beutner <31829097+cptpcrd@users.noreply.github.com> --- shell/browser/native_window_views.cc | 5 +++++ spec/api-browser-window-spec.ts | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/shell/browser/native_window_views.cc b/shell/browser/native_window_views.cc index 78821fe2722..12617c1db77 100644 --- a/shell/browser/native_window_views.cc +++ b/shell/browser/native_window_views.cc @@ -538,6 +538,11 @@ void NativeWindowViews::ShowInactive() { #if BUILDFLAG(IS_LINUX) if (global_menu_bar_) global_menu_bar_->OnWindowMapped(); + + // On X11, setting Z order before showing the window doesn't take effect, + // so we have to call it again. + if (IsX11()) + widget()->SetZOrderLevel(widget()->GetZOrderLevel()); #endif } diff --git a/spec/api-browser-window-spec.ts b/spec/api-browser-window-spec.ts index cfa4bf58d34..c0934d250e9 100755 --- a/spec/api-browser-window-spec.ts +++ b/spec/api-browser-window-spec.ts @@ -2514,6 +2514,22 @@ describe('BrowserWindow module', () => { expect(c.isAlwaysOnTop()).to.be.true('child is not always on top'); expect(c._getAlwaysOnTopLevel()).to.equal('screen-saver'); }); + + it('works when called prior to show', async () => { + w = new BrowserWindow({ show: false }); + w.setAlwaysOnTop(true, 'screen-saver'); + w.show(); + await setTimeout(1000); + expect(w.isAlwaysOnTop()).to.be.true('is not alwaysOnTop'); + }); + + it('works when called prior to showInactive', async () => { + w = new BrowserWindow({ show: false }); + w.setAlwaysOnTop(true, 'screen-saver'); + w.showInactive(); + await setTimeout(1000); + expect(w.isAlwaysOnTop()).to.be.true('is not alwaysOnTop'); + }); }); describe('preconnect feature', () => {