messageTray: Simplify the actor hierarchy a bit
With no more tricky interaction between bottom tray and notification banners, we can merge the remaining actors into a single one. https://bugzilla.gnome.org/show_bug.cgi?id=744850
This commit is contained in:
parent
830b4559c0
commit
77413feb57
@ -1351,22 +1351,19 @@ const MessageTray = new Lang.Class({
|
||||
this._onStatusChanged(status);
|
||||
}));
|
||||
|
||||
this._notificationWidget = new St.Widget({ name: 'notification-container',
|
||||
reactive: true,
|
||||
track_hover: true,
|
||||
y_align: Clutter.ActorAlign.START,
|
||||
x_align: Clutter.ActorAlign.CENTER,
|
||||
y_expand: true,
|
||||
x_expand: true,
|
||||
layout_manager: new Clutter.BinLayout() });
|
||||
this._notificationWidget.connect('key-release-event', Lang.bind(this, this._onNotificationKeyRelease));
|
||||
this._notificationWidget.connect('notify::hover', Lang.bind(this, this._onNotificationHoverChanged));
|
||||
this.actor = new St.Widget({ name: 'notification-container',
|
||||
reactive: true,
|
||||
track_hover: true,
|
||||
y_align: Clutter.ActorAlign.START,
|
||||
x_align: Clutter.ActorAlign.CENTER,
|
||||
y_expand: true,
|
||||
x_expand: true,
|
||||
layout_manager: new Clutter.BinLayout() });
|
||||
this.actor.connect('key-release-event', Lang.bind(this, this._onNotificationKeyRelease));
|
||||
this.actor.connect('notify::hover', Lang.bind(this, this._onNotificationHoverChanged));
|
||||
|
||||
this._notificationBin = new St.Bin({ y_expand: true });
|
||||
this._notificationBin.set_y_align(Clutter.ActorAlign.START);
|
||||
this._notificationWidget.add_actor(this._notificationBin);
|
||||
this._notificationWidget.hide();
|
||||
this._notificationFocusGrabber = new FocusGrabber(this._notificationWidget);
|
||||
this.actor.hide();
|
||||
this._notificationFocusGrabber = new FocusGrabber(this.actor);
|
||||
this._notificationQueue = [];
|
||||
this._notification = null;
|
||||
this._notificationClickedId = 0;
|
||||
@ -1374,7 +1371,7 @@ const MessageTray = new Lang.Class({
|
||||
this._closeButton = Util.makeCloseButton();
|
||||
this._closeButton.hide();
|
||||
this._closeButton.connect('clicked', Lang.bind(this, this._closeNotification));
|
||||
this._notificationWidget.add_actor(this._closeButton);
|
||||
this.actor.add_actor(this._closeButton);
|
||||
|
||||
this._userActiveWhileNotificationShown = false;
|
||||
|
||||
@ -1389,7 +1386,7 @@ const MessageTray = new Lang.Class({
|
||||
// state of the pointer when a notification pops up.
|
||||
this._pointerInNotification = false;
|
||||
|
||||
// This tracks this._notificationWidget.hover and is used to fizzle
|
||||
// This tracks this.actor.hover and is used to fizzle
|
||||
// out non-changing hover notifications in onNotificationHoverChanged.
|
||||
this._notificationHovered = false;
|
||||
|
||||
@ -1400,8 +1397,8 @@ const MessageTray = new Lang.Class({
|
||||
|
||||
this.clearableCount = 0;
|
||||
|
||||
Main.layoutManager.trayBox.add_actor(this._notificationWidget);
|
||||
Main.layoutManager.trackChrome(this._notificationWidget);
|
||||
Main.layoutManager.trayBox.add_actor(this.actor);
|
||||
Main.layoutManager.trackChrome(this.actor);
|
||||
Main.layoutManager.trackChrome(this._closeButton);
|
||||
|
||||
global.screen.connect('in-fullscreen-changed', Lang.bind(this, this._updateState));
|
||||
@ -1558,10 +1555,10 @@ const MessageTray = new Lang.Class({
|
||||
},
|
||||
|
||||
_onNotificationHoverChanged: function() {
|
||||
if (this._notificationWidget.hover == this._notificationHovered)
|
||||
if (this.actor.hover == this._notificationHovered)
|
||||
return;
|
||||
|
||||
this._notificationHovered = this._notificationWidget.hover;
|
||||
this._notificationHovered = this.actor.hover;
|
||||
if (this._notificationHovered) {
|
||||
this._resetNotificationLeftTimeout();
|
||||
|
||||
@ -1575,7 +1572,7 @@ const MessageTray = new Lang.Class({
|
||||
// automatically. Instead, the user is able to expand the notification by mousing away from it and then
|
||||
// mousing back in. Because this is an expected action, we set the boolean flag that indicates that a longer
|
||||
// timeout should be used before popping down the notification.
|
||||
if (this._notificationWidget.contains(actorAtShowNotificationPosition)) {
|
||||
if (this.actor.contains(actorAtShowNotificationPosition)) {
|
||||
this._useLongerNotificationLeftTimeout = true;
|
||||
return;
|
||||
}
|
||||
@ -1743,11 +1740,11 @@ const MessageTray = new Lang.Class({
|
||||
this._notificationUnfocusedId = this._notification.connect('unfocused', Lang.bind(this, function() {
|
||||
this._updateState();
|
||||
}));
|
||||
this._notificationBin.child = this._notification.actor;
|
||||
this.actor.add_actor(this._notification.actor);
|
||||
|
||||
this._notificationWidget.opacity = 0;
|
||||
this._notificationWidget.y = 0;
|
||||
this._notificationWidget.show();
|
||||
this.actor.opacity = 0;
|
||||
this.actor.y = 0;
|
||||
this.actor.show();
|
||||
|
||||
this._updateShowingNotification();
|
||||
|
||||
@ -1790,14 +1787,14 @@ const MessageTray = new Lang.Class({
|
||||
// notification is being shown.
|
||||
|
||||
let tweenParams = { opacity: 255,
|
||||
y: -this._notificationWidget.height,
|
||||
y: -this.actor.height,
|
||||
time: ANIMATION_TIME,
|
||||
transition: 'easeOutQuad',
|
||||
onComplete: this._showNotificationCompleted,
|
||||
onCompleteScope: this
|
||||
};
|
||||
|
||||
this._tween(this._notificationWidget, '_notificationState', State.SHOWN, tweenParams);
|
||||
this._tween(this.actor, '_notificationState', State.SHOWN, tweenParams);
|
||||
},
|
||||
|
||||
_showNotificationCompleted: function() {
|
||||
@ -1861,8 +1858,8 @@ const MessageTray = new Lang.Class({
|
||||
this._resetNotificationLeftTimeout();
|
||||
|
||||
if (animate) {
|
||||
this._tween(this._notificationWidget, '_notificationState', State.HIDDEN,
|
||||
{ y: this._notificationWidget.height,
|
||||
this._tween(this.actor, '_notificationState', State.HIDDEN,
|
||||
{ y: this.actor.height,
|
||||
opacity: 0,
|
||||
time: ANIMATION_TIME,
|
||||
transition: 'easeOutQuad',
|
||||
@ -1870,9 +1867,9 @@ const MessageTray = new Lang.Class({
|
||||
onCompleteScope: this
|
||||
});
|
||||
} else {
|
||||
Tweener.removeTweens(this._notificationWidget);
|
||||
this._notificationWidget.y = this._notificationWidget.height;
|
||||
this._notificationWidget.opacity = 0;
|
||||
Tweener.removeTweens(this.actor);
|
||||
this.actor.y = this.actor.height;
|
||||
this.actor.opacity = 0;
|
||||
this._notificationState = State.HIDDEN;
|
||||
this._hideNotificationCompleted();
|
||||
}
|
||||
@ -1889,8 +1886,8 @@ const MessageTray = new Lang.Class({
|
||||
this._closeButton.hide();
|
||||
this._pointerInNotification = false;
|
||||
this._notificationRemoved = false;
|
||||
this._notificationBin.child = null;
|
||||
this._notificationWidget.hide();
|
||||
this.actor.remove_actor(notification.actor);
|
||||
this.actor.hide();
|
||||
},
|
||||
|
||||
_expandActiveNotification: function() {
|
||||
@ -1914,17 +1911,18 @@ const MessageTray = new Lang.Class({
|
||||
},
|
||||
|
||||
_onNotificationExpanded: function() {
|
||||
let expandedY = - this._notificationWidget.height;
|
||||
let expandedY = - this.actor.height;
|
||||
this.actor.set_child_above_sibling(this._closeButton, null);
|
||||
this._closeButton.show();
|
||||
|
||||
// Don't animate the notification to its new position if it has shrunk:
|
||||
// there will be a very visible "gap" that breaks the illusion.
|
||||
if (this._notificationWidget.y < expandedY) {
|
||||
this._notificationWidget.y = expandedY;
|
||||
if (this.actor.y < expandedY) {
|
||||
this.actor.y = expandedY;
|
||||
} else if (this._notification.y != expandedY) {
|
||||
// Tween also opacity here, to override a possible tween that's
|
||||
// currently hiding the notification.
|
||||
Tweener.addTween(this._notificationWidget,
|
||||
Tweener.addTween(this.actor,
|
||||
{ y: expandedY,
|
||||
opacity: 255,
|
||||
time: ANIMATION_TIME,
|
||||
|
Loading…
Reference in New Issue
Block a user