From a80b8f77913cf3429ad7e958ff1556614314375b Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Wed, 28 May 2014 14:34:57 -0400 Subject: [PATCH] kill tray --- data/theme/gnome-shell.css | 54 -- js/ui/messageTray.js | 1020 +----------------------------------- 2 files changed, 6 insertions(+), 1068 deletions(-) diff --git a/data/theme/gnome-shell.css b/data/theme/gnome-shell.css index f626e0895..73f6f20cc 100644 --- a/data/theme/gnome-shell.css +++ b/data/theme/gnome-shell.css @@ -1497,30 +1497,10 @@ StScrollBar StButton#vhandle:active { height: 72px; } -.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; @@ -1586,40 +1566,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; diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js index f5e66194c..03c265735 100644 --- a/js/ui/messageTray.js +++ b/js/ui/messageTray.js @@ -31,8 +31,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; @@ -820,131 +818,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', @@ -991,27 +864,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'); @@ -1036,20 +888,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) @@ -1101,21 +939,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(); }, @@ -1147,285 +976,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.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); - 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, - - _init: function(button, tray) { - this.parent(button, 0, St.Side.BOTTOM); - - this._tray = tray; - - this._presence = new GnomeSession.Presence(Lang.bind(this, function(proxy, error) { - if (error) { - logError(error, 'Error while reading gnome-session presence'); - return; - } - - this._onStatusChanged(proxy.status); - })); - this._presence.connectSignal('StatusChanged', Lang.bind(this, function(proxy, senderName, [status]) { - this._onStatusChanged(status); - })); - - this._accountManager = Tp.AccountManager.dup(); - this._accountManager.connect('most-available-presence-changed', - Lang.bind(this, this._onIMPresenceChanged)); - this._accountManager.prepare_async(null, Lang.bind(this, this._onIMPresenceChanged)); - - this.actor.hide(); - Main.layoutManager.addChrome(this.actor); - - this._busyItem = new PopupMenu.PopupSwitchMenuItem(_("Notifications")); - this._busyItem.connect('toggled', Lang.bind(this, this._updatePresence)); - this.addMenuItem(this._busyItem); - - let separator = new PopupMenu.PopupSeparatorMenuItem(); - this.addMenuItem(separator); - - this._clearItem = this.addAction(_("Clear Messages"), function() { - let toDestroy = tray.getSources().filter(function(source) { - return source.isClearable; - }); - - toDestroy.forEach(function(source) { - source.destroy(); - }); - - tray.close(); - }); - - tray.connect('source-added', Lang.bind(this, this._updateClearSensitivity)); - tray.connect('source-removed', Lang.bind(this, this._updateClearSensitivity)); - this._updateClearSensitivity(); - - let separator = new PopupMenu.PopupSeparatorMenuItem(); - this.addMenuItem(separator); - - let settingsItem = this.addSettingsAction(_("Notification Settings"), 'gnome-notifications-panel.desktop'); - settingsItem.connect('activate', function() { tray.close(); }); - }, - - _onStatusChanged: function(status) { - this._sessionStatus = status; - this._busyItem.setToggleState(status != GnomeSession.PresenceStatus.BUSY); - }, - - _onIMPresenceChanged: function(am, type) { - if (type == Tp.ConnectionPresenceType.AVAILABLE && - this._sessionStatus == GnomeSession.PresenceStatus.BUSY) - this._presence.SetStatusRemote(GnomeSession.PresenceStatus.AVAILABLE); - }, - - _updateClearSensitivity: function() { - this._clearItem.setSensitive(this._tray.clearableCount > 0); - }, - - _updatePresence: function(item, state) { - let status = state ? GnomeSession.PresenceStatus.AVAILABLE - : GnomeSession.PresenceStatus.BUSY; - this._presence.SetStatusRemote(status); - - let [type, s ,msg] = this._accountManager.get_most_available_presence(); - let newType = 0; - let newStatus; - if (status == GnomeSession.PresenceStatus.BUSY && - type == Tp.ConnectionPresenceType.AVAILABLE) { - newType = Tp.ConnectionPresenceType.BUSY; - newStatus = 'busy'; - } else if (status == GnomeSession.PresenceStatus.AVAILABLE && - type == Tp.ConnectionPresenceType.BUSY) { - newType = Tp.ConnectionPresenceType.AVAILABLE; - newStatus = 'available'; - } - - if (newType > 0) - this._accountManager.set_all_requested_presences(newType, - newStatus, msg); - } -}); - -const MessageTrayMenuButton = new Lang.Class({ - Name: 'MessageTrayMenuButton', - - _init: function(tray) { - this._icon = new St.Icon(); - this.actor = new St.Button({ style_class: 'message-tray-menu-button', - reactive: true, - track_hover: true, - can_focus: true, - button_mask: St.ButtonMask.ONE | St.ButtonMask.TWO | St.ButtonMask.THREE, - accessible_name: _("Tray Menu"), - accessible_role: Atk.Role.MENU, - child: this._icon }); - - // Standard hack for ClutterBinLayout. - this.actor.set_x_expand(true); - this.actor.set_y_expand(true); - this.actor.set_x_align(Clutter.ActorAlign.START); - - this._menu = new MessageTrayMenu(this.actor, tray); - this._manager = new PopupMenu.PopupMenuManager({ actor: this.actor }); - this._manager.addMenu(this._menu); - this._menu.connect('open-state-changed', Lang.bind(this, function(menu, open) { - if (open) - this.actor.add_style_pseudo_class('active'); - else - this.actor.remove_style_pseudo_class('active'); - })); - - this.actor.connect('clicked', Lang.bind(this, function() { - this._menu.toggle(); - })); - - this._accountManager = Tp.AccountManager.dup(); - this._accountManager.connect('most-available-presence-changed', - Lang.bind(this, this._sync)); - this._accountManager.prepare_async(null, Lang.bind(this, this._sync)); - }, - - _iconForPresence: function(presence) { - if (presence == Tp.ConnectionPresenceType.AVAILABLE) - return 'user-available-symbolic'; - else if (presence == Tp.ConnectionPresenceType.BUSY) - return 'user-busy-symbolic'; - else if (presence == Tp.ConnectionPresenceType.HIDDEN) - return 'user-hidden-symbolic'; - else if (presence == Tp.ConnectionPresenceType.AWAY) - return 'user-away-symbolic'; - else if (presence == Tp.ConnectionPresenceType.EXTENDED_AWAY) - return 'user-idle-symbolic'; - else - return 'emblem-system-symbolic'; - }, - - _sync: function() { - let [presence, status, message] = this._accountManager.get_most_available_presence(); - this._icon.icon_name = this._iconForPresence(presence); - }, -}); - const MessageTray = new Lang.Class({ Name: 'MessageTray', @@ -1438,14 +988,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, @@ -1469,55 +1011,10 @@ 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._summary = new St.BoxLayout({ style_class: 'message-tray-summary', - reactive: true, - x_align: Clutter.ActorAlign.END, - x_expand: true, - y_align: Clutter.ActorAlign.CENTER, - y_expand: true }); - this.actor.add_actor(this._summary); - - 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._userActiveWhileNotificationShown = false; 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); - - 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 // partially driven by the hover state of the notification, but has @@ -1532,159 +1029,21 @@ const MessageTray = new Lang.Class({ this._keyboardVisible = false; this._notificationState = State.HIDDEN; this._notificationTimeoutId = 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._notificationWidget); - Main.layoutManager.trackChrome(this.actor); Main.layoutManager.trackChrome(this._notificationWidget); 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', - new Gio.Settings({ schema: SHELL_KEYBINDINGS_SCHEMA }), - Meta.KeyBindingFlags.NONE, - Shell.KeyBindingMode.NORMAL | - Shell.KeyBindingMode.MESSAGE_TRAY | - Shell.KeyBindingMode.OVERVIEW, - Lang.bind(this, this.toggleAndNavigate)); this._sources = new Map(); - this._chatSummaryItemsCount = 0; - - this._trayDwellTimeoutId = 0; - this._setupTrayDwellIfNeeded(); - this._sessionUpdated(); - this._hotCornersChanged(); - - this._noMessages = new St.Label({ text: _("No Messages"), - style_class: 'no-messages-label', - x_align: Clutter.ActorAlign.CENTER, - x_expand: true, - y_align: Clutter.ActorAlign.CENTER, - y_expand: true }); - this.actor.add_actor(this._noMessages); - this._updateNoMessagesLabel(); - - this._messageTrayMenuButton = new MessageTrayMenuButton(this); - this.actor.add_actor(this._messageTrayMenuButton.actor); }, close: function() { this._escapeTray(); }, - _setupTrayDwellIfNeeded: function() { - // If we don't have extended barrier features, then we need - // to support the old tray dwelling mechanism. - if (!global.display.supports_extended_barriers()) { - let pointerWatcher = PointerWatcher.getPointerWatcher(); - pointerWatcher.addWatch(TRAY_DWELL_CHECK_INTERVAL, Lang.bind(this, this._checkTrayDwell)); - this._trayDwelling = false; - this._trayDwellUserTime = 0; - } - }, - - _updateNoMessagesLabel: function() { - this._noMessages.visible = this._sources.size == 0; - }, - - _sessionUpdated: function() { - if (Main.sessionMode.isLocked || Main.sessionMode.isGreeter) { - if (this._inCtrlAltTab) - Main.ctrlAltTabManager.removeGroup(this._summary); - this._inCtrlAltTab = false; - } else if (!this._inCtrlAltTab) { - Main.ctrlAltTabManager.addGroup(this._summary, _("Message Tray"), 'user-available-symbolic', - { focusCallback: Lang.bind(this, this.toggleAndNavigate), - sortGroup: CtrlAltTab.SortGroup.BOTTOM }); - this._inCtrlAltTab = true; - } - this._updateState(); - }, - - _checkTrayDwell: function(x, y) { - let monitor = Main.layoutManager.bottomMonitor; - let shouldDwell = (x >= monitor.x && x <= monitor.x + monitor.width && - y == monitor.y + monitor.height - 1); - if (shouldDwell) { - // We only set up dwell timeout when the user is not hovering over the tray - // (!this._notificationHovered). This avoids bringing up the message tray after the - // user clicks on a notification with the pointer on the bottom pixel - // 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._notificationHovered && 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)); - GLib.Source.set_name_by_id(this._trayDwellTimeoutId, '[gnome-shell] this._trayDwellTimeout'); - } - this._trayDwelling = true; - } else { - this._cancelTrayDwell(); - this._trayDwelling = false; - } - }, - - _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(); @@ -1720,22 +1079,10 @@ const MessageTray = new Lang.Class({ _addSource: function(source) { let obj = { source: source, - summaryItem: new SummaryItem(source), notifyId: 0, destroyId: 0, mutedChangedId: 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++; this._sources.set(source, obj); @@ -1749,48 +1096,18 @@ const MessageTray = new Lang.Class({ }); })); - 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._updateNoMessagesLabel(); }, _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--; source.disconnect(obj.notifyId); source.disconnect(obj.destroyId); source.disconnect(obj.mutedChangedId); - summaryItem.destroy(); - this.emit('source-removed', source); - - this._updateNoMessagesLabel(); }, getSources: function() { @@ -1834,53 +1151,12 @@ const MessageTray = new Lang.Class({ this._updateState(); }, - toggle: function() { - if (Main.overview.animationInProgress) - return false; - - this._traySummoned = !this._traySummoned; - this._updateState(); - return true; - }, - - toggleAndNavigate: function() { - if (!this.toggle()) - return; - - if (this._traySummoned) - this._summary.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false); - }, - hide: function() { this._traySummoned = false; this._updateState(); }, _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. @@ -1898,27 +1174,6 @@ 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() { this._useLongerNotificationLeftTimeout = false; if (this._notificationLeftTimeoutId) { @@ -1936,7 +1191,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(); @@ -1950,10 +1205,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; @@ -2022,7 +1279,6 @@ const MessageTray = new Lang.Class({ _escapeTray: function() { this._pointerInNotification = false; this._traySummoned = false; - this._setClickedSummaryItem(null); this._updateNotificationTimeout(0); this._updateState(); }, @@ -2048,7 +1304,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; @@ -2072,53 +1328,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 @@ -2151,6 +1360,7 @@ const MessageTray = new Lang.Class({ }, _showTray: function() { + /* if (!this._grabHelper.grab({ actor: this.actor, onUngrab: Lang.bind(this, this._escapeTray) })) { this._traySummoned = false; @@ -2164,80 +1374,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); @@ -2387,154 +1527,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);