about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/command/command.c22
-rw-r--r--src/command/commands.c20
-rw-r--r--src/config/preferences.c4
-rw-r--r--src/config/preferences.h1
-rw-r--r--src/ui/console.c5
-rw-r--r--src/ui/core.c17
-rw-r--r--src/xmpp/message.c4
7 files changed, 57 insertions, 16 deletions
diff --git a/src/command/command.c b/src/command/command.c
index ee5635a6..9fb8a820 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -486,6 +486,8 @@ static struct cmd_t command_defs[] =
           "                : use 0 to disable.",
           "typing          : Notifications when contacts are typing.",
           "                : on|off",
+          "typing current  : Whether typing notifications are triggerd for the current window.",
+          "                : on|off",
           "invite          : Notifications for chat room invites.",
           "                : on|off",
           "sub             : Notifications for subscription requests.",
@@ -884,6 +886,7 @@ static Autocomplete help_ac;
 static Autocomplete notify_ac;
 static Autocomplete notify_room_ac;
 static Autocomplete notify_message_ac;
+static Autocomplete notify_typing_ac;
 static Autocomplete prefs_ac;
 static Autocomplete sub_ac;
 static Autocomplete log_ac;
@@ -991,6 +994,11 @@ cmd_init(void)
     autocomplete_add(notify_room_ac, "mention");
     autocomplete_add(notify_room_ac, "current");
 
+    notify_typing_ac = autocomplete_new();
+    autocomplete_add(notify_typing_ac, "on");
+    autocomplete_add(notify_typing_ac, "off");
+    autocomplete_add(notify_typing_ac, "current");
+
     sub_ac = autocomplete_new();
     autocomplete_add(sub_ac, "request");
     autocomplete_add(sub_ac, "allow");
@@ -1167,6 +1175,7 @@ cmd_uninit(void)
     autocomplete_free(notify_ac);
     autocomplete_free(notify_message_ac);
     autocomplete_free(notify_room_ac);
+    autocomplete_free(notify_typing_ac);
     autocomplete_free(sub_ac);
     autocomplete_free(titlebar_ac);
     autocomplete_free(log_ac);
@@ -1281,6 +1290,7 @@ cmd_reset_autocomplete()
     autocomplete_reset(notify_ac);
     autocomplete_reset(notify_message_ac);
     autocomplete_reset(notify_room_ac);
+    autocomplete_reset(notify_typing_ac);
     autocomplete_reset(sub_ac);
 
     if (ui_current_win_type() == WIN_MUC) {
@@ -1806,6 +1816,11 @@ _notify_autocomplete(char *input, int *size)
         return result;
     }
 
+    result = autocomplete_param_with_func(input, size, "/notify typing current", prefs_autocomplete_boolean_choice);
+    if (result != NULL) {
+        return result;
+    }
+
     result = autocomplete_param_with_ac(input, size, "/notify room", notify_room_ac);
     if (result != NULL) {
         return result;
@@ -1816,7 +1831,12 @@ _notify_autocomplete(char *input, int *size)
         return result;
     }
 
