diff options
author | Marcus Lundblad <ml@update.uu.se> | 2018-04-03 23:13:57 +0200 |
---|---|---|
committer | Marcus Lundblad <ml@update.uu.se> | 2018-04-03 23:13:57 +0200 |
commit | 77a891079226b2d8f86a16a7e5206c9c0008b0ac (patch) | |
tree | 2077b7a9dfa89d23f63eda6bc9e7d7a6ff761d58 | |
parent | 222fb8422b14280a590405fee5748294749a4a79 (diff) | |
download | gnome-maps-wip/mlundblad/notifications-in-popover.tar.gz |
notificationManager: Put notifications in a popoverwip/mlundblad/notifications-in-popover
As a workaround for the Clutter Wayland overlay
visibility issue, put the notifications in a popover.
-rw-r--r-- | src/notificationManager.js | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/notificationManager.js b/src/notificationManager.js index 576af860..6a03baa8 100644 --- a/src/notificationManager.js +++ b/src/notificationManager.js @@ -22,6 +22,9 @@ const Mainloop = imports.mainloop; +const Gdk = imports.gi.Gdk; +const Gtk = imports.gi.Gtk; + const Notification = imports.notification; const _TIMEOUT = 5000; /* ms */ @@ -30,6 +33,9 @@ var NotificationManager = class NotificationManager { constructor(overlay) { this._overlay = overlay; + this._placeholderMenu = + new Gtk.Popover({ relative_to: this._overlay, + transitions_enabled: false }); } _add(notification) { @@ -41,15 +47,31 @@ var NotificationManager = class NotificationManager { this._current = null; }); } - this._overlay.add_overlay(notification); + /* Don't add the notification to the overlay, since they won't work + * on Wayland... + * + * this._overlay.add_overlay(notification); + */ + let oldNotification = this._placeholderMenu.get_child(); + let rect = new Gdk.Rectangle({ x: this._overlay.window.get_width() / 2, + y: 0, width: 0, height: 0 }); + + if (oldNotification) + this._placeholderMenu.remove(oldNotification); + this._placeholderMenu.add(notification); + this._placeholderMenu.pointing_to = rect; + this._placeholderMenu.popup(); let timeoutId = Mainloop.timeout_add(_TIMEOUT, () => { timeoutId = 0; notification.dismiss(); + this._placeholderMenu.remove(notification); + this._placeholderMenu.hide(); }); notification.connect('destroy', () => { if (timeoutId !== 0) Mainloop.source_remove(timeoutId); }); + notification.connect('dismissed', () => this._placeholderMenu.hide()); notification.reveal(); } |