Skip to content

Commit

Permalink
tooltips.js: add a hide timer to check if a tooltip should hide itself,
Browse files Browse the repository at this point in the history
but for various reasons never got to act on a leave-event (due to vagaries
in event reporting).
  • Loading branch information
mtwebster committed Jan 1, 2017
1 parent 3936ac1 commit 0b3f831
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
Expand Up @@ -124,7 +124,7 @@ WindowPreview.prototype = {
if (this._applet._tooltipShowing)
this.show();
else if (!this._showTimer)
this._showTimer = Mainloop.timeout_add(300, Lang.bind(this, this._onTimerComplete));
this._showTimer = Mainloop.timeout_add(300, Lang.bind(this, this._onShowTimerComplete));

this.mousePosition = event.get_coords();
},
Expand Down
47 changes: 42 additions & 5 deletions js/ui/tooltips.js
Expand Up @@ -68,7 +68,7 @@ TooltipBase.prototype = {
// An allocation change could mean that the actor has moved,
// so hide, but wait until after the allocation cycle.
Mainloop.idle_add(Lang.bind(this, function() {
this.hide();
this._hide();
}));
});

Expand All @@ -84,24 +84,49 @@ TooltipBase.prototype = {
this._showTimer = null;
}

if (this._hideTimer) {
Mainloop.source_remove(this._hideTimer);
this._hideTimer = null;
}

if (!this.visible) {
this._showTimer = Mainloop.timeout_add(300, Lang.bind(this, this._onTimerComplete));
this._showTimer = Mainloop.timeout_add(300, Lang.bind(this, this._onShowTimerComplete));
this.mousePosition = event.get_coords();
} else {
this._hideTimer = Mainloop.timeout_add(500, Lang.bind(this, this._onHideTimerComplete));
}
},

_onEnterEvent: function(actor, event) {
if (!this._showTimer) {
this._showTimer = Mainloop.timeout_add(300, Lang.bind(this, this._onTimerComplete));
this._showTimer = Mainloop.timeout_add(300, Lang.bind(this, this._onShowTimerComplete));
this.mousePosition = event.get_coords();
}
},

_onTimerComplete: function() {
_onShowTimerComplete: function() {
this._showTimer = null;

if (!this.preventShow)
if (!this.preventShow) {
this.show();
}

return false;
},

_onHideTimerComplete: function() {
this._hideTimer = null;

let [abs_x, abs_y, mods] = global.get_pointer();
let box = this.item.get_allocation_box();

let [success, x, y] = this.item.get_parent().transform_stage_point(abs_x, abs_y);

if ((x < box.x1) || (x > box.x2) ||
(y < box.y1) || (y > box.y2)) {
log("__________________________________hide complete!");
this._hide();
}

return false;
},
Expand All @@ -111,6 +136,12 @@ TooltipBase.prototype = {
Mainloop.source_remove(this._showTimer);
this._showTimer = null;
}

if (this._hideTimer) {
Mainloop.source_remove(this._hideTimer);
this._hideTimer = null;
}

this.hide();
},

Expand All @@ -124,6 +155,12 @@ TooltipBase.prototype = {
Mainloop.source_remove(this._showTimer);
this._showTimer = null;
}

if (this._hideTimer) {
Mainloop.source_remove(this._hideTimer);
this._hideTimer = null;
}

this.signals.disconnectAllSignals();
this._destroy();
}
Expand Down

0 comments on commit 0b3f831

Please sign in to comment.