Skip to content

Instantly share code, notes, and snippets.

@mgedmin
Last active October 13, 2015 09:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mgedmin/4174803 to your computer and use it in GitHub Desktop.
Save mgedmin/4174803 to your computer and use it in GitHub Desktop.
Initial patch to make Firefox swap tabs on Ctrl+Shift+PgUp/PgDn (later updated, fixed and merged upstream!)
Ctrl+Shift+PageUp/Down reorder tabs (try #3, this one works and seems to be in the right place)
https://bugzilla.mozilla.org/show_bug.cgi?id=702960
diff -r d2fbc67f69f5 browser/base/content/tabbrowser.xml
--- a/browser/base/content/tabbrowser.xml Fri Nov 30 13:51:45 2012 +0000
+++ b/browser/base/content/tabbrowser.xml Mon Dec 03 14:35:29 2012 +0200
@@ -2504,6 +2504,25 @@
return;
}
+ switch (aEvent.keyCode) {
+ case aEvent.DOM_VK_PAGE_UP:
+ if (aEvent.ctrlKey && aEvent.shiftKey && !aEvent.altKey && !aEvent.metaKey) {
+ this.moveTabBackward();
+ aEvent.stopPropagation();
+ aEvent.preventDefault();
+ return;
+ }
+ break;
+ case aEvent.DOM_VK_PAGE_DOWN:
+ if (aEvent.ctrlKey && aEvent.shiftKey && !aEvent.altKey && !aEvent.metaKey) {
+ this.moveTabForward();
+ aEvent.stopPropagation();
+ aEvent.preventDefault();
+ return;
+ }
+ break;
+ }
+
if (aEvent.altKey)
return;
@mgedmin
Copy link
Author

mgedmin commented Dec 1, 2012

Well, it does not work. I know I'm editing the right file (e.g. I can make Ctrl+Shift+PgUp/PgDn call advanceSelectedTab and it works), so the bug is in my swapAdjacentTabs.

@mgedmin
Copy link
Author

mgedmin commented Dec 2, 2012

Updated to version #2, which actually works (but feels like a horrible hack).

https://developer.mozilla.org/en-US/docs/Simple_Firefox_build is a useful page and works much better -- faster builds! --than apt-get source firefox && fakeroot debian/rules binary.

@mgedmin
Copy link
Author

mgedmin commented Dec 2, 2012

Credit where it's due: http://blog.yjl.im/2010/11/ctrlshiftpageup-to-move-tab-in-firefox.html hinted at the names moveTabForward/Backward which I then found with a recursive grep. I found the place to change with a recursive grep for PAGE_DOWN, although now I'm beginning to think it might be the wrong place to make this change.

@mgedmin
Copy link
Author

mgedmin commented Dec 2, 2012

Let's have a clickable link to the bug, shall we? https://bugzilla.mozilla.org/show_bug.cgi?id=702960

@mgedmin
Copy link
Author

mgedmin commented Dec 3, 2012

Ok, patch #2 caused the ctrl+shift+pgup/down code to be run even in places like the Preferences dialog, with errors appearing in the error console ('tabbrowser is undefined').

Patch #3 modifies tabbrowser.xml instead of tabbox.xml and (a) works, and (b) seems to be in the right place.

@mgedmin
Copy link
Author

mgedmin commented Dec 6, 2012

Continued via attachments on the original mozilla bug, and then (when it was closed as a duplicate), on https://bugzilla.mozilla.org/show_bug.cgi?id=364845

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment