From 632a563dab49d9c0b534dc9d29f7ff2aa021dcea Mon Sep 17 00:00:00 2001
From: George Hazan <ghazan@miranda.im>
Date: Tue, 21 Jul 2020 17:33:46 +0300
Subject: =?UTF-8?q?fixes=20#2222=20(TabSRMM:=20=D0=BD=D0=B5=20=D0=BE=D1=82?=
 =?UTF-8?q?=D0=BA=D0=BB=D1=8E=D1=87=D0=B0=D1=82=D1=8C=20=D0=BF=D0=BE=D0=BB?=
 =?UTF-8?q?=D1=83=D1=87=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BD=D0=BE=D0=B2=D1=8B?=
 =?UTF-8?q?=D1=85=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D0=B9?=
 =?UTF-8?q?=20=D0=BF=D1=80=D0=B8=20=D0=BE=D1=82=D0=BA=D0=BB=D1=8E=D1=87?=
 =?UTF-8?q?=D1=91=D0=BD=D0=BD=D0=BE=D0=B9=20=D0=B0=D0=B2=D1=82=D0=BE=D0=BF?=
 =?UTF-8?q?=D1=80=D0=BE=D0=BA=D1=80=D1=83=D1=82=D0=BA=D0=B5)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 plugins/TabSRMM/src/generic_msghandlers.cpp | 21 ++++-----------------
 plugins/TabSRMM/src/msgdialog.cpp           |  6 +-----
 plugins/TabSRMM/src/msgdlgother.cpp         | 13 -------------
 plugins/TabSRMM/src/msglog.cpp              | 13 ++++++++-----
 plugins/TabSRMM/src/msgs.h                  |  5 -----
 plugins/TabSRMM/src/version.h               |  2 +-
 6 files changed, 14 insertions(+), 46 deletions(-)

(limited to 'plugins')

diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp
index 009b6f3f64..5d093e9bd9 100644
--- a/plugins/TabSRMM/src/generic_msghandlers.cpp
+++ b/plugins/TabSRMM/src/generic_msghandlers.cpp
@@ -1083,23 +1083,10 @@ void CMsgDialog::DM_EventAdded(WPARAM hContact, LPARAM lParam)
 	}
 	m_cache->updateStats(TSessionStats::UPDATE_WITH_LAST_RCV, 0);
 
-	if (hDbEvent != m_hDbEventFirst || isChat()) {
-		if (!m_bScrollingDisabled)
-			StreamEvents(hDbEvent, 1, 1);
-		else {
-			if (m_iNextQueuedEvent >= m_iEventQueueSize) {
-				m_hQueuedEvents = (MEVENT*)mir_realloc(m_hQueuedEvents, (m_iEventQueueSize + 10) * sizeof(MEVENT));
-				m_iEventQueueSize += 10;
-			}
-			m_hQueuedEvents[m_iNextQueuedEvent++] = hDbEvent;
-
-			wchar_t szBuf[100];
-			mir_snwprintf(szBuf, TranslateT("Auto scrolling is disabled, %d message(s) queued (press F12 to enable it)"), m_iNextQueuedEvent);
-			SetDlgItemText(m_hwnd, IDC_LOGFROZENTEXT, szBuf);
-			RedrawWindow(GetDlgItem(m_hwnd, IDC_LOGFROZENTEXT), nullptr, nullptr, RDW_INVALIDATE);
-		}
-	}
-	else RemakeLog();
+	if (hDbEvent != m_hDbEventFirst || isChat())
+		StreamEvents(hDbEvent, 1, 1);
+	else
+		RemakeLog();
 
 	// handle tab flashing
 	if (!bDisableNotify && !bIsStatusChangeEvent)
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp
index 888095a85b..54c381ed0a 100644
--- a/plugins/TabSRMM/src/msgdialog.cpp
+++ b/plugins/TabSRMM/src/msgdialog.cpp
@@ -374,7 +374,6 @@ CMsgDialog::~CMsgDialog()
 {
 	mir_free(m_sendBuffer);
 	mir_free(m_hHistoryEvents);
-	mir_free(m_hQueuedEvents);
 
 	if (m_hClientIcon) DestroyIcon(m_hClientIcon);
 	if (m_hSmileyIcon) DestroyIcon(m_hSmileyIcon);
@@ -469,8 +468,6 @@ bool CMsgDialog::OnInitDialog()
 	if (M.GetByte(m_hContact, "no_ack", 0))
 		m_sendMode |= SMODE_NOACK;
 
-	m_hQueuedEvents = (MEVENT*)mir_calloc(sizeof(MEVENT)* EVENT_QUEUE_SIZE);
-	m_iEventQueueSize = EVENT_QUEUE_SIZE;
 	m_iCurrentQueueError = -1;
 
 	// message history limit
@@ -1573,8 +1570,7 @@ int CMsgDialog::OnFilter(MSGFILTER *pFilter)
 	if (msg == WM_KEYDOWN && wp == VK_F12) {
 		if (isShift || isCtrl || isAlt)
 			return _dlgReturn(m_hwnd, 1);
-		if (m_bScrollingDisabled)
-			ReplayQueue();
+
 		m_bScrollingDisabled = !m_bScrollingDisabled;
 		Utils::showDlgControl(m_hwnd, IDC_LOGFROZENTEXT, (m_bNotOnList || m_bScrollingDisabled) ? SW_SHOW : SW_HIDE);
 		if (!m_bScrollingDisabled)
diff --git a/plugins/TabSRMM/src/msgdlgother.cpp b/plugins/TabSRMM/src/msgdlgother.cpp
index 67e85f43b8..4eefe4db8c 100644
--- a/plugins/TabSRMM/src/msgdlgother.cpp
+++ b/plugins/TabSRMM/src/msgdlgother.cpp
@@ -1228,19 +1228,6 @@ void CMsgDialog::RemakeLog()
 	StreamEvents(m_hDbEventFirst, -1, 0);
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////
-
-void CMsgDialog::ReplayQueue()
-{
-	for (int i = 0; i < m_iNextQueuedEvent; i++)
-		if (m_hQueuedEvents[i] != 0)
-			StreamEvents(m_hQueuedEvents[i], 1, 1);
-
-	m_iNextQueuedEvent = 0;
-	SetDlgItemText(m_hwnd, IDC_LOGFROZENTEXT, m_bNotOnList ? TranslateT("Contact not on list. You may add it...") :
-		TranslateT("Auto scrolling is disabled (press F12 to enable it)"));
-}
-
 /////////////////////////////////////////////////////////////////////////////////////////
 // saves a contact picture to disk
 // takes hbm (bitmap handle) and bool isOwnPic (1 == save the picture as your own avatar)
diff --git a/plugins/TabSRMM/src/msglog.cpp b/plugins/TabSRMM/src/msglog.cpp
index 5e05db523c..e00e5d603a 100644
--- a/plugins/TabSRMM/src/msglog.cpp
+++ b/plugins/TabSRMM/src/msglog.cpp
@@ -1269,10 +1269,8 @@ void CLogWindow::LogEvents(MEVENT hDbEventFirst, int count, bool fAppend, DBEVEN
 
 	// begin to draw
 	m_rtf.SendMsg(WM_SETREDRAW, FALSE, 0);
-
 	m_rtf.SendMsg(EM_STREAMIN, fAppend ? SFF_SELECTION | SF_RTF : SFF_SELECTION | SF_RTF, (LPARAM)&stream);
-	m_rtf.SendMsg(EM_EXSETSEL, 0, (LPARAM)&oldSel);
-	m_rtf.SendMsg(EM_HIDESELECTION, FALSE, 0);
+
 	m_pDlg.m_hDbEventLast = streamData.hDbEventLast;
 
 	if (m_pDlg.m_isAutoRTL & 1)
@@ -1304,8 +1302,13 @@ void CLogWindow::LogEvents(MEVENT hDbEventFirst, int count, bool fAppend, DBEVEN
 	ReplaceIcons(startAt, fAppend, isSent);
 	m_pDlg.m_bClrAdded = false;
 
-	int len = GetWindowTextLength(m_rtf.GetHwnd())-1;
-	m_rtf.SendMsg(EM_SETSEL, len, len);
+ 	if (!m_pDlg.m_bScrollingDisabled) {
+		int len = GetWindowTextLength(m_rtf.GetHwnd()) - 1;
+		m_rtf.SendMsg(EM_SETSEL, len, len);
+	}
+	else m_rtf.SendMsg(EM_EXSETSEL, 0, (LPARAM)&oldSel);
+	
+	m_rtf.SendMsg(EM_HIDESELECTION, FALSE, 0);
 
 	m_rtf.SendMsg(WM_SETREDRAW, TRUE, 0);
 	InvalidateRect(m_rtf.GetHwnd(), nullptr, FALSE);
diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h
index 0305e83909..bf365bf55f 100644
--- a/plugins/TabSRMM/src/msgs.h
+++ b/plugins/TabSRMM/src/msgs.h
@@ -392,7 +392,6 @@ class CMsgDialog : public CSrmmBaseDialog
 	void    LoadSplitter(void);
 	void    PlayIncomingSound(void) const;
 	LRESULT ProcessHotkeysByMsgFilter(const CCtrlBase &pCtrl, UINT msg, WPARAM wParam, LPARAM lParam);
-	void    ReplayQueue(void);
 	void    SaveAvatarToFile(HBITMAP hbm, int isOwnPic);
 	void 	  SendHBitmapAsFile(HBITMAP hbmp) const;
 	void    ShowPopupMenu(const CCtrlBase&, POINT pt);
@@ -435,10 +434,6 @@ class CMsgDialog : public CSrmmBaseDialog
 	bool    m_bDeferredScroll, m_bDeferredRemakeLog;
 	bool    m_bWasBackgroundCreate;
 
-	MEVENT *m_hQueuedEvents;
-	int     m_iNextQueuedEvent;
-	int     m_iEventQueueSize;
-
 	int     m_iRealAvatarHeight;
 	int     m_iButtonBarReallyNeeds;
 	DWORD   m_dwLastActivity;
diff --git a/plugins/TabSRMM/src/version.h b/plugins/TabSRMM/src/version.h
index 555d02ff66..ff0f96126a 100644
--- a/plugins/TabSRMM/src/version.h
+++ b/plugins/TabSRMM/src/version.h
@@ -1,7 +1,7 @@
 #define __MAJOR_VERSION       3
 #define __MINOR_VERSION       6
 #define __RELEASE_NUM         1
-#define __BUILD_NUM           2
+#define __BUILD_NUM           3
 
 #include <stdver.h>
 
-- 
cgit v1.2.3