To: vim-dev@vim.org Subject: Patch 6.3a.010 (extra) Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.3a.010 (extra) Problem: Win32: Characters in the window title that do not appear in the active codepage are replaced by a question mark. Solution: Use DefWindowProcW() instead of DefWindowProc() when possible. Files: src/glbl_ime.cpp, src/globals.h, src/proto/gui_w16.pro, src/proto/gui_w32.pro, src/gui_w16.c, src/gui_w32.c, src/gui_w48.c *** ../vim-6.3a.009/src/glbl_ime.cpp Fri May 7 10:59:39 2004 --- src/glbl_ime.cpp Tue May 11 22:29:41 2004 *************** *** 133,139 **** if (pIApp == NULL || pIApp->OnDefWindowProc(hWnd, Msg, wParam, lParam, &lResult) != S_OK) ! lResult = DefWindowProc(hWnd, Msg, wParam, lParam); return lResult; } --- 133,146 ---- if (pIApp == NULL || pIApp->OnDefWindowProc(hWnd, Msg, wParam, lParam, &lResult) != S_OK) ! { ! #if defined(WIN3264) && defined(FEAT_MBYTE) ! if (wide_WindowProc) ! lResult = DefWindowProcW(hwnd, Msg, wParam, lParam); ! else ! #endif ! lResult = DefWindowProc(hWnd, Msg, wParam, lParam); ! } return lResult; } *** ../vim-6.3a.009/src/globals.h Fri May 7 10:59:37 2004 --- src/globals.h Tue May 11 21:42:47 2004 *************** *** 675,680 **** --- 675,684 ---- # endif EXTERN int has_mbyte INIT(= 0); /* any multi-byte encoding */ + #if defined(WIN3264) && defined(FEAT_MBYTE) + EXTERN int wide_WindowProc INIT(= FALSE); /* use wide WindowProc() */ + #endif + /* * To speed up BYTELEN() we fill a table with the byte lengths whenever * enc_utf8 or enc_dbcs changes. *** ../vim-6.3a.009/src/proto/gui_w16.pro Fri May 7 10:59:36 2004 --- src/proto/gui_w16.pro Tue May 11 22:20:32 2004 *************** *** 2,7 **** --- 2,8 ---- void gui_mch_set_blinking __ARGS((long wait, long on, long off)); void gui_mch_stop_blink __ARGS((void)); void gui_mch_start_blink __ARGS((void)); + LRESULT WINAPI vim_WindowProc __ARGS((HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)); void gui_mch_new_colors __ARGS((void)); void gui_mch_def_colors __ARGS((void)); int gui_mch_open __ARGS((void)); *** ../vim-6.3a.009/src/proto/gui_w32.pro Fri May 7 10:59:36 2004 --- src/proto/gui_w32.pro Tue May 11 22:20:27 2004 *************** *** 2,7 **** --- 2,8 ---- void gui_mch_set_blinking __ARGS((long wait, long on, long off)); void gui_mch_stop_blink __ARGS((void)); void gui_mch_start_blink __ARGS((void)); + LRESULT WINAPI vim_WindowProc __ARGS((HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)); void gui_mch_new_colors __ARGS((void)); void gui_mch_def_colors __ARGS((void)); int gui_mch_open __ARGS((void)); *** ../vim-6.3a.009/src/gui_w16.c Fri May 7 10:59:38 2004 --- src/gui_w16.c Tue May 11 22:19:49 2004 *************** *** 37,42 **** --- 37,46 ---- # include #endif + #ifdef PROTO + # define WINAPI + #endif + #define HANDLE_WM_DROPFILES(hwnd, wParam, lParam, fn) \ ((fn)((hwnd), (HDROP)(wParam)), 0L) *************** *** 222,228 **** return HANDLE_WM_SYSCHAR((hwnd), (wParam), (lParam), (_OnSysChar)); #ifdef FEAT_MENU else ! return DefWindowProc(hwnd, uMsg, wParam, lParam); #endif case WM_SYSKEYUP: --- 226,232 ---- return HANDLE_WM_SYSCHAR((hwnd), (wParam), (lParam), (_OnSysChar)); #ifdef FEAT_MENU else ! return MyWindowProc(hwnd, uMsg, wParam, lParam); #endif case WM_SYSKEYUP: *************** *** 230,236 **** /* Only when menu is active, ALT key is used for that. */ if (gui.menu_is_active) { ! return DefWindowProc(hwnd, uMsg, wParam, lParam); } else #endif --- 234,240 ---- /* Only when menu is active, ALT key is used for that. */ if (gui.menu_is_active) { ! return MyWindowProc(hwnd, uMsg, wParam, lParam); } else #endif *************** *** 269,275 **** int x, y; int xPos = GET_X_LPARAM(lParam); ! result = DefWindowProc(hwnd, uMsg, wParam, lParam); if (result == HTCLIENT) { gui_mch_get_winpos(&x, &y); --- 273,279 ---- int x, y; int xPos = GET_X_LPARAM(lParam); ! result = MyWindowProc(hwnd, uMsg, wParam, lParam); if (result == HTCLIENT) { gui_mch_get_winpos(&x, &y); *************** *** 291,297 **** _OnFindRepl(); } #endif ! return DefWindowProc(hwnd, uMsg, wParam, lParam); } return 1; --- 295,301 ---- _OnFindRepl(); } #endif ! return MyWindowProc(hwnd, uMsg, wParam, lParam); } return 1; *** ../vim-6.3a.009/src/gui_w32.c Fri May 7 10:59:40 2004 --- src/gui_w32.c Tue May 11 22:20:08 2004 *************** *** 48,53 **** --- 48,57 ---- # include "xpm_w32.h" #endif + #ifdef PROTO + # define WINAPI + #endif + #ifdef __MINGW32__ /* * Add a lot of missing defines. *************** *** 200,205 **** --- 204,210 ---- #define VIM_NAME "vim" #define VIM_CLASS "Vim" + #define VIM_CLASSW L"Vim" /* Initial size for the dialog template. For gui_mch_dialog() it's fixed, * thus there should be room for every dialog. For tearoffs it's made bigger *************** *** 545,551 **** netbeans_frame_moved(x, y); } /* Allow to send WM_SIZE and WM_MOVE */ ! FORWARD_WM_WINDOWPOSCHANGED(hwnd, lpwpos, DefWindowProc); } #endif --- 550,556 ---- netbeans_frame_moved(x, y); } /* Allow to send WM_SIZE and WM_MOVE */ ! FORWARD_WM_WINDOWPOSCHANGED(hwnd, lpwpos, MyWindowProc); } #endif *************** *** 653,659 **** return HANDLE_WM_SYSCHAR((hwnd), (wParam), (lParam), (_OnSysChar)); #ifdef FEAT_MENU else ! return DefWindowProc(hwnd, uMsg, wParam, lParam); #endif case WM_SYSKEYUP: --- 658,664 ---- return HANDLE_WM_SYSCHAR((hwnd), (wParam), (lParam), (_OnSysChar)); #ifdef FEAT_MENU else ! return MyWindowProc(hwnd, uMsg, wParam, lParam); #endif case WM_SYSKEYUP: *************** *** 662,668 **** * that. But that caused problems when menu is disabled and using * Alt-Tab-Esc: get into a strange state where no mouse-moved events * are received, mouse pointer remains hidden. */ ! return DefWindowProc(hwnd, uMsg, wParam, lParam); #else return 0; #endif --- 667,673 ---- * that. But that caused problems when menu is disabled and using * Alt-Tab-Esc: get into a strange state where no mouse-moved events * are received, mouse pointer remains hidden. */ ! return MyWindowProc(hwnd, uMsg, wParam, lParam); #else return 0; #endif *************** *** 742,748 **** int x, y; int xPos = GET_X_LPARAM(lParam); ! result = DefWindowProc(hwnd, uMsg, wParam, lParam); if (result == HTCLIENT) { gui_mch_get_winpos(&x, &y); --- 747,753 ---- int x, y; int xPos = GET_X_LPARAM(lParam); ! result = MyWindowProc(hwnd, uMsg, wParam, lParam); if (result == HTCLIENT) { gui_mch_get_winpos(&x, &y); *************** *** 761,771 **** #ifdef FEAT_MBYTE_IME case WM_IME_NOTIFY: if (!_OnImeNotify(hwnd, (DWORD)wParam, (DWORD)lParam)) ! return DefWindowProc(hwnd, uMsg, wParam, lParam); break; case WM_IME_COMPOSITION: if (!_OnImeComposition(hwnd, wParam, lParam)) ! return DefWindowProc(hwnd, uMsg, wParam, lParam); break; #endif --- 766,776 ---- #ifdef FEAT_MBYTE_IME case WM_IME_NOTIFY: if (!_OnImeNotify(hwnd, (DWORD)wParam, (DWORD)lParam)) ! return MyWindowProc(hwnd, uMsg, wParam, lParam); break; case WM_IME_COMPOSITION: if (!_OnImeComposition(hwnd, wParam, lParam)) ! return MyWindowProc(hwnd, uMsg, wParam, lParam); break; #endif *************** *** 782,788 **** _OnFindRepl(); } #endif ! return DefWindowProc(hwnd, uMsg, wParam, lParam); } return 1; --- 787,793 ---- _OnFindRepl(); } #endif ! return MyWindowProc(hwnd, uMsg, wParam, lParam); } return 1; *************** *** 964,969 **** --- 969,978 ---- const char szVimWndClass[] = VIM_CLASS; const char szTextAreaClass[] = "VimTextArea"; WNDCLASS wndclass; + #ifdef FEAT_MBYTE + const WCHAR szVimWndClassW[] = VIM_CLASSW; + WNDCLASSW wndclassw; + #endif #ifdef GLOBAL_IME ATOM atom; #endif *************** *** 991,996 **** --- 1000,1039 ---- gui.border_width = 0; s_brush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); + + #ifdef FEAT_MBYTE + /* First try using the wide version, so that we can use any title. + * Otherwise only characters in the active codepage will work. */ + if (GetClassInfoW(s_hinst, szVimWndClassW, &wndclassw) == 0) + { + wndclassw.style = 0; + wndclassw.lpfnWndProc = _WndProc; + wndclassw.cbClsExtra = 0; + wndclassw.cbWndExtra = 0; + wndclassw.hInstance = s_hinst; + wndclassw.hIcon = LoadIcon(wndclassw.hInstance, "IDR_VIM"); + wndclassw.hCursor = LoadCursor(NULL, IDC_ARROW); + wndclassw.hbrBackground = s_brush; + wndclassw.lpszMenuName = NULL; + wndclassw.lpszClassName = szVimWndClassW; + + if (( + #ifdef GLOBAL_IME + atom = + #endif + RegisterClassW(&wndclassw)) == 0) + { + if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) + return FAIL; + + /* Must be Windows 98, fall back to non-wide function. */ + } + else + wide_WindowProc = TRUE; + } + + if (!wide_WindowProc) + #endif if (GetClassInfo(s_hinst, szVimWndClass, &wndclass) == 0) { *** ../vim-6.3a.009/src/gui_w48.c Fri May 7 10:59:38 2004 --- src/gui_w48.c Tue May 11 22:20:25 2004 *************** *** 82,88 **** # define CONST # define FAR # define NEAR - # define WINAPI # define _cdecl typedef int BOOL; typedef int BYTE; --- 82,87 ---- *************** *** 186,200 **** */ static int allow_scrollbar = FALSE; - #ifdef GLOBAL_IME - # undef DefWindowProc - # define DefWindowProc(a, b, c, d) global_ime_DefWindowProc(a, b, c, d) # define MyTranslateMessage(x) global_ime_TranslateMessage(x) #else # define MyTranslateMessage(x) TranslateMessage(x) #endif extern int current_font_height; /* this is in os_mswin.c */ static struct --- 185,204 ---- */ static int allow_scrollbar = FALSE; #ifdef GLOBAL_IME # define MyTranslateMessage(x) global_ime_TranslateMessage(x) #else # define MyTranslateMessage(x) TranslateMessage(x) #endif + #if (defined(WIN3264) && defined(FEAT_MBYTE)) || defined(GLOBAL_IME) + /* use of WindowProc depends on wide_WindowProc */ + # define MyWindowProc vim_WindowProc + #else + /* use ordinary WindowProc */ + # define MyWindowProc DefWindowProc + #endif + extern int current_font_height; /* this is in os_mswin.c */ static struct *************** *** 951,960 **** #endif default: ! return DefWindowProc(hwnd, uMsg, wParam, lParam); } } /* * Called when the foreground or background color has been changed. */ --- 955,984 ---- #endif default: ! return MyWindowProc(hwnd, uMsg, wParam, lParam); } } + #if (defined(WIN3264) && defined(FEAT_MBYTE)) \ + || defined(GLOBAL_IME) \ + || defined(PROTO) + # ifdef PROTO + typedef int WINAPI; + # endif + + LRESULT WINAPI + vim_WindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) + { + # ifdef GLOBAL_IME + return global_ime_DefWindowProc(hwnd, message, wParam, lParam); + # else + if (wide_WindowProc) + return DefWindowProcW(hwnd, message, wParam, lParam); + return DefWindowProc(hwnd, message, wParam, lParam); + #endif + } + #endif + /* * Called when the foreground or background color has been changed. */ *************** *** 2245,2251 **** HWND hwndOldFocus) { gui_focus_change(TRUE); ! (void)DefWindowProc(hwnd, WM_SETFOCUS, (WPARAM)hwndOldFocus, 0); } static void --- 2269,2275 ---- HWND hwndOldFocus) { gui_focus_change(TRUE); ! (void)MyWindowProc(hwnd, WM_SETFOCUS, (WPARAM)hwndOldFocus, 0); } static void *************** *** 2254,2260 **** HWND hwndNewFocus) { gui_focus_change(FALSE); ! (void)DefWindowProc(hwnd, WM_KILLFOCUS, (WPARAM)hwndNewFocus, 0); } /* --- 2278,2284 ---- HWND hwndNewFocus) { gui_focus_change(FALSE); ! (void)MyWindowProc(hwnd, WM_KILLFOCUS, (WPARAM)hwndNewFocus, 0); } /* *************** *** 2277,2283 **** { /* we call gui_focus_change() in _OnSetFocus() */ /* gui_focus_change((int)fActivate); */ ! return DefWindowProc(hwnd, WM_ACTIVATEAPP, fActivate, (DWORD)dwThreadId); } #if defined(FEAT_WINDOWS) || defined(PROTO) --- 2301,2307 ---- { /* we call gui_focus_change() in _OnSetFocus() */ /* gui_focus_change((int)fActivate); */ ! return MyWindowProc(hwnd, WM_ACTIVATEAPP, fActivate, (DWORD)dwThreadId); } #if defined(FEAT_WINDOWS) || defined(PROTO) *** ../vim-6.3a.009/src/version.c Tue May 11 19:47:24 2004 --- src/version.c Tue May 11 22:27:14 2004 *************** *** 643,644 **** --- 643,646 ---- { /* Add new patch number below this line */ + /**/ + 10, /**/ -- Vi is clearly superior to emacs, since "vi" has only two characters (and two keystrokes), while "emacs" has five. (Randy C. Ford) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///