Closed Bug 358573 Opened 18 years ago Closed 16 years ago

Ctrl+W should close the window only if it has only one about:blank tab

Categories

(Firefox :: Tabbed Browser, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: nitro, Unassigned)

References

Details

(Keywords: polish, ue)

Attachments

(1 file, 1 obsolete file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0

Note:  I know this issue has been previously reported - see my comments at the end.

Like many others that have reported this as a bug, I was surprised by the changes introduced in bug 236721, "ctrl-w on last tab closes firefox".  Initially I was quite upset with the change, as I'm very use to using Ctrl-W to close whatever I'm working on, but after reading through the numerous bugs files about this I understand the arguments coming from both sides.  The arguments are pretty thoroughly covered in bugs 236721 and 341067, so I won't rehash them here (unless asked :-).

However, I still feel that there are some very valid reasons for allowing Ctrl-W to close the window, even when browser.tabs.autoHide is set to false.  Ideally, I think there should be a separate preference for this; it doesn't even need a GUI.  Since the pro-MDI side is against this idea, though, I believe I've come up with an alternative that should appease both sides.

The attached patch retains Firefox's current behavior of clearing the last tab when Ctrl-W is pressed.  However, it will also check to see what the URL is of that tab.  If the URL is about:blank (meaning the tab has already been cleared), it will then close the window instead of clearing the tab again.  So, if I attempt to close the last tab without meaning to, the window will clear ed rather than closed, just as Firefox 2.0 does by default.  If I really do want to close the window, I can hit Ctrl-W one more time to do so.

I think this should satisfy the need to prevent users from accidentally closing the window, while also allowing those that have a need to close the window to do so.

As I said at the beginning, I know that this issue has already been reported multiple times.  However, all of them have been closed as either DUPLICATE or WONTFIX (except for 348031, which is Mac-specific).  Since I'm providing a patch and proposing a new method of dealing with the issue, I think a new bug report is more appropriate than appending this to the bottom of an already-closed bug.  If you do feel this is a dupe, though, please direct me to the correct bug and I'll post the patch there.

Thanks.

Reproducible: Always

Steps to Reproduce:
1. Apply patch to browser.js
2. Open multiple tabs
3. Close all tabs with Ctrl-W
4. On the last tab, Ctrl-W will clear the page
5. After the page has been cleared, and additional Ctrl-W will close the window
Summary: Suggestion + patch to address the "Ctrl-W should close last tab/window" debate → Suggestion + patch to address the "Ctrl-W should close last tab/window" debate: close the window iff the only tab is about:blank
i actually pondered this option myself.  still a bit annoying, but much much better than 2.0's behaviour.  i'd deal with it.
This option was mentioned in bug 341067 comment #25 and you can find counter-arguments in the following comments. In summary, this behaviour could be potentially confusing and inconsistent with any app except OpenOffice.
No, please don't do this. It means you can't hold down ctrl-W to quickly close all open tabs (unless you like playing chicken with a gigahertz processor), and it means you need to think about what's in the last open tab to know what it's going to do.

A separate preference is absolutely fine (at least as far as I'm concerned), but magic behaviour depending on what's in the last open tab isn't.
Please do this.

(In reply to comment #4)
...
> It means you can't hold down ctrl-W to quickly close
> all open tabs [...]

So?  Is this something that a lot of Firefox users do?

> it means you need to think about what's in the last open tab to know what it's
> going to do.

Good point, but IMO the convenience of the OR's proposal is enough to outweigh this nonorthogonality. :-)
Have any devs given this patch some thought?  I've been using this method for a while now and it works REALLY well.  It's a good combination of the ability to close all open tabs and start with a clean slate without restarting Firefox, as well as giving users the ability to still close the window if they really want to (ie, "close the window, dang it!").

One reason it's so useful to me is that I have Ctrl-W assigned to one of the buttons on my mouse, so I can very easily close browser tabs and windows very quickly using my mouse.  Another reason is the simple Ctrl-W muscle memory, since that combination is used by a large number of applications for the same functionality (as previously discussed).  I'm sure users of mouse gestures may run into this problem as well, if they map a particular gesture to Ctrl-W.

In fact, I recently looked into this issue again and figured out how to add a preference to revert to the previous 1.x BrowserCloseTabOrWindow() window behavior.  After changing back to that behavior, however, I discovered that I prefer this new close on blank tab behavior instead.  I like being able to close all open tabs and revert to a clean state, but I still need the ability to close the window when desired.

Please, give this some thought.  If it's decided that it's not for everyone, consider at least making it an option.

Thanks.
Attachment #243950 - Attachment is obsolete: true
How about another option: use Ctrl-Q to quit (i.e. close the browser window)?

This would allow users to hold down Ctrl-W without fear of accidentally closing the browser, and would add minimal keyboard requirement to hit one key to the left if a full browser close is desired.
(In reply to comment #7)
> Created an attachment (id=257369)
> Patch for 2.0.0.2

General rule when making patches: patch and test against trunk (latest development code) and then if branch fix is wanted as well patch and test against that too.  (preferred to have a single patch for trunk and branch(es) for convenience but stability, correctness, etc. usually takes precedence.)
As I written in Bug 440484, a short cut to close a window already exists, CTRL+SHIFT+W.
The current behaviour is misleading, because with CTRL+W you normally close the focused tab. If you see menu File, when you have more than one tab there are two commands: 'Close window (CTRL+SHIFT+W)' and 'Close tab (CTRL+W)'. When you have only one tab, there's only one command, 'Close (CTRL+W)'!!

Furthermore, if you have only one Fx window opened with only one tab, currently if you press CTRL+W Firefox quits.

IMO, when a window has only one tab, an about:blank tab should be created and the previous tab should be closed.
Flags: wanted-firefox3.1?
Keywords: polish, ue
Version: unspecified → Trunk
Summary: Suggestion + patch to address the "Ctrl-W should close last tab/window" debate: close the window iff the only tab is about:blank → Ctrl+W should close the window only if it has only one about:blank tab
We've already rejected this behaviour, its not going to change.  
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Flags: wanted-firefox3.1?
Resolution: --- → WONTFIX
(In reply to comment #12)
> We've already rejected this behaviour, its not going to change.  
> 

I can understand and agree the default behaviour don't be changed, but can't be added an option to don't close a window with CTRL+W, but only with CTRL+SHIFT+W?
Tried on Firefox 3.1 beta 2 release on OpenSolaris and Wine+Windows version, CTRL+SHIFT+W and CTRL+W both will close the window instead of the last tab. Firefox 3.0.5 works as expected. A regression?
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: