From 80651ea59f02da3c68a83fd7969605f8f7665d3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 15 Feb 2018 14:14:07 +0100 Subject: [PATCH 1/3] mediaMessage: Don't try to raise player while locked We don't allow windows on the lock screen, so don't raise a player window while locked, as the result of the action would only become visible on unlock. Part-of: --- js/ui/messageList.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/js/ui/messageList.js b/js/ui/messageList.js index 169168c3ae..0dda98cdf5 100644 --- a/js/ui/messageList.js +++ b/js/ui/messageList.js @@ -798,6 +798,9 @@ class MediaMessage extends Message { } vfunc_clicked() { + if (Main.sessionMode.isLocked) + return; + this._player.raise(); Main.panel.closeCalendar(); } -- GitLab From 385bc3ead02ebeba9d78efad54a92cd476f8552f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 15 Feb 2018 13:55:34 +0100 Subject: [PATCH 2/3] messageList: Export MediaMessage This will allow reusing it on the lock screen. Part-of: --- js/ui/messageList.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/ui/messageList.js b/js/ui/messageList.js index 0dda98cdf5..1d2453b0a0 100644 --- a/js/ui/messageList.js +++ b/js/ui/messageList.js @@ -770,7 +770,7 @@ class NotificationMessage extends Message { } }); -const MediaMessage = GObject.registerClass( +export const MediaMessage = GObject.registerClass( class MediaMessage extends Message { constructor(player) { super(player.source); -- GitLab From 49566feb4457f9f61ebb9d8769d98a42575cb53b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Sun, 26 Feb 2017 14:55:48 +0100 Subject: [PATCH 3/3] unlockDialog: Show media notifications on lock screen While we have included a built-in media section in the calendar for a while, it is currently only available when the session is unlocked. The ability to quickly pause or resume media playback directly from the lock screen is quite handy though, so start showing them alongside the existing screen shield notifications. Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/488 Part-of: --- js/ui/unlockDialog.js | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/js/ui/unlockDialog.js b/js/ui/unlockDialog.js index 77e80571ee..fae4d0787d 100644 --- a/js/ui/unlockDialog.js +++ b/js/ui/unlockDialog.js @@ -16,6 +16,8 @@ import * as MessageTray from './messageTray.js'; import * as SwipeTracker from './swipeTracker.js'; import {formatDateWithCFormatString} from '../misc/dateUtils.js'; import * as AuthPrompt from '../gdm/authPrompt.js'; +import {MprisSource} from './mpris.js'; +import {MediaMessage} from './messageList.js'; // The timeout before going back automatically to the lock screen (in seconds) const IDLE_TIMEOUT = 2 * 60; @@ -49,6 +51,16 @@ const NotificationsBox = GObject.registerClass({ }); this.add_child(this._scrollView); + this._players = new Map(); + this._mediaSource = new MprisSource(); + this._mediaSource.connectObject( + 'player-added', (o, player) => this._addPlayer(player), + 'player-removed', (o, player) => this._removePlayer(player), + this); + this._mediaSource.players.forEach(player => { + this._addPlayer(player); + }); + this._settings = new Gio.Settings({ schema_id: 'org.gnome.desktop.notifications', }); @@ -69,6 +81,9 @@ const NotificationsBox = GObject.registerClass({ let items = this._sources.entries(); for (let [source, obj] of items) this._removeSource(source, obj); + + for (const player of this._players.keys()) + this._removePlayer(player); } _updateVisibility() { @@ -202,6 +217,20 @@ const NotificationsBox = GObject.registerClass({ this.emit('wake-up-screen'); } + _addPlayer(player) { + const message = new MediaMessage(player); + this._players.set(player, message); + this._notificationBox.insert_child_at_index(message, 0); + this._updateVisibility(); + } + + _removePlayer(player) { + const message = this._players.get(player); + this._players.delete(player); + message.destroy(); + this._updateVisibility(); + } + _sourceAdded(tray, source, initial) { let obj = { visible: source.policy.showInLockScreen, @@ -217,7 +246,7 @@ const NotificationsBox = GObject.registerClass({ x_expand: true, }); this._showSource(source, obj, obj.sourceBox); - this._notificationBox.add_child(obj.sourceBox); + this._notificationBox.insert_child_at_index(obj.sourceBox, this._players.size); source.connectObject( 'notify::count', () => this._countChanged(source, obj), -- GitLab