[Pkg-mozext-commits] [tabmixplus] 07/123: Split the options 'Prevent clicking on Tab-bar from dragging the window.' and 'Prevent double click on Tab-bar from changing window size.'
David Prévot
taffit at moszumanska.debian.org
Wed Sep 17 21:16:22 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository tabmixplus.
commit cfc46cd7def559664bc1157cde1cc2b1c2f785f3
Author: onemen <tabmix.onemen at gmail.com>
Date: Thu Aug 7 19:31:28 2014 +0300
Split the options 'Prevent clicking on Tab-bar from dragging the window.' and 'Prevent double click on Tab-bar from changing window size.'
---
chrome/content/click/click.js | 22 +++++++++++++++++++++-
chrome/content/minit/tablib.js | 8 ++++++++
chrome/content/preferences/mouse.js | 12 ++++++++++--
chrome/content/preferences/mouse.xul | 11 ++++++++---
chrome/content/tab/tab.js | 19 ++++++++++++++++++-
chrome/content/tab/tabbrowser_4.xml | 3 ++-
chrome/content/tabmix.js | 14 +++++++++-----
defaults/preferences/tabmix.js | 3 ++-
8 files changed, 78 insertions(+), 14 deletions(-)
diff --git a/chrome/content/click/click.js b/chrome/content/click/click.js
index a33687a..51fe1f2 100644
--- a/chrome/content/click/click.js
+++ b/chrome/content/click/click.js
@@ -95,8 +95,10 @@ var TabmixTabClickOptions = {
// See hack note in the tabbrowser-close-tab-button binding
// if we are here the target is not closeTabButton or newtabButton
- if (gBrowser.tabContainer._blockDblClick || this._blockDblClick)
+ if (gBrowser.tabContainer._blockDblClick || this._blockDblClick) {
+ aEvent.preventDefault();
return;
+ }
var clickOutTabs = aEvent.target.localName == "tabs";
@@ -252,6 +254,24 @@ var TabmixTabClickOptions = {
return false;
}
return true;
+ },
+
+ toggleEventListener: function(enable) {
+ let eventListener = enable ? "addEventListener" : "removeEventListener";
+ document.getElementById("TabsToolbar")[eventListener]("dblclick", this.blockDblclick, false);
+ },
+
+ /**
+ * block dblclick on TabsToolbar when tabbar.dblclick_changesize is false
+ * and tabbar.click_dragwindow is true
+ */
+ blockDblclick: function(aEvent) {
+ if (aEvent.button != 0 || aEvent.target.localName == "tabs" ||
+ Tabmix.prefs.getBoolPref("tabbar.dblclick_changesize") ||
+ !Tabmix.prefs.getBoolPref("tabbar.click_dragwindow"))
+ return;
+
+ aEvent.preventDefault();
}
}
diff --git a/chrome/content/minit/tablib.js b/chrome/content/minit/tablib.js
index 173113e..0bb1cc5 100644
--- a/chrome/content/minit/tablib.js
+++ b/chrome/content/minit/tablib.js
@@ -1624,6 +1624,14 @@ var tablib = {
// make sure that our function don't break removeTab function
onRemoveTab: function TMP_onRemoveTab(tab) {
+ if (Tabmix.prefs.getBoolPref("tabbar.click_dragwindow") &&
+ TabmixTabClickOptions._blockDblClick) {
+ setTimeout(function() {
+ TabmixTabClickOptions._blockDblClick = false;
+ gBrowser.tabContainer._blockDblClick = false;
+ }, 0);
+ }
+
try {
TMP_ClosedTabs.setButtonDisableState();
}
diff --git a/chrome/content/preferences/mouse.js b/chrome/content/preferences/mouse.js
index eb7afe6..c506e8b 100644
--- a/chrome/content/preferences/mouse.js
+++ b/chrome/content/preferences/mouse.js
@@ -26,10 +26,9 @@ var gMousePane = {
this.clickTabbar = $("ClickTabbar");
this.clickTabbar.appendChild(this.clickTab.firstChild.cloneNode(true));
this.updatePanelPrefs($("tabclick").selectedIndex);
- $("dblClickTabbar_changesize").setAttribute("style",
- "width: #px;".replace("#", $("mouseClick_tabbox").boxObject.width));
this.updateBroadcaster('tabbarscrolling');
this.updateBroadcaster('disableMoveTab');
+ this.updatedblClickTabbar($("pref_click_dragwindow"));
gPrefWindow.initPane("paneMouse");
},
@@ -87,6 +86,15 @@ var gMousePane = {
menulist[prefID] = val;
menulist.disabled = val == -1;
menulist.previousSibling.checked = !menulist.disabled;
+ },
+
+ updatedblClickTabbar: function (pref) {
+ let dblClickTabbar = $("pref_dblclick_changesize");
+ if (pref.value && !dblClickTabbar.value)
+ dblClickTabbar.value = pref.value;
+ let checkbox = $("dblclick_changesize")._checkbox;
+ let image = document.getAnonymousElementByAttribute(checkbox, "class", "checkbox-check")
+ Tabmix.setItem(image, "disabled", pref.value || null);
}
}
diff --git a/chrome/content/preferences/mouse.xul b/chrome/content/preferences/mouse.xul
index d5cfba6..4b4d3a9 100644
--- a/chrome/content/preferences/mouse.xul
+++ b/chrome/content/preferences/mouse.xul
@@ -47,7 +47,10 @@
<preference id="pref_shiftClickTabbar" name="extensions.tabmix.shiftClickTabbar" type="int"/>
<preference id="pref_altClickTab" name="extensions.tabmix.altClickTab" type="int"/>
<preference id="pref_altClickTabbar" name="extensions.tabmix.altClickTabbar" type="int"/>
- <preference id="pref_dblClickTabbar_changesize" name="extensions.tabmix.dblClickTabbar_changesize"
+ <preference id="pref_click_dragwindow" name="extensions.tabmix.tabbar.click_dragwindow"
+ type="bool" inverted="true"
+ onchange="gMousePane.updatedblClickTabbar(this);"/>
+ <preference id="pref_dblclick_changesize" name="extensions.tabmix.tabbar.dblclick_changesize"
type="bool" inverted="true"/>
<preference id="pref_disableMoveTab" name="extensions.tabmix.tabBarMode" type="int"
onchange="gMousePane.updateBroadcaster('disableMoveTab');"/>
@@ -193,8 +196,10 @@
</tabpanels>
</tabbox>
<spacer style="height: 12px;"/>
- <checkbox_tmp id="dblClickTabbar_changesize" label="&ontabbar.dblClick.label; &ontabbar.click.label;"
- preference="pref_dblClickTabbar_changesize"/>
+ <checkbox_tmp id="click_dragwindow" label="&ontabbar.click.label;"
+ preference="pref_click_dragwindow"/>
+ <checkbox_tmp id="dblclick_changesize" label="&ontabbar.dblClick.label;"
+ preference="pref_dblclick_changesize"/>
</tabpanel>
</tabpanels>
</tabbox>
diff --git a/chrome/content/tab/tab.js b/chrome/content/tab/tab.js
index 5508ce7..a4b2d59 100644
--- a/chrome/content/tab/tab.js
+++ b/chrome/content/tab/tab.js
@@ -644,8 +644,16 @@ var gTMPprefObserver = {
case "extensions.tabmix.titlefrombookmark":
TMP_Places.onPreferencChanged(Services.prefs.getBoolPref(prefName));
break;
- case "extensions.tabmix.dblClickTabbar_changesize":
+ case "extensions.tabmix.tabbar.click_dragwindow":
document.getElementById("TabsToolbar")._dragBindingAlive = Services.prefs.getBoolPref(prefName);
+ case "extensions.tabmix.tabbar.dblclick_changesize":
+ let dragwindow = Tabmix.prefs.getBoolPref("tabbar.click_dragwindow");
+ let changesize = Tabmix.prefs.getBoolPref("tabbar.dblclick_changesize");
+ if (!dragwindow && changesize) {
+ Tabmix.prefs.setBoolPref("tabbar.dblclick_changesize", false);
+ changesize = !changesize;
+ }
+ TabmixTabClickOptions.toggleEventListener(dragwindow && !changesize);
break;
case "extensions.tabmix.lockallTabs":
TabmixTabbar.lockallTabs = Services.prefs.getBoolPref(prefName);
@@ -1774,6 +1782,15 @@ try {
Tabmix.prefs.setIntPref("scrollTabs", 1);
Tabmix.prefs.clearUserPref("enableScrollSwitch");
}
+ // 2014-08-07
+ if (Tabmix.prefs.prefHasUserValue("dblClickTabbar_changesize")) {
+ let val = Tabmix.prefs.getBoolPref("dblClickTabbar_changesize");
+ // make sure to set click_dragwindow first, dblclick_changesize depend
+ // on it see gTMPprefObserver.observe.
+ Tabmix.prefs.setBoolPref("tabbar.click_dragwindow", val);
+ Tabmix.prefs.setBoolPref("tabbar.dblclick_changesize", val);
+ Tabmix.prefs.clearUserPref("dblClickTabbar_changesize");
+ }
// verify valid value
if (Tabmix.prefs.prefHasUserValue("tabs.closeButtons")) {
diff --git a/chrome/content/tab/tabbrowser_4.xml b/chrome/content/tab/tabbrowser_4.xml
index 4b7cf67..a35ae14 100644
--- a/chrome/content/tab/tabbrowser_4.xml
+++ b/chrome/content/tab/tabbrowser_4.xml
@@ -901,7 +901,8 @@
]]></handler>
<handler event="dblclick" phase="capturing"><![CDATA[
- if (Tabmix.prefs.getBoolPref("dblClickTabbar_changesize") &&
+ if (Tabmix.prefs.getBoolPref("tabbar.click_dragwindow") &&
+ Tabmix.prefs.getBoolPref("tabbar.dblclick_changesize") &&
!TabmixSvc.isMac && event.target.localName == "tabs") {
let displayAppButton = !(document.getElementById("titlebar") || document.getElementById("appmenu-toolbar-button")).hidden;
let tabsOnTop = !window.TabsOnTop || TabsOnTop.enabled;
diff --git a/chrome/content/tabmix.js b/chrome/content/tabmix.js
index 0ae81b2..e0052c9 100644
--- a/chrome/content/tabmix.js
+++ b/chrome/content/tabmix.js
@@ -174,10 +174,13 @@ Tabmix.delayedStartup = function TMP_delayedStartup() {
this.navToolbox.init();
- // set option to Prevent double click on Tab-bar from changing window size.
- var tabsToolbar = document.getElementById("TabsToolbar");
- if (!this.prefs.getBoolPref("dblClickTabbar_changesize"))
- tabsToolbar._dragBindingAlive = false;
+ // set option to Prevent clicking on Tab-bar from dragging the window.
+ if (this.prefs.getBoolPref("tabbar.click_dragwindow")) {
+ if (!Tabmix.prefs.getBoolPref("tabbar.dblclick_changesize"))
+ TabmixTabClickOptions.toggleEventListener(true);
+ }
+ else
+ document.getElementById("TabsToolbar")._dragBindingAlive = false;
TMP_extensionsCompatibility.onDelayedStartup();
@@ -325,7 +328,7 @@ var TMP_eventListener = {
'let $ = $&', {check: Tabmix._debugMode}
)._replace(
'this._dragBindingAlive',
- '$& && Tabmix.prefs.getBoolPref("dblClickTabbar_changesize")'
+ '$& && Tabmix.prefs.getBoolPref("tabbar.click_dragwindow")'
)._replace(
'function rect(ele)',
'let rect = function _rect(ele)' // for strict mode
@@ -911,6 +914,7 @@ var TMP_eventListener = {
}
TabmixSessionManager.onWindowClose(isLastWindow);
+ TabmixTabClickOptions.toggleEventListener(false);
TabmixContext.toggleEventListener(false);
TMP_Places.deinit();
diff --git a/defaults/preferences/tabmix.js b/defaults/preferences/tabmix.js
index 3e57273..dbac4d1 100644
--- a/defaults/preferences/tabmix.js
+++ b/defaults/preferences/tabmix.js
@@ -128,7 +128,8 @@ pref("extensions.tabmix.shiftClickTabbar", 0);
pref("extensions.tabmix.altClickTab", 6);
pref("extensions.tabmix.altClickTabbar", 0);
-pref("extensions.tabmix.dblClickTabbar_changesize", true);
+pref("extensions.tabmix.tabbar.dblclick_changesize", true);
+pref("extensions.tabmix.tabbar.click_dragwindow", true);
/*
2011-01-26
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git
More information about the Pkg-mozext-commits
mailing list