$ git clone http://tcclient.ion.nu/tc_client.git
commit 90088cbb5b9d69d94b96acd39f30f83c28643abd
Author: Alicia <...>
Date:   Wed Sep 14 23:57:06 2016 +0200

    tc_client-gtk: prevent new PM tabs from stopping automatic scrolling.

diff --git a/ChangeLog b/ChangeLog
index dde94a1..6f1616a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -22,6 +22,7 @@ tc_client-gtk: limit the camera preview to 640 by 480, scaling down if the input
 tc_client-gtk: when resizing the window, resize the camera pane before the chat pane.
 tc_client-gtk: break the cameras into two or more rows if it means they can be larger and still fit.
 tc_client-gtk: un-highlight selected PM tabs even if the sender has left.
+tc_client-gtk: prevent new PM tabs from stopping automatic scrolling.
 tc_client-gtk and camviewer: fixed compatibility with newer libavutil.
 tc_client-gtk and camviewer: added compatibility fallbacks for av_image_get_buffer_size() and av_packet_unref()
 tc_client-gtk and camviewer: specify a scaling algorithm for libswscale (mandatory for older versions of libswscale)
diff --git a/utilities/gtk/camviewer.c b/utilities/gtk/camviewer.c
index 32a1d8f..a8582c1 100644
--- a/utilities/gtk/camviewer.c
+++ b/utilities/gtk/camviewer.c
@@ -91,7 +91,7 @@ void printchat(const char* text, const char* pm)
   struct user* user;
   if(pm && (user=finduser(pm)))
   {
-    pm_open(pm, 0);
+    pm_open(pm, 0, data->scroll);
     scroll=user->pm_scroll;
     buffer=user->pm_buffer;
   }else{
@@ -115,7 +115,7 @@ void printchat_color(const char* text, const char* color, unsigned int offset, c
   struct user* user;
   if(pm && (user=finduser(pm)))
   {
-    pm_open(pm, 0);
+    pm_open(pm, 0, data->scroll);
     scroll=user->pm_scroll;
     buffer=user->pm_buffer;
   }else{
@@ -675,7 +675,7 @@ gboolean inputkeys(GtkWidget* widget, GdkEventKey* event, void* data)
 }
 
 char sendingmsg=0;
-void sendmessage(GtkEntry* entry, void* data)
+void sendmessage(GtkEntry* entry, void* x)
 {
   const char* msg=gtk_entry_get_text(entry);
   if(!msg[0]){return;} // Don't send empty lines
@@ -685,7 +685,7 @@ void sendmessage(GtkEntry* entry, void* data)
   char* pm=0;
   if(!strncmp(msg, "/pm ", 4))
   {
-    pm_open(&msg[4], 1);
+    pm_open(&msg[4], 1, data->scroll);
     gtk_entry_set_text(entry, "");
     sendingmsg=0;
     return;
diff --git a/utilities/gtk/gui.c b/utilities/gtk/gui.c
index 52584ff..136c846 100644
--- a/utilities/gtk/gui.c
+++ b/utilities/gtk/gui.c
@@ -338,7 +338,7 @@ void pm_close(GtkButton* btn, GtkWidget* tab)
   user->pm_highlight=0;
 }
 
-void pm_open(const char* nick, char select)
+void pm_open(const char* nick, char select, GtkAdjustment* scroll)
 {
   struct user* user=finduser(nick);
   if(!user){return;}
@@ -350,6 +350,7 @@ void pm_open(const char* nick, char select)
     gtk_notebook_set_current_page(tabs, num);
     return;
   }
+  char bottom=autoscroll_before(scroll); // If PM tabs (with close buttons) are taller we need to make sure pushing down the chat field doesn't make it stop scrolling
   GtkWidget* textview=gtk_text_view_new();
   user->pm_tab=gtk_scrolled_window_new(0, 0);
   user->pm_buffer=gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
@@ -376,6 +377,7 @@ void pm_open(const char* nick, char select)
   {
     gtk_notebook_set_current_page(tabs, num);
   }
+  if(bottom){autoscroll_after(scroll);}
 }
 
 void pm_highlight(const char* nick)
diff --git a/utilities/gtk/gui.h b/utilities/gtk/gui.h
index e383117..8d3c111 100644
--- a/utilities/gtk/gui.h
+++ b/utilities/gtk/gui.h
@@ -32,7 +32,7 @@ extern void toggle_logging(GtkToggleButton* button, GtkBuilder* gui);
 extern void toggle_youtubecmd(GtkToggleButton* button, GtkBuilder* gui);
 extern void deletechannel(GtkButton* button, void* x);
 extern void channeldialog(GtkButton* button, struct channelopts* opts);
-extern void pm_open(const char* nick, char select);
+extern void pm_open(const char* nick, char select, GtkAdjustment* scroll);
 extern void pm_highlight(const char* nick);
 extern char pm_select(GtkNotebook* tabs, GtkWidget* tab, int num, void* x);
 extern void buffer_setup_colors(GtkTextBuffer* buffer);