diff options
-rw-r--r-- | plugins/TabSRMM/src/chat/window.cpp | 11 | ||||
-rw-r--r-- | plugins/TabSRMM/src/generic_msghandlers.cpp | 29 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdialog.cpp | 55 |
3 files changed, 31 insertions, 64 deletions
diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index 6916828dd8..b65c6b9c76 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -2647,16 +2647,7 @@ LABEL_SHOWWINDOW: CallService(MS_UTILS_OPENURL, OUF_TCHAR, (LPARAM)tr.lpstrText); break; case ID_COPY: - if (!OpenClipboard(hwndDlg)) - break; - EmptyClipboard(); - { - HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE, sizeof(TCHAR) * (mir_tstrlen(tr.lpstrText) + 1)); - mir_tstrcpy((TCHAR*)GlobalLock(hData), tr.lpstrText); - GlobalUnlock(hData); - SetClipboardData(CF_UNICODETEXT, hData); - } - CloseClipboard(); + Utils::CopyToClipBoard(tr.lpstrText, hwndDlg); SetFocus(GetDlgItem(hwndDlg, IDC_CHAT_MESSAGE)); break; } diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp index 8d4caea25c..8fcb10d750 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.cpp +++ b/plugins/TabSRMM/src/generic_msghandlers.cpp @@ -1094,32 +1094,17 @@ void TSAPI DM_SaveLocale(TWindowData *dat, WPARAM, LPARAM lParam) ///////////////////////////////////////////////////////////////////////////////////////// // generic handler for the WM_COPY message in message log/chat history richedit control(s). // it filters out the invisible event boundary markers from the text copied to the clipboard. - +// WINE Fix: overwrite clippboad data from original control data LRESULT TSAPI DM_WMCopyHandler(HWND hwnd, WNDPROC oldWndProc, UINT msg, WPARAM wParam, LPARAM lParam) { LRESULT result = mir_callNextSubclass(hwnd, oldWndProc, msg, wParam, lParam); - if (!OpenClipboard(hwnd)) - return result; - HANDLE hClip = GetClipboardData(CF_UNICODETEXT); - if (!hClip) - goto err_out; - TCHAR *tszText = (TCHAR*)mir_alloc((mir_tstrlen((TCHAR*)hClip) + 2) * sizeof(TCHAR)); - if (!tszText) - goto err_out; - mir_tstrcpy(tszText, (TCHAR*)hClip); - Utils::FilterEventMarkers(tszText); - EmptyClipboard(); - - HGLOBAL hgbl = GlobalAlloc(GMEM_MOVEABLE, (mir_tstrlen(tszText) + 1) * sizeof(TCHAR)); - TCHAR *tszLocked = (TCHAR*)GlobalLock(hgbl); - mir_tstrcpy(tszLocked, tszText); - GlobalUnlock(hgbl); - SetClipboardData(CF_UNICODETEXT, hgbl); - mir_free(tszText); - -err_out: - CloseClipboard(); + ptrA szFromStream(Message_GetFromStream(hwnd, SF_TEXT | SFF_SELECTION));
+ ptrW converted(mir_utf8decodeW(szFromStream));
+
+ Utils::FilterEventMarkers(converted); + Utils::CopyToClipBoard(converted, hwnd); + return result; } diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index bc19a5b87a..7203911193 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -2000,31 +2000,31 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP // holding ctrl while releasing the button pastes the selection to the input area, using plain text
// holding ctrl-alt does the same, but pastes formatted text
case WM_LBUTTONUP:
- if (((NMHDR*)lParam)->idFrom == IDC_LOG) {
+ if (((NMHDR*)lParam)->idFrom == IDC_LOG && M.GetByte("autocopy", 1)) {
CHARRANGE cr;
SendDlgItemMessage(hwndDlg, IDC_LOG, EM_EXGETSEL, 0, (LPARAM)&cr);
- if (cr.cpMax != cr.cpMin) {
- cr.cpMin = cr.cpMax;
- if (isCtrl && M.GetByte("autocopy", 1)) {
- SETTEXTEX stx = { ST_KEEPUNDO | ST_SELECTION, CP_UTF8 };
- char *streamOut = NULL;
- if (isAlt)
- streamOut = Message_GetFromStream(GetDlgItem(hwndDlg, IDC_LOG), SF_RTFNOOBJS | SFF_PLAINRTF | SFF_SELECTION);
- else
- streamOut = Message_GetFromStream(GetDlgItem(hwndDlg, IDC_LOG), SF_TEXT | SFF_SELECTION);
- if (streamOut) {
- Utils::FilterEventMarkers(streamOut);
- SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETTEXTEX, (WPARAM)&stx, (LPARAM)streamOut);
- mir_free(streamOut);
- }
- SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGE));
- }
- else if (M.GetByte("autocopy", 1) && !isShift) {
- SendDlgItemMessage(hwndDlg, IDC_LOG, WM_COPY, 0, 0);
- SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGE));
- if (m_pContainer->hwndStatus)
- SendMessage(m_pContainer->hwndStatus, SB_SETTEXT, 0, (LPARAM)TranslateT("Selection copied to clipboard"));
+ if (cr.cpMax == cr.cpMin)
+ break;
+ cr.cpMin = cr.cpMax;
+ if (isCtrl) {
+ SETTEXTEX stx = { ST_KEEPUNDO | ST_SELECTION, CP_UTF8 };
+ char *streamOut = NULL;
+ if (isAlt)
+ streamOut = Message_GetFromStream(GetDlgItem(hwndDlg, IDC_LOG), SF_RTFNOOBJS | SFF_PLAINRTF | SFF_SELECTION);
+ else
+ streamOut = Message_GetFromStream(GetDlgItem(hwndDlg, IDC_LOG), SF_TEXT | SFF_SELECTION);
+ if (streamOut) {
+ Utils::FilterEventMarkers(streamOut);
+ SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETTEXTEX, (WPARAM)&stx, (LPARAM)streamOut);
+ mir_free(streamOut);
}
+ SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGE));
+ }
+ else if (!isShift) {
+ SendDlgItemMessage(hwndDlg, IDC_LOG, WM_COPY, 0, 0);
+ SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGE));
+ if (m_pContainer->hwndStatus)
+ SendMessage(m_pContainer->hwndStatus, SB_SETTEXT, 0, (LPARAM)TranslateT("Selection copied to clipboard"));
}
}
break;
@@ -2084,16 +2084,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP break;
case IDM_COPYLINK:
- if (!OpenClipboard(hwndDlg))
- break;
-
- EmptyClipboard();
- HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE, sizeof(TCHAR)*(mir_tstrlen(tszUrl) + 1));
- TCHAR *buf = (TCHAR*)GlobalLock(hData);
- mir_tstrcpy(buf, tszUrl);
- GlobalUnlock(hData);
- SetClipboardData(CF_UNICODETEXT, hData);
- CloseClipboard();
+ Utils::CopyToClipBoard(tszUrl, hwndDlg);
break;
}
DestroyMenu(hMenu);
|