MessageTray: Use status from gnome-session
This patch modifies MessageTray behaviour so that normal (not urgent) notifications are not shown when the user is Busy (they're sent immediately to the Summary area). When status is then changed, notifications still pending are shown again. Additionally, when status is modified from Idle to anything other than Busy, the message tray is forced open for 4 seconds, so that summary icons are visible. https://bugzilla.gnome.org/show_bug.cgi?id=617225
This commit is contained in:
parent
998ef7d861
commit
1496c85bb6
@ -11,11 +11,12 @@ const Pango = imports.gi.Pango;
|
|||||||
const Shell = imports.gi.Shell;
|
const Shell = imports.gi.Shell;
|
||||||
const Signals = imports.signals;
|
const Signals = imports.signals;
|
||||||
const St = imports.gi.St;
|
const St = imports.gi.St;
|
||||||
const Tweener = imports.ui.tweener;
|
|
||||||
|
|
||||||
const Main = imports.ui.main;
|
|
||||||
const BoxPointer = imports.ui.boxpointer;
|
const BoxPointer = imports.ui.boxpointer;
|
||||||
|
const GnomeSession = imports.misc.gnomeSession;
|
||||||
|
const Main = imports.ui.main;
|
||||||
const Params = imports.misc.params;
|
const Params = imports.misc.params;
|
||||||
|
const Tweener = imports.ui.tweener;
|
||||||
const Util = imports.misc.util;
|
const Util = imports.misc.util;
|
||||||
|
|
||||||
const Gettext = imports.gettext.domain('gnome-shell');
|
const Gettext = imports.gettext.domain('gnome-shell');
|
||||||
@ -24,6 +25,7 @@ const _ = Gettext.gettext;
|
|||||||
const ANIMATION_TIME = 0.2;
|
const ANIMATION_TIME = 0.2;
|
||||||
const NOTIFICATION_TIMEOUT = 4;
|
const NOTIFICATION_TIMEOUT = 4;
|
||||||
const SUMMARY_TIMEOUT = 1;
|
const SUMMARY_TIMEOUT = 1;
|
||||||
|
const LONGER_SUMMARY_TIMEOUT = 4;
|
||||||
|
|
||||||
const HIDE_TIMEOUT = 0.2;
|
const HIDE_TIMEOUT = 0.2;
|
||||||
const LONGER_HIDE_TIMEOUT = 0.6;
|
const LONGER_HIDE_TIMEOUT = 0.6;
|
||||||
@ -940,6 +942,13 @@ function MessageTray() {
|
|||||||
|
|
||||||
MessageTray.prototype = {
|
MessageTray.prototype = {
|
||||||
_init: function() {
|
_init: function() {
|
||||||
|
this._presence = new GnomeSession.Presence();
|
||||||
|
this._userStatus = GnomeSession.PresenceStatus.AVAILABLE;
|
||||||
|
this._busy = false;
|
||||||
|
this._backFromAway = false;
|
||||||
|
this._presence.connect('StatusChanged', Lang.bind(this, this._onStatusChanged));
|
||||||
|
this._presence.getStatus(Lang.bind(this, this._onStatusChanged));
|
||||||
|
|
||||||
this.actor = new St.Group({ name: 'message-tray',
|
this.actor = new St.Group({ name: 'message-tray',
|
||||||
reactive: true,
|
reactive: true,
|
||||||
track_hover: true });
|
track_hover: true });
|
||||||
@ -1412,6 +1421,28 @@ MessageTray.prototype = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_onStatusChanged: function(presence, status) {
|
||||||
|
this._backFromAway = (this._userStatus == GnomeSession.PresenceStatus.IDLE && this._userStatus != status);
|
||||||
|
this._userStatus = status;
|
||||||
|
|
||||||
|
if (status == GnomeSession.PresenceStatus.BUSY) {
|
||||||
|
// remove notification and allow the summary to be closed now
|
||||||
|
this._updateNotificationTimeout(0);
|
||||||
|
if (this._summaryTimeoutId) {
|
||||||
|
Mainloop.source_remove(this._summaryTimeoutId);
|
||||||
|
this._summaryTimeoutId = 0;
|
||||||
|
}
|
||||||
|
this._busy = true;
|
||||||
|
} else if (status != GnomeSession.PresenceStatus.IDLE) {
|
||||||
|
// We preserve the previous value of this._busy if the status turns to IDLE
|
||||||
|
// so that we don't start showing notifications queued during the BUSY state
|
||||||
|
// as the screensaver gets activated.
|
||||||
|
this._busy = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._updateState();
|
||||||
|
},
|
||||||
|
|
||||||
_onTrayLeftTimeout: function() {
|
_onTrayLeftTimeout: function() {
|
||||||
let [x, y, mods] = global.get_pointer();
|
let [x, y, mods] = global.get_pointer();
|
||||||
// We extend the timeout once if the mouse moved no further than MOUSE_LEFT_ACTOR_THRESHOLD to either side or up.
|
// We extend the timeout once if the mouse moved no further than MOUSE_LEFT_ACTOR_THRESHOLD to either side or up.
|
||||||
@ -1450,7 +1481,8 @@ MessageTray.prototype = {
|
|||||||
// at the present time.
|
// at the present time.
|
||||||
_updateState: function() {
|
_updateState: function() {
|
||||||
// Notifications
|
// Notifications
|
||||||
let notificationsPending = this._notificationQueue.length > 0;
|
let notificationsPending = this._notificationQueue.length > 0 &&
|
||||||
|
(!this._busy || this._notificationQueue[0].urgency == Urgency.CRITICAL);
|
||||||
let notificationPinned = this._pointerInTray && !this._pointerInSummary && !this._notificationRemoved;
|
let notificationPinned = this._pointerInTray && !this._pointerInSummary && !this._notificationRemoved;
|
||||||
let notificationExpanded = this._notificationBin.y < 0;
|
let notificationExpanded = this._notificationBin.y < 0;
|
||||||
let notificationExpired = (this._notificationTimeoutId == 0 && !(this._notification && this._notification.urgency == Urgency.CRITICAL) && !this._pointerInTray && !this._locked) || this._notificationRemoved;
|
let notificationExpired = (this._notificationTimeoutId == 0 && !(this._notification && this._notification.urgency == Urgency.CRITICAL) && !this._pointerInTray && !this._locked) || this._notificationRemoved;
|
||||||
@ -1479,10 +1511,16 @@ MessageTray.prototype = {
|
|||||||
let notificationsDone = !notificationsVisible && !notificationsPending;
|
let notificationsDone = !notificationsVisible && !notificationsPending;
|
||||||
|
|
||||||
if (this._summaryState == State.HIDDEN) {
|
if (this._summaryState == State.HIDDEN) {
|
||||||
if (notificationsDone && this._newSummaryItems.length > 0)
|
if (this._backFromAway) {
|
||||||
this._showSummary(true);
|
// Immediately set this to false, so that we don't schedule a timeout later
|
||||||
else if (summarySummoned)
|
this._backFromAway = false;
|
||||||
this._showSummary(false);
|
if (!this._busy)
|
||||||
|
this._showSummary(LONGER_SUMMARY_TIMEOUT);
|
||||||
|
} else if (notificationsDone && this._newSummaryItems.length > 0 && !this._busy) {
|
||||||
|
this._showSummary(SUMMARY_TIMEOUT);
|
||||||
|
} else if (summarySummoned) {
|
||||||
|
this._showSummary(0);
|
||||||
|
}
|
||||||
} else if (this._summaryState == State.SHOWN) {
|
} else if (this._summaryState == State.SHOWN) {
|
||||||
if (!summaryPinned)
|
if (!summaryPinned)
|
||||||
this._hideSummary();
|
this._hideSummary();
|
||||||
@ -1718,7 +1756,7 @@ MessageTray.prototype = {
|
|||||||
this._focusGrabber.grabFocus(this._notification.actor);
|
this._focusGrabber.grabFocus(this._notification.actor);
|
||||||
},
|
},
|
||||||
|
|
||||||
_showSummary: function(withTimeout) {
|
_showSummary: function(timeout) {
|
||||||
let primary = global.get_primary_monitor();
|
let primary = global.get_primary_monitor();
|
||||||
this._summaryBin.opacity = 0;
|
this._summaryBin.opacity = 0;
|
||||||
this._summaryBin.y = this.actor.height;
|
this._summaryBin.y = this.actor.height;
|
||||||
@ -1729,16 +1767,16 @@ MessageTray.prototype = {
|
|||||||
transition: 'easeOutQuad',
|
transition: 'easeOutQuad',
|
||||||
onComplete: this._showSummaryCompleted,
|
onComplete: this._showSummaryCompleted,
|
||||||
onCompleteScope: this,
|
onCompleteScope: this,
|
||||||
onCompleteParams: [withTimeout]
|
onCompleteParams: [timeout]
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_showSummaryCompleted: function(withTimeout) {
|
_showSummaryCompleted: function(timeout) {
|
||||||
this._newSummaryItems = [];
|
this._newSummaryItems = [];
|
||||||
|
|
||||||
if (withTimeout) {
|
if (timeout != 0) {
|
||||||
this._summaryTimeoutId =
|
this._summaryTimeoutId =
|
||||||
Mainloop.timeout_add(SUMMARY_TIMEOUT * 1000,
|
Mainloop.timeout_add(timeout * 1000,
|
||||||
Lang.bind(this, this._summaryTimeout));
|
Lang.bind(this, this._summaryTimeout));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user