Closed Bug 265847 Opened 20 years ago Closed 17 years ago

Chatzilla tab-switching shortcuts should not collide with OS and Mozilla-based ones (replace Function keys with other keybindings)

Categories

(Other Applications :: ChatZilla, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: bugzillamozilla, Assigned: sdwilsh)

References

Details

(Whiteboard: [cz-0.9.78])

Attachments

(1 file, 1 obsolete file)

4.27 KB, patch
bugzilla-mozilla-20000923
: review+
Details | Diff | Splinter Review
Chatzilla currently uses F1-F12 to switch tabs. These shortcuts collide with the
following:

F1 - Help, cross platform
F2 - Brings up system control panel on Mac
F3 - Find again, cross platform
F6 - Next frame/pane in Windows
F9 - Toggle sidebar, cross platform (could be useful in cz to hide the users pane)
F9 - Exposé tile open windows in Mac OS X
F10 - Send focus to main menu bar (same as Alt)
F10 - Exposé tile open application windows in Mac OS X
F11 - Toggle full screen mode in Windows and Unix/Linux
F11 - Exposé hide all open windows in Mac OS X

The main alternatives are:

1. Accel+Numbers (Ctrl+Numbers in Win/Unix/Linux, Cmd+Numbers in OS X)
Pro: Compatible with Firefox which *currently uses the same shortcuts, for the
exact same behavior. * See Bug 249764
Con: Collides with Seamonkey Accel+1,2,3,4,5

2. Alt+Numbers (Alt+Numbers in Win/Unix/Linux, Opt+Numbers in OS X)
Pro: Doesn't collide with Seamonkey Accel+1,2,3,4,5
Cons: Not compatible with Firefox shortcuts; Is WONTFIXed for Browser(see 139025)

Note that the current F-based shortcuts not only collide with other shortcuts,
they are also not discoverable. A better solution would be to highlight each tab
with a number when the modifier keys is pressed (a la Lotus Notes). This would
hint that pressing a number switches to the chosen tab and will make this whole
system much easier to use when more than a few tabs are involved.

Prog.
Product: Core → Other Applications
(In reply to comment #0)
> A better solution would be to highlight each tab with a number when the
> modifier keys is pressed (a la Lotus Notes). This would hint that pressing
> a number switches to the chosen tab and will make this whole system much
> easier to use when more than a few tabs are involved.

I've implemented a basic version of this (with bugs), however I ran into some
limitations of Gecko in doing so... the problem being you can't overlay XUL
elements on top of the <browser>, so for now it resizes that to fit the labels
in above the tabs.

The other question is this - how should it handle tabs > 9? My current code,
which I'm not too happy with, works like a textbox. You press and hold Ctrl (for
this example), and up pop the little tab labels. You then type a number whilst
holding Ctrl down, and when you release the tab is changed. If the tab number is
not valid, it beeps when Ctrl is released. Nothing happens if you don't type a
number while Ctrl is down.

