Closed Bug 201242 Opened 22 years ago Closed 22 years ago

When minimize and then restore, two carets appear in a mail compose window

Categories

(MailNews Core :: Composition, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: rubydoo123, Assigned: bugzilla)

References

Details

Attachments

(2 files, 3 obsolete files)

I am using a trunk build from 20030407 on win 2K 1. open a new mail compose window, caret is in the To: field, set focus in the compose window 2. start entering some text, then minimize the window 3. restore the window Expected: I expected focus to remain within the body of the message. Actual: there was a cursor I-beam in the body of the message where I had stopped typing. There was also an I-beam in the two field. At this point when I started typing, focus was in the To: field instead of in the body of the message.
neil, can you pay attention to this bug? :) btw, this bug may be related to bug 195798.
Just doing some quick debugging, after minimizing the compose window its focus controller believes that both the To: and the body have focus (there is a separate body focus flag), which is obviously wrong :-( BTW, using Mozilla's Window menu to restore the compose window works (because it sees that the body should have focus and restores it correctly).
It's worse than that, I can duplicate the problem in the browser: 1. Focus the location bar 2. Click in the body (but NOT in an input or textarea) 3. Minimize and restore the browser Actual results: focus returns to the location bar Expected results: focus returns to the previously focused frame ere, one of yours?
As just a shot in the dark, this could be related to bug 201996.
My shot was a miss. Anyway, I think I found the problem in focus controller. Patch coming up soon.
Attached patch Proposed patch (obsolete) — Splinter Review
When focusing a window only (no element), explicitly set the focused element to null to keep the previous element and previous window synchronized.
Attachment #121439 - Flags: superreview?(jst)
Attachment #121439 - Flags: review?(neil)
Comment on attachment 121439 [details] [diff] [review] Proposed patch Looks good to me (Hyvalta nayttaa) sr=jst, but I think bryner should have a look at this one before it's checked in.
Attachment #121439 - Flags: superreview?(jst)
Attachment #121439 - Flags: superreview+
Attachment #121439 - Flags: review?(neil)
Attachment #121439 - Flags: review?(bryner)
Comment on attachment 121439 [details] [diff] [review] Proposed patch >+ SetFocusedElement(nsnull); > SetFocusedWindow(domWindow); > if (mCurrentElement) { This just looks wrong... but it's probably the right idea, there's an mCurrentElement = later that might need to be SetFocusedElement instead.
Comment on attachment 121439 [details] [diff] [review] Proposed patch Hm, no, I don't think this is quite right. You're forcing mCurrentElement to null, which sort of makes the following if (mCurrentElement) moot. Can you describe in more detail what's happening to cause this?
Attachment #121439 - Flags: review?(bryner) → review-
Attached patch Patch v2 (obsolete) — Splinter Review
Thanks for catching that. Here's a fixed patch. Here is the deal: if we don't have a suitable element to focus, we must use SetFocusedElement() so that mPreviousElement is updated. Otherwise we'll end up in a situation where mPreviousElement points to an element that isn't a child of mPreviousWindow and RewindFocusState() messes it up.
Attachment #121439 - Attachment is obsolete: true
Attachment #121522 - Flags: review?(bryner)
Attached patch alternate patch (obsolete) — Splinter Review
I think this one is more correct... it keeps mPreviousELement from becoming incorrect in the first place.
The alternate patch doesn't work for me. The focus is always lost if I minimize and restore a window where the focus was on an element.
Ok, after debugging some more, I think ere's approach is probably the right one. I'd prefer if we just set mPreviousElement directly though, instead of calling SetFocusedElement(), so that we don't call UpdateCommands() twice.
ere, does this look ok?
Attachment #121695 - Attachment is obsolete: true
Looks better and works better. My only concern is that this sets mPreviousElement to nsnull instead of cycling mCurrentElement to it. Apparently at the moment we don't have a situation where we would need mPreviousElement right after Focus(), so this doesn't seem to cause any harm, but wouldn't it be ok to call SetFocusedElement(nsnull) and just remove UpdateCommands() from Focus()?
Attachment #121522 - Attachment is obsolete: true
Attachment #121522 - Flags: review?(bryner)
I found out that we just have to guard against setting mPreviousElement to null in SetFocusedElement(). For example when minimizing the window by clicking its button on the taskbar. This causes Blur() when focus is suppressed, which causes us not to call SetFocusedElement() there. With these additional checks everything I tried worked fine. And these checks are the same as in SetFocusedWindow(). Bryner, what do you think?
Attachment #121820 - Flags: review+
Attachment #121820 - Flags: superreview?(jst)
Comment on attachment 121820 [details] [diff] [review] Bryner's patch with an additional check sr=jst
Attachment #121820 - Flags: superreview?(jst) → superreview+
Comment on attachment 121820 [details] [diff] [review] Bryner's patch with an additional check Seeking approval. This is a fairly simple patch to fix a fairly high-visibility focus problem at least in compose and navigator windows.
Attachment #121820 - Flags: approval1.4b?
Comment on attachment 121820 [details] [diff] [review] Bryner's patch with an additional check a=sspitzer
Attachment #121820 - Flags: approval1.4b? → approval1.4b+
Fix checked in to trunk.
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
*** Bug 147077 has been marked as a duplicate of this bug. ***
related bugs for OS X, which are still problems with bryner's test build: bug 203827: have 0 caret with every other new msg window bug 124929: restoring a minimized window loses focus
with bug 124929 fixed, this looks fixed on OS X now.
Product: MailNews → Core
Product: Core → MailNews Core
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: