messageTray: Disable the tray dwell when the user is interacting

Look at the focus window's interaction timestamp to catch the case
where the user is typing and knocks the pointer into the tray or
mouses down to the bottom of the screen and clicks on something.
If the focus window's interaction time differs at the start and
end of the tray dwell then we don't activate the tray.

https://bugzilla.gnome.org/show_bug.cgi?id=683811
This commit is contained in:
Owen W. Taylor 2012-09-06 12:02:26 -04:00
parent f7a95b5edc
commit b1451523ca

View File

@ -1510,6 +1510,7 @@ const MessageTray = new Lang.Class({
pointerWatcher.addWatch(TRAY_DWELL_CHECK_INTERVAL, Lang.bind(this, this._checkTrayDwell));
this._trayDwellTimeoutId = 0;
this._trayDwelling = false;
this._trayDwellUserTime = 0;
},
_checkTrayDwell: function(x, y) {
@ -1523,9 +1524,14 @@ const MessageTray = new Lang.Class({
// of the monitor. The _trayDwelling variable is used so that we only try to
// fire off one tray dwell - if it fails (because, say, the user has the mouse down),
// we don't try again until the user moves the mouse up and down again.
if (!this._trayDwelling && !this.actor.hover && this._trayDwellTimeoutId == 0)
if (!this._trayDwelling && !this.actor.hover && this._trayDwellTimeoutId == 0) {
// Save the interaction timestamp so we can detect user input
let focusWindow = global.display.focus_window;
this._trayDwellUserTime = focusWindow ? focusWindow.user_time : 0;
this._trayDwellTimeoutId = Mainloop.timeout_add(TRAY_DWELL_TIME,
Lang.bind(this, this._trayDwellTimeout));
}
this._trayDwelling = true;
} else {
this._cancelTrayDwell();
@ -1541,6 +1547,13 @@ const MessageTray = new Lang.Class({
},
_trayDwellTimeout: function() {
// If the user interacted with the focus window since we started the tray
// dwell (by clicking or typing), don't activate the message tray
let focusWindow = global.display.focus_window;
let currentUserTime = focusWindow ? focusWindow.user_time : 0;
if (currentUserTime != this._trayDwellUserTime)
return false;
this._trayDwellTimeoutId = 0;
this._traySummoned = true;