This is good for lots of tabs, since you can do Ctrl-(1,2) to go to tab 12, but
potentially arkward for tabs <10 because you need to do the complete
down-up-press event cycle for the number /before/ releasing Ctrl.
*** Bug 275497 has been marked as a duplicate of this bug. ***
(In reply to comment #1)
> I've implemented a basic version of this (with bugs),

Can you please attach/host this test version so that we can better evaluate your
suggested solution?

> The other question is this - how should it handle tabs > 9?

Many remote control units handle this by treating buttons 1-9 as 01-09 and
requiring a preceding keypress for > 9, in our case, pressing Ctrl+'`' can pop
up an input for double digit tabs.

BTW, are you sure that once this bug is fixed, Caret Browsing mode should be
available in Chatzilla? Because if you don't, then the dupe should probably be
re-opened.

Prog.
Sure, I will put up an XPI with this feature when I get a moment.

Not sure I like using ` (is it always near the numeric keys on keyboards?), but
I don't really know what else to do. The XPI will use Ctrl(1, 2) for now, as I
don't really have time to try re-implementing that.

As for the duplicate, I understood it to be the fact you got the dialog instead
of it switching tabs that was the problem which is, esentially, the same as this
bug. However, once this bug is fixed, ChatZilla will behave the same as
described in bug 275497, except for not switching tabs at the same time (and
thus it will do just what the browser does).
(In reply to James Ross, comment #4)
> Sure, I will put up an XPI with this feature when I get a moment.

Allow me to nag ;-)

Prog.
Whooops! *tries to find CVS tree*
http://silver.warwickcompsoc.co.uk/temp/chatzilla-0.9.67-notif.xpi

Ping-pong!

I don't really like it, as having to hold Ctrl until after typing the number
sorta sucks. I'll have a go at some other ideas on my away-time until April.
(In reply to comment #7)
> I don't really like it, as having to hold Ctrl until after typing the number
> sorta sucks.

Using Ctrl does get annoying when using other accelerator keybindings. I guess
Alt would make more sense, as the concept of access-keys is more closely related
to these numeric tabs. Though I'm not sure what should be the right way to
handle this on the Mac.

Then there's the layout issues (which you hinted at in comment #0). Ideally, the
numbers should be attached to the tabs themselves, and should be separated from
each other.

Other than these two, I like this feature. A lot. It suddenly makes it possible
to access the right tab without the mouse, and without guesswork.

Prog.
I can add spacing between the number boxes... but I'm not sure what you mean by
"attached to" the tabs. Could you draw a little diagram?

Command is what I planned to use on Mac, but I have no idea what keycode it is.
:)  So currently it is Ctrl on Windows, and Alt elsewhere.  I guess Alt on
Windows would be more consistent, and no collide with the SM tasks stuff.
(In reply to comment #9)

> Command is what I planned to use on Mac, but I have no idea what keycode it is.

VK_META (224)
What I had in mind is numbers enclosed within circles (or squares) which partly
overlap the top of each tab. 

See attachment 150553 [details] (Bug 101689, comment #31) for Lotus Notes implementation
of this feature. If that's still not clear enough, I'll try to draw something.

Prog.
Aah, cunning.  I'm not sure overlaying them will be so easy in XUL, given the
issues I had initially, but I can try. :)
Blocks: 250072
On SuSE 10.0 with KDE 3.4.2 my (SeaMonkey trunk w/ CZ 0.9.69.1) CZ window is usually focused when I Ctrl-Alt-F[1-6] to goto a virtual console. To return to X/KDE requires Alt-F7 or Ctrl-Alt-F7. On each return from virtual console to X, CZ tab #7 has stolen focus from whichever tab had had focus when I went to the virtual console.
Felix Miata, that is nothing to do with this bug. The environment should not be passing on keys to applications that it has handled. All you have found is a bug/limitation in the Linux virtual console code, X, or KDE (I have no idea which is more likely to be to blame here).
When hitting TAB in ChatZilla with Firefox 1.5 on Windows there happens no auto completion. Focus jumps to URLs in client window instead (like in a page view of regular webpages in Firefox).
Is there any method to circumvent this?
(In reply to comment #15)
> When hitting TAB in ChatZilla with Firefox 1.5 on Windows there happens no auto
> completion. Focus jumps to URLs in client window instead (like in a page view
> of regular webpages in Firefox).
> Is there any method to circumvent this?
> 

Focus the input box?
And use the single-line input. And DON'T use Bugzilla for general support!
So, I'd be willing to submit a patch for this to use meta + # just like browser does because right now on a mac the way to access tabs just isn't reasonable (the function keys are reserved by the OS, as well as cmd+tab/cmd+shift+tab).  Chatzilla is difficult to use a result.
Attached patch v1.0 (obsolete) — Splinter Review
Makes the behavior identical to that of browser:
pressing cmd/ctrl + 1-8 takes you to tab 1-8
pressing cmd/ctrl + 9 takes you to the last tab if there are more than 8 tabs total (nothing otherwise)
Assignee: rginda → comrade693+bmo
Status: NEW → ASSIGNED
Attachment #250796 - Flags: review?
Comment on attachment 250796 [details] [diff] [review]
v1.0

> function onWindowKeyPress (e)
> {
>-    var code = Number(e.keyCode);
>+    var code = Number(e.which);

This breaks all the other shortcuts (Control-Tab, Page Up, etc.).

>+        case 56: /* 8 */
>+            if (!e.metaKey)
>                 break;

This is false on Windows for all modifier keys (officially meta is the Win key, but that doesn't work in Mozilla either).

>+        case 57: /* 9 */
>+            if (!e.metaKey)
>+                break;
>+            if (client.viewsArray.length > 8)
>+            {
>+              var idx = client.viewsArray.length - 1;
>+              if ((idx in client.viewsArray) && client.viewsArray[idx].source)

This if isn't needed, just do the change - you know there's more than 8 views, and you have the last one, it'll always work.

>+              {
>+                var newView = client.viewsArray[idx].source;
>+                dispatch("set-current-view", { view: newView });
>+              }
>+            }
Attachment #250796 - Flags: review? → review-
To completely copy Firefox, we basically want to copy this code:

http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/browser/base/content/browser.js&rev=1.748&mark=1397-1421#1384

The problem is that Control shortcuts are not suitable for Mozilla Suite/SeaMonkey, as they are already assigned app-wide. We /could/ not do this at all there, or maybe use Alt on Windows as well as Linux. But then I don't know id Linux/Mac Mozilla Suite/SeaMonkey still use Control for their task options...
Attached patch v2.0Splinter Review
yey for rewrites.  This addressed this issue of Suite and reserved keys too!

I could have condensed the big if statement that figures out if we should run, but I felt that leaving it this way makes it clear about what it is doing.

I can only test this on a mac, so I hope I didn't break anything for other platforms.
Attachment #250796 - Attachment is obsolete: true
Attachment #250909 - Flags: review?
Attachment #250909 - Flags: review? → review?(silver)
Comment on attachment 250909 [details] [diff] [review]
v2.0

Sorry for the delay, here's a review.

>+    // code is zero if we have an alphanumeric being given to us in the event
>+    if (code != 0)
>+      return;
>+    
>+    // See browser's code for selecting tabs to understand this craziness

I'd feel much happier if the comments were copied in their entirety, possibly with an aditional note about where the code originated.

>+    if (!/\d/.test(String.fromCharCode(e.charCode)))
>+        return;
>+
>+    var digit1 = (e.charCode & 0xFFF0) | 1;
>+    if (!/\d/.test(String.fromCharCode(e.charCode)))

The e.charCode on this line is wrong; it's digit1 in the browser code.

>+      digit1 += 6;
>+
>+    var idx = e.charCode - digit1;
>+
>+    const isMac     = client.platform == "Mac";
>+    const isLinux   = client.platform == "Linux";
>+    const isWindows = client.platform == "Windows";
>+    const isUnknown = client.platform == "Unknown";

Nit: I think we'd be better off using isUnknown for cases /except/ those we know, so:
  const isUnknown = !(isMac || isLinux || isWindows || isOS2);

>+    const isOS2     = client.platform == "OS/2";
>+    const SUITE     = client.host == "Mozilla";

Not sure this is for the best, but can't think of anything better.

>+
>+    if (0 <= idx && idx <= 8)

Nit: I'd be happier with parentheses here.

>+    {
>+        if ((!SUITE && isMac && e.metaKey) ||
>+            (!SUITE && (isLinux || isOS2) && e.altKey) ||
>+            (!SUITE && (isWindows || isUnkown) && e.ctrlKey) ||

isUnknown is mispelt here.

>+            (SUITE && e.altKey))
>+        {
>+            // pressing 1-8 takes you to that tab, while pressing 9 takes you
>+            // to the last tab always.
>+            if (idx == 8)
>+                idx = client.viewsArray.length - 1;

I don't like the way the comment says 1-8 and then the if compares with 8, but I don't think there's a particular easier way to do this.

>+
>+            if ((idx in client.viewsArray) && client.viewsArray[idx].source)

r=silver with those changes (which I'll make before checking in, if you don't have CVS access)
Attachment #250909 - Flags: review?(silver) → review+
(In reply to comment #23)
> isUnknown is mispelt here.

That's funny how I didn't get any warnings in the console :/

> r=silver with those changes (which I'll make before checking in, if you don't
> have CVS access)

I don't have CVS access, but do you want me to submit a new patch with these changes?
No, you needn't do another version of the patch, unless you have changes that disagree with the suggestions I made.
No complaints, and I agree with everything baring your nit on parentheses, but I'm not too concerned about that :)

Thanks!
Checked in, with review comments.

I believe that this resolves this bug as originally described; the shortcut keys now match the respective browser, and any further changes (such as support for jumping to tabs between 8 and the last) should be filed as separate enhancement bugs. Issues with this code, such as cases it is not matching the associated browser, should be filed as new bugs as well.

A nightly build with this patch will appear automatically in 35 minutes at:
  http://twpol.dyndns.org/mozilla/chatzilla/nightly/
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Whiteboard: [cz-0.9.78]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: