Blame SOURCES/0001-heads-up-display-Add-extension-for-showing-persisten.patch

dd45d7
From 8beb3b27486fd50f74c15d2cf9ed8ca22fb546c2 Mon Sep 17 00:00:00 2001
dd45d7
From: Ray Strode <rstrode@redhat.com>
dd45d7
Date: Tue, 24 Aug 2021 15:03:57 -0400
dd45d7
Subject: [PATCH] heads-up-display: Add extension for showing persistent heads
dd45d7
 up display message
dd45d7
dd45d7
---
dd45d7
 extensions/heads-up-display/extension.js      | 436 ++++++++++++++++++
dd45d7
 extensions/heads-up-display/headsUpMessage.js | 170 +++++++
dd45d7
 extensions/heads-up-display/meson.build       |   8 +
dd45d7
 extensions/heads-up-display/metadata.json.in  |  11 +
dd45d7
 ...ll.extensions.heads-up-display.gschema.xml |  54 +++
dd45d7
 extensions/heads-up-display/prefs.js          | 194 ++++++++
dd45d7
 extensions/heads-up-display/stylesheet.css    |  32 ++
dd45d7
 meson.build                                   |   1 +
dd45d7
 8 files changed, 906 insertions(+)
dd45d7
 create mode 100644 extensions/heads-up-display/extension.js
dd45d7
 create mode 100644 extensions/heads-up-display/headsUpMessage.js
dd45d7
 create mode 100644 extensions/heads-up-display/meson.build
dd45d7
 create mode 100644 extensions/heads-up-display/metadata.json.in
dd45d7
 create mode 100644 extensions/heads-up-display/org.gnome.shell.extensions.heads-up-display.gschema.xml
dd45d7
 create mode 100644 extensions/heads-up-display/prefs.js
dd45d7
 create mode 100644 extensions/heads-up-display/stylesheet.css
dd45d7
dd45d7
diff --git a/extensions/heads-up-display/extension.js b/extensions/heads-up-display/extension.js
dd45d7
new file mode 100644
dd45d7
index 00000000..7cebfa99
dd45d7
--- /dev/null
dd45d7
+++ b/extensions/heads-up-display/extension.js
dd45d7
@@ -0,0 +1,436 @@
dd45d7
+/* exported init enable disable */
dd45d7
+
dd45d7
+const Signals = imports.signals;
dd45d7
+
dd45d7
+const {
dd45d7
+    Atk, Clutter, Gio, GLib, GObject, Gtk, Meta, Shell, St,
dd45d7
+} = imports.gi;
dd45d7
+
dd45d7
+const ExtensionUtils = imports.misc.extensionUtils;
dd45d7
+const Me = ExtensionUtils.getCurrentExtension();
dd45d7
+
dd45d7
+const Main = imports.ui.main;
dd45d7
+const Layout = imports.ui.layout;
dd45d7
+const HeadsUpMessage = Me.imports.headsUpMessage;
dd45d7
+
dd45d7
+const _ = ExtensionUtils.gettext;
dd45d7
+
dd45d7
+var HeadsUpConstraint = GObject.registerClass({
dd45d7
+    Properties: {
dd45d7
+        'offset': GObject.ParamSpec.int('offset',
dd45d7
+                                        'Offset', 'offset',
dd45d7
+                                        GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE,
dd45d7
+                                        -1, 0, -1),
dd45d7
+        'active': GObject.ParamSpec.boolean('active',
dd45d7
+                                            'Active', 'active',
dd45d7
+                                            GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE,
dd45d7
+                                            true),
dd45d7
+    },
dd45d7
+}, class HeadsUpConstraint extends Layout.MonitorConstraint {
dd45d7
+    _init(props) {
dd45d7
+        super._init(props);
dd45d7
+        this._offset = 0;
dd45d7
+        this._active = true;
dd45d7
+    }
dd45d7
+
dd45d7
+    get offset() {
dd45d7
+        return this._offset;
dd45d7
+    }
dd45d7
+
dd45d7
+    set offset(o) {
dd45d7
+        this._offset = o
dd45d7
+    }
dd45d7
+
dd45d7
+    get active() {
dd45d7
+        return this._active;
dd45d7
+    }
dd45d7
+
dd45d7
+    set active(a) {
dd45d7
+        this._active = a;
dd45d7
+    }
dd45d7
+
dd45d7
+    vfunc_update_allocation(actor, actorBox) {
dd45d7
+        if (!Main.layoutManager.primaryMonitor)
dd45d7
+            return;
dd45d7
+
dd45d7
+        if (!this.active)
dd45d7
+            return;
dd45d7
+
dd45d7
+        if (actor.has_allocation())
dd45d7
+            return;
dd45d7
+
dd45d7
+        const workArea = Main.layoutManager.getWorkAreaForMonitor(Main.layoutManager.primaryIndex);
dd45d7
+        actorBox.init_rect(workArea.x, workArea.y + this.offset, workArea.width, workArea.height - this.offset);
dd45d7
+    }
dd45d7
+});
dd45d7
+
dd45d7
+class Extension {
dd45d7
+    constructor() {
dd45d7
+        ExtensionUtils.initTranslations();
dd45d7
+    }
dd45d7
+
dd45d7
+    enable() {
dd45d7
+        this._settings = ExtensionUtils.getSettings('org.gnome.shell.extensions.heads-up-display');
dd45d7
+        this._settingsChangedId = this._settings.connect('changed', this._updateMessage.bind(this));
dd45d7
+
dd45d7
+        this._idleMonitor = Meta.IdleMonitor.get_core();
dd45d7
+        this._messageInhibitedUntilIdle = false;
dd45d7
+        this._oldMapWindow = Main.wm._mapWindow;
dd45d7
+        Main.wm._mapWindow = this._mapWindow;
dd45d7
+        this._windowManagerMapId = global.window_manager.connect('map', this._onWindowMap.bind(this));
dd45d7
+
dd45d7
+        if (Main.layoutManager._startingUp)
dd45d7
+            this._startupCompleteId = Main.layoutManager.connect('startup-complete', this._onStartupComplete.bind(this));
dd45d7
+        else
dd45d7
+            this._onStartupComplete(this);
dd45d7
+    }
dd45d7
+
dd45d7
+    disable() {
dd45d7
+        this._dismissMessage();
dd45d7
+
dd45d7
+        this._stopWatchingForIdle();
dd45d7
+
dd45d7
+        if (this._sessionModeUpdatedId) {
dd45d7
+            Main.sessionMode.disconnect(this._sessionModeUpdatedId);
dd45d7
+            this._sessionModeUpdatedId = 0;
dd45d7
+        }
dd45d7
+
dd45d7
+        if (this._overviewShowingId) {
dd45d7
+            Main.overview.disconnect(this._overviewShowingId);
dd45d7
+            this._overviewShowingId = 0;
dd45d7
+        }
dd45d7
+
dd45d7
+        if (this._overviewHiddenId) {
dd45d7
+            Main.overview.disconnect(this._overviewHiddenId);
dd45d7
+            this._overviewHiddenId = 0;
dd45d7
+        }
dd45d7
+
dd45d7
+        if (this._screenShieldVisibleId) {
dd45d7
+            Main.screenShield._dialog._clock.disconnect(this._screenShieldVisibleId);
dd45d7
+            this._screenShieldVisibleId = 0;
dd45d7
+        }
dd45d7
+
dd45d7
+        if (this._panelConnectionId) {
dd45d7
+            Main.layoutManager.panelBox.disconnect(this._panelConnectionId);
dd45d7
+            this._panelConnectionId = 0;
dd45d7
+        }
dd45d7
+
dd45d7
+        if (this._oldMapWindow) {
dd45d7
+            Main.wm._mapWindow = this._oldMapWindow;
dd45d7
+            this._oldMapWindow = null;
dd45d7
+        }
dd45d7
+
dd45d7
+        if (this._windowManagerMapId) {
dd45d7
+            global.window_manager.disconnect(this._windowManagerMapId);
dd45d7
+            this._windowManagerMapId = 0;
dd45d7
+        }
dd45d7
+
dd45d7
+        if (this._startupCompleteId) {
dd45d7
+            Main.layoutManager.disconnect(this._startupCompleteId);
dd45d7
+            this._startupCompleteId = 0;
dd45d7
+        }
dd45d7
+
dd45d7
+        if (this._settingsChangedId) {
dd45d7
+            this._settings.disconnect(this._settingsChangedId);
dd45d7
+            this._settingsChangedId = 0;
dd45d7
+        }
dd45d7
+    }
dd45d7
+
dd45d7
+    _onWindowMap(shellwm, actor) {
dd45d7
+        const windowObject = actor.meta_window;
dd45d7
+        const windowType = windowObject.get_window_type();
dd45d7
+
dd45d7
+        if (windowType != Meta.WindowType.NORMAL)
dd45d7
+            return;
dd45d7
+
dd45d7
+        if (!this._message || !this._message.visible)
dd45d7
+            return;
dd45d7
+
dd45d7
+        const messageRect = new Meta.Rectangle({ x: this._message.x, y: this._message.y, width: this._message.width, height: this._message.height });
dd45d7
+        const windowRect = windowObject.get_frame_rect();
dd45d7
+
dd45d7
+        if (windowRect.intersect(messageRect)) {
dd45d7
+            windowObject.move_frame(false, windowRect.x, this._message.y + this._message.height);
dd45d7
+        }
dd45d7
+    }
dd45d7
+
dd45d7
+    _onStartupComplete() {
dd45d7
+        this._overviewShowingId = Main.overview.connect('showing', this._updateMessage.bind(this));
dd45d7
+        this._overviewHiddenId = Main.overview.connect('hidden', this._updateMessage.bind(this));
dd45d7
+        this._panelConnectionId = Main.layoutManager.panelBox.connect('notify::visible', this._updateMessage.bind(this));
dd45d7
+        this._sessionModeUpdatedId = Main.sessionMode.connect('updated', this._onSessionModeUpdated.bind(this));
dd45d7
+
dd45d7
+        this._updateMessage();
dd45d7
+    }
dd45d7
+
dd45d7
+    _onSessionModeUpdated() {
dd45d7
+         if (!Main.sessionMode.hasWindows)
dd45d7
+             this._messageInhibitedUntilIdle = false;
dd45d7
+
dd45d7
+        const dialog = Main.screenShield._dialog;
dd45d7
+        if (!Main.sessionMode.isGreeter && dialog && !this._screenShieldVisibleId) {
dd45d7
+            this._screenShieldVisibleId = dialog._clock.connect('notify::visible',
dd45d7
+                                                                this._updateMessage.bind(this));
dd45d7
+            this._screenShieldDestroyId = dialog._clock.connect('destroy', () => {
dd45d7
+                this._screenShieldVisibleId = 0;
dd45d7
+                this._screenShieldDestroyId = 0;
dd45d7
+            });
dd45d7
+        }
dd45d7
+         this._updateMessage();
dd45d7
+    }
dd45d7
+
dd45d7
+    _stopWatchingForIdle() {
dd45d7
+        if (this._idleWatchId) {
dd45d7
+            this._idleMonitor.remove_watch(this._idleWatchId);
dd45d7
+            this._idleWatchId = 0;
dd45d7
+        }
dd45d7
+
dd45d7
+        if (this._idleTimeoutChangedId) {
dd45d7
+            this._settings.disconnect(this._idleTimeoutChangedId);
dd45d7
+            this._idleTimeoutChangedId = 0;
dd45d7
+        }
dd45d7
+    }
dd45d7
+
dd45d7
+    _onIdleTimeoutChanged() {
dd45d7
+        this._stopWatchingForIdle();
dd45d7
+        this._messageInhibitedUntilIdle = false;
dd45d7
+    }
dd45d7
+
dd45d7
+    _onUserIdle() {
dd45d7
+        this._messageInhibitedUntilIdle = false;
dd45d7
+        this._updateMessage();
dd45d7
+    }
dd45d7
+
dd45d7
+    _watchForIdle() {
dd45d7
+        this._stopWatchingForIdle();
dd45d7
+
dd45d7
+        const idleTimeout = this._settings.get_uint('idle-timeout');
dd45d7
+
dd45d7
+        this._idleTimeoutChangedId = this._settings.connect('changed::idle-timeout', this._onIdleTimeoutChanged.bind(this));
dd45d7
+        this._idleWatchId = this._idleMonitor.add_idle_watch(idleTimeout * 1000, this._onUserIdle.bind(this));
dd45d7
+    }
dd45d7
+
dd45d7
+    _updateMessage() {
dd45d7
+        if (this._messageInhibitedUntilIdle) {
dd45d7
+            if (this._message)
dd45d7
+                this._dismissMessage();
dd45d7
+            return;
dd45d7
+        }
dd45d7
+
dd45d7
+        this._stopWatchingForIdle();
dd45d7
+
dd45d7
+        if (Main.sessionMode.hasOverview && Main.overview.visible) {
dd45d7
+            this._dismissMessage();
dd45d7
+            return;
dd45d7
+        }
dd45d7
+
dd45d7
+        if (!Main.layoutManager.panelBox.visible) {
dd45d7
+            this._dismissMessage();
dd45d7
+            return;
dd45d7
+        }
dd45d7
+
dd45d7
+        let supportedModes = [];
dd45d7
+
dd45d7
+        if (this._settings.get_boolean('show-when-unlocked'))
dd45d7
+            supportedModes.push('user');
dd45d7
+
dd45d7
+        if (this._settings.get_boolean('show-when-unlocking') ||
dd45d7
+            this._settings.get_boolean('show-when-locked'))
dd45d7
+            supportedModes.push('unlock-dialog');
dd45d7
+
dd45d7
+        if (this._settings.get_boolean('show-on-login-screen'))
dd45d7
+            supportedModes.push('gdm');
dd45d7
+
dd45d7
+        if (!supportedModes.includes(Main.sessionMode.currentMode) &&
dd45d7
+            !supportedModes.includes(Main.sessionMode.parentMode)) {
dd45d7
+            this._dismissMessage();
dd45d7
+            return;
dd45d7
+        }
dd45d7
+
dd45d7
+        if (Main.sessionMode.currentMode === 'unlock-dialog') {
dd45d7
+            const dialog = Main.screenShield._dialog;
dd45d7
+            if (!this._settings.get_boolean('show-when-locked')) {
dd45d7
+                if (dialog._clock.visible) {
dd45d7
+                    this._dismissMessage();
dd45d7
+                    return;
dd45d7
+                }
dd45d7
+            }
dd45d7
+
dd45d7
+            if (!this._settings.get_boolean('show-when-unlocking')) {
dd45d7
+                if (!dialog._clock.visible) {
dd45d7
+                    this._dismissMessage();
dd45d7
+                    return;
dd45d7
+                }
dd45d7
+            }
dd45d7
+        }
dd45d7
+
dd45d7
+        const heading = this._settings.get_string('message-heading');
dd45d7
+        const body = this._settings.get_string('message-body');
dd45d7
+
dd45d7
+        if (!heading && !body) {
dd45d7
+            this._dismissMessage();
dd45d7
+            return;
dd45d7
+        }
dd45d7
+
dd45d7
+        if (!this._message) {
dd45d7
+            this._message = new HeadsUpMessage.HeadsUpMessage(heading, body);
dd45d7
+
dd45d7
+            this._message.connect('notify::allocation', this._adaptSessionForMessage.bind(this));
dd45d7
+            this._message.connect('clicked', this._onMessageClicked.bind(this));
dd45d7
+        }
dd45d7
+
dd45d7
+        this._message.reactive = true;
dd45d7
+        this._message.track_hover = true;
dd45d7
+
dd45d7
+        this._message.setHeading(heading);
dd45d7
+        this._message.setBody(body);
dd45d7
+
dd45d7
+        if (!Main.sessionMode.hasWindows) {
dd45d7
+            this._message.track_hover = false;
dd45d7
+            this._message.reactive = false;
dd45d7
+        }
dd45d7
+    }
dd45d7
+
dd45d7
+    _onMessageClicked() {
dd45d7
+        if (!Main.sessionMode.hasWindows)
dd45d7
+          return;
dd45d7
+
dd45d7
+        this._watchForIdle();
dd45d7
+        this._messageInhibitedUntilIdle = true;
dd45d7
+        this._updateMessage();
dd45d7
+    }
dd45d7
+
dd45d7
+    _dismissMessage() {
dd45d7
+        if (!this._message) {
dd45d7
+            return;
dd45d7
+        }
dd45d7
+
dd45d7
+        this._message.visible = false;
dd45d7
+        this._message.destroy();
dd45d7
+        this._message = null;
dd45d7
+        this._resetMessageTray();
dd45d7
+        this._resetLoginDialog();
dd45d7
+    }
dd45d7
+
dd45d7
+    _resetMessageTray() {
dd45d7
+        if (!Main.messageTray)
dd45d7
+            return;
dd45d7
+
dd45d7
+        if (this._updateMessageTrayId) {
dd45d7
+            global.stage.disconnect(this._updateMessageTrayId);
dd45d7
+            this._updateMessageTrayId = 0;
dd45d7
+        }
dd45d7
+
dd45d7
+        if (this._messageTrayConstraint) {
dd45d7
+            Main.messageTray.remove_constraint(this._messageTrayConstraint);
dd45d7
+            this._messageTrayConstraint = null;
dd45d7
+        }
dd45d7
+    }
dd45d7
+
dd45d7
+    _alignMessageTray() {
dd45d7
+        if (!Main.messageTray)
dd45d7
+            return;
dd45d7
+
dd45d7
+        if (!this._message || !this._message.visible) {
dd45d7
+            this._resetMessageTray()
dd45d7
+            return;
dd45d7
+        }
dd45d7
+
dd45d7
+        if (this._updateMessageTrayId)
dd45d7
+            return;
dd45d7
+
dd45d7
+        this._updateMessageTrayId = global.stage.connect('before-update', () => {
dd45d7
+            if (!this._messageTrayConstraint) {
dd45d7
+                this._messageTrayConstraint = new HeadsUpConstraint({ primary: true });
dd45d7
+
dd45d7
+                Main.layoutManager.panelBox.bind_property('visible',
dd45d7
+                    this._messageTrayConstraint, 'active',
dd45d7
+                    GObject.BindingFlags.SYNC_CREATE);
dd45d7
+
dd45d7
+                Main.messageTray.add_constraint(this._messageTrayConstraint);
dd45d7
+            }
dd45d7
+
dd45d7
+            const panelBottom = Main.layoutManager.panelBox.y + Main.layoutManager.panelBox.height;
dd45d7
+            const messageBottom = this._message.y + this._message.height;
dd45d7
+
dd45d7
+            this._messageTrayConstraint.offset = messageBottom - panelBottom;
dd45d7
+            global.stage.disconnect(this._updateMessageTrayId);
dd45d7
+            this._updateMessageTrayId = 0;
dd45d7
+        });
dd45d7
+    }
dd45d7
+
dd45d7
+    _resetLoginDialog() {
dd45d7
+        if (!Main.sessionMode.isGreeter)
dd45d7
+            return;
dd45d7
+
dd45d7
+        if (!Main.screenShield || !Main.screenShield._dialog)
dd45d7
+            return;
dd45d7
+
dd45d7
+        const dialog = Main.screenShield._dialog;
dd45d7
+
dd45d7
+        if (this._authPromptAllocatedId) {
dd45d7
+            dialog.disconnect(this._authPromptAllocatedId);
dd45d7
+            this._authPromptAllocatedId = 0;
dd45d7
+        }
dd45d7
+
dd45d7
+        if (this._updateLoginDialogId) {
dd45d7
+            global.stage.disconnect(this._updateLoginDialogId);
dd45d7
+            this._updateLoginDialogId = 0;
dd45d7
+        }
dd45d7
+
dd45d7
+        if (this._loginDialogConstraint) {
dd45d7
+            dialog.remove_constraint(this._loginDialogConstraint);
dd45d7
+            this._loginDialogConstraint = null;
dd45d7
+        }
dd45d7
+    }
dd45d7
+
dd45d7
+    _adaptLoginDialogForMessage() {
dd45d7
+        if (!Main.sessionMode.isGreeter)
dd45d7
+            return;
dd45d7
+
dd45d7
+        if (!Main.screenShield || !Main.screenShield._dialog)
dd45d7
+            return;
dd45d7
+
dd45d7
+        if (!this._message || !this._message.visible) {
dd45d7
+            this._resetLoginDialog()
dd45d7
+            return;
dd45d7
+        }
dd45d7
+
dd45d7
+        const dialog = Main.screenShield._dialog;
dd45d7
+
dd45d7
+        if (this._updateLoginDialogId)
dd45d7
+            return;
dd45d7
+
dd45d7
+        this._updateLoginDialogId = global.stage.connect('before-update', () => {
dd45d7
+        let messageHeight = this._message.y + this._message.height;
dd45d7
+            if (dialog._logoBin.visible)
dd45d7
+                messageHeight -= dialog._logoBin.height;
dd45d7
+
dd45d7
+            if (!this._logindDialogConstraint) {
dd45d7
+                this._loginDialogConstraint = new HeadsUpConstraint({ primary: true });
dd45d7
+                dialog.add_constraint(this._loginDialogConstraint);
dd45d7
+            }
dd45d7
+
dd45d7
+            this._loginDialogConstraint.offset = messageHeight;
dd45d7
+
dd45d7
+            global.stage.disconnect(this._updateLoginDialogId);
dd45d7
+            this._updateLoginDialogId = 0;
dd45d7
+        });
dd45d7
+    }
dd45d7
+
dd45d7
+    _adaptSessionForMessage() {
dd45d7
+        this._alignMessageTray();
dd45d7
+
dd45d7
+        if (Main.sessionMode.isGreeter) {
dd45d7
+            this._adaptLoginDialogForMessage();
dd45d7
+            if (!this._authPromptAllocatedId) {
dd45d7
+                const dialog = Main.screenShield._dialog;
dd45d7
+                this._authPromptAllocatedId = dialog._authPrompt.connect('notify::allocation', this._adaptLoginDialogForMessage.bind(this));
dd45d7
+            }
dd45d7
+        }
dd45d7
+    }
dd45d7
+}
dd45d7
+
dd45d7
+function init() {
dd45d7
+    return new Extension();
dd45d7
+}
dd45d7
diff --git a/extensions/heads-up-display/headsUpMessage.js b/extensions/heads-up-display/headsUpMessage.js
dd45d7
new file mode 100644
dd45d7
index 00000000..87a8c8ba
dd45d7
--- /dev/null
dd45d7
+++ b/extensions/heads-up-display/headsUpMessage.js
dd45d7
@@ -0,0 +1,170 @@
dd45d7
+const { Atk, Clutter, GLib, GObject, Pango, St } = imports.gi;
dd45d7
+const Layout = imports.ui.layout;
dd45d7
+const Main = imports.ui.main;
dd45d7
+const Signals = imports.signals;
dd45d7
+
dd45d7
+var HeadsUpMessageBodyLabel = GObject.registerClass({
dd45d7
+}, class HeadsUpMessageBodyLabel extends St.Label {
dd45d7
+    _init(params) {
dd45d7
+        super._init(params);
dd45d7
+
dd45d7
+        this._widthCoverage = 0.75;
dd45d7
+        this._heightCoverage = 0.25;
dd45d7
+
dd45d7
+        this._workAreasChangedId = global.display.connect('workareas-changed', this._getWorkAreaAndMeasureLineHeight.bind(this));
dd45d7
+    }
dd45d7
+
dd45d7
+    _getWorkAreaAndMeasureLineHeight() {
dd45d7
+        if (!this.get_parent())
dd45d7
+            return;
dd45d7
+
dd45d7
+        this._workArea = Main.layoutManager.getWorkAreaForMonitor(Main.layoutManager.primaryIndex);
dd45d7
+
dd45d7
+        this.clutter_text.single_line_mode = true;
dd45d7
+        this.clutter_text.line_wrap = false;
dd45d7
+
dd45d7
+        this._lineHeight = super.vfunc_get_preferred_height(-1)[0];
dd45d7
+
dd45d7
+        this.clutter_text.single_line_mode = false;
dd45d7
+        this.clutter_text.line_wrap = true;
dd45d7
+    }
dd45d7
+
dd45d7
+    vfunc_parent_set(oldParent) {
dd45d7
+        this._getWorkAreaAndMeasureLineHeight();
dd45d7
+    }
dd45d7
+
dd45d7
+    vfunc_get_preferred_width(forHeight) {
dd45d7
+        const maxWidth = this._widthCoverage * this._workArea.width
dd45d7
+
dd45d7
+        let [labelMinimumWidth, labelNaturalWidth] = super.vfunc_get_preferred_width(forHeight);
dd45d7
+
dd45d7
+        labelMinimumWidth = Math.min(labelMinimumWidth, maxWidth);
dd45d7
+        labelNaturalWidth = Math.min(labelNaturalWidth, maxWidth);
dd45d7
+
dd45d7
+        return [labelMinimumWidth, labelNaturalWidth];
dd45d7
+    }
dd45d7
+
dd45d7
+    vfunc_get_preferred_height(forWidth) {
dd45d7
+        const labelHeightUpperBound = this._heightCoverage * this._workArea.height;
dd45d7
+        const numberOfLines = Math.floor(labelHeightUpperBound / this._lineHeight);
dd45d7
+        this._numberOfLines = Math.max(numberOfLines, 1);
dd45d7
+
dd45d7
+        const maxHeight = this._lineHeight * this._numberOfLines;
dd45d7
+
dd45d7
+        let [labelMinimumHeight, labelNaturalHeight] = super.vfunc_get_preferred_height(forWidth);
dd45d7
+
dd45d7
+        labelMinimumHeight = Math.min(labelMinimumHeight, maxHeight);
dd45d7
+        labelNaturalHeight = Math.min(labelNaturalHeight, maxHeight);
dd45d7
+
dd45d7
+        return [labelMinimumHeight, labelNaturalHeight];
dd45d7
+    }
dd45d7
+
dd45d7
+    destroy() {
dd45d7
+        if (this._workAreasChangedId) {
dd45d7
+            global.display.disconnect(this._workAreasChangedId);
dd45d7
+            this._workAreasChangedId = 0;
dd45d7
+        }
dd45d7
+
dd45d7
+        super.destroy();
dd45d7
+    }
dd45d7
+});
dd45d7
+
dd45d7
+var HeadsUpMessage = GObject.registerClass({
dd45d7
+}, class HeadsUpMessage extends St.Button {
dd45d7
+    _init(heading, body) {
dd45d7
+        super._init({
dd45d7
+            style_class: 'message',
dd45d7
+            accessible_role: Atk.Role.NOTIFICATION,
dd45d7
+            can_focus: false,
dd45d7
+            opacity: 0,
dd45d7
+        });
dd45d7
+
dd45d7
+        Main.layoutManager.addChrome(this, { affectsInputRegion: true });
dd45d7
+
dd45d7
+        this.add_style_class_name('heads-up-display-message');
dd45d7
+
dd45d7
+        this._panelAllocationId = Main.layoutManager.panelBox.connect('notify::allocation', this._alignWithPanel.bind(this));
dd45d7
+        this.connect('notify::allocation', this._alignWithPanel.bind(this));
dd45d7
+
dd45d7
+        const contentsBox = new St.BoxLayout({ style_class: 'heads-up-message-content',
dd45d7
+                                               vertical: true,
dd45d7
+                                               x_align: Clutter.ActorAlign.CENTER });
dd45d7
+        this.add_actor(contentsBox);
dd45d7
+
dd45d7
+        this.headingLabel = new St.Label({ style_class: 'heads-up-message-heading',
dd45d7
+                                           x_expand: true,
dd45d7
+                                           x_align: Clutter.ActorAlign.CENTER });
dd45d7
+        this.setHeading(heading);
dd45d7
+        contentsBox.add_actor(this.headingLabel);
dd45d7
+        this.contentsBox = contentsBox;
dd45d7
+
dd45d7
+        this.bodyLabel = new HeadsUpMessageBodyLabel({ style_class: 'heads-up-message-body',
dd45d7
+                                                       x_expand: true,
dd45d7
+                                                       y_expand: true });
dd45d7
+        contentsBox.add_actor(this.bodyLabel);
dd45d7
+
dd45d7
+        this.setBody(body);
dd45d7
+    }
dd45d7
+
dd45d7
+    vfunc_parent_set(oldParent) {
dd45d7
+        this._alignWithPanel();
dd45d7
+    }
dd45d7
+
dd45d7
+    _alignWithPanel() {
dd45d7
+        if (this._afterUpdateId)
dd45d7
+            return;
dd45d7
+
dd45d7
+        this._afterUpdateId = global.stage.connect('before-update', () => {
dd45d7
+            let x = Main.panel.x;
dd45d7
+            let y = Main.panel.y + Main.panel.height;
dd45d7
+
dd45d7
+            x += Main.panel.width / 2;
dd45d7
+            x -= this.width / 2;
dd45d7
+            x = Math.floor(x);
dd45d7
+            this.set_position(x,y);
dd45d7
+            this.opacity = 255;
dd45d7
+
dd45d7
+            global.stage.disconnect(this._afterUpdateId);
dd45d7
+            this._afterUpdateId = 0;
dd45d7
+        });
dd45d7
+    }
dd45d7
+
dd45d7
+    setHeading(text) {
dd45d7
+        if (text) {
dd45d7
+            const heading = text ? text.replace(/\n/g, ' ') : '';
dd45d7
+            this.headingLabel.text = heading;
dd45d7
+            this.headingLabel.visible = true;
dd45d7
+        } else {
dd45d7
+            this.headingLabel.text = text;
dd45d7
+            this.headingLabel.visible = false;
dd45d7
+        }
dd45d7
+    }
dd45d7
+
dd45d7
+    setBody(text) {
dd45d7
+        this.bodyLabel.text = text;
dd45d7
+        if (text) {
dd45d7
+            this.bodyLabel.visible = true;
dd45d7
+        } else {
dd45d7
+            this.bodyLabel.visible = false;
dd45d7
+        }
dd45d7
+    }
dd45d7
+
dd45d7
+    destroy() {
dd45d7
+        if (this._panelAllocationId) {
dd45d7
+            Main.layoutManager.panelBox.disconnect(this._panelAllocationId);
dd45d7
+            this._panelAllocationId = 0;
dd45d7
+        }
dd45d7
+
dd45d7
+        if (this._afterUpdateId) {
dd45d7
+            global.stage.disconnect(this._afterUpdateId);
dd45d7
+            this._afterUpdateId = 0;
dd45d7
+        }
dd45d7
+
dd45d7
+        if (this.bodyLabel) {
dd45d7
+            this.bodyLabel.destroy();
dd45d7
+            this.bodyLabel = null;
dd45d7
+        }
dd45d7
+
dd45d7
+        super.destroy();
dd45d7
+    }
dd45d7
+});
dd45d7
diff --git a/extensions/heads-up-display/meson.build b/extensions/heads-up-display/meson.build
dd45d7
new file mode 100644
dd45d7
index 00000000..40c3de0a
dd45d7
--- /dev/null
dd45d7
+++ b/extensions/heads-up-display/meson.build
dd45d7
@@ -0,0 +1,8 @@
dd45d7
+extension_data += configure_file(
dd45d7
+  input: metadata_name + '.in',
dd45d7
+  output: metadata_name,
dd45d7
+  configuration: metadata_conf
dd45d7
+)
dd45d7
+
dd45d7
+extension_sources += files('headsUpMessage.js', 'prefs.js')
dd45d7
+extension_schemas += files(metadata_conf.get('gschemaname') + '.gschema.xml')
dd45d7
diff --git a/extensions/heads-up-display/metadata.json.in b/extensions/heads-up-display/metadata.json.in
dd45d7
new file mode 100644
dd45d7
index 00000000..e7ab71aa
dd45d7
--- /dev/null
dd45d7
+++ b/extensions/heads-up-display/metadata.json.in
dd45d7
@@ -0,0 +1,11 @@
dd45d7
+{
dd45d7
+"extension-id": "@extension_id@",
dd45d7
+"uuid": "@uuid@",
dd45d7
+"gettext-domain": "@gettext_domain@",
dd45d7
+"name": "Heads-up Display Message",
dd45d7
+"description": "Add a message to be displayed on screen always above all windows and chrome.",
dd45d7
+"original-authors": [ "rstrode@redhat.com" ],
dd45d7
+"shell-version": [ "@shell_current@" ],
dd45d7
+"url": "@url@",
dd45d7
+"session-modes":  [ "gdm", "lock-screen", "unlock-dialog", "user" ]
dd45d7
+}
dd45d7
diff --git a/extensions/heads-up-display/org.gnome.shell.extensions.heads-up-display.gschema.xml b/extensions/heads-up-display/org.gnome.shell.extensions.heads-up-display.gschema.xml
dd45d7
new file mode 100644
dd45d7
index 00000000..ea1f3774
dd45d7
--- /dev/null
dd45d7
+++ b/extensions/heads-up-display/org.gnome.shell.extensions.heads-up-display.gschema.xml
dd45d7
@@ -0,0 +1,54 @@
dd45d7
+<schemalist gettext-domain="gnome-shell-extensions">
dd45d7
+  
dd45d7
+          path="/org/gnome/shell/extensions/heads-up-display/">
dd45d7
+    <key name="idle-timeout" type="u">
dd45d7
+      <default>30</default>
dd45d7
+      <summary>Idle Timeout</summary>
dd45d7
+      <description>
dd45d7
+        Number of seconds until message is reshown after user goes idle.
dd45d7
+      </description>
dd45d7
+    </key>
dd45d7
+    <key name="message-heading" type="s">
dd45d7
+      <default>""</default>
dd45d7
+      <summary>Message to show at top of display</summary>
dd45d7
+      <description>
dd45d7
+        The top line of the heads up display message.
dd45d7
+      </description>
dd45d7
+    </key>
dd45d7
+    <key name="message-body" type="s">
dd45d7
+      <default>""</default>
dd45d7
+      <summary>Banner message</summary>
dd45d7
+      <description>
dd45d7
+        A message to always show at the top of the screen.
dd45d7
+      </description>
dd45d7
+    </key>
dd45d7
+    <key name="show-on-login-screen" type="b">
dd45d7
+      <default>true</default>
dd45d7
+      <summary>Show on login screen</summary>
dd45d7
+      <description>
dd45d7
+        Whether or not the message should display on the login screen
dd45d7
+      </description>
dd45d7
+    </key>
dd45d7
+    <key name="show-when-locked" type="b">
dd45d7
+      <default>false</default>
dd45d7
+      <summary>Show on screen shield</summary>
dd45d7
+      <description>
dd45d7
+        Whether or not the message should display when the screen is locked
dd45d7
+      </description>
dd45d7
+    </key>
dd45d7
+    <key name="show-when-unlocking" type="b">
dd45d7
+      <default>false</default>
dd45d7
+      <summary>Show on unlock screen</summary>
dd45d7
+      <description>
dd45d7
+        Whether or not the message should display on the unlock screen.
dd45d7
+      </description>
dd45d7
+    </key>
dd45d7
+    <key name="show-when-unlocked" type="b">
dd45d7
+      <default>false</default>
dd45d7
+      <summary>Show in user session</summary>
dd45d7
+      <description>
dd45d7
+        Whether or not the message should display when the screen is unlocked.
dd45d7
+      </description>
dd45d7
+    </key>
dd45d7
+  </schema>
dd45d7
+</schemalist>
dd45d7
diff --git a/extensions/heads-up-display/prefs.js b/extensions/heads-up-display/prefs.js
dd45d7
new file mode 100644
dd45d7
index 00000000..a7106e07
dd45d7
--- /dev/null
dd45d7
+++ b/extensions/heads-up-display/prefs.js
dd45d7
@@ -0,0 +1,194 @@
dd45d7
+
dd45d7
+/* Desktop Icons GNOME Shell extension
dd45d7
+ *
dd45d7
+ * Copyright (C) 2017 Carlos Soriano <csoriano@redhat.com>
dd45d7
+ *
dd45d7
+ * This program is free software: you can redistribute it and/or modify
dd45d7
+ * it under the terms of the GNU General Public License as published by
dd45d7
+ * the Free Software Foundation, either version 3 of the License, or
dd45d7
+ * (at your option) any later version.
dd45d7
+ *
dd45d7
+ * This program is distributed in the hope that it will be useful,
dd45d7
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
dd45d7
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
dd45d7
+ * GNU General Public License for more details.
dd45d7
+ *
dd45d7
+ * You should have received a copy of the GNU General Public License
dd45d7
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
dd45d7
+ */
dd45d7
+
dd45d7
+const { Gio, GObject, Gdk, Gtk } = imports.gi;
dd45d7
+const ExtensionUtils = imports.misc.extensionUtils;
dd45d7
+const Gettext = imports.gettext.domain('gnome-shell-extensions');
dd45d7
+const _ = Gettext.gettext;
dd45d7
+const N_ = e => e;
dd45d7
+const cssData = `
dd45d7
+   .no-border {
dd45d7
+       border: none;
dd45d7
+   }
dd45d7
+
dd45d7
+   .border {
dd45d7
+       border: 1px solid;
dd45d7
+       border-radius: 3px;
dd45d7
+       border-color: #b6b6b3;
dd45d7
+       box-shadow: inset 0 0 0 1px rgba(74, 144, 217, 0);
dd45d7
+       background-color: white;
dd45d7
+   }
dd45d7
+
dd45d7
+   .margins {
dd45d7
+       padding-left: 8px;
dd45d7
+       padding-right: 8px;
dd45d7
+       padding-bottom: 8px;
dd45d7
+   }
dd45d7
+
dd45d7
+   .contents {
dd45d7
+       padding: 20px;
dd45d7
+   }
dd45d7
+
dd45d7
+   .message-label {
dd45d7
+       font-weight: bold;
dd45d7
+   }
dd45d7
+`;
dd45d7
+
dd45d7
+var settings;
dd45d7
+
dd45d7
+function init() {
dd45d7
+    settings = ExtensionUtils.getSettings("org.gnome.shell.extensions.heads-up-display");
dd45d7
+    const cssProvider = new Gtk.CssProvider();
dd45d7
+    cssProvider.load_from_data(cssData);
dd45d7
+
dd45d7
+    const display = Gdk.Display.get_default();
dd45d7
+    Gtk.StyleContext.add_provider_for_display(display, cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
dd45d7
+}
dd45d7
+
dd45d7
+function buildPrefsWidget() {
dd45d7
+    ExtensionUtils.initTranslations();
dd45d7
+
dd45d7
+    const contents = new Gtk.Box({
dd45d7
+        orientation: Gtk.Orientation.VERTICAL,
dd45d7
+        spacing: 10,
dd45d7
+        visible: true,
dd45d7
+    });
dd45d7
+
dd45d7
+    contents.append(buildSwitch('show-when-locked', _("Show message when screen is locked")));
dd45d7
+    contents.append(buildSwitch('show-when-unlocking', _("Show message on unlock screen")));
dd45d7
+    contents.append(buildSwitch('show-when-unlocked', _("Show message when screen is unlocked")));
dd45d7
+    contents.append(buildSpinButton('idle-timeout', _("Seconds after user goes idle before reshowing message")));
dd45d7
+    contents.get_style_context().add_class("contents");
dd45d7
+
dd45d7
+    const outerMessageBox = new Gtk.Box({
dd45d7
+        orientation: Gtk.Orientation.VERTICAL,
dd45d7
+        spacing: 5,
dd45d7
+        visible: true,
dd45d7
+    });
dd45d7
+    contents.append(outerMessageBox);
dd45d7
+
dd45d7
+    const messageLabel = new Gtk.Label({
dd45d7
+        label: 'Message',
dd45d7
+        halign: Gtk.Align.START,
dd45d7
+        visible: true,
dd45d7
+    });
dd45d7
+    messageLabel.get_style_context().add_class("message-label");
dd45d7
+    outerMessageBox.append(messageLabel);
dd45d7
+
dd45d7
+    const innerMessageBox = new Gtk.Box({
dd45d7
+        orientation: Gtk.Orientation.VERTICAL,
dd45d7
+        spacing: 0,
dd45d7
+        visible: true,
dd45d7
+    });
dd45d7
+    innerMessageBox.get_style_context().add_class("border");
dd45d7
+    outerMessageBox.append(innerMessageBox);
dd45d7
+
dd45d7
+    innerMessageBox.append(buildEntry('message-heading', _("Message Heading")));
dd45d7
+    innerMessageBox.append(buildTextView('message-body', _("Message Body")));
dd45d7
+    return contents;
dd45d7
+}
dd45d7
+
dd45d7
+function buildTextView(key, labelText) {
dd45d7
+    const textView = new Gtk.TextView({
dd45d7
+        accepts_tab: false,
dd45d7
+        visible: true,
dd45d7
+        wrap_mode: Gtk.WrapMode.WORD,
dd45d7
+    });
dd45d7
+
dd45d7
+    settings.bind(key, textView.get_buffer(), 'text', Gio.SettingsBindFlags.DEFAULT);
dd45d7
+
dd45d7
+    const scrolledWindow = new Gtk.ScrolledWindow({
dd45d7
+        hexpand: true,
dd45d7
+        vexpand: true,
dd45d7
+        visible: true,
dd45d7
+    });
dd45d7
+    const styleContext = scrolledWindow.get_style_context();
dd45d7
+    styleContext.add_class("margins");
dd45d7
+
dd45d7
+    scrolledWindow.set_child(textView);
dd45d7
+    return scrolledWindow;
dd45d7
+}
dd45d7
+function buildEntry(key, labelText) {
dd45d7
+    const entry = new Gtk.Entry({
dd45d7
+        placeholder_text: labelText,
dd45d7
+        visible: true,
dd45d7
+    });
dd45d7
+    const styleContext = entry.get_style_context();
dd45d7
+    styleContext.add_class("no-border");
dd45d7
+    settings.bind(key, entry, 'text', Gio.SettingsBindFlags.DEFAULT);
dd45d7
+
dd45d7
+    entry.get_settings()['gtk-entry-select-on-focus'] = false;
dd45d7
+
dd45d7
+    return entry;
dd45d7
+}
dd45d7
+
dd45d7
+function buildSpinButton(key, labelText) {
dd45d7
+    const hbox = new Gtk.Box({
dd45d7
+        orientation: Gtk.Orientation.HORIZONTAL,
dd45d7
+        spacing: 10,
dd45d7
+        visible: true,
dd45d7
+    });
dd45d7
+    const label = new Gtk.Label({
dd45d7
+        hexpand: true,
dd45d7
+        label: labelText,
dd45d7
+        visible: true,
dd45d7
+        xalign: 0,
dd45d7
+    });
dd45d7
+    const adjustment = new Gtk.Adjustment({
dd45d7
+        value: 0,
dd45d7
+        lower: 0,
dd45d7
+        upper: 2147483647,
dd45d7
+        step_increment: 1,
dd45d7
+        page_increment: 60,
dd45d7
+        page_size: 60,
dd45d7
+    });
dd45d7
+    const spinButton = new Gtk.SpinButton({
dd45d7
+        adjustment: adjustment,
dd45d7
+        climb_rate: 1.0,
dd45d7
+        digits: 0,
dd45d7
+        max_width_chars: 3,
dd45d7
+        visible: true,
dd45d7
+        width_chars: 3,
dd45d7
+    });
dd45d7
+    settings.bind(key, spinButton, 'value', Gio.SettingsBindFlags.DEFAULT);
dd45d7
+    hbox.append(label);
dd45d7
+    hbox.append(spinButton);
dd45d7
+    return hbox;
dd45d7
+}
dd45d7
+
dd45d7
+function buildSwitch(key, labelText) {
dd45d7
+    const hbox = new Gtk.Box({
dd45d7
+        orientation: Gtk.Orientation.HORIZONTAL,
dd45d7
+        spacing: 10,
dd45d7
+        visible: true,
dd45d7
+    });
dd45d7
+    const label = new Gtk.Label({
dd45d7
+        hexpand: true,
dd45d7
+        label: labelText,
dd45d7
+        visible: true,
dd45d7
+        xalign: 0,
dd45d7
+    });
dd45d7
+    const switcher = new Gtk.Switch({
dd45d7
+        active: settings.get_boolean(key),
dd45d7
+    });
dd45d7
+    settings.bind(key, switcher, 'active', Gio.SettingsBindFlags.DEFAULT);
dd45d7
+    hbox.append(label);
dd45d7
+    hbox.append(switcher);
dd45d7
+    return hbox;
dd45d7
+}
dd45d7
diff --git a/extensions/heads-up-display/stylesheet.css b/extensions/heads-up-display/stylesheet.css
dd45d7
new file mode 100644
dd45d7
index 00000000..93034469
dd45d7
--- /dev/null
dd45d7
+++ b/extensions/heads-up-display/stylesheet.css
dd45d7
@@ -0,0 +1,32 @@
dd45d7
+.heads-up-display-message {
dd45d7
+    background-color: rgba(0.24, 0.24, 0.24, 0.80);
dd45d7
+    border: 1px solid black;
dd45d7
+    border-radius: 6px;
dd45d7
+    color: #eeeeec;
dd45d7
+    font-size: 11pt;
dd45d7
+    margin-top: 0.5em;
dd45d7
+    margin-bottom: 0.5em;
dd45d7
+    padding: 0.9em;
dd45d7
+}
dd45d7
+
dd45d7
+.heads-up-display-message:insensitive {
dd45d7
+    background-color: rgba(0.24, 0.24, 0.24, 0.33);
dd45d7
+}
dd45d7
+
dd45d7
+.heads-up-display-message:hover {
dd45d7
+    background-color: rgba(0.24, 0.24, 0.24, 0.2);
dd45d7
+    border: 1px solid rgba(0.0, 0.0, 0.0, 0.5);
dd45d7
+    color: #4d4d4d;
dd45d7
+    transition-duration: 250ms;
dd45d7
+}
dd45d7
+
dd45d7
+.heads-up-message-heading {
dd45d7
+    height: 1.75em;
dd45d7
+    font-size: 1.25em;
dd45d7
+    font-weight: bold;
dd45d7
+    text-align: center;
dd45d7
+}
dd45d7
+
dd45d7
+.heads-up-message-body {
dd45d7
+    text-align: center;
dd45d7
+}
dd45d7
diff --git a/meson.build b/meson.build
dd45d7
index 582535c4..ecc86fc8 100644
dd45d7
--- a/meson.build
dd45d7
+++ b/meson.build
dd45d7
@@ -39,6 +39,7 @@ classic_extensions = [
dd45d7
 default_extensions = classic_extensions
dd45d7
 default_extensions += [
dd45d7
   'drive-menu',
dd45d7
+  'heads-up-display',
dd45d7
   'screenshot-window-sizer',
dd45d7
   'windowsNavigator',
dd45d7
   'workspace-indicator'
dd45d7
-- 
dd45d7
2.33.1
dd45d7