Skip to content
Browse files

Added rocker gestures involving the middle mouse button.

  • Loading branch information...
1 parent 2a540d2 commit 202813ee9ec6792561bfcafd99925350c9923201 @tobiasbrunner committed Mar 24, 2011
View
4 chrome/content/firegestures/browser.js
@@ -105,6 +105,10 @@ var FireGestures = {
case "wheel-down":
case "rocker-left":
case "rocker-right":
+ case "rocker-middle-left":
+ case "rocker-middle-right":
+ case "rocker-left-middle":
+ case "rocker-right-middle":
case "keypress-ctrl":
case "keypress-shift":
this.onMouseGesture(event, aGesture);
View
46 chrome/content/firegestures/prefs-generic.xul
@@ -46,9 +46,10 @@
<prefpane id="advancedPane" label="&advancedPane;" flex="1">
<!-- dummy -->
<preferences>
- <preference id="pref:triggerbutton" name="extensions.firegestures.trigger_button" type="int" />
- <preference id="pref:wheelgesture" name="extensions.firegestures.wheelgesture" type="bool" />
- <preference id="pref:rockergesture" name="extensions.firegestures.rockergesture" type="bool" />
+ <preference id="pref:triggerbutton" name="extensions.firegestures.trigger_button" type="int" />
+ <preference id="pref:wheelgesture" name="extensions.firegestures.wheelgesture" type="bool" />
+ <preference id="pref:rockergesture" name="extensions.firegestures.rockergesture" type="bool" />
+ <preference id="pref:rockergesture.middle" name="extensions.firegestures.rockergesture.middle" type="bool" />
</preferences>
<groupbox uigroup="wheelgesture">
<!-- dummy -->
@@ -113,6 +114,45 @@
</rows>
</grid>
</groupbox>
+ <groupbox uigroup="rockergesturemiddle">
+ <!-- dummy -->
+ <checkbox id="rockergesturemiddle" hidden="true"
+ preference="pref:rockergesture.middle"
+ onsyncfrompreference="PrefsUI.updateUIGroup('rockergesturemiddle');" />
+ <caption label="&rockerGesture.middle;" />
+ <grid>
+ <columns>
+ <column />
+ <column />
+ </columns>
+ <rows>
+ <row align="center">
+ <label value="&rockerGesture.middle.left;:" />
+ <menulist id="rockerGestureML" sizetopopup="none" oncommand="gShouldCommit = true;">
+ <menupopup />
+ </menulist>
+ </row>
+ <row align="center">
+ <label value="&rockerGesture.middle.right;:" />
+ <menulist id="rockerGestureMR" sizetopopup="none" oncommand="gShouldCommit = true;">
+ <menupopup />
+ </menulist>
+ </row>
+ <row align="center">
+ <label value="&rockerGesture.left.middle;:" />
+ <menulist id="rockerGestureLM" sizetopopup="none" oncommand="gShouldCommit = true;">
+ <menupopup />
+ </menulist>
+ </row>
+ <row align="center">
+ <label value="&rockerGesture.right.middle;:" />
+ <menulist id="rockerGestureRM" sizetopopup="none" oncommand="gShouldCommit = true;">
+ <menupopup />
+ </menulist>
+ </row>
+ </rows>
+ </grid>
+ </groupbox>
<box hidden="true">
<menuitem id="separatorTemplate" disabled="true">
<label />
View
12 chrome/content/firegestures/prefs.js
@@ -16,10 +16,14 @@ const kDirectionCol = 3;
const kFlagsCol = 4;
const kExtraArray1 = [
- ["wheelGestureU", "wheel-up" ],
- ["wheelGestureD", "wheel-down" ],
- ["rockerGestureL", "rocker-left" ],
- ["rockerGestureR", "rocker-right"],
+ ["wheelGestureU", "wheel-up" ],
+ ["wheelGestureD", "wheel-down" ],
+ ["rockerGestureL", "rocker-left" ],
+ ["rockerGestureR", "rocker-right" ],
+ ["rockerGestureML", "rocker-middle-left" ],
+ ["rockerGestureMR", "rocker-middle-right"],
+ ["rockerGestureLM", "rocker-left-middle" ],
+ ["rockerGestureRM", "rocker-right-middle"],
];
const kExtraArray2 = [
View
49 chrome/content/firegestures/prefs.xul
@@ -156,10 +156,11 @@
<prefpane id="advancedPane" label="&advancedPane;" flex="1">
<preferences>
- <preference id="pref:wheelgesture" name="extensions.firegestures.wheelgesture" type="bool" />
- <preference id="pref:rockergesture" name="extensions.firegestures.rockergesture" type="bool" />
- <preference id="pref:keypressgesture" name="extensions.firegestures.keypressgesture" type="bool" />
- <preference id="pref:tabwheelgesture" name="extensions.firegestures.tabwheelgesture" type="bool" />
+ <preference id="pref:wheelgesture" name="extensions.firegestures.wheelgesture" type="bool" />
+ <preference id="pref:rockergesture" name="extensions.firegestures.rockergesture" type="bool" />
+ <preference id="pref:rockergesture.middle" name="extensions.firegestures.rockergesture.middle" type="bool" />
+ <preference id="pref:keypressgesture" name="extensions.firegestures.keypressgesture" type="bool" />
+ <preference id="pref:tabwheelgesture" name="extensions.firegestures.tabwheelgesture" type="bool" />
</preferences>
<groupbox uigroup="wheelgesture">
<caption>
@@ -221,6 +222,46 @@
</rows>
</grid>
</groupbox>
+ <groupbox uigroup="rockergesturemiddle">
+ <caption>
+ <checkbox id="rockergesturemiddle" label="&rockerGesture.middle;"
+ preference="pref:rockergesture.middle"
+ onsyncfrompreference="PrefsUI.updateUIGroup('rockergesturemiddle');" />
+ </caption>
+ <description style="font-style: italic">&rockerGesture.middle.description;</description>
+ <grid>
+ <columns>
+ <column />
+ <column />
+ </columns>
+ <rows>
+ <row align="center">
+ <label value="&rockerGesture.middle.left;:" />
+ <menulist id="rockerGestureML" sizetopopup="none" oncommand="gShouldCommit = true;">
+ <menupopup />
+ </menulist>
+ </row>
+ <row align="center">
+ <label value="&rockerGesture.middle.right;:" />
+ <menulist id="rockerGestureMR" sizetopopup="none" oncommand="gShouldCommit = true;">
+ <menupopup />
+ </menulist>
+ </row>
+ <row align="center">
+ <label value="&rockerGesture.left.middle;:" />
+ <menulist id="rockerGestureLM" sizetopopup="none" oncommand="gShouldCommit = true;">
+ <menupopup />
+ </menulist>
+ </row>
+ <row align="center">
+ <label value="&rockerGesture.right.middle;:" />
+ <menulist id="rockerGestureRM" sizetopopup="none" oncommand="gShouldCommit = true;">
+ <menupopup />
+ </menulist>
+ </row>
+ </rows>
+ </grid>
+ </groupbox>
<groupbox uigroup="keypressgesture">
<caption>
<checkbox id="keypressgesture" label="&keypressGesture;"
View
6 chrome/locale/en-US/firegestures/prefs.dtd
@@ -34,6 +34,12 @@
<!ENTITY rockerGesture "Rocker Gestures">
<!ENTITY rockerGesture.left "Left-click with holding right-button">
<!ENTITY rockerGesture.right "Right-click with holding left-button">
+<!ENTITY rockerGesture.middle "Rocker Gestures with middle-button">
+<!ENTITY rockerGesture.middle.description "These gestures are not compatible with autoscroll, which gets disabled on restart.">
+<!ENTITY rockerGesture.middle.left "Left-click with holding middle-button">
+<!ENTITY rockerGesture.middle.right "Right-click with holding middle-button">
+<!ENTITY rockerGesture.left.middle "Middle-click with holding left-button">
+<!ENTITY rockerGesture.right.middle "Middle-click with holding right-button">
<!ENTITY keypressGesture "Keypress Gestures">
<!ENTITY keypressGesture.ctrl "Mouse gesture with holding Ctrl key">
<!ENTITY keypressGesture.shift "Mouse gesture with holding Shift key">
View
55 components/xdGestureHandler.js
@@ -145,16 +145,17 @@ xdGestureHandler.prototype = {
this._trailSize = getPref("mousetrail.size");
this._trailColor = getPref("mousetrail.color");
this._gestureTimeout = getPref("gesture_timeout");
- this._mouseGestureEnabled = getPref("mousegesture");
- this._wheelGestureEnabled = getPref("wheelgesture");
- this._rockerGestureEnabled = getPref("rockergesture");
- this._keypressGestureEnabled = getPref("keypressgesture");
+ this._mouseGestureEnabled = getPref("mousegesture");
+ this._wheelGestureEnabled = getPref("wheelgesture");
+ this._rockerGestureEnabled = getPref("rockergesture");
+ this._rockerGestureMiddleEnabled = getPref("rockergesture.middle");
+ this._keypressGestureEnabled = getPref("keypressgesture");
// prefs for wheel gestures and rocker gestures
this._drawArea.removeEventListener("DOMMouseScroll", this, true);
this._drawArea.removeEventListener("click", this, true);
if (this._wheelGestureEnabled)
this._drawArea.addEventListener("DOMMouseScroll", this, true);
- if (this._rockerGestureEnabled)
+ if (this._rockerGestureEnabled || this._rockerGestureMiddleEnabled)
this._drawArea.addEventListener("click", this, true);
// prefs for tab wheel gesture
var tabbrowser = this._drawArea.ownerDocument.getBindingParent(this._drawArea);
@@ -163,11 +164,15 @@ xdGestureHandler.prototype = {
if (getPref("tabwheelgesture"))
tabbrowser.mStrip.addEventListener("DOMMouseScroll", this._wheelOnTabBar, true);
}
+ var prefSvc = Cc["@mozilla.org/preferences-service;1"]
+ .getService(Ci.nsIPrefBranch2)
+ .QueryInterface(Ci.nsIPrefService);
+ // if rocker gestures involving the middle mouse button are enabled, disable autoscroll
+ if (this._rockerGestureMiddleEnabled) {
+ prefSvc.setBoolPref("general.autoScroll", false);
+ }
// if trigger button is middle, disable loading the clipboard URL with middle click.
if (this._triggerButton == 1) {
- var prefSvc = Cc["@mozilla.org/preferences-service;1"]
- .getService(Ci.nsIPrefBranch2)
- .QueryInterface(Ci.nsIPrefService);
prefSvc.setBoolPref("middlemouse.contentLoadURL", false);
// alert("middlemouse.contentLoadURL has been changed."); // #debug
}
@@ -198,7 +203,9 @@ xdGestureHandler.prototype = {
break;
}
this._isMouseDownL = true;
- this._isMouseDownM = false; // fixed invalid state of _isMouseDownM after autoscrolling
+ if (!this._rockerGestureMiddleEnabled) {
+ this._isMouseDownM = false; // fixed invalid state of _isMouseDownM after autoscrolling
+ }
// any gestures with left-button - start
if (this._triggerButton == 0 && !this._isMouseDownM && !this._isMouseDownR && !this._altKey(event)) {
this._state = STATE_GESTURE;
@@ -207,11 +214,15 @@ xdGestureHandler.prototype = {
if (this._mouseGestureEnabled)
event.preventDefault();
}
- // rocker gesture
+ // rocker gestures
else if (this._rockerGestureEnabled && this._isMouseDownR) {
this._state = STATE_ROCKER;
this._invokeExtraGesture(event, "rocker-left");
}
+ else if (this._rockerGestureMiddleEnabled && this._isMouseDownM) {
+ this._state = STATE_ROCKER;
+ this._invokeExtraGesture(event, "rocker-middle-left");
+ }
}
else if (event.button == 1) {
this._isMouseDownM = true;
@@ -222,6 +233,15 @@ xdGestureHandler.prototype = {
// prevent auto-scroll
event.stopPropagation();
}
+ // rocker gestures
+ else if (this._rockerGestureMiddleEnabled && this._isMouseDownL) {
+ this._state = STATE_ROCKER;
+ this._invokeExtraGesture(event, "rocker-left-middle");
+ }
+ else if (this._rockerGestureMiddleEnabled && this._isMouseDownR) {
+ this._state = STATE_ROCKER;
+ this._invokeExtraGesture(event, "rocker-right-middle");
+ }
}
else if (event.button == 2) {
// this fixes the problem: when showing context menu of a Flash movie,
@@ -232,19 +252,25 @@ xdGestureHandler.prototype = {
break;
}
this._isMouseDownR = true;
- this._isMouseDownM = false; // fixed invalid state of _isMouseDownM after autoscrolling
+ if (!this._rockerGestureMiddleEnabled) {
+ this._isMouseDownM = false; // fixed invalid state of _isMouseDownM after autoscrolling
+ }
this._suppressContext = false; // only time to reset _suppressContext flag
this._enableContextMenu(true);
// any gestures with right-button - start
if (this._triggerButton == 2 && !this._isMouseDownL && !this._isMouseDownM && !this._altKey(event)) {
this._state = STATE_GESTURE;
this._startGesture(event);
}
- // rocker gesture
+ // rocker gestures
else if (this._rockerGestureEnabled && this._isMouseDownL) {
this._state = STATE_ROCKER;
this._invokeExtraGesture(event, "rocker-right");
}
+ else if (this._rockerGestureMiddleEnabled && this._isMouseDownM) {
+ this._state = STATE_ROCKER;
+ this._invokeExtraGesture(event, "rocker-middle-right");
+ }
}
break;
case "mousemove":
@@ -304,8 +330,9 @@ xdGestureHandler.prototype = {
}
break;
case "contextmenu":
- // [Linux] if right-click without holding left-button, display context menu artificially
- if (!this._isMouseDownL && this._isMouseDownR) {
+ // [Linux] if right-click without holding left-button or middle-button, display context menu artificially
+ if (this._isMouseDownR &&
+ !this._isMouseDownL && (!this._rockerGestureMiddleEnabled || !this._isMouseDownM)) {
// #debug-begin
log("*** display context menu artificially");
if (PLATFORM == "Windows_NT")
View
1 defaults/preferences/firegestures-prefs.js
@@ -1,6 +1,7 @@
pref("extensions.firegestures.mousegesture", true);
pref("extensions.firegestures.wheelgesture", true);
pref("extensions.firegestures.rockergesture", false);
+pref("extensions.firegestures.rockergesture.middle", false);
pref("extensions.firegestures.keypressgesture", true);
pref("extensions.firegestures.tabwheelgesture", false);
pref("extensions.firegestures.trigger_button", 2);

0 comments on commit 202813e

Please sign in to comment.
Something went wrong with that request. Please try again.