-    gchar *boolean_choices[] = { "/notify typing", "/notify invite", "/notify sub" };
+    result = autocomplete_param_with_ac(input, size, "/notify typing", notify_typing_ac);
+    if (result != NULL) {
+        return result;
+    }
+
+    gchar *boolean_choices[] = { "/notify invite", "/notify sub" };
     for (i = 0; i < ARRAY_SIZE(boolean_choices); i++) {
         result = autocomplete_param_with_func(input, size, boolean_choices[i],
             prefs_autocomplete_boolean_choice);
diff --git a/src/command/commands.c b/src/command/commands.c
index e81c4e66..c64b3883 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -2212,10 +2212,10 @@ cmd_notify(gchar **args, struct cmd_help_t help)
             prefs_set_boolean(PREF_NOTIFY_MESSAGE, FALSE);
         } else if (strcmp(args[1], "current") == 0) {
             if (g_strcmp0(args[2], "on") == 0) {
-                cons_show("Current window messages notifications enabled.");
+                cons_show("Current window message notifications enabled.");
                 prefs_set_boolean(PREF_NOTIFY_MESSAGE_CURRENT, TRUE);
             } else if (g_strcmp0(args[2], "off") == 0) {
-                cons_show("Current window messages notifications disabled.");
+                cons_show("Current window message notifications disabled.");
                 prefs_set_boolean(PREF_NOTIFY_MESSAGE_CURRENT, FALSE);
             } else {
                 cons_show("Usage: /notify message current on|off");
@@ -2233,14 +2233,14 @@ cmd_notify(gchar **args, struct cmd_help_t help)
             cons_show("Chat room notifications disabled.");
             prefs_set_string(PREF_NOTIFY_ROOM, "off");
         } else if (strcmp(args[1], "mention") == 0) {
-            cons_show("Chat room notifications enable on mention.");
+            cons_show("Chat room notifications enabled on mention.");
             prefs_set_string(PREF_NOTIFY_ROOM, "mention");
         } else if (strcmp(args[1], "current") == 0) {
             if (g_strcmp0(args[2], "on") == 0) {
-                cons_show("Current window chat room messages notifications enabled.");
+                cons_show("Current window chat room message notifications enabled.");
                 prefs_set_boolean(PREF_NOTIFY_ROOM_CURRENT, TRUE);
             } else if (g_strcmp0(args[2], "off") == 0) {
-                cons_show("Current window chat room messages notifications disabled.");
+                cons_show("Current window chat room message notifications disabled.");
                 prefs_set_boolean(PREF_NOTIFY_ROOM_CURRENT, FALSE);
             } else {
                 cons_show("Usage: /notify room current on|off");
@@ -2257,6 +2257,16 @@ cmd_notify(gchar **args, struct cmd_help_t help)
         } else if (strcmp(args[1], "off") == 0) {
             cons_show("Typing notifications disabled.");
             prefs_set_boolean(PREF_NOTIFY_TYPING, FALSE);
+        } else if (strcmp(args[1], "current") == 0) {
+            if (g_strcmp0(args[2], "on") == 0) {
+                cons_show("Current window typing notifications enabled.");
+                prefs_set_boolean(PREF_NOTIFY_TYPING_CURRENT, TRUE);
+            } else if (g_strcmp0(args[2], "off") == 0) {
+                cons_show("Current window typing notifications disabled.");
+                prefs_set_boolean(PREF_NOTIFY_TYPING_CURRENT, FALSE);
+            } else {
+                cons_show("Usage: /notify typing current on|off");
+            }
         } else {
             cons_show("Usage: /notify typing on|off");
         }
diff --git a/src/config/preferences.c b/src/config/preferences.c
index eb32d558..c5dd75b7 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -400,6 +400,7 @@ _get_group(preference_t pref)
         case PREF_OUTTYPE:
             return PREF_GROUP_CHATSTATES;
         case PREF_NOTIFY_TYPING:
+        case PREF_NOTIFY_TYPING_CURRENT:
         case PREF_NOTIFY_MESSAGE:
         case PREF_NOTIFY_MESSAGE_CURRENT:
         case PREF_NOTIFY_ROOM:
@@ -464,6 +465,8 @@ _get_key(preference_t pref)
             return "outtype";
         case PREF_NOTIFY_TYPING:
             return "typing";
+        case PREF_NOTIFY_TYPING_CURRENT:
+            return "typing.current";
         case PREF_NOTIFY_MESSAGE:
             return "message";
         case PREF_NOTIFY_MESSAGE_CURRENT:
@@ -515,6 +518,7 @@ _get_default_boolean(preference_t pref)
         case PREF_LOG_SHARED:
         case PREF_NOTIFY_MESSAGE_CURRENT:
         case PREF_NOTIFY_ROOM_CURRENT:
+        case PREF_NOTIFY_TYPING_CURRENT:
             return TRUE;
         default:
             return FALSE;
diff --git a/src/config/preferences.h b/src/config/preferences.h
index 75a4c576..66d0d41c 100644
--- a/src/config/preferences.h
+++ b/src/config/preferences.h
@@ -52,6 +52,7 @@ typedef enum {
     PREF_STATES,
     PREF_OUTTYPE,
     PREF_NOTIFY_TYPING,
+    PREF_NOTIFY_TYPING_CURRENT,
     PREF_NOTIFY_MESSAGE,
     PREF_NOTIFY_MESSAGE_CURRENT,
     PREF_NOTIFY_ROOM,
diff --git a/src/ui/console.c b/src/ui/console.c
index 1afd0a49..e7ca07a1 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1181,6 +1181,11 @@ _cons_notify_setting(void)
     else
         cons_show("Composing (/notify typing)          : OFF");
 
+    if (prefs_get_boolean(PREF_NOTIFY_TYPING_CURRENT))
+        cons_show("Composing current (/notify typing)  : ON");
+    else
+        cons_show("Composing current (/notify typing)  : OFF");
+
     if (prefs_get_boolean(PREF_NOTIFY_INVITE))
         cons_show("Room invites (/notify invite)       : ON");
     else
diff --git a/src/ui/core.c b/src/ui/core.c
index 8f554f5b..7b3190ed 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -277,14 +277,17 @@ _ui_contact_typing(const char * const barejid)
     }
 
     if (prefs_get_boolean(PREF_NOTIFY_TYPING)) {
-        PContact contact = roster_get_contact(barejid);
-        char const *display_usr = NULL;
-        if (p_contact_name(contact) != NULL) {
-            display_usr = p_contact_name(contact);
-        } else {
-            display_usr = barejid;
+        gboolean is_current = wins_is_current(window);
+        if ( !is_current || (is_current && prefs_get_boolean(PREF_NOTIFY_TYPING_CURRENT)) ) {
+            PContact contact = roster_get_contact(barejid);
+            char const *display_usr = NULL;
+            if (p_contact_name(contact) != NULL) {
+                display_usr = p_contact_name(contact);
+            } else {
+                display_usr = barejid;
+            }
+            notify_typing(display_usr);
         }
-        notify_typing(display_usr);
     }
 }
 
diff --git a/src/xmpp/message.c b/src/xmpp/message.c
index f8e2e18b..8efe90af 100644
--- a/src/xmpp/message.c
+++ b/src/xmpp/message.c
@@ -476,9 +476,7 @@ _chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
         // deal with chat states if recipient supports them
         if (recipient_supports && (!delayed)) {
             if (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_COMPOSING) != NULL) {
-                if (prefs_get_boolean(PREF_NOTIFY_TYPING) || prefs_get_boolean(PREF_INTYPE)) {
-                    handle_typing(jid->barejid);
-                }
+                handle_typing(jid->barejid);
             } else if (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_GONE) != NULL) {
                 handle_gone(jid->barejid);
             } else if (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_PAUSED) != NULL) {