Closed Bug 1977581 Opened 5 months ago Closed 5 months ago

When inserting image into new e-mail, Thunderbird brings main window to front

Categories

(Core :: Widget: Win32, defect)

Desktop
Windows
defect

Tracking

()

VERIFIED FIXED
143 Branch
Tracking Status
thunderbird_esr128 --- unaffected
thunderbird_esr140 --- affected
firefox-esr115 --- unaffected
firefox-esr128 --- unaffected
firefox-esr140 --- fixed
firefox141 --- wontfix
firefox142 --- fixed
firefox143 --- fixed

People

(Reporter: brille1, Assigned: emilio)

References

(Regression)

Details

(Keywords: regression)

Attachments

(3 files, 1 obsolete file)

When composing an e-mail, if an image is added to the e-mail using the Insert > Graphic menu item and dialog, Thunderbird brings the program main window to front. This should not happen. Commonly, users want to continue composing their e-mail draft in the New E-Mail window after inserting images to the draft.

Attachment #9500930 - Attachment is obsolete: true

What version are you using?

Flags: needinfo?(brille1)

It's 140.0.1 (latest release). I downloaded and installed Thunderbird yesterday.

Flags: needinfo?(brille1)

I wasn't able to recreate this on 140.0.1 on Ubuntu 24.04. What OS are you using?

Thank you for trying to reproduce the issue. I'm using Windows 10x64.

Same here: TB 140.0.1 (german) on windows 11.

New compose mail window, insert image using using the menu (Einfügen > Grafik).
After inserting the image, the compose window is no longer the top window - it drops to a lower layer and focus is set to now top window.
The top and now focused window is not always the thunderbird main window - can be any window I used meanwhile; seems to be the last active window:
(1) Thunderbird, open new mail, insert image -> thunderbird main window is on top
(2) Thunderbird, open new mail, switch to explorer (or any other application), switch back to compose window, insert image -> last application window is now in foreground and focused.

Vlad/Ramona, can you recreate on Windows?

Flags: needinfo?(vlucaci)
Flags: needinfo?(ramona)

Hello Corey!

We checked and were able to reproduce this issue.
We tested on Win 10, TB 140.0.1esr(20250709213912).

We tried to find a regression range.
It seems the last good build was from 2024-06-19 and the first bad build was from 2024-06-20
I could not find a culprit as the bisection kept skipping builds.

We also checked on macOS Sequoia and Ubuntu 24 and it’s not reproducible

Flags: needinfo?(vlucaci)

This behavior is triggered by opening the file picker dialog (the same happens with 'Format'->'Page Colors and Background'). Maybe regressed by bug 1902315, see also bug 1903605.

Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: regression
See Also: → 1902315, 1903605
Version: unspecified → Thunderbird 129
OS: Unspecified → Windows
Hardware: Unspecified → Desktop

I don't know which framework you are using, but perhaps it may help that the IModalDialog::Show() method accepts a handle to the parent (owner) window.

The owner window is the one supposed to be blocked while the dialog is opened and given focus to after the dialog closes.

Perhaps the handle provided to this method is incorrect?

(In reply to Axel from comment #10)

I don't know which framework you are using, but perhaps it may help that the IModalDialog::Show() method accepts a handle to the parent (owner) window.

The owner window is the one supposed to be blocked while the dialog is opened and given focus to after the dialog closes.

Perhaps the handle provided to this method is incorrect?

I think that's rather a question for Emilio.

Emilio, can you give us some insight about this bug?

Flags: needinfo?(emilio)

Sure, can you link me to the code that's launching the "insert image" modal? I don't know Thunderbird's code by heart :)

Flags: needinfo?(emilio) → needinfo?(h.w.forms)
Flags: needinfo?(emilio)

So... I can't repro this on Linux. Looking into this, this is most likely caused by bug 1902315. This chunk definitely used to run when exiting the modal loop on windows, and I missed that we were passing true to aActivate which means that that call also had the side effect of activating the window.

Flags: needinfo?(emilio)

Bug 1902315 removed a PlaceBehind call here, which in this case happened
to also activate the window (via the aActivate = true parameter).

Keep raising the window manually, but with simpler APIs.

Assignee: nobody → emilio
Status: NEW → ASSIGNED

AppWindow::GetMainWidget() is just mWindow. Add a helper to simplify
GetMainWidget() usage and use it across the tree, simplifying users.

See Also: → 1979597
Pushed by ealvarez@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/1aa98365aff2 https://hg.mozilla.org/integration/autoland/rev/7667a5c661d0 Keep activating the parent window on Windows when destroying a child. r=win-reviewers,handyman

Can you confirm the patch works for you? If so we should probably uplift it.

Duplicate of this bug: 1981071
Status: ASSIGNED → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → 143 Branch

(In reply to Emilio Cobos Álvarez (:emilio) from comment #18)

Can you confirm the patch works for you? If so we should probably uplift it.

With Thunderbird Daily 143.0a1 20250806104453 this appears to be working as expected again. So I think uplifting this to ESR would be much appreciated.

Maybe Ramona can verify this, just to be sure.

Comment on attachment 9503001 [details]
Bug 1977581 - Keep activating the parent window on Windows when destroying a child. r=#win-reviewers

ESR Uplift Approval Request

  • If this is not a sec:{high,crit} bug, please state case for ESR consideration: restores previous behavior relevant for Thunderbird
  • User impact if declined: comment 0
  • Fix Landed on Version: 143
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): While not totally trivial, it restores pre-existing behavior from the regressing bug in a more straight-forward way.
Attachment #9503001 - Flags: approval-mozilla-esr140?
Component: Message Compose Window → Widget
Product: Thunderbird → Core
Regressed by: 1902315
See Also: 1902315
Version: Thunderbird 129 → unspecified

Might be worth a Beta uplift request also?

Flags: needinfo?(emilio)

Comment on attachment 9503001 [details]
Bug 1977581 - Keep activating the parent window on Windows when destroying a child. r=#win-reviewers

Beta/Release Uplift Approval Request

  • User impact if declined/Reason for urgency: see above
  • Is this code covered by automated tests?: No
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: none
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): See above
  • String changes made/needed: none
  • Is Android affected?: No
Flags: needinfo?(emilio)
Attachment #9503001 - Flags: approval-mozilla-beta?

Comment on attachment 9503001 [details]
Bug 1977581 - Keep activating the parent window on Windows when destroying a child. r=#win-reviewers

Approved for 142.0rc1

Attachment #9503001 - Flags: approval-mozilla-beta? → approval-mozilla-beta+

Comment on attachment 9503001 [details]
Bug 1977581 - Keep activating the parent window on Windows when destroying a child. r=#win-reviewers

Approved for 140.2.0esr

Attachment #9503001 - Flags: approval-mozilla-esr140? → approval-mozilla-esr140+
Regressions: 1982386
No longer regressions: 1982386

Confirm this as verified fixed on TB 143.0A1(20250811095431)
Will check again once is available in TB 140.2.0esr

Status: RESOLVED → VERIFIED
Flags: needinfo?(ramona)
See Also: → 1983519
Duplicate of this bug: 1983519
Duplicate of this bug: 2004154
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: