Show the full tooltip near the original tooltip correctly, even if there are multiple screens. (#302)
This commit is contained in:
parent
e58a7b9987
commit
d2ff4f545e
@ -45,6 +45,9 @@ Components.utils.import('resource://treestyletab-modules/pseudoTreeBuilder.js');
|
|||||||
|
|
||||||
XPCOMUtils.defineLazyModuleGetter(this, 'utils', 'resource://treestyletab-modules/utils.js', 'TreeStyleTabUtils');
|
XPCOMUtils.defineLazyModuleGetter(this, 'utils', 'resource://treestyletab-modules/utils.js', 'TreeStyleTabUtils');
|
||||||
|
|
||||||
|
XPCOMUtils.defineLazyServiceGetter(this, 'ScreenManager',
|
||||||
|
'@mozilla.org/gfx/screenmanager;1', 'nsIScreenManager');
|
||||||
|
|
||||||
function FullTooltipManager(aOwner)
|
function FullTooltipManager(aOwner)
|
||||||
{
|
{
|
||||||
this.init(aOwner);
|
this.init(aOwner);
|
||||||
@ -345,6 +348,36 @@ FullTooltipManager.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the window is maximized, screenX and screenY can be out of
|
||||||
|
* visible screen rect. On the other hand,
|
||||||
|
* nsIPopupBoxObject#openPopupAtScreen() automatically reposition
|
||||||
|
* the popup if it is going to be shown out of the visible screen
|
||||||
|
* rect. As the result, the popup will be repositioned unexpectedly
|
||||||
|
* if I use the raw screenX and screenY.
|
||||||
|
* https://github.com/piroor/treestyletab/issues/302
|
||||||
|
* To prevent such a result, I have to calculate valid base position
|
||||||
|
* for the popup.
|
||||||
|
*/
|
||||||
|
get windowBasePosition() {
|
||||||
|
var screen = ScreenManager.screenForRect(
|
||||||
|
this.window.screenX,
|
||||||
|
this.window.screenY,
|
||||||
|
this.window.outerWidth,
|
||||||
|
this.window.outerHeight
|
||||||
|
);
|
||||||
|
var screenMinX = {},
|
||||||
|
screenMinY = {},
|
||||||
|
screenMaxX = {},
|
||||||
|
screenMaxY = {};
|
||||||
|
screen.GetAvailRect(screenMinX, screenMinY, screenMaxX, screenMaxY);
|
||||||
|
|
||||||
|
return {
|
||||||
|
x: Math.max(this.window.screenX, screenMinX.value),
|
||||||
|
y: Math.max(this.window.screenY, screenMinY.value)
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
setup : function FTM_setup(aBaseTooltip, aTab, aExtraLabels)
|
setup : function FTM_setup(aBaseTooltip, aTab, aExtraLabels)
|
||||||
{
|
{
|
||||||
this.cancel();
|
this.cancel();
|
||||||
@ -354,9 +387,10 @@ FullTooltipManager.prototype = {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
this._fullTooltipTimer = this.window.setTimeout(function(aSelf) {
|
this._fullTooltipTimer = this.window.setTimeout(function(aSelf) {
|
||||||
|
var basePosition = aSelf.windowBasePosition;
|
||||||
var box = aBaseTooltip.boxObject;
|
var box = aBaseTooltip.boxObject;
|
||||||
var x = box.screenX - this.window.screenX;
|
var x = box.screenX - basePosition.x;
|
||||||
var y = box.screenY - this.window.screenY;
|
var y = box.screenY - basePosition.y;
|
||||||
var w = box.width;
|
var w = box.width;
|
||||||
var h = box.height;
|
var h = box.height;
|
||||||
aBaseTooltip.hidePopup();
|
aBaseTooltip.hidePopup();
|
||||||
@ -370,7 +404,7 @@ FullTooltipManager.prototype = {
|
|||||||
style.maxWidth = style.minWidth = w+'px';
|
style.maxWidth = style.minWidth = w+'px';
|
||||||
style.maxHeight = style.minHeight = h+'px';
|
style.maxHeight = style.minHeight = h+'px';
|
||||||
}
|
}
|
||||||
tooltip.openPopupAtScreen(this.window.screenX, this.window.screenY, false);
|
tooltip.openPopupAtScreen(basePosition.x, basePosition.y, false);
|
||||||
}, Math.max(delay, 0), this);
|
}, Math.max(delay, 0), this);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user