[polari/wip/fmuellner/window-experiments: 10/24] chatView: Only show notifications for the active window



commit 90f9cfca7e7a663058c69050187cb420a3ea4b5f
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Jul 15 21:17:29 2016 +0200

    chatView: Only show notifications for the active window
    
    When we allow opening additional windows, the condition for showing
    a notification may be true for multiple views representing the same
    room, but it doesn't make sense to notify more than once for the
    same message. To ensure that, restrict notifications to the app's
    :active-window. Assuming that this is the only window that may have
    toplevel focus, this should work correctly in all cases (i.e. we
    don't suppress notifications that should be shown or show ones that
    should not).

 src/chatView.js |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index d9cfe7a..0e2fc94 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -1212,8 +1212,6 @@ const ChatView = new Lang.Class({
 
     _insertTpMessage: function(tpMessage) {
         let message = this._createMessage(tpMessage);
-        let shouldHighlight = this._room.should_highlight_message(message.nick,
-                                                                  message.text);
 
         this._ensureNewLine();
 
@@ -1221,8 +1219,12 @@ const ChatView = new Lang.Class({
         this._insertMessage(iter, message, this._state);
         this._trackContact(tpMessage.sender);
 
-        if (shouldHighlight &&
-            !(this._toplevelFocus && this._active)) {
+        let highlight = this._room.should_highlight_message(message.nick,
+                                                            message.text);
+        let visible = this._toplevelFocus && this._active && this._autoscroll;
+        let toplevelActive = this.get_toplevel() == this._app.active_window;
+
+        if (highlight && !visible && toplevelActive) {
             let summary = '%s %s'.format(this._room.display_name, message.nick);
             let notification = new Gio.Notification();
             notification.set_title(summary);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]