From 38833d302a95f02a86dc75d9c2abb1a3a94a4c03 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 1/4] mprisPlayer: Make close() method public Currently we only close players according to the client status, so keeping the method internal was fine. However we should also clean up when the MediaSection itself is destroyed, so we'll need to be able to explicitly close players from outside the class as well. --- js/ui/mpris.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/ui/mpris.js b/js/ui/mpris.js index 6a4e31136..911fb751e 100644 --- a/js/ui/mpris.js +++ b/js/ui/mpris.js @@ -151,7 +151,7 @@ export class MprisPlayer extends Signals.EventEmitter { this._mprisProxy.RaiseAsync().catch(logError); } - _close() { + close() { this._mprisProxy.disconnectObject(this); this._mprisProxy = null; @@ -165,13 +165,13 @@ export class MprisPlayer extends Signals.EventEmitter { this._mprisProxy.connectObject('notify::g-name-owner', () => { if (!this._mprisProxy.g_name_owner) - this._close(); + this.close(); }, this); // It is possible for the bus to disappear before the previous signal // is connected, so we must ensure that the bus still exists at this // point. if (!this._mprisProxy.g_name_owner) - this._close(); + this.close(); } _onPlayerProxyReady() { From decec891632001cba67e8ec88b132f496094f3dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 15 Feb 2018 14:09:11 +0100 Subject: [PATCH 2/4] mediaSection: Clean up on destroy We currently assume that the media section sticks around. While this is expected in the calendar popup, we want to reuse it on the lock screen that is recreated on every screen lock. Prepare for that by cleaning up on destroy. --- js/ui/mpris.js | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/js/ui/mpris.js b/js/ui/mpris.js index 911fb751e..14539a002 100644 --- a/js/ui/mpris.js +++ b/js/ui/mpris.js @@ -249,9 +249,15 @@ class MediaSection extends MessageList.MessageListSection { _init() { super._init(); + this.connect('destroy', + () => this._onDestroy()); + this._players = new Map(); - this._proxy = new DBusProxy(Gio.DBus.session, + this._proxy = null; + this._nameOwnerChangedId = 0; + + new DBusProxy(Gio.DBus.session, 'org.freedesktop.DBus', '/org/freedesktop/DBus', this._onProxyReady.bind(this)); @@ -283,7 +289,9 @@ class MediaSection extends MessageList.MessageListSection { this._players.set(busName, player); } - async _onProxyReady() { + async _onProxyReady(proxy) { + this._proxy = proxy; + const [names] = await this._proxy.ListNamesAsync(); names.forEach(name => { if (!name.startsWith(MPRIS_PLAYER_PREFIX)) @@ -291,8 +299,9 @@ class MediaSection extends MessageList.MessageListSection { this._addPlayer(name); }); - this._proxy.connectSignal('NameOwnerChanged', - this._onNameOwnerChanged.bind(this)); + this._nameOwnerChangedId = + this._proxy.connectSignal('NameOwnerChanged', + this._onNameOwnerChanged.bind(this)); } _onNameOwnerChanged(proxy, sender, [name, oldOwner, newOwner]) { @@ -302,4 +311,11 @@ class MediaSection extends MessageList.MessageListSection { if (newOwner && !oldOwner) this._addPlayer(name); } + + _onDestroy() { + for (const player of this._players.values()) + player.close(); + this._proxy?.disconnectSignal(this._nameOwnerChangedId); + this._proxy = null; + } }); From 8de5416913e5ca5ee62543c9f4bcd6a864d26f76 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 3/4] 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. --- js/ui/mpris.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/js/ui/mpris.js b/js/ui/mpris.js index 14539a002..bc9a6fd77 100644 --- a/js/ui/mpris.js +++ b/js/ui/mpris.js @@ -49,6 +49,9 @@ class MediaMessage extends MessageList.Message { } vfunc_clicked() { + if (Main.sessionMode.isLocked) + return; + this._player.raise(); Main.panel.closeCalendar(); } From fb17311dcedf8838894c1195e213b83c6ea30f75 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 4/4] 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 --- data/theme/gnome-shell-sass/widgets/_login-lock.scss | 5 +++++ js/ui/unlockDialog.js | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/data/theme/gnome-shell-sass/widgets/_login-lock.scss b/data/theme/gnome-shell-sass/widgets/_login-lock.scss index 909fa6238..033b9d69f 100644 --- a/data/theme/gnome-shell-sass/widgets/_login-lock.scss +++ b/data/theme/gnome-shell-sass/widgets/_login-lock.scss @@ -263,6 +263,11 @@ $_gdm_dialog_width: 25em; &.critical { background-color: transparentize($_gdm_fg,0.8) } } + + .unlock-dialog-notification-source .message { + background-color: transparent; + &:hover,&:focus { background-color: transparent; } + } } .unlock-dialog-notification-icon { diff --git a/js/ui/unlockDialog.js b/js/ui/unlockDialog.js index 7b2ab8d38..1c781efe5 100644 --- a/js/ui/unlockDialog.js +++ b/js/ui/unlockDialog.js @@ -18,6 +18,7 @@ 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 {MediaSection} from './mpris.js'; // The timeout before going back automatically to the lock screen (in seconds) const IDLE_TIMEOUT = 2 * 60; @@ -51,6 +52,12 @@ const NotificationsBox = GObject.registerClass({ }); this.add_child(this._scrollView); + const mediaSection = new MediaSection(); + mediaSection.style_class = 'unlock-dialog-notification-source'; + mediaSection.connect('notify::visible', + () => this._updateVisibility()); + this._notificationBox.add_child(mediaSection); + this._settings = new Gio.Settings({ schema_id: 'org.gnome.desktop.notifications', });