diff options
author | fvogel <fvogelnew1@free.fr> | 2017-06-05 18:32:24 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2017-06-05 18:32:24 (GMT) |
commit | fbac4859a673c9a5f0c8936ed8d18ea9e9145304 (patch) | |
tree | 4e184d638205d9ce2ef854ebea9393e5d8d91bd3 /win | |
parent | 452ee6a6849e04a6a94bc7488e935129614041f8 (diff) | |
parent | fd3fd3d844d9ff5f83c3fd26ee88f2c02892c180 (diff) | |
download | tk-fbac4859a673c9a5f0c8936ed8d18ea9e9145304.zip tk-fbac4859a673c9a5f0c8936ed8d18ea9e9145304.tar.gz tk-fbac4859a673c9a5f0c8936ed8d18ea9e9145304.tar.bz2 |
merge trunk
Diffstat (limited to 'win')
-rw-r--r-- | win/tcl.m4 | 2 | ||||
-rw-r--r-- | win/tkWinClipboard.c | 2 | ||||
-rw-r--r-- | win/tkWinDialog.c | 54 | ||||
-rw-r--r-- | win/tkWinFont.c | 6 | ||||
-rw-r--r-- | win/tkWinInit.c | 7 | ||||
-rw-r--r-- | win/tkWinSend.c | 43 | ||||
-rw-r--r-- | win/tkWinSendCom.c | 25 | ||||
-rw-r--r-- | win/tkWinTest.c | 5 | ||||
-rw-r--r-- | win/tkWinX.c | 30 |
9 files changed, 131 insertions, 43 deletions
@@ -1132,7 +1132,7 @@ AC_DEFUN([SC_WITH_TCL], [ TCL_BIN_DEFAULT=../../tcl8.7/win fi - AC_ARG_WITH(tcl, [ --with-tcl=DIR use Tcl 8.6+ binaries from DIR], + AC_ARG_WITH(tcl, [ --with-tcl=DIR use Tcl 8.7 binaries from DIR], TCL_BIN_DIR=$withval, TCL_BIN_DIR=`cd $TCL_BIN_DEFAULT; pwd`) if test ! -d $TCL_BIN_DIR; then AC_MSG_ERROR(Tcl directory $TCL_BIN_DIR does not exist) diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c index 929070b..03c0cde 100644 --- a/win/tkWinClipboard.c +++ b/win/tkWinClipboard.c @@ -331,7 +331,7 @@ TkWinClipboardRender( #ifdef UNICODE Tcl_DStringInit(&ds); - Tcl_UtfToUniCharDString(rawText, -1, &ds); + Tcl_WinUtfToTChar(rawText, -1, &ds); ckfree(rawText); handle = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE, (unsigned) Tcl_DStringLength(&ds) + 2); diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index a7d8c7d..5be6776 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -1379,17 +1379,27 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, goto vamoose; if (optsPtr->extObj != NULL) { - wstr = Tcl_GetUnicode(optsPtr->extObj); + Tcl_DString ds; + const char *src; + + src = Tcl_GetString(optsPtr->extObj); + wstr = (LPWSTR) Tcl_WinUtfToTChar(src, optsPtr->extObj->length, &ds); if (wstr[0] == L'.') ++wstr; hr = fdlgIf->lpVtbl->SetDefaultExtension(fdlgIf, wstr); + Tcl_DStringFree(&ds); if (FAILED(hr)) goto vamoose; } if (optsPtr->titleObj != NULL) { - hr = fdlgIf->lpVtbl->SetTitle(fdlgIf, - Tcl_GetUnicode(optsPtr->titleObj)); + Tcl_DString ds; + const char *src; + + src = Tcl_GetString(optsPtr->titleObj); + wstr = (LPWSTR) Tcl_WinUtfToTChar(src, optsPtr->titleObj->length, &ds); + hr = fdlgIf->lpVtbl->SetTitle(fdlgIf, wstr); + Tcl_DStringFree(&ds); if (FAILED(hr)) goto vamoose; } @@ -1464,12 +1474,14 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, SIGDN_FILESYSPATH, &wstr); if (SUCCEEDED(hr)) { Tcl_DString fnds; + ConvertExternalFilename(wstr, &fnds); CoTaskMemFree(wstr); Tcl_ListObjAppendElement( interp, multiObj, Tcl_NewStringObj(Tcl_DStringValue(&fnds), Tcl_DStringLength(&fnds))); + Tcl_DStringFree(&fnds); } itemIf->lpVtbl->Release(itemIf); if (FAILED(hr)) @@ -1490,10 +1502,12 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, &wstr); if (SUCCEEDED(hr)) { Tcl_DString fnds; + ConvertExternalFilename(wstr, &fnds); resultObj = Tcl_NewStringObj(Tcl_DStringValue(&fnds), Tcl_DStringLength(&fnds)); CoTaskMemFree(wstr); + Tcl_DStringFree(&fnds); } resultIf->lpVtbl->Release(resultIf); } @@ -1501,13 +1515,20 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, if (SUCCEEDED(hr)) { if (filterPtr && optsPtr->typeVariableObj) { UINT ftix; + hr = fdlgIf->lpVtbl->GetFileTypeIndex(fdlgIf, &ftix); if (SUCCEEDED(hr)) { /* Note ftix is a 1-based index */ if (ftix > 0 && ftix <= nfilters) { + Tcl_DString ftds; + Tcl_Obj *ftobj; + + Tcl_WinTCharToUtf(filterPtr[ftix-1].pszName, -1, &ftds); + ftobj = Tcl_NewStringObj(Tcl_DStringValue(&ftds), + Tcl_DStringLength(&ftds)); Tcl_ObjSetVar2(interp, optsPtr->typeVariableObj, NULL, - Tcl_NewUnicodeObj(filterPtr[ftix-1].pszName, -1), - TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG); + ftobj, TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG); + Tcl_DStringFree(&ftds); } } } @@ -2786,6 +2807,9 @@ Tk_MessageBoxObjCmd( }; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_DString titleBuf, tmpBuf; + const WCHAR *titlePtr, *tmpPtr; + const char *src; defaultBtn = -1; detailObj = NULL; @@ -2896,7 +2920,9 @@ Tk_MessageBoxObjCmd( : Tcl_NewUnicodeObj(NULL, 0); Tcl_IncrRefCount(tmpObj); if (detailObj) { - Tcl_AppendUnicodeToObj(tmpObj, L"\n\n", 2); + const Tcl_UniChar twoNL[] = { '\n', '\n' }; + + Tcl_AppendUnicodeToObj(tmpObj, twoNL, 2); Tcl_AppendObjToObj(tmpObj, detailObj); } @@ -2915,8 +2941,18 @@ Tk_MessageBoxObjCmd( tsdPtr->hBigIcon = TkWinGetIcon(parent, ICON_BIG); tsdPtr->hMsgBoxHook = SetWindowsHookEx(WH_CBT, MsgBoxCBTProc, NULL, GetCurrentThreadId()); - winCode = MessageBox(hWnd, Tcl_GetUnicode(tmpObj), - titleObj ? Tcl_GetUnicode(titleObj) : L"", flags); + src = Tcl_GetString(tmpObj); + tmpPtr = Tcl_WinUtfToTChar(src, tmpObj->length, &tmpBuf); + if (titleObj != NULL) { + src = Tcl_GetString(titleObj); + titlePtr = Tcl_WinUtfToTChar(src, titleObj->length, &titleBuf); + } else { + titlePtr = L""; + Tcl_DStringInit(&titleBuf); + } + winCode = MessageBox(hWnd, tmpPtr, titlePtr, flags); + Tcl_DStringFree(&titleBuf); + Tcl_DStringFree(&tmpBuf); UnhookWindowsHookEx(tsdPtr->hMsgBoxHook); (void) Tcl_SetServiceMode(oldMode); @@ -3451,7 +3487,7 @@ FontchooserShowCmd( LF_FACESIZE-1); Tcl_DStringFree(&ds); lf.lfFaceName[LF_FACESIZE-1] = 0; - lf.lfHeight = -MulDiv(TkFontGetPoints(tkwin, fontPtr->fa.size), + lf.lfHeight = -MulDiv((int)(TkFontGetPoints(tkwin, fontPtr->fa.size) + 0.5), GetDeviceCaps(hdc, LOGPIXELSY), 72); if (fontPtr->fa.weight == TK_FW_BOLD) { lf.lfWeight = FW_BOLD; diff --git a/win/tkWinFont.c b/win/tkWinFont.c index c01dc3f..aa0697c 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -562,7 +562,7 @@ TkpGetFontFromAttributes( ReleaseDC(hwnd, hdc); hFont = GetScreenFont(faPtr, faceName, - TkFontGetPixels(tkwin, faPtr->size), 0.0); + (int)(TkFontGetPixels(tkwin, faPtr->size) + 0.5), 0.0); if (tkFontPtr == NULL) { fontPtr = ckalloc(sizeof(WinFont)); } else { @@ -763,7 +763,7 @@ TkpGetFontAttrsForChar( ReleaseDC(fontPtr->hwnd, hdc); faPtr->family = familyPtr->faceName; faPtr->size = TkFontGetPoints(tkwin, - tm.tmInternalLeading - tm.tmHeight); + (double)(tm.tmInternalLeading - tm.tmHeight)); faPtr->weight = (tm.tmWeight > FW_MEDIUM) ? TK_FW_BOLD : TK_FW_NORMAL; faPtr->slant = tm.tmItalic ? TK_FS_ITALIC : TK_FS_ROMAN; faPtr->underline = (tm.tmUnderlined != 0); @@ -1600,7 +1600,7 @@ InitFont( faPtr->family = Tk_GetUid(Tcl_DStringValue(&faceString)); faPtr->size = - TkFontGetPoints(tkwin, -(fontPtr->pixelSize)); + TkFontGetPoints(tkwin, (double)-(fontPtr->pixelSize)); faPtr->weight = (tm.tmWeight > FW_MEDIUM) ? TK_FW_BOLD : TK_FW_NORMAL; faPtr->slant = (tm.tmItalic != 0) ? TK_FS_ITALIC : TK_FS_ROMAN; diff --git a/win/tkWinInit.c b/win/tkWinInit.c index b1b2d6b..4c18399 100644 --- a/win/tkWinInit.c +++ b/win/tkWinInit.c @@ -181,6 +181,9 @@ TkWin32ErrorObj( LPTSTR lpBuffer = NULL, p = NULL; TCHAR sBuffer[30]; Tcl_Obj* errPtr = NULL; +#ifdef _UNICODE + Tcl_DString ds; +#endif FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, (DWORD)hrError, @@ -196,7 +199,9 @@ TkWin32ErrorObj( } #ifdef _UNICODE - errPtr = Tcl_NewUnicodeObj(lpBuffer, (int)wcslen(lpBuffer)); + Tcl_WinTCharToUtf(lpBuffer, (int)wcslen(lpBuffer) * sizeof (WCHAR), &ds); + errPtr = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); + Tcl_DStringFree(&ds); #else errPtr = Tcl_NewStringObj(lpBuffer, (int)strlen(lpBuffer)); #endif /* _UNICODE */ diff --git a/win/tkWinSend.c b/win/tkWinSend.c index 6c4731a..fca8561 100644 --- a/win/tkWinSend.c +++ b/win/tkWinSend.c @@ -252,8 +252,14 @@ TkGetInterpNames( LPOLESTR p = olestr + wcslen(oleszStub); if (*p) { + Tcl_DString ds; + + Tcl_WinTCharToUtf(p + 1, -1, &ds); result = Tcl_ListObjAppendElement(interp, - objList, Tcl_NewUnicodeObj(p + 1, -1)); + objList, + Tcl_NewStringObj(Tcl_DStringValue(&ds), + Tcl_DStringLength(&ds))); + Tcl_DStringFree(&ds); } } @@ -613,8 +619,7 @@ BuildMoniker( LPMONIKER pmkItem = NULL; Tcl_DString dString; - Tcl_DStringInit(&dString); - Tcl_UtfToUniCharDString(name, -1, &dString); + Tcl_WinUtfToTChar(name, -1, &dString); hr = CreateFileMoniker((LPOLESTR)Tcl_DStringValue(&dString), &pmkItem); Tcl_DStringFree(&dString); if (SUCCEEDED(hr)) { @@ -740,6 +745,8 @@ Send( HRESULT hr = S_OK, ehr = S_OK; Tcl_Obj *cmd = NULL; DISPID dispid; + Tcl_DString ds; + const char *src; cmd = Tcl_ConcatObj(objc, objv); @@ -753,7 +760,10 @@ Send( memset(&ei, 0, sizeof(ei)); vCmd.vt = VT_BSTR; - vCmd.bstrVal = SysAllocString(Tcl_GetUnicode(cmd)); + src = Tcl_GetString(cmd); + Tcl_WinUtfToTChar(src, cmd->length, &ds); + vCmd.bstrVal = SysAllocString((WCHAR *) Tcl_DStringValue(&ds)); + Tcl_DStringFree(&ds); dp.cArgs = 1; dp.rgvarg = &vCmd; @@ -774,7 +784,9 @@ Send( ehr = VariantChangeType(&vResult, &vResult, 0, VT_BSTR); if (SUCCEEDED(ehr)) { - Tcl_SetObjResult(interp, Tcl_NewUnicodeObj(vResult.bstrVal, -1)); + Tcl_WinTCharToUtf(vResult.bstrVal, (int) SysStringLen(vResult.bstrVal) * + sizeof (WCHAR), &ds); + Tcl_DStringResult(interp, &ds); } /* @@ -785,8 +797,11 @@ Send( if (hr == DISP_E_EXCEPTION && ei.bstrSource != NULL) { Tcl_Obj *opError, *opErrorCode, *opErrorInfo; - - opError = Tcl_NewUnicodeObj(ei.bstrSource, -1); + Tcl_WinTCharToUtf(ei.bstrSource, (int) SysStringLen(ei.bstrSource) * + sizeof (WCHAR), &ds); + opError = Tcl_NewStringObj(Tcl_DStringValue(&ds), + Tcl_DStringLength(&ds)); + Tcl_DStringFree(&ds); Tcl_ListObjIndex(interp, opError, 0, &opErrorCode); Tcl_SetObjErrorCode(interp, opErrorCode); Tcl_ListObjIndex(interp, opError, 1, &opErrorInfo); @@ -833,6 +848,8 @@ TkWinSend_SetExcepInfo( ICreateErrorInfo *pCEI; IErrorInfo *pEI, **ppEI = &pEI; HRESULT hr; + Tcl_DString ds; + const char *src; if (!pExcepInfo) { return; @@ -851,8 +868,16 @@ TkWinSend_SetExcepInfo( Tcl_ListObjAppendElement(interp, opErrorCode, opErrorInfo); /* TODO: Handle failure to append */ - pExcepInfo->bstrDescription = SysAllocString(Tcl_GetUnicode(opError)); - pExcepInfo->bstrSource = SysAllocString(Tcl_GetUnicode(opErrorCode)); + src = Tcl_GetString(opError); + Tcl_WinUtfToTChar(src, opError->length, &ds); + pExcepInfo->bstrDescription = + SysAllocString((WCHAR *) Tcl_DStringValue(&ds)); + Tcl_DStringFree(&ds); + src = Tcl_GetString(opErrorCode); + Tcl_WinUtfToTChar(src, opErrorCode->length, &ds); + pExcepInfo->bstrSource = + SysAllocString((WCHAR *) Tcl_DStringValue(&ds)); + Tcl_DStringFree(&ds); Tcl_DecrRefCount(opErrorCode); pExcepInfo->scode = E_FAIL; diff --git a/win/tkWinSendCom.c b/win/tkWinSendCom.c index 83dd56b..9e5b7a0 100644 --- a/win/tkWinSendCom.c +++ b/win/tkWinSendCom.c @@ -370,6 +370,7 @@ Async( { HRESULT hr = S_OK; VARIANT vCmd; + Tcl_DString ds; VariantInit(&vCmd); @@ -382,9 +383,13 @@ Async( } if (SUCCEEDED(hr) && obj->interp) { - Tcl_Obj *scriptPtr = Tcl_NewUnicodeObj(vCmd.bstrVal, - (int) SysStringLen(vCmd.bstrVal)); + Tcl_Obj *scriptPtr; + Tcl_WinTCharToUtf(vCmd.bstrVal, (int) SysStringLen(vCmd.bstrVal) * + sizeof (WCHAR), &ds); + scriptPtr = + Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); + Tcl_DStringFree(&ds); TkWinSend_QueueCommand(obj->interp, scriptPtr); } @@ -424,6 +429,7 @@ Send( VARIANT v; register Tcl_Interp *interp = obj->interp; Tcl_Obj *scriptPtr; + Tcl_DString ds; if (interp == NULL) { return S_OK; @@ -434,17 +440,26 @@ Send( return hr; } - scriptPtr = Tcl_NewUnicodeObj(v.bstrVal, (int) SysStringLen(v.bstrVal)); + Tcl_WinTCharToUtf(v.bstrVal, (int) SysStringLen(v.bstrVal) * + sizeof (WCHAR), &ds); + scriptPtr = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); + Tcl_DStringFree(&ds); Tcl_Preserve(interp); Tcl_IncrRefCount(scriptPtr); result = Tcl_EvalObjEx(interp, scriptPtr, TCL_EVAL_DIRECT | TCL_EVAL_GLOBAL); Tcl_DecrRefCount(scriptPtr); if (pvResult != NULL) { + Tcl_Obj *obj; + const char *src; + VariantInit(pvResult); pvResult->vt = VT_BSTR; - pvResult->bstrVal = SysAllocString(Tcl_GetUnicode( - Tcl_GetObjResult(interp))); + obj = Tcl_GetObjResult(interp); + src = Tcl_GetString(obj); + Tcl_WinUtfToTChar(src, obj->length, &ds); + pvResult->bstrVal = SysAllocString((WCHAR *) Tcl_DStringValue(&ds)); + Tcl_DStringFree(&ds); } if (result == TCL_ERROR) { hr = DISP_E_EXCEPTION; diff --git a/win/tkWinTest.c b/win/tkWinTest.c index 095358d..1c121cc 100644 --- a/win/tkWinTest.c +++ b/win/tkWinTest.c @@ -515,6 +515,7 @@ TestgetwindowinfoObjCmd( Tcl_Obj *childrenObj = NULL; TCHAR buf[512]; int cch, cchBuf = 256; + Tcl_DString ds; if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "hwnd"); @@ -542,7 +543,9 @@ TestgetwindowinfoObjCmd( Tcl_NewWideIntObj(GetWindowLongPtr((HWND)(size_t)hwnd, GWL_ID))); cch = GetWindowText((HWND)(size_t)hwnd, (LPTSTR)buf, cchBuf); - textObj = Tcl_NewUnicodeObj((LPCWSTR)buf, cch); + Tcl_WinTCharToUtf(buf, cch * sizeof (WCHAR), &ds); + textObj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); + Tcl_DStringFree(&ds); Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("text", 4), textObj); Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("parent", 6), diff --git a/win/tkWinX.c b/win/tkWinX.c index d41b6c1..6293ce7 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -676,19 +676,6 @@ TkClipCleanup( TkDisplay *dispPtr) /* Display associated with clipboard. */ { if (dispPtr->clipWindow != NULL) { - /* - * Force the clipboard to be rendered if we are the clipboard owner. - */ - - HWND hwnd = Tk_GetHWND(Tk_WindowId(dispPtr->clipWindow)); - - if (GetClipboardOwner() == hwnd) { - OpenClipboard(hwnd); - EmptyClipboard(); - TkWinClipboardRender(dispPtr, CF_TEXT); - CloseClipboard(); - } - Tk_DeleteSelHandler(dispPtr->clipWindow, dispPtr->clipboardAtom, dispPtr->applicationAtom); Tk_DeleteSelHandler(dispPtr->clipWindow, dispPtr->clipboardAtom, @@ -865,6 +852,23 @@ Tk_TranslateWinEvent( return 1; } + case WM_RENDERALLFORMATS: { + TkWindow *winPtr = (TkWindow *) Tk_HWNDToWindow(hwnd); + + if (winPtr && OpenClipboard(hwnd)) { + /* + * Make sure that nobody had taken ownership of the clipboard + * before we opened it. + */ + + if (GetClipboardOwner() == hwnd) { + TkWinClipboardRender(winPtr->dispPtr, CF_TEXT); + } + CloseClipboard(); + } + return 1; + } + case WM_COMMAND: case WM_NOTIFY: case WM_VSCROLL: |