• R/O
  • SSH

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-c誰得qtcocoapythonrubywindowsphpgameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwitterdombtronvb.nettestarduinodirectxpreviewerゲームエンジン

K.Takata's patch queue for Vim


Commit MetaInfo

Revision5f87019dc74c150d2d18111ed0738e8e0e880e13 (tree)
Zeit2022-01-15 17:49:18
AutorK.Takata <kentkt@csc....>
CommiterK.Takata

Log Message

Fix IME

Ändern Zusammenfassung

Diff

diff -r e2138bc9e88f -r 5f87019dc74c win32-permonitorv2.patch
--- a/win32-permonitorv2.patch Sat Jan 15 15:43:58 2022 +0900
+++ b/win32-permonitorv2.patch Sat Jan 15 17:49:18 2022 +0900
@@ -1,5 +1,5 @@
11 # HG changeset patch
2-# Parent a7f575af18dd59e86011961ae073200cedf5decc
2+# Parent 0ded9a803032c91cc8ae873c80740e271e4fee02
33
44 diff --git a/src/gui.c b/src/gui.c
55 --- a/src/gui.c
@@ -94,7 +94,7 @@
9494 static FINDREPLACEW s_findrep_struct;
9595 static HWND s_findrep_hwnd = NULL;
9696 static int s_findrep_is_find; // TRUE for find dialog, FALSE
97-@@ -358,6 +364,61 @@ static int allow_scrollbar = FALSE;
97+@@ -358,6 +364,63 @@ static int allow_scrollbar = FALSE;
9898 # define MyTranslateMessage(x) TranslateMessage(x)
9999 #endif
100100
@@ -118,12 +118,14 @@
118118 +#define DEFAULT_DPI 96
119119 +static int s_dpi = DEFAULT_DPI;
120120 +static BOOL s_in_dpichanged = FALSE;
121++static DPI_AWARENESS s_process_dpi_aware = DPI_AWARENESS_INVALID;
121122 +
122123 +static UINT (WINAPI *pGetDpiForSystem)(void) = NULL;
123124 +static UINT (WINAPI *pGetDpiForWindow)(HWND hwnd) = NULL;
124125 +static int (WINAPI *pGetSystemMetricsForDpi)(int, UINT) = NULL;
125126 +//static INT (WINAPI *pGetWindowDpiAwarenessContext)(HWND hwnd) = NULL;
126127 +static DPI_AWARENESS_CONTEXT (WINAPI *pSetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT dpiContext) = NULL;
128++static DPI_AWARENESS (WINAPI *pGetAwarenessFromDpiAwarenessContext)(DPI_AWARENESS_CONTEXT) = NULL;
127129 +
128130 + static UINT WINAPI
129131 +stubGetDpiForSystem(void)
@@ -156,7 +158,7 @@
156158 #if defined(FEAT_DIRECTX)
157159 static int
158160 directx_enabled(void)
159-@@ -1348,7 +1409,7 @@ gui_mch_set_text_area_pos(int x, int y,
161+@@ -1348,7 +1411,7 @@ gui_mch_set_text_area_pos(int x, int y,
160162 #ifdef FEAT_TOOLBAR
161163 if (vim_strchr(p_go, GO_TOOLBAR) != NULL)
162164 SendMessage(s_toolbarhwnd, WM_SIZE,
@@ -165,7 +167,7 @@
165167 #endif
166168 #if defined(FEAT_GUI_TABLINE)
167169 if (showing_tabline)
168-@@ -1358,7 +1419,7 @@ gui_mch_set_text_area_pos(int x, int y,
170+@@ -1358,7 +1421,7 @@ gui_mch_set_text_area_pos(int x, int y,
169171
170172 # ifdef FEAT_TOOLBAR
171173 if (vim_strchr(p_go, GO_TOOLBAR) != NULL)
@@ -174,7 +176,7 @@
174176 # endif
175177 GetClientRect(s_hwnd, &rect);
176178 MoveWindow(s_tabhwnd, 0, top, rect.right, gui.tabline_height, TRUE);
177-@@ -1414,8 +1475,8 @@ gui_mch_get_scrollbar_xpadding(void)
179+@@ -1414,8 +1477,8 @@ gui_mch_get_scrollbar_xpadding(void)
178180 GetWindowRect(s_textArea, &rcTxt);
179181 GetWindowRect(s_hwnd, &rcWnd);
180182 xpad = rcWnd.right - rcTxt.right - gui.scrollbar_width
@@ -185,7 +187,7 @@
185187 return (xpad < 0) ? 0 : xpad;
186188 }
187189
188-@@ -1428,8 +1489,8 @@ gui_mch_get_scrollbar_ypadding(void)
190+@@ -1428,8 +1491,8 @@ gui_mch_get_scrollbar_ypadding(void)
189191 GetWindowRect(s_textArea, &rcTxt);
190192 GetWindowRect(s_hwnd, &rcWnd);
191193 ypad = rcWnd.bottom - rcTxt.bottom - gui.scrollbar_height
@@ -196,7 +198,7 @@
196198 return (ypad < 0) ? 0 : ypad;
197199 }
198200
199-@@ -1467,6 +1528,13 @@ gui_mswin_find_scrollbar(HWND hwnd)
201+@@ -1467,6 +1530,13 @@ gui_mswin_find_scrollbar(HWND hwnd)
200202 return NULL;
201203 }
202204
@@ -210,7 +212,7 @@
210212 /*
211213 * Get the character size of a font.
212214 */
213-@@ -1545,7 +1613,10 @@ gui_mch_get_font(
215+@@ -1545,7 +1615,10 @@ gui_mch_get_font(
214216 GuiFont font = NOFONT;
215217
216218 if (get_logfont(&lf, name, NULL, giveErrorIfMissing) == OK)
@@ -221,7 +223,7 @@
221223 if (font == NOFONT && giveErrorIfMissing)
222224 semsg(_(e_unknown_font_str), name);
223225 return font;
224-@@ -2858,14 +2929,12 @@ gui_mch_show_popupmenu_at(vimmenu_T *men
226+@@ -2858,14 +2931,12 @@ gui_mch_show_popupmenu_at(vimmenu_T *men
225227 int cx,
226228 int cy)
227229 {
@@ -237,7 +239,7 @@
237239 }
238240 }
239241
240-@@ -2949,16 +3018,13 @@ gui_mswin_get_valid_dimensions(
242+@@ -2949,16 +3020,13 @@ gui_mswin_get_valid_dimensions(
241243 int base_width, base_height;
242244
243245 base_width = gui_get_base_width()
@@ -260,7 +262,7 @@
260262 *cols = (w - base_width) / gui.char_width;
261263 *rows = (h - base_height) / gui.char_height;
262264 *valid_w = base_width + *cols * gui.char_width;
263-@@ -3245,7 +3311,7 @@ logfont2name(LOGFONTW lf)
265+@@ -3245,12 +3313,12 @@ logfont2name(LOGFONTW lf)
264266 #ifdef FEAT_MBYTE_IME
265267 /*
266268 * Set correct LOGFONTW to IME. Use 'guifontwide' if available, otherwise use
@@ -269,7 +271,26 @@
269271 */
270272 static void
271273 update_im_font(void)
272-@@ -3310,13 +3376,17 @@ gui_mch_wide_font_changed(void)
274+ {
275+- LOGFONTW lf_wide;
276++ LOGFONTW lf_wide, lf;
277+
278+ if (p_guifontwide != NULL && *p_guifontwide != NUL
279+ && gui.wide_font != NOFONT
280+@@ -3258,7 +3326,11 @@ update_im_font(void)
281+ norm_logfont = lf_wide;
282+ else
283+ norm_logfont = sub_logfont;
284+- im_set_font(&norm_logfont);
285++
286++ lf = norm_logfont;
287++ if (s_process_dpi_aware == DPI_AWARENESS_UNAWARE)
288++ lf.lfHeight = lf.lfHeight * 96 / s_dpi;
289++ im_set_font(&lf);
290+ }
291+ #endif
292+
293+@@ -3310,13 +3382,17 @@ gui_mch_wide_font_changed(void)
273294 int
274295 gui_mch_init_font(char_u *font_name, int fontset UNUSED)
275296 {
@@ -288,7 +309,7 @@
288309 if (font == NOFONT)
289310 return FAIL;
290311
291-@@ -3329,20 +3399,20 @@ gui_mch_init_font(char_u *font_name, int
312+@@ -3329,20 +3405,20 @@ gui_mch_init_font(char_u *font_name, int
292313 sub_logfont = lf;
293314 #endif
294315 #ifdef FEAT_MBYTE_IME
@@ -313,7 +334,7 @@
313334 if (STRCMP(font_name, "*") == 0 && STRCMP(p_guifont, "*") == 0)
314335 {
315336 vim_free(p_guifont);
316-@@ -3428,26 +3498,19 @@ gui_mch_newfont(void)
337+@@ -3428,26 +3504,19 @@ gui_mch_newfont(void)
317338 if (win_socket_id == 0)
318339 {
319340 gui_resize_shell(rect.right - rect.left
@@ -347,7 +368,7 @@
347368 }
348369 }
349370
350-@@ -4101,7 +4164,7 @@ typedef HRESULT (WINAPI* DLLGETVERSIONPR
371+@@ -4101,7 +4170,7 @@ typedef HRESULT (WINAPI* DLLGETVERSIONPR
351372 #if defined(FEAT_TOOLBAR) || defined(FEAT_GUI_TABLINE)
352373 // Older MSVC compilers don't have LPNMTTDISPINFO[AW] thus we need to define
353374 // it here if LPNMTTDISPINFO isn't defined.
@@ -356,7 +377,7 @@
356377 // _MSC_VER.
357378 # if !defined(LPNMTTDISPINFO) && defined(_MSC_VER)
358379 typedef struct tagNMTTDISPINFOA {
359-@@ -4178,8 +4241,11 @@ static int mouse_scroll_lines = 0;
380+@@ -4178,8 +4247,11 @@ static int mouse_scroll_lines = 0;
360381 static int s_usenewlook; // emulate W95/NT4 non-bold dialogs
361382 #ifdef FEAT_TOOLBAR
362383 static void initialise_toolbar(void);
@@ -368,7 +389,7 @@
368389 #endif
369390
370391 #ifdef FEAT_GUI_TABLINE
371-@@ -4419,6 +4485,7 @@ set_tabline_font(void)
392+@@ -4419,6 +4491,7 @@ set_tabline_font(void)
372393 if (gui_w32_get_menu_font(&lfSysmenu) != OK)
373394 return;
374395
@@ -376,7 +397,7 @@
376397 font = CreateFontIndirectW(&lfSysmenu);
377398
378399 SendMessage(s_tabhwnd, WM_SETFONT, (WPARAM)font, TRUE);
379-@@ -4441,6 +4508,8 @@ set_tabline_font(void)
400+@@ -4441,6 +4514,8 @@ set_tabline_font(void)
380401 */
381402 gui.tabline_height = tm.tmHeight + tm.tmInternalLeading + 7;
382403 }
@@ -385,7 +406,7 @@
385406 #endif
386407
387408 /*
388-@@ -4452,10 +4521,8 @@ set_tabline_font(void)
409+@@ -4452,10 +4527,8 @@ set_tabline_font(void)
389410 if (n == SPI_SETWHEELSCROLLLINES)
390411 SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0,
391412 &mouse_scroll_lines, 0);
@@ -396,7 +417,7 @@
396417 return 0;
397418 }
398419
399-@@ -4556,6 +4623,28 @@ destroy_sizing_tip(void)
420+@@ -4556,6 +4629,28 @@ destroy_sizing_tip(void)
400421 return TRUE;
401422 }
402423
@@ -425,7 +446,7 @@
425446
426447
427448 static LRESULT CALLBACK
428-@@ -4916,6 +5005,9 @@ destroy_sizing_tip(void)
449+@@ -4916,6 +5011,9 @@ destroy_sizing_tip(void)
429450 return MyWindowProc(hwnd, uMsg, wParam, lParam);
430451 return 1L;
431452 #endif
@@ -435,7 +456,7 @@
435456
436457 default:
437458 #ifdef MSWIN_FIND_REPLACE
438-@@ -5269,6 +5361,37 @@ gui_mch_prepare(int *argc, char **argv)
459+@@ -5269,6 +5367,43 @@ gui_mch_prepare(int *argc, char **argv)
439460 #endif
440461 }
441462
@@ -453,13 +474,18 @@
453474 + pGetSystemMetricsForDpi = (void*)GetProcAddress(hUser32, "GetSystemMetricsForDpi");
454475 + //pGetWindowDpiAwarenessContext = (void*)GetProcAddress(hUser32, "GetWindowDpiAwarenessContext");
455476 + pSetThreadDpiAwarenessContext = (void*)GetProcAddress(hUser32, "SetThreadDpiAwarenessContext");
477++ pGetAwarenessFromDpiAwarenessContext = (void*)GetProcAddress(hUser32, "GetAwarenessFromDpiAwarenessContext");
456478 +
457-+ if (pSetThreadDpiAwarenessContext != NULL &&
458-+ pSetThreadDpiAwarenessContext(
459-+ DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2))
479++ if (pSetThreadDpiAwarenessContext != NULL)
460480 + {
461-+ //TRACE("DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 enabled");
462-+ return;
481++ DPI_AWARENESS_CONTEXT oldctx = pSetThreadDpiAwarenessContext(
482++ DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
483++ if (oldctx != NULL)
484++ {
485++ TRACE("DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 enabled");
486++ s_process_dpi_aware = pGetAwarenessFromDpiAwarenessContext(oldctx);
487++ return;
488++ }
463489 + }
464490 +
465491 +fail:
@@ -468,12 +494,13 @@
468494 + pGetDpiForWindow = NULL;
469495 + pGetSystemMetricsForDpi = stubGetSystemMetricsForDpi;
470496 + pSetThreadDpiAwarenessContext = NULL;
497++ pGetAwarenessFromDpiAwarenessContext = NULL;
471498 +}
472499 +
473500 /*
474501 * Initialise the GUI. Create all the windows, set up all the call-backs
475502 * etc.
476-@@ -5295,12 +5418,18 @@ gui_mch_init(void)
503+@@ -5295,12 +5430,18 @@ gui_mch_init(void)
477504 s_htearbitmap = LoadBitmap(g_hinst, "IDB_TEAROFF");
478505 #endif
479506
@@ -494,7 +521,7 @@
494521
495522 s_brush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
496523
497-@@ -5389,6 +5518,13 @@ gui_mch_init(void)
524+@@ -5389,6 +5530,13 @@ gui_mch_init(void)
498525 if (s_hwnd == NULL)
499526 return FAIL;
500527
@@ -508,7 +535,7 @@
508535 #ifdef GLOBAL_IME
509536 global_ime_init(atom, s_hwnd);
510537 #endif
511-@@ -5444,7 +5580,7 @@ gui_mch_init(void)
538+@@ -5444,7 +5592,7 @@ gui_mch_init(void)
512539 DragAcceptFiles(s_hwnd, TRUE);
513540
514541 // Do we need to bother with this?
@@ -517,7 +544,7 @@
517544
518545 // Get background/foreground colors from the system
519546 gui_mch_def_colors();
520-@@ -5586,15 +5722,12 @@ gui_mch_set_shellsize(
547+@@ -5586,15 +5734,12 @@ gui_mch_set_shellsize(
521548 GetWindowRect(s_hwnd, &window_rect);
522549
523550 // compute the size of the outside of the window
@@ -539,7 +566,7 @@
539566
540567 // The following should take care of keeping Vim on the same monitor, no
541568 // matter if the secondary monitor is left or right of the primary
542-@@ -5621,10 +5754,8 @@ gui_mch_set_shellsize(
569+@@ -5621,10 +5766,8 @@ gui_mch_set_shellsize(
543570 SetActiveWindow(s_hwnd);
544571 SetFocus(s_hwnd);
545572
@@ -550,7 +577,31 @@
550577 }
551578
552579
553-@@ -6491,20 +6622,17 @@ gui_mch_get_screen_dimensions(int *scree
580+@@ -5722,7 +5865,10 @@ gui_mch_set_sp_color(guicolor_T color)
581+ case IMN_SETOPENSTATUS:
582+ if (pImmGetOpenStatus(hImc))
583+ {
584+- pImmSetCompositionFontW(hImc, &norm_logfont);
585++ LOGFONTW lf = norm_logfont;
586++ if (s_process_dpi_aware == DPI_AWARENESS_UNAWARE)
587++ lf.lfHeight = lf.lfHeight * 96 / s_dpi;
588++ pImmSetCompositionFontW(hImc, &lf);
589+ im_set_position(gui.row, gui.col);
590+
591+ // Disable langmap
592+@@ -5890,6 +6036,11 @@ im_set_position(int row, int col)
593+ cfs.ptCurrentPos.x = FILL_X(col);
594+ cfs.ptCurrentPos.y = FILL_Y(row);
595+ MapWindowPoints(s_textArea, s_hwnd, &cfs.ptCurrentPos, 1);
596++ if (s_process_dpi_aware == DPI_AWARENESS_UNAWARE)
597++ {
598++ cfs.ptCurrentPos.x = cfs.ptCurrentPos.x * 96 / s_dpi;
599++ cfs.ptCurrentPos.y = cfs.ptCurrentPos.y * 96 / s_dpi;
600++ }
601+ pImmSetCompositionWindow(hImc, &cfs);
602+
603+ pImmReleaseContext(s_hwnd, hImc);
604+@@ -6491,20 +6642,17 @@ gui_mch_get_screen_dimensions(int *scree
554605 get_work_area(&workarea_rect);
555606
556607 *screen_w = workarea_rect.right - workarea_rect.left
@@ -577,7 +628,7 @@
577628 }
578629
579630
580-@@ -6958,6 +7086,9 @@ gui_mch_dialog(
631+@@ -6958,6 +7106,9 @@ gui_mch_dialog(
581632 # endif
582633 garray_T ga;
583634 int l;
@@ -587,7 +638,7 @@
587638
588639 # ifndef NO_CONSOLE
589640 // Don't output anything in silent mode ("ex -s")
590-@@ -6969,7 +7100,13 @@ gui_mch_dialog(
641+@@ -6969,7 +7120,13 @@ gui_mch_dialog(
591642 # endif
592643
593644 if (s_hwnd == NULL)
@@ -601,7 +652,7 @@
601652
602653 if ((type < 0) || (type > VIM_LAST_TYPE))
603654 type = 0;
604-@@ -7027,7 +7164,7 @@ gui_mch_dialog(
655+@@ -7027,7 +7184,7 @@ gui_mch_dialog(
605656 else
606657 # endif
607658 font = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -610,7 +661,7 @@
610661 if (s_usenewlook)
611662 {
612663 oldFont = SelectFont(hdc, font);
613-@@ -7054,8 +7191,8 @@ gui_mch_dialog(
664+@@ -7054,8 +7211,8 @@ gui_mch_dialog(
614665 // We don't have a window, use the desktop area.
615666 get_work_area(&workarea_rect);
616667 maxDialogWidth = workarea_rect.right - workarea_rect.left - 100;
@@ -621,7 +672,7 @@
621672 // Leave some room for the taskbar.
622673 maxDialogHeight = workarea_rect.bottom - workarea_rect.top - 150;
623674 }
624-@@ -7064,17 +7201,17 @@ gui_mch_dialog(
675+@@ -7064,17 +7221,17 @@ gui_mch_dialog(
625676 // Use our own window for the size, unless it's very small.
626677 GetWindowRect(s_hwnd, &rect);
627678 maxDialogWidth = rect.right - rect.left
@@ -648,7 +699,7 @@
648699 }
649700
650701 // Set dlgwidth to width of message.
651-@@ -7110,7 +7247,8 @@ gui_mch_dialog(
702+@@ -7110,7 +7267,8 @@ gui_mch_dialog(
652703 if (last_white != NULL)
653704 {
654705 // break the line just after a space
@@ -658,7 +709,7 @@
658709 pend = last_white + 1;
659710 last_white = NULL;
660711 }
661-@@ -7135,12 +7273,15 @@ gui_mch_dialog(
712+@@ -7135,12 +7293,15 @@ gui_mch_dialog(
662713
663714 messageWidth += 10; // roundoff space
664715
@@ -679,7 +730,7 @@
679730
680731 /*
681732 * Check button names. A long one will make the dialog wider.
682-@@ -7228,7 +7369,7 @@ gui_mch_dialog(
733+@@ -7228,7 +7389,7 @@ gui_mch_dialog(
683734 dlgheight = maxDialogHeight;
684735 scroll_flag = WS_VSCROLL;
685736 // Make sure scrollbar doesn't appear in the middle of the dialog
@@ -688,7 +739,7 @@
688739 }
689740
690741 add_word(PixelToDialogY(dlgheight));
691-@@ -7325,14 +7466,14 @@ gui_mch_dialog(
742+@@ -7325,14 +7486,14 @@ gui_mch_dialog(
692743 p = add_dialog_element(p, SS_ICON,
693744 PixelToDialogX(dlgPaddingX),
694745 PixelToDialogY(dlgPaddingY),
@@ -706,7 +757,7 @@
706757 PixelToDialogY(dlgPaddingY),
707758 (WORD)(PixelToDialogX(messageWidth) + 1),
708759 PixelToDialogY(msgheight),
709-@@ -7626,7 +7767,7 @@ get_dialog_font_metrics(void)
760+@@ -7626,7 +7787,7 @@ get_dialog_font_metrics(void)
710761 else
711762 #endif
712763 hfontTools = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0,
@@ -715,7 +766,7 @@
715766
716767 if (hfontTools)
717768 {
718-@@ -7732,7 +7873,7 @@ gui_mch_tearoff(
769+@@ -7732,7 +7893,7 @@ gui_mch_tearoff(
719770 else
720771 # endif
721772 font = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -724,7 +775,7 @@
724775 if (s_usenewlook)
725776 oldFont = SelectFont(hdc, font);
726777 else
727-@@ -8031,6 +8172,33 @@ initialise_toolbar(void)
778+@@ -8031,6 +8192,33 @@ initialise_toolbar(void)
728779 s_toolbar_wndproc = SubclassWindow(s_toolbarhwnd, toolbar_wndproc);
729780
730781 gui_mch_show_toolbar(vim_strchr(p_go, GO_TOOLBAR) != NULL);
@@ -758,7 +809,7 @@
758809 }
759810
760811 static LRESULT CALLBACK
761-@@ -8124,9 +8292,7 @@ initialise_tabline(void)
812+@@ -8124,9 +8312,7 @@ initialise_tabline(void)
762813
763814 gui.tabline_height = TABLINE_HEIGHT;
764815
@@ -768,7 +819,7 @@
768819 }
769820
770821 /*
771-@@ -8143,7 +8309,7 @@ GetTabFromPoint(
822+@@ -8143,7 +8329,7 @@ GetTabFromPoint(
772823 {
773824 TCHITTESTINFO htinfo;
774825 htinfo.pt = pt;
@@ -777,7 +828,7 @@
777828 if (s_tabhwnd == hWnd)
778829 {
779830 int idx = TabCtrl_HitTest(s_tabhwnd, &htinfo);
780-@@ -8189,7 +8355,8 @@ tabline_wndproc(
831+@@ -8189,7 +8375,8 @@ tabline_wndproc(
781832 {
782833 pt.x = GET_X_LPARAM(lParam);
783834 pt.y = s_pt.y;