MessageTray: fix showing and hiding summary notifications when summary items are clicked

This patch fixes the summary notification reappearing if you click on the
summary item to hide it and hover away. It also ensures that when you click
on any summary item which doesn't correspond to the summary notification
being shown, a new summary notification will replace it right away.

What used to happen is that we'd unset the clicked item in _unlock() that
was called when the focus was ungrabbed because the user clicked outside
of the summary notification, but then would have this._clickedSummaryItem
be null in _onSummaryItemClicked() , and set it to the clicked item all
over again. This patch ensures that we unset the clicked item only when
it is necessary.

We also needed to add the code to call _updateState() again to show a new
summary notification when a previous one was hidden, but
this._clickedSummaryItem was set.

https://bugzilla.gnome.org/show_bug.cgi?id=642005
This commit is contained in:
Marina Zhurakhinskaya 2011-02-15 18:37:33 -05:00
parent 37d307c80e
commit 1aba99336a

View File

@ -261,7 +261,7 @@ FocusGrabber.prototype = {
switch (event.type()) { switch (event.type()) {
case Clutter.EventType.BUTTON_PRESS: case Clutter.EventType.BUTTON_PRESS:
if (!this.actor.contains(source)) if (!this.actor.contains(source))
this.ungrabFocus(); this.emit('button-pressed', source);
break; break;
case Clutter.EventType.KEY_PRESS: case Clutter.EventType.KEY_PRESS:
let symbol = event.get_key_symbol(); let symbol = event.get_key_symbol();
@ -991,6 +991,12 @@ MessageTray.prototype = {
this._lock(); this._lock();
})); }));
this._focusGrabber.connect('focus-ungrabbed', Lang.bind(this, this._unlock)); this._focusGrabber.connect('focus-ungrabbed', Lang.bind(this, this._unlock));
this._focusGrabber.connect('button-pressed', Lang.bind(this,
function(focusGrabber, source) {
if (this._clickedSummaryItem && !this._clickedSummaryItem.actor.contains(source))
this._unsetClickedSummaryItem();
this._focusGrabber.ungrabFocus();
}));
this._focusGrabber.connect('escape-pressed', Lang.bind(this, this._escapeTray)); this._focusGrabber.connect('escape-pressed', Lang.bind(this, this._escapeTray));
this._trayState = State.HIDDEN; this._trayState = State.HIDDEN;
@ -1023,18 +1029,22 @@ MessageTray.prototype = {
Main.overview.connect('showing', Lang.bind(this, Main.overview.connect('showing', Lang.bind(this,
function() { function() {
this._overviewVisible = true; this._overviewVisible = true;
if (this._locked) if (this._locked) {
this._unsetClickedSummaryItem();
this._unlock(); this._unlock();
else } else {
this._updateState(); this._updateState();
}
})); }));
Main.overview.connect('hiding', Lang.bind(this, Main.overview.connect('hiding', Lang.bind(this,
function() { function() {
this._overviewVisible = false; this._overviewVisible = false;
if (this._locked) if (this._locked) {
this._unsetClickedSummaryItem();
this._unlock(); this._unlock();
else } else {
this._updateState(); this._updateState();
}
})); }));
this._summaryItems = []; this._summaryItems = [];
@ -1206,7 +1216,6 @@ MessageTray.prototype = {
if (!this._locked) if (!this._locked)
return; return;
this._locked = false; this._locked = false;
this._unsetClickedSummaryItem();
this._updateState(); this._updateState();
}, },
@ -1839,6 +1848,8 @@ MessageTray.prototype = {
this._onNotify(summaryNotification.source, summaryNotification); this._onNotify(summaryNotification.source, summaryNotification);
this._reNotifyWithSummaryNotificationAfterHide = false; this._reNotifyWithSummaryNotificationAfterHide = false;
} }
if (this._clickedSummaryItem)
this._updateState();
} }
}; };