kill tray

This commit is contained in:
Jasper St. Pierre 2014-05-28 14:34:57 -04:00
parent a4091adbf2
commit 798f17a97d
2 changed files with 25 additions and 804 deletions

View File

@ -1491,14 +1491,6 @@ StScrollBar StButton#vhandle:active {
/* Message Tray */
#message-tray {
background: #2e3436 url(message-tray-background.png);
background-repeat: repeat;
height: 72px;
padding-right: 8px;
}
.system-tray-icons {
border-radius: 8px;
border: 1px solid #4c4c4c;
@ -1515,30 +1507,10 @@ StScrollBar StButton#vhandle:active {
background: 1px solid #4c4c4c;
}
.message-tray-summary {
height: 72px;
}
.message-tray-menu-button StIcon {
padding: 0 20px;
color: #aaaaaa;
icon-size: 24px;
}
.message-tray-menu-button:hover StIcon,
.message-tray-menu-button:active StIcon,
.message-tray-menu-button:focus StIcon {
color: #eeeeee;
}
.url-highlighter {
link-color: #ccccff;
}
.no-messages-label {
color: #999999;
}
.notification, #notification-container {
font-size: 11pt;
width: 34em;
@ -1590,40 +1562,6 @@ StScrollBar StButton#vhandle:active {
padding-right: 6px;
}
.summary-boxpointer {
-arrow-border-radius: 15px;
-arrow-background-color: rgba(0,0,0,0.9);
-arrow-base: 36px;
-arrow-rise: 18px;
color: white;
-boxpointer-gap: 4px;
}
.summary-boxpointer .notification {
border-radius: 9px;
background: rgba(0,0,0,0) !important;
padding-bottom: 12px;
}
.summary-boxpointer #summary-right-click-menu {
padding-top: 12px;
padding-bottom: 12px;
}
.summary-notification-stack-scrollview {
max-height: 18em;
padding-top: 8px;
padding-bottom: 8px;
}
.summary-notification-stack-scrollview:ltr {
padding-right: 8px;
}
.summary-notification-stack-scrollview:rtl {
padding-left: 8px;
}
.notification-scrollview {
max-height: 10em;
-st-vfade-offset: 24px;

View File

@ -32,8 +32,6 @@ const SHELL_KEYBINDINGS_SCHEMA = 'org.gnome.shell.keybindings';
const ANIMATION_TIME = 0.2;
const NOTIFICATION_TIMEOUT = 4;
const SUMMARY_TIMEOUT = 1;
const LONGER_SUMMARY_TIMEOUT = 4;
const HIDE_TIMEOUT = 0.2;
const LONGER_HIDE_TIMEOUT = 0.6;
@ -909,131 +907,6 @@ const Notification = new Lang.Class({
});
Signals.addSignalMethods(Notification.prototype);
const SourceActor = new Lang.Class({
Name: 'SourceActor',
_init: function(source, size) {
this._source = source;
this._size = size;
this.actor = new Shell.GenericContainer();
this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth));
this.actor.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight));
this.actor.connect('allocate', Lang.bind(this, this._allocate));
this.actor.connect('destroy', Lang.bind(this, function() {
this._actorDestroyed = true;
}));
this._actorDestroyed = false;
let scale_factor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
this._iconBin = new St.Bin({ x_fill: true,
height: size * scale_factor,
width: size * scale_factor });
this.actor.add_actor(this._iconBin);
this._source.connect('icon-updated', Lang.bind(this, this._updateIcon));
this._updateIcon();
},
setIcon: function(icon) {
this._iconBin.child = icon;
this._iconSet = true;
},
_getPreferredWidth: function (actor, forHeight, alloc) {
let [min, nat] = this._iconBin.get_preferred_width(forHeight);
alloc.min_size = min; alloc.nat_size = nat;
},
_getPreferredHeight: function (actor, forWidth, alloc) {
let [min, nat] = this._iconBin.get_preferred_height(forWidth);
alloc.min_size = min; alloc.nat_size = nat;
},
_allocate: function(actor, box, flags) {
// the iconBin should fill our entire box
this._iconBin.allocate(box, flags);
},
_updateIcon: function() {
if (this._actorDestroyed)
return;
if (!this._iconSet)
this._iconBin.child = this._source.createIcon(this._size);
}
});
const SourceActorWithLabel = new Lang.Class({
Name: 'SourceActorWithLabel',
Extends: SourceActor,
_init: function(source, size) {
this.parent(source, size);
this._counterLabel = new St.Label({ x_align: Clutter.ActorAlign.CENTER,
x_expand: true,
y_align: Clutter.ActorAlign.CENTER,
y_expand: true });
this._counterBin = new St.Bin({ style_class: 'summary-source-counter',
child: this._counterLabel,
layout_manager: new Clutter.BinLayout() });
this._counterBin.hide();
this._counterBin.connect('style-changed', Lang.bind(this, function() {
let themeNode = this._counterBin.get_theme_node();
this._counterBin.translation_x = themeNode.get_length('-shell-counter-overlap-x');
this._counterBin.translation_y = themeNode.get_length('-shell-counter-overlap-y');
}));
this.actor.add_actor(this._counterBin);
this._source.connect('count-updated', Lang.bind(this, this._updateCount));
this._updateCount();
},
_allocate: function(actor, box, flags) {
this.parent(actor, box, flags);
let childBox = new Clutter.ActorBox();
let [minWidth, minHeight, naturalWidth, naturalHeight] = this._counterBin.get_preferred_size();
let direction = this.actor.get_text_direction();
if (direction == Clutter.TextDirection.LTR) {
// allocate on the right in LTR
childBox.x1 = box.x2 - naturalWidth;
childBox.x2 = box.x2;
} else {
// allocate on the left in RTL
childBox.x1 = 0;
childBox.x2 = naturalWidth;
}
childBox.y1 = box.y2 - naturalHeight;
childBox.y2 = box.y2;
this._counterBin.allocate(childBox, flags);
},
_updateCount: function() {
if (this._actorDestroyed)
return;
this._counterBin.visible = this._source.countVisible;
let text;
if (this._source.count < 100)
text = this._source.count.toString();
else
text = String.fromCharCode(0x22EF); // midline horizontal ellipsis
this._counterLabel.set_text(text);
}
});
const Source = new Lang.Class({
Name: 'MessageTraySource',
@ -1081,27 +954,6 @@ const Source = new Lang.Class({
return new NotificationPolicy();
},
buildRightClickMenu: function() {
let item;
let rightClickMenu = new St.BoxLayout({ name: 'summary-right-click-menu',
vertical: true });
item = new PopupMenu.PopupMenuItem(_("Open"));
item.connect('activate', Lang.bind(this, function() {
this.open();
this.emit('done-displaying-content', true);
}));
rightClickMenu.add(item.actor);
item = new PopupMenu.PopupMenuItem(_("Remove"));
item.connect('activate', Lang.bind(this, function() {
this.destroy();
this.emit('done-displaying-content', false);
}));
rightClickMenu.add(item.actor);
return rightClickMenu;
},
setTitle: function(newTitle) {
this.title = newTitle;
this.emit('title-changed');
@ -1126,20 +978,6 @@ const Source = new Lang.Class({
return new Gio.ThemedIcon({ name: this.iconName });
},
_ensureMainIcon: function() {
if (this._mainIcon)
return;
this._mainIcon = new SourceActorWithLabel(this, this.SOURCE_ICON_SIZE);
},
// Unlike createIcon, this always returns the same actor;
// there is only one summary icon actor for a Source.
getSummaryIcon: function() {
this._ensureMainIcon();
return this._mainIcon.actor;
},
_onNotificationDestroy: function(notification) {
let index = this.notifications.indexOf(notification);
if (index < 0)
@ -1191,21 +1029,12 @@ const Source = new Lang.Class({
this.emit('destroy', reason);
},
// A subclass can redefine this to "steal" clicks from the
// summaryitem; Use Clutter.get_current_event() to get the
// details, return true to prevent the default handling from
// ocurring.
handleSummaryClick: function() {
return false;
},
iconUpdated: function() {
this.emit('icon-updated');
},
//// Protected methods ////
_setSummaryIcon: function(icon) {
this._ensureMainIcon();
this._mainIcon.setIcon(icon);
this.iconUpdated();
},
@ -1237,129 +1066,6 @@ const Source = new Lang.Class({
});
Signals.addSignalMethods(Source.prototype);
const SummaryItem = new Lang.Class({
Name: 'SummaryItem',
_init: function(source) {
this.source = source;
this.source.connect('notification-added', Lang.bind(this, this._notificationAddedToSource));
this.actor = new St.Button({ style_class: 'summary-source-button',
y_fill: true,
reactive: true,
button_mask: St.ButtonMask.ONE | St.ButtonMask.TWO | St.ButtonMask.THREE,
can_focus: true,
track_hover: true });
this.actor.label_actor = new St.Label({ text: source.title });
this.actor.connect('key-press-event', Lang.bind(this, this._onKeyPress));
this._sourceBox = new St.BoxLayout({ style_class: 'summary-source' });
this._sourceIcon = source.getSummaryIcon();
this._sourceBox.add(this._sourceIcon, { y_fill: false });
this.actor.child = this._sourceBox;
this.notificationStackWidget = new St.Widget({ layout_manager: new Clutter.BinLayout() });
this.notificationStackView = new St.ScrollView({ style_class: source.isChat ? '' : 'summary-notification-stack-scrollview',
vscrollbar_policy: source.isChat ? Gtk.PolicyType.NEVER : Gtk.PolicyType.AUTOMATIC,
hscrollbar_policy: Gtk.PolicyType.NEVER });
this.notificationStackView.add_style_class_name('vfade');
this.notificationStack = new St.BoxLayout({ style_class: 'summary-notification-stack',
vertical: true });
this.notificationStackView.add_actor(this.notificationStack);
this.notificationStackWidget.add_actor(this.notificationStackView);
this._closeButton = Util.makeCloseButton();
this._closeButton.connect('clicked', Lang.bind(this, function() {
source.destroy();
source.emit('done-displaying-content', false);
}));
this.notificationStackWidget.add_actor(this._closeButton);
this._stackedNotifications = [];
this._oldMaxScrollAdjustment = 0;
this.notificationStackView.vscroll.adjustment.connect('changed', Lang.bind(this, function(adjustment) {
let currentValue = adjustment.value + adjustment.page_size;
if (currentValue == this._oldMaxScrollAdjustment)
this.scrollTo(St.Side.BOTTOM);
this._oldMaxScrollAdjustment = adjustment.upper;
}));
this.rightClickMenu = source.buildRightClickMenu();
if (this.rightClickMenu)
global.focus_manager.add_group(this.rightClickMenu);
},
destroy: function() {
// remove the actor from the summary item so it doesn't get destroyed
// with us
this._sourceBox.remove_actor(this._sourceIcon);
this.actor.destroy();
},
_onKeyPress: function(actor, event) {
if (event.get_key_symbol() == Clutter.KEY_Up) {
actor.emit('clicked', 1);
return Clutter.EVENT_STOP;
}
return Clutter.EVENT_PROPAGATE;
},
prepareNotificationStackForShowing: function() {
if (this.notificationStack.get_n_children() > 0)
return;
this.source.notifications.forEach(Lang.bind(this, this._appendNotificationToStack));
this.scrollTo(St.Side.BOTTOM);
},
doneShowingNotificationStack: function() {
this.source.notifications.forEach(Lang.bind(this, function(notification) {
notification.collapseCompleted();
notification.setIconVisible(true);
notification.enableScrolling(true);
this.notificationStack.remove_actor(notification.actor);
}));
},
_notificationAddedToSource: function(source, notification) {
if (this.notificationStack.mapped)
this._appendNotificationToStack(notification);
},
_contentUpdated: function() {
this.source.notifications.forEach(function(notification, i) {
notification.setIconVisible(i == 0);
});
this.emit('content-updated');
},
_appendNotificationToStack: function(notification) {
notification.connect('destroy', Lang.bind(this, this._contentUpdated));
if (!this.source.isChat)
notification.enableScrolling(false);
notification.expand(false);
this.notificationStack.add(notification.actor);
this._contentUpdated();
},
// scrollTo:
// @side: St.Side.TOP or St.Side.BOTTOM
//
// Scrolls the notifiction stack to the indicated edge
scrollTo: function(side) {
let adjustment = this.notificationStackView.vscroll.adjustment;
if (side == St.Side.TOP)
adjustment.value = adjustment.lower;
else if (side == St.Side.BOTTOM)
adjustment.value = adjustment.upper;
},
});
Signals.addSignalMethods(SummaryItem.prototype);
const MessageTrayMenu = new Lang.Class({
Name: 'MessageTrayMenu',
Extends: PopupMenu.PopupMenu,
@ -1708,14 +1414,6 @@ const MessageTray = new Lang.Class({
this._onStatusChanged(status);
}));
this.actor = new St.Widget({ name: 'message-tray',
reactive: true,
layout_manager: new Clutter.BinLayout(),
x_expand: true,
y_expand: true,
y_align: Clutter.ActorAlign.START,
});
this._notificationWidget = new St.Widget({ name: 'notification-container',
reactive: true,
track_hover: true,
@ -1741,44 +1439,6 @@ const MessageTray = new Lang.Class({
this._notification = null;
this._notificationClickedId = 0;
this.actor.connect('button-release-event', Lang.bind(this, function(actor, event) {
this._setClickedSummaryItem(null);
this._updateState();
actor.grab_key_focus();
return Clutter.EVENT_PROPAGATE;
}));
global.focus_manager.add_group(this.actor);
this._summaryGroup = new St.BoxLayout({ x_align: Clutter.ActorAlign.END,
x_expand: true,
y_align: Clutter.ActorAlign.CENTER,
y_expand: true });
this.actor.add_child(this._summaryGroup);
this._summary = new St.BoxLayout({ style_class: 'message-tray-summary' });
this._summaryGroup.add_child(this._summary);
this._systemTray = new SystemTraySection(this);
this._summaryGroup.add_child(this._systemTray.actor);
this._summaryMotionId = 0;
this._summaryBoxPointer = new BoxPointer.BoxPointer(St.Side.BOTTOM,
{ reactive: true,
track_hover: true });
this._summaryBoxPointer.actor.connect('key-press-event',
Lang.bind(this, this._onSummaryBoxPointerKeyPress));
this._summaryBoxPointer.actor.style_class = 'summary-boxpointer';
this._summaryBoxPointer.actor.hide();
Main.layoutManager.addChrome(this._summaryBoxPointer.actor);
this._summaryBoxPointerItem = null;
this._summaryBoxPointerContentUpdatedId = 0;
this._summaryBoxPointerDoneDisplayingId = 0;
this._clickedSummaryItem = null;
this._clickedSummaryItemMouseButton = -1;
this._clickedSummaryItemAllocationChangedId = 0;
this._closeButton = Util.makeCloseButton();
this._closeButton.hide();
this._closeButton.connect('clicked', Lang.bind(this, this._closeNotification));
@ -1788,17 +1448,14 @@ const MessageTray = new Lang.Class({
this.idleMonitor = Meta.IdleMonitor.get_core();
this._grabHelper = new GrabHelper.GrabHelper(this.actor,
{ keybindingMode: Shell.KeyBindingMode.MESSAGE_TRAY });
this._grabHelper.addActor(this._summaryBoxPointer.actor);
this._grabHelper.addActor(this.actor);
/*
this._systemTray = new SystemTraySection(this);
this.actor.add_child(this._systemTray.actor);
*/
/*
Main.layoutManager.connect('keyboard-visible-changed', Lang.bind(this, this._onKeyboardVisibleChanged));
this._trayState = State.HIDDEN;
this._traySummoned = false;
this._useLongerNotificationLeftTimeout = false;
this._trayLeftTimeoutId = 0;
*/
// pointerInNotification is sort of a misnomer -- it tracks whether
// a message tray notification should expand. The value is
@ -1815,39 +1472,19 @@ const MessageTray = new Lang.Class({
this._notificationState = State.HIDDEN;
this._notificationTimeoutId = 0;
this._notificationExpandedId = 0;
this._summaryBoxPointerState = State.HIDDEN;
this._summaryBoxPointerTimeoutId = 0;
this._desktopCloneState = State.HIDDEN;
this._notificationRemoved = false;
this._reNotifyAfterHideNotification = null;
this._desktopClone = null;
this._inCtrlAltTab = false;
this.clearableCount = 0;
this._lightboxes = [];
let lightboxContainers = [global.window_group,
Main.layoutManager.overviewGroup];
for (let i = 0; i < lightboxContainers.length; i++)
this._lightboxes.push(new Lightbox.Lightbox(lightboxContainers[i],
{ inhibitEvents: true,
fadeFactor: 0.2
}));
Main.layoutManager.trayBox.add_actor(this.actor);
Main.layoutManager.trayBox.add_actor(this._notificationRevealer.actor);
Main.layoutManager.trackChrome(this.actor);
Main.layoutManager.trackChrome(this._notificationWidget);
Main.layoutManager.trackChrome(this._closeButton);
global.screen.connect('in-fullscreen-changed', Lang.bind(this, this._updateState));
Main.layoutManager.connect('hot-corners-changed', Lang.bind(this, this._hotCornersChanged));
// If the overview shows or hides while we're in
// the message tray, revert back to normal mode.
Main.overview.connect('showing', Lang.bind(this, this._escapeTray));
Main.overview.connect('hiding', Lang.bind(this, this._escapeTray));
Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
Main.wm.addKeybinding('toggle-message-tray',
@ -1866,13 +1503,13 @@ const MessageTray = new Lang.Class({
Lang.bind(this, this._expandActiveNotification));
this._sources = new Map();
this._chatSummaryItemsCount = 0;
this._trayDwellTimeoutId = 0;
this._setupTrayDwellIfNeeded();
// this._setupTrayDwellIfNeeded();
this._sessionUpdated();
this._hotCornersChanged();
/*
this._noMessages = new St.Label({ text: _("No Messages"),
style_class: 'no-messages-label',
x_align: Clutter.ActorAlign.CENTER,
@ -1884,11 +1521,14 @@ const MessageTray = new Lang.Class({
this._messageTrayMenuButton = new MessageTrayMenuButton(this);
this.actor.add_actor(this._messageTrayMenuButton.actor);
*/
/*
this._indicator = new MessageTrayIndicator(this);
Main.layoutManager.trayBox.add_child(this._indicator.actor);
Main.layoutManager.trackChrome(this._indicator.actor);
this._grabHelper.addActor(this._indicator.actor);
*/
},
close: function() {
@ -1907,10 +1547,11 @@ const MessageTray = new Lang.Class({
},
_updateNoMessagesLabel: function() {
this._noMessages.visible = this._sources.size == 0;
// this._noMessages.visible = this._sources.size == 0;
},
_sessionUpdated: function() {
/*
if (Main.sessionMode.isLocked || Main.sessionMode.isGreeter) {
if (this._inCtrlAltTab)
Main.ctrlAltTabManager.removeGroup(this._summary);
@ -1922,6 +1563,7 @@ const MessageTray = new Lang.Class({
this._inCtrlAltTab = true;
}
this._updateState();
*/
},
_checkTrayDwell: function(x, y) {
@ -1951,36 +1593,6 @@ const MessageTray = new Lang.Class({
}
},
_cancelTrayDwell: function() {
if (this._trayDwellTimeoutId != 0) {
Mainloop.source_remove(this._trayDwellTimeoutId);
this._trayDwellTimeoutId = 0;
}
},
_trayDwellTimeout: function() {
this._trayDwellTimeoutId = 0;
if (Main.layoutManager.bottomMonitor.inFullscreen)
return GLib.SOURCE_REMOVE;
// We don't want to open the tray when a modal dialog
// is up, so we check the modal count for that. When we are in the
// overview we have to take the overview's modal push into account
if (Main.modalCount > (Main.overview.visible ? 1 : 0))
return GLib.SOURCE_REMOVE;
// 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 GLib.SOURCE_REMOVE;
this.openTray();
return GLib.SOURCE_REMOVE;
},
_onNotificationKeyRelease: function(actor, event) {
if (event.get_key_symbol() == Clutter.KEY_Escape && event.get_state() == 0) {
this._expireNotification();
@ -2024,20 +1636,11 @@ const MessageTray = new Lang.Class({
_addSource: function(source) {
let obj = {
source: source,
summaryItem: new SummaryItem(source),
notifyId: 0,
destroyId: 0,
mutedChangedId: 0,
countChangedId: 0,
};
let summaryItem = obj.summaryItem;
if (source.isChat) {
this._summary.insert_child_at_index(summaryItem.actor, 0);
this._chatSummaryItemsCount++;
} else {
this._summary.insert_child_at_index(summaryItem.actor, this._chatSummaryItemsCount);
}
if (source.isClearable)
this.clearableCount++;
@ -2057,23 +1660,6 @@ const MessageTray = new Lang.Class({
this.emit('indicator-count-updated');
}));
summaryItem.actor.connect('clicked', Lang.bind(this,
function(actor, button) {
actor.grab_key_focus();
this._onSummaryItemClicked(summaryItem, button);
}));
summaryItem.actor.connect('popup-menu', Lang.bind(this,
function(actor, button) {
actor.grab_key_focus();
this._onSummaryItemClicked(summaryItem, 3);
}));
// We need to display the newly-added summary item, but if the
// caller is about to post a notification, we want to show that
// *first* and not show the summary item until after it hides.
// So postpone calling _updateState() a tiny bit.
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this, function() { this._updateState(); return false; }));
this.emit('source-added', source);
this.emit('indicator-count-updated');
@ -2083,10 +1669,6 @@ const MessageTray = new Lang.Class({
_removeSource: function(source) {
let obj = this._sources.get(source);
this._sources.delete(source);
let summaryItem = obj.summaryItem;
if (source.isChat)
this._chatSummaryItemsCount--;
if (source.isClearable)
this.clearableCount--;
@ -2096,8 +1678,6 @@ const MessageTray = new Lang.Class({
source.disconnect(obj.mutedChangedId);
source.disconnect(obj.countChangedId);
summaryItem.destroy();
this.emit('source-removed', source);
this.emit('indicator-count-updated');
@ -2175,8 +1755,10 @@ const MessageTray = new Lang.Class({
if (!this.toggle())
return;
/*
if (this._traySummoned)
this._summary.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
this._.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
*/
},
hide: function() {
@ -2185,30 +1767,6 @@ const MessageTray = new Lang.Class({
},
_onNotify: function(source, notification) {
if (this._summaryBoxPointerItem && this._summaryBoxPointerItem.source == source) {
if (this._summaryBoxPointerState == State.HIDING) {
// We are in the process of hiding the summary box pointer.
// If there is an update for one of the notifications or
// a new notification to be added to the notification stack
// while it is in the process of being hidden, we show it as
// a new notification. However, we first wait till the hide
// is complete. This is especially important if one of the
// notifications in the stack was updated because we will
// need to be able to re-parent its actor to a different
// part of the stage.
this._reNotifyAfterHideNotification = notification;
} else {
// The summary box pointer is showing or shown (otherwise,
// this._summaryBoxPointerItem would be null)
// Immediately mark the notification as acknowledged and play its
// sound, as it's not going into the queue
notification.acknowledged = true;
notification.playSound();
}
return;
}
if (this._notification == notification) {
// If a notification that is being shown is updated, we update
// how it is shown and extend the time until it auto-hides.
@ -2226,25 +1784,13 @@ const MessageTray = new Lang.Class({
this._updateState();
},
_onSummaryItemClicked: function(summaryItem, button) {
if (summaryItem.source.handleSummaryClick(button)) {
if (summaryItem.source.keepTrayOnSummaryClick)
this._setClickedSummaryItem(null);
else
this._escapeTray();
} else {
if (!this._setClickedSummaryItem(summaryItem, button))
this._setClickedSummaryItem(null);
}
this._updateState();
},
_hotCornersChanged: function() {
/*
let primary = Main.layoutManager.primaryIndex;
let corner = Main.layoutManager.hotCorners[primary];
if (corner && corner.actor)
this._grabHelper.addActor(corner.actor);
*/
},
_resetNotificationLeftTimeout: function() {
@ -2264,7 +1810,7 @@ const MessageTray = new Lang.Class({
this._notificationHovered = this._notificationWidget.hover;
if (this._notificationHovered) {
// No dwell inside notifications at the bottom of the screen
this._cancelTrayDwell();
// this._cancelTrayDwell();
this._resetNotificationLeftTimeout();
@ -2278,10 +1824,12 @@ 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.actor.contains(actorAtShowNotificationPosition)) {
this._useLongerNotificationLeftTimeout = true;
return;
}
*/
}
this._pointerInNotification = true;
@ -2350,7 +1898,6 @@ const MessageTray = new Lang.Class({
_escapeTray: function() {
this._pointerInNotification = false;
this._traySummoned = false;
this._setClickedSummaryItem(null);
this._updateNotificationTimeout(0);
this._updateState();
},
@ -2380,7 +1927,7 @@ const MessageTray = new Lang.Class({
let hasNotifications = Main.sessionMode.hasNotifications;
if (this._notificationState == State.HIDDEN) {
let shouldShowNotification = (hasNotifications && this._trayState == State.HIDDEN && !this._traySummoned);
let shouldShowNotification = (hasNotifications && !this._traySummoned);
let nextNotification = this._notificationQueue[0] || null;
if (shouldShowNotification && nextNotification) {
let limited = this._busy || Main.layoutManager.bottomMonitor.inFullscreen;
@ -2406,53 +1953,6 @@ const MessageTray = new Lang.Class({
}
}
// Summary notification
let haveClickedSummaryItem = this._clickedSummaryItem != null;
let requestedNotificationStackIsEmpty = (haveClickedSummaryItem &&
this._clickedSummaryItemMouseButton == 1 &&
this._clickedSummaryItem.source.notifications.length == 0);
if (this._summaryBoxPointerState == State.HIDDEN) {
if (haveClickedSummaryItem && !requestedNotificationStackIsEmpty)
this._showSummaryBoxPointer();
} else if (this._summaryBoxPointerState == State.SHOWN) {
if (haveClickedSummaryItem && hasNotifications) {
let wrongSummaryNotificationStack = (this._clickedSummaryItemMouseButton == 1 &&
this._summaryBoxPointer.bin.child != this._clickedSummaryItem.notificationStackWidget &&
requestedNotificationStackIsEmpty);
let wrongSummaryRightClickMenu = (this._clickedSummaryItemMouseButton == 3 &&
this._clickedSummaryItem.rightClickMenu != null &&
this._summaryBoxPointer.bin.child != this._clickedSummaryItem.rightClickMenu);
let wrongSummaryBoxPointer = (wrongSummaryNotificationStack || wrongSummaryRightClickMenu);
if (wrongSummaryBoxPointer) {
this._hideSummaryBoxPointer();
this._showSummaryBoxPointer();
}
} else {
this._hideSummaryBoxPointer();
}
}
// Tray itself
let trayIsVisible = (this._trayState == State.SHOWING ||
this._trayState == State.SHOWN);
let trayShouldBeVisible = this._traySummoned && !this._keyboardVisible && hasNotifications;
if (!trayIsVisible && trayShouldBeVisible)
trayShouldBeVisible = this._showTray();
else if (trayIsVisible && !trayShouldBeVisible)
this._hideTray();
// Desktop clone
let desktopCloneIsVisible = (this._desktopCloneState == State.SHOWING ||
this._desktopCloneState == State.SHOWN);
let desktopCloneShouldBeVisible = (trayShouldBeVisible);
if (!desktopCloneIsVisible && desktopCloneShouldBeVisible)
this._showDesktopClone();
else if (desktopCloneIsVisible && !desktopCloneShouldBeVisible)
this._hideDesktopClone();
this._updatingState = false;
// Clean transient variables that are used to communicate actions
@ -2485,6 +1985,7 @@ const MessageTray = new Lang.Class({
},
_showTray: function() {
/*
if (!this._grabHelper.grab({ actor: this.actor,
onUngrab: Lang.bind(this, this._escapeTray) })) {
this._traySummoned = false;
@ -2498,80 +1999,10 @@ const MessageTray = new Lang.Class({
transition: 'easeOutQuad'
});
for (let i = 0; i < this._lightboxes.length; i++)
this._lightboxes[i].show(ANIMATION_TIME);
*/
return true;
},
_updateDesktopCloneClip: function() {
let geometry = this._bottomMonitorGeometry;
let progress = -Math.round(this._desktopClone.y);
this._desktopClone.set_clip(geometry.x,
geometry.y + progress,
geometry.width,
geometry.height - progress);
},
_showDesktopClone: function() {
let bottomMonitor = Main.layoutManager.bottomMonitor;
this._bottomMonitorGeometry = { x: bottomMonitor.x,
y: bottomMonitor.y,
width: bottomMonitor.width,
height: bottomMonitor.height };
if (this._desktopClone)
this._desktopClone.destroy();
let cloneSource = Main.overview.visible ? Main.layoutManager.overviewGroup : global.window_group;
this._desktopClone = new Clutter.Clone({ source: cloneSource,
clip: new Clutter.Geometry(this._bottomMonitorGeometry) });
Main.uiGroup.insert_child_above(this._desktopClone, cloneSource);
this._desktopClone.x = 0;
this._desktopClone.y = 0;
this._desktopClone.show();
this._tween(this._desktopClone, '_desktopCloneState', State.SHOWN,
{ y: -this.actor.height,
time: ANIMATION_TIME,
transition: 'easeOutQuad',
onUpdate: Lang.bind(this, this._updateDesktopCloneClip)
});
},
_hideTray: function() {
// Having the summary item animate out while sliding down the tray
// is distracting, so hide it immediately in case it was visible.
this._summaryBoxPointer.actor.hide();
this.emit('hiding');
this._tween(this.actor, '_trayState', State.HIDDEN,
{ y: 0,
time: ANIMATION_TIME,
transition: 'easeOutQuad'
});
// Note that we might have entered here without a grab,
// which would happen if GrabHelper ungrabbed for us.
// This is a no-op in that case.
this._grabHelper.ungrab({ actor: this.actor });
for (let i = 0; i < this._lightboxes.length; i++)
this._lightboxes[i].hide(ANIMATION_TIME);
},
_hideDesktopClone: function() {
this._tween(this._desktopClone, '_desktopCloneState', State.HIDDEN,
{ y: 0,
time: ANIMATION_TIME,
transition: 'easeOutQuad',
onComplete: Lang.bind(this, function() {
this._desktopClone.destroy();
this._desktopClone = null;
this._bottomMonitorGeometry = null;
}),
onUpdate: Lang.bind(this, this._updateDesktopCloneClip)
});
},
_onIdleMonitorBecameActive: function() {
this._userActiveWhileNotificationShown = true;
this._updateNotificationTimeout(2000);
@ -2763,154 +2194,6 @@ const MessageTray = new Lang.Class({
_ensureNotificationFocused: function() {
this._notificationFocusGrabber.grabFocus();
},
_onSourceDoneDisplayingContent: function(source, closeTray) {
if (closeTray) {
this._escapeTray();
} else {
this._setClickedSummaryItem(null);
this._updateState();
}
},
_showSummaryBoxPointer: function() {
let child;
let summaryItem = this._clickedSummaryItem;
if (this._clickedSummaryItemMouseButton == 1) {
// Acknowledge all our notifications
summaryItem.source.notifications.forEach(function(n) { n.acknowledged = true; });
summaryItem.prepareNotificationStackForShowing();
child = summaryItem.notificationStackWidget;
} else if (this._clickedSummaryItemMouseButton == 3) {
child = summaryItem.rightClickMenu;
}
// If the user clicked the middle mouse button, or the item
// doesn't have a right-click menu, do nothing.
if (!child)
return;
this._summaryBoxPointerItem = summaryItem;
this._summaryBoxPointerContentUpdatedId = this._summaryBoxPointerItem.connect('content-updated',
Lang.bind(this, this._onSummaryBoxPointerContentUpdated));
this._sourceDoneDisplayingId = this._summaryBoxPointerItem.source.connect('done-displaying-content',
Lang.bind(this, this._onSourceDoneDisplayingContent));
this._summaryBoxPointer.bin.child = child;
this._summaryBoxPointer.actor.opacity = 0;
this._summaryBoxPointer.actor.show();
this._adjustSummaryBoxPointerPosition();
this._grabHelper.grab({ actor: this._summaryBoxPointer.bin.child,
onUngrab: Lang.bind(this, this._onSummaryBoxPointerUngrabbed) });
this._summaryBoxPointerState = State.SHOWING;
this._summaryBoxPointer.show(BoxPointer.PopupAnimation.FULL, Lang.bind(this, function() {
this._summaryBoxPointerState = State.SHOWN;
}));
},
_onSummaryBoxPointerContentUpdated: function() {
if (this._summaryBoxPointerItem.notificationStack.get_n_children() == 0)
this._hideSummaryBoxPointer();
},
_adjustSummaryBoxPointerPosition: function() {
this._summaryBoxPointer.setPosition(this._summaryBoxPointerItem.actor, 0);
},
_setClickedSummaryItem: function(item, button) {
if (item == this._clickedSummaryItem &&
button == this._clickedSummaryItemMouseButton)
return false;
if (this._clickedSummaryItem) {
this._clickedSummaryItem.actor.remove_style_pseudo_class('selected');
this._clickedSummaryItem.actor.disconnect(this._clickedSummaryItemAllocationChangedId);
this._summary.disconnect(this._summaryMotionId);
this._clickedSummaryItemAllocationChangedId = 0;
this._summaryMotionId = 0;
}
this._clickedSummaryItem = item;
this._clickedSummaryItemMouseButton = button;
if (this._clickedSummaryItem) {
this._clickedSummaryItem.actor.add_style_pseudo_class('selected');
this._clickedSummaryItem.actor.connect('destroy', Lang.bind(this, function() {
this._setClickedSummaryItem(null);
this._updateState();
}));
this._clickedSummaryItemAllocationChangedId =
this._clickedSummaryItem.actor.connect('allocation-changed',
Lang.bind(this, this._adjustSummaryBoxPointerPosition));
// _clickedSummaryItem.actor can change absolute position without changing allocation
this._summaryMotionId = this._summary.connect('allocation-changed',
Lang.bind(this, this._adjustSummaryBoxPointerPosition));
}
return true;
},
_onSummaryBoxPointerKeyPress: function(actor, event) {
switch (event.get_key_symbol()) {
case Clutter.KEY_Down:
case Clutter.KEY_Escape:
this._setClickedSummaryItem(null);
this._updateState();
return Clutter.EVENT_STOP;
case Clutter.KEY_Delete:
this._clickedSummaryItem.source.destroy();
this._escapeTray();
return Clutter.EVENT_STOP;
}
return Clutter.EVENT_PROPAGATE;
},
_onSummaryBoxPointerUngrabbed: function() {
this._summaryBoxPointerState = State.HIDING;
this._setClickedSummaryItem(null);
if (this._summaryBoxPointerContentUpdatedId) {
this._summaryBoxPointerItem.disconnect(this._summaryBoxPointerContentUpdatedId);
this._summaryBoxPointerContentUpdatedId = 0;
}
if (this._sourceDoneDisplayingId) {
this._summaryBoxPointerItem.source.disconnect(this._sourceDoneDisplayingId);
this._sourceDoneDisplayingId = 0;
}
let animate = (this._summaryBoxPointerItem.source.notifications.length > 0);
this._summaryBoxPointer.hide(animate ? BoxPointer.PopupAnimation.FULL : BoxPointer.PopupAnimation.NONE,
Lang.bind(this, this._hideSummaryBoxPointerCompleted));
},
_hideSummaryBoxPointer: function() {
this._grabHelper.ungrab({ actor: this._summaryBoxPointer.bin.child });
},
_hideSummaryBoxPointerCompleted: function() {
let doneShowingNotificationStack = (this._summaryBoxPointer.bin.child == this._summaryBoxPointerItem.notificationStackWidget);
this._summaryBoxPointerState = State.HIDDEN;
this._summaryBoxPointer.bin.child = null;
if (doneShowingNotificationStack) {
let source = this._summaryBoxPointerItem.source;
this._summaryBoxPointerItem.doneShowingNotificationStack();
this._summaryBoxPointerItem = null;
if (this._reNotifyAfterHideNotification) {
this._onNotify(this._reNotifyAfterHideNotification.source, this._reNotifyAfterHideNotification);
this._reNotifyAfterHideNotification = null;
}
}
if (this._clickedSummaryItem)
this._updateState();
}
});
Signals.addSignalMethods(MessageTray.prototype);