Keep tab bar shown (expanded) if one of triggers is still there. (#552)

The tab bar can be shown by three reasons: mouseover, keyboard shortcut,
and feedback for new tabs. However, sometimes two or more triggers can
be fired in a same time. Now TST keeps the tab bar showing (expanded)
for combinated cases, like: shown by the keyboard shortcut, the mouse
goes onto the tab bar, and it leaves from the tab bar.
This commit is contained in:
YUKI Hiroshi 2013-09-17 16:22:29 +09:00
parent d7aa5da30d
commit 47774acf54
2 changed files with 24 additions and 31 deletions

View File

@ -135,13 +135,6 @@ pref("extensions.treestyletab.tabbar.autoShow.accelKeyDown.delay", 800);
pref("extensions.treestyletab.tabbar.autoShow.tabSwitch", true); pref("extensions.treestyletab.tabbar.autoShow.tabSwitch", true);
pref("extensions.treestyletab.tabbar.autoShow.feedback", false); pref("extensions.treestyletab.tabbar.autoShow.feedback", false);
pref("extensions.treestyletab.tabbar.autoShow.feedback.delay", 3000); pref("extensions.treestyletab.tabbar.autoShow.feedback.delay", 3000);
/**
* When the tab bar is automatically shown by keyboard shortcuts or other
* reasons, the tab bar will be hidden again automatically. If you set
* this pref to "true", TST cancels to hide the tab bar if the cursor is on the
* expanded tab bar, even if it is shown by other triggers not mousemove.
*/
pref("extensions.treestyletab.tabbar.autoShow.keepShownOnMouseover", true);
/** /**
* Size of the placeholder for "hidden tab bar". * Size of the placeholder for "hidden tab bar".
* When "tabbar.autoHide.mode"==1, the tab bar will be hidden completely. * When "tabbar.autoHide.mode"==1, the tab bar will be hidden completely.

View File

@ -77,12 +77,12 @@ AutoHideBrowser.prototype = {
kSHOWN_BY_SHORTCUT : 1 << 0, kSHOWN_BY_SHORTCUT : 1 << 0,
kSHOWN_BY_MOUSEMOVE : 1 << 1, kSHOWN_BY_MOUSEMOVE : 1 << 1,
kSHOWN_BY_FEEDBACK : 1 << 2, kSHOWN_BY_FEEDBACK : 1 << 2,
kSHOWN_BY_SOME_REASON : (1 << 0) | (1 << 1) | (1 << 2),
kSHOWHIDE_BY_START : 1 << 3, kSHOWHIDE_BY_START : 1 << 3,
kSHOWHIDE_BY_END : 1 << 4, kSHOWHIDE_BY_END : 1 << 4,
kSHOWHIDE_BY_POSITION_CHANGE : 1 << 5, kSHOWHIDE_BY_POSITION_CHANGE : 1 << 5,
kSHOWHIDE_BY_RESIZE : 1 << 6, kSHOWHIDE_BY_RESIZE : 1 << 6,
kHIDDEN_BY_CLICK : 1 << 7, kHIDDEN_BY_CLICK : 1 << 7,
kKEEP_SHOWN_ON_MOUSEOVER : (1 << 0) | (1 << 1) | (1 << 2),
get mode() /* PUBLIC API */ get mode() /* PUBLIC API */
{ {
@ -358,13 +358,9 @@ AutoHideBrowser.prototype = {
var w = this.window; var w = this.window;
var shouldShow = position & this.MOUSE_POSITION_SENSITIVE; var shouldShow = position & this.MOUSE_POSITION_SENSITIVE;
if (this.expanded) { if (this.expanded) { // currently shown, let's hide it.
if ( if (shouldShow) {
shouldShow && this.show(this.kSHOWN_BY_MOUSEMOVE);
this.showHideReason & this.kKEEP_SHOWN_ON_MOUSEOVER &&
utils.getTreePref('tabbar.autoShow.keepShownOnMouseover')
) {
this.showHideReason = this.kSHOWN_BY_MOUSEMOVE;
this.cancelDelayedShowForShortcut(); this.cancelDelayedShowForShortcut();
this.cancelHideForFeedback(); this.cancelHideForFeedback();
} }
@ -375,15 +371,14 @@ AutoHideBrowser.prototype = {
this.showHideOnMouseMoveTimer = w.setTimeout( this.showHideOnMouseMoveTimer = w.setTimeout(
function(aSelf) { function(aSelf) {
aSelf.cancelDelayedShowForShortcut(); aSelf.cancelDelayedShowForShortcut();
if (aSelf.showHideReason == aSelf.kSHOWN_BY_MOUSEMOVE) aSelf.hide(aSelf.kSHOWN_BY_MOUSEMOVE);
aSelf.hide(aSelf.kSHOWN_BY_MOUSEMOVE);
}, },
utils.getTreePref('tabbar.autoHide.delay'), utils.getTreePref('tabbar.autoHide.delay'),
this this
); );
} }
} }
else if (shouldShow) { else if (shouldShow) { // currently shown, let's show it.
this.showHideOnMouseMoveTimer = w.setTimeout( this.showHideOnMouseMoveTimer = w.setTimeout(
function(aSelf) { function(aSelf) {
aSelf.cancelDelayedShowForShortcut(); aSelf.cancelDelayedShowForShortcut();
@ -564,8 +559,7 @@ AutoHideBrowser.prototype = {
this.delayedHideTabbarForFeedbackTimer = this.window.setTimeout( this.delayedHideTabbarForFeedbackTimer = this.window.setTimeout(
function(aSelf) { function(aSelf) {
aSelf.delayedHideTabbarForFeedbackTimer = null; aSelf.delayedHideTabbarForFeedbackTimer = null;
if (aSelf.showHideReason == aSelf.kSHOWN_BY_FEEDBACK) aSelf.hide(aSelf.kSHOWN_BY_FEEDBACK);
aSelf.hide(aSelf.kSHOWN_BY_FEEDBACK);
}, },
utils.getTreePref('tabbar.autoShow.feedback.delay'), utils.getTreePref('tabbar.autoShow.feedback.delay'),
this this
@ -666,11 +660,11 @@ AutoHideBrowser.prototype = {
if (this.expanded) { // to be hidden or shrunken if (this.expanded) { // to be hidden or shrunken
this.onHiding(); this.onHiding();
this.showHideReason = aReason || this.kSHOWN_BY_UNKNOWN; this.showHideReason = this.kSHOWN_BY_UNKNOWN;
} }
else { // to be shown or expanded else { // to be shown or expanded
this.onShowing(); this.onShowing();
this.showHideReason = aReason || this.kSHOWN_BY_UNKNOWN; this.showHideReason = aReason || this.showHideReason || this.kSHOWN_BY_UNKNOWN;
} }
if (DEBUG) { if (DEBUG) {
@ -736,14 +730,23 @@ AutoHideBrowser.prototype = {
show : function AHB_show(aReason) /* PUBLIC API */ show : function AHB_show(aReason) /* PUBLIC API */
{ {
if (aReason) {
this.showHideReason |= aReason;
}
if (!this.expanded) if (!this.expanded)
this.showHideInternal(aReason); this.showHideInternal();
}, },
hide : function AHB_hide(aReason) /* PUBLIC API */ hide : function AHB_hide(aReason) /* PUBLIC API */
{ {
if (aReason) {
if (this.showHideReason & aReason)
this.showHideReason ^= aReason;
if (this.showHideReason & this.kSHOWN_BY_SOME_REASON)
return;
}
if (this.expanded) if (this.expanded)
this.showHideInternal(aReason); this.showHideInternal();
}, },
onShowing : function AHB_onShowing() onShowing : function AHB_onShowing()
@ -1000,8 +1003,7 @@ AutoHideBrowser.prototype = {
case this.treeStyleTab.kEVENT_TYPE_TAB_FOCUS_SWITCHING_END: case this.treeStyleTab.kEVENT_TYPE_TAB_FOCUS_SWITCHING_END:
this.cancelDelayedShowForShortcut(); this.cancelDelayedShowForShortcut();
if (this.enabled && if (this.enabled)
this.showHideReason == this.kSHOWN_BY_SHORTCUT)
this.hide(this.kSHOWN_BY_SHORTCUT); this.hide(this.kSHOWN_BY_SHORTCUT);
return; return;
@ -1073,7 +1075,7 @@ AutoHideBrowser.prototype = {
!sv.isPopupShown() && !sv.isPopupShown() &&
( (
!this.expanded || !this.expanded ||
this.showHideReason & this.kKEEP_SHOWN_ON_MOUSEOVER this.showHideReason & this.kSHOWN_BY_SOME_REASON
) && ) &&
!this.lastMouseDownTarget !this.lastMouseDownTarget
) )
@ -1138,7 +1140,6 @@ AutoHideBrowser.prototype = {
) { ) {
if (this.enabled && if (this.enabled &&
utils.getTreePref('tabbar.autoShow.accelKeyDown') && utils.getTreePref('tabbar.autoShow.accelKeyDown') &&
!this.expanded &&
!this.delayedAutoShowTimer && !this.delayedAutoShowTimer &&
!this.delayedShowForShortcutTimer) { !this.delayedShowForShortcutTimer) {
this.delayedShowForShortcutTimer = w.setTimeout( this.delayedShowForShortcutTimer = w.setTimeout(
@ -1155,8 +1156,7 @@ AutoHideBrowser.prototype = {
} }
} }
else { else {
if (this.enabled && if (this.enabled)
this.showHideReason == this.kSHOWN_BY_SHORTCUT)
this.hide(this.kSHOWN_BY_SHORTCUT); this.hide(this.kSHOWN_BY_SHORTCUT);
} }
}, },
@ -1184,7 +1184,7 @@ AutoHideBrowser.prototype = {
this.enabled = false; this.enabled = false;
this.mouseMoveListening = false; this.mouseMoveListening = false;
this.showHideReason = 0; this.showHideReason = this.kSHOWN_BY_UNKNOWN;
this.lastMouseDownTarget = null; this.lastMouseDownTarget = null;
this.isResizing = false; this.isResizing = false;