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

RESOLVED FIXED

Status

RESOLVED FIXED
14 years ago
12 years ago

People

(Reporter: bugzillamozilla, Assigned: sdwilsh)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [cz-0.9.78])

Attachments

(1 attachment, 1 obsolete attachment)

4.27 KB, patch
bugzilla-mozilla-20000923
: review+
Details | Diff | Splinter Review
(Reporter)

Description

14 years ago
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

Comment 1

14 years ago
(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.

Comment 2

14 years ago
*** Bug 275497 has been marked as a duplicate of this bug. ***
(Reporter)

Comment 3

14 years ago
(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.

Comment 4

14 years ago
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).
(Reporter)

Comment 5

14 years ago
(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.

Comment 6

14 years ago
Whooops! *tries to find CVS tree*

Comment 7

14 years ago
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.
(Reporter)

Comment 8

14 years ago
(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.

Comment 9

14 years ago
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)
(Reporter)

Comment 11

14 years ago
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.

Comment 12

14 years ago
Aah, cunning.  I'm not sure overlaying them will be so easy in XUL, given the
issues I had initially, but I can try. :)

Updated

14 years ago
Blocks: 250072

Comment 13

13 years ago
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.

Comment 14

13 years ago
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).

Comment 15

12 years ago
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?

Comment 16

12 years ago
(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?

Comment 17

12 years ago
And use the single-line input. And DON'T use Bugzilla for general support!
(Assignee)

Comment 18

12 years ago
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.
(Assignee)

Comment 19

12 years ago
Created attachment 250796 [details] [diff] [review]
v1.0

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 20

12 years ago
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-

Comment 21

12 years ago
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...
(Assignee)

Comment 22

12 years ago
Created attachment 250909 [details] [diff] [review]
v2.0

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?
(Assignee)

Updated

12 years ago
Attachment #250909 - Flags: review? → review?(silver)

Comment 23

12 years ago
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+
(Assignee)

Comment 24

12 years ago
(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?

Comment 25

12 years ago
No, you needn't do another version of the patch, unless you have changes that disagree with the suggestions I made.
(Assignee)

Comment 26

12 years ago
No complaints, and I agree with everything baring your nit on parentheses, but I'm not too concerned about that :)

Thanks!

Comment 27

12 years ago
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
Last Resolved: 12 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.