To: vim_dev@googlegroups.com Subject: Patch 8.2.4175 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4175 Problem: MS-Windows: runtime check for multi-line balloon is obsolete. Solution: Remove the obsolete code. (Ken Takata, closes #9592) Files: src/evalfunc.c, src/gui_w32.c, src/proto/gui_w32.pro *** ../vim-8.2.4174/src/evalfunc.c 2022-01-16 13:30:29.877688041 +0000 --- src/evalfunc.c 2022-01-22 10:21:53.830682568 +0000 *************** *** 5104,5111 **** #endif }, {"balloon_multiline", ! #if defined(FEAT_BEVAL_GUI) && !defined(FEAT_GUI_MSWIN) ! // MS-Windows requires runtime check, see below 1 #else 0 --- 5104,5110 ---- #endif }, {"balloon_multiline", ! #ifdef FEAT_BEVAL_GUI 1 #else 0 *************** *** 6079,6088 **** { // intentionally empty } - #if defined(FEAT_BEVAL) && defined(FEAT_GUI_MSWIN) - else if (STRICMP(name, "balloon_multiline") == 0) - n = multiline_balloon_available(); - #endif #ifdef VIMDLL else if (STRICMP(name, "filterpipe") == 0) n = gui.in_use || gui.starting; --- 6078,6083 ---- *************** *** 6261,6269 **** dynamic_feature(char_u *feature) { return (feature == NULL - #if defined(FEAT_BEVAL) && defined(FEAT_GUI_MSWIN) - || STRICMP(feature, "balloon_multiline") == 0 - #endif #if defined(FEAT_GUI) && defined(FEAT_BROWSE) || (STRICMP(feature, "browse") == 0 && !gui.in_use) #endif --- 6256,6261 ---- *************** *** 6716,6722 **** if (*end != NUL) { semsg(_(lv.ll_name == lv.ll_name_end ! ? e_invalid_argument_str : e_trailing_characters_str), end); } else { --- 6708,6714 ---- if (*end != NUL) { semsg(_(lv.ll_name == lv.ll_name_end ! ? e_invalid_argument_str : e_trailing_characters_str), end); } else { *** ../vim-8.2.4174/src/gui_w32.c 2022-01-21 11:37:03.640642885 +0000 --- src/gui_w32.c 2022-01-22 10:21:53.834682487 +0000 *************** *** 4035,4076 **** static DWORD LastActivity = 0; - // cproto fails on missing include files - # ifndef PROTO - - /* - * excerpts from headers since this may not be presented - * in the extremely old compilers - */ - # include - - # endif - - typedef struct _DllVersionInfo - { - DWORD cbSize; - DWORD dwMajorVersion; - DWORD dwMinorVersion; - DWORD dwBuildNumber; - DWORD dwPlatformID; - } DLLVERSIONINFO; - - # ifndef PROTO - # include - # endif - - typedef struct tagTOOLINFOA_NEW - { - UINT cbSize; - UINT uFlags; - HWND hwnd; - UINT_PTR uId; - RECT rect; - HINSTANCE hinst; - LPSTR lpszText; - LPARAM lParam; - } TOOLINFO_NEW; - typedef struct tagNMTTDISPINFO_NEW { NMHDR hdr; --- 4035,4040 ---- *************** *** 4105,4111 **** } NMTTDISPINFOW_NEW; - typedef HRESULT (WINAPI* DLLGETVERSIONPROC)(DLLVERSIONINFO *); # ifndef TTM_SETMAXTIPWIDTH # define TTM_SETMAXTIPWIDTH (WM_USER+24) # endif --- 4069,4074 ---- *************** *** 8497,8585 **** * 5) WM_NOTIFY:TTN_POP destroys created tooltip */ - /* - * determine whether installed Common Controls support multiline tooltips - * (i.e. their version is >= 4.70 - */ - int - multiline_balloon_available(void) - { - HINSTANCE hDll; - static char comctl_dll[] = "comctl32.dll"; - static int multiline_tip = MAYBE; - - if (multiline_tip != MAYBE) - return multiline_tip; - - hDll = GetModuleHandle(comctl_dll); - if (hDll != NULL) - { - DLLGETVERSIONPROC pGetVer; - pGetVer = (DLLGETVERSIONPROC)GetProcAddress(hDll, "DllGetVersion"); - - if (pGetVer != NULL) - { - DLLVERSIONINFO dvi; - HRESULT hr; - - ZeroMemory(&dvi, sizeof(dvi)); - dvi.cbSize = sizeof(dvi); - - hr = (*pGetVer)(&dvi); - - if (SUCCEEDED(hr) - && (dvi.dwMajorVersion > 4 - || (dvi.dwMajorVersion == 4 - && dvi.dwMinorVersion >= 70))) - { - multiline_tip = TRUE; - return multiline_tip; - } - } - else - { - // there is chance we have ancient CommCtl 4.70 - // which doesn't export DllGetVersion - DWORD dwHandle = 0; - DWORD len = GetFileVersionInfoSize(comctl_dll, &dwHandle); - if (len > 0) - { - VS_FIXEDFILEINFO *ver; - UINT vlen = 0; - void *data = alloc(len); - - if ((data != NULL - && GetFileVersionInfo(comctl_dll, 0, len, data) - && VerQueryValue(data, "\\", (void **)&ver, &vlen) - && vlen - && HIWORD(ver->dwFileVersionMS) > 4) - || ((HIWORD(ver->dwFileVersionMS) == 4 - && LOWORD(ver->dwFileVersionMS) >= 70))) - { - vim_free(data); - multiline_tip = TRUE; - return multiline_tip; - } - vim_free(data); - } - } - } - multiline_tip = FALSE; - return multiline_tip; - } - static void make_tooltip(BalloonEval *beval, char *text, POINT pt) { ! TOOLINFOW *pti; ! int ToolInfoSize; ! ! if (multiline_balloon_available()) ! ToolInfoSize = sizeof(TOOLINFOW_NEW); ! else ! ToolInfoSize = sizeof(TOOLINFOW); ! pti = alloc(ToolInfoSize); if (pti == NULL) return; --- 8460,8472 ---- * 5) WM_NOTIFY:TTN_POP destroys created tooltip */ static void make_tooltip(BalloonEval *beval, char *text, POINT pt) { ! TOOLINFOW_NEW *pti; ! RECT rect; ! pti = alloc(sizeof(TOOLINFOW_NEW)); if (pti == NULL) return; *************** *** 8591,8620 **** SetWindowPos(beval->balloon, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); ! pti->cbSize = ToolInfoSize; pti->uFlags = TTF_SUBCLASS; pti->hwnd = beval->target; pti->hinst = 0; // Don't use string resources pti->uId = ID_BEVAL_TOOLTIP; ! if (multiline_balloon_available()) ! { ! RECT rect; ! TOOLINFOW_NEW *ptin = (TOOLINFOW_NEW *)pti; ! pti->lpszText = LPSTR_TEXTCALLBACKW; ! beval->tofree = enc_to_utf16((char_u*)text, NULL); ! ptin->lParam = (LPARAM)beval->tofree; ! // switch multiline tooltips on ! if (GetClientRect(s_textArea, &rect)) ! SendMessageW(beval->balloon, TTM_SETMAXTIPWIDTH, 0, ! (LPARAM)rect.right); ! } ! else ! { ! // do this old way ! beval->tofree = enc_to_utf16((char_u*)text, NULL); ! pti->lpszText = (LPWSTR)beval->tofree; ! } // Limit ballooneval bounding rect to CursorPos neighbourhood. pti->rect.left = pt.x - 3; --- 8478,8496 ---- SetWindowPos(beval->balloon, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); ! pti->cbSize = sizeof(TOOLINFOW_NEW); pti->uFlags = TTF_SUBCLASS; pti->hwnd = beval->target; pti->hinst = 0; // Don't use string resources pti->uId = ID_BEVAL_TOOLTIP; ! pti->lpszText = LPSTR_TEXTCALLBACKW; ! beval->tofree = enc_to_utf16((char_u*)text, NULL); ! pti->lParam = (LPARAM)beval->tofree; ! // switch multiline tooltips on ! if (GetClientRect(s_textArea, &rect)) ! SendMessageW(beval->balloon, TTM_SETMAXTIPWIDTH, 0, ! (LPARAM)rect.right); // Limit ballooneval bounding rect to CursorPos neighbourhood. pti->rect.left = pt.x - 3; *** ../vim-8.2.4174/src/proto/gui_w32.pro 2020-07-17 21:16:58.390212926 +0100 --- src/proto/gui_w32.pro 2022-01-22 10:21:53.834682487 +0000 *************** *** 90,96 **** void gui_mch_drawsign(int row, int col, int typenr); void *gui_mch_register_sign(char_u *signfile); void gui_mch_destroy_sign(void *sign); - int multiline_balloon_available(void); void gui_mch_disable_beval_area(BalloonEval *beval); void gui_mch_enable_beval_area(BalloonEval *beval); void gui_mch_post_balloon(BalloonEval *beval, char_u *mesg); --- 90,95 ---- *** ../vim-8.2.4174/src/version.c 2022-01-21 20:37:02.287408821 +0000 --- src/version.c 2022-01-22 10:22:18.130187179 +0000 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4175, /**/ -- An indication you must be a manager: You can explain to somebody the difference between "re-engineering", "down-sizing", "right-sizing", and "firing people's asses". /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///