diff options
| author | Geoff Voelker | 1996-02-02 01:58:01 +0000 |
|---|---|---|
| committer | Geoff Voelker | 1996-02-02 01:58:01 +0000 |
| commit | a1a80b404e7c9a67335acdd9341e4668342a0ffe (patch) | |
| tree | dea3b675b69dc753000e4af0387174db42576f07 | |
| parent | 7c69181b61d51094f461933198c114edbacad31b (diff) | |
| download | emacs-a1a80b404e7c9a67335acdd9341e4668342a0ffe.tar.gz emacs-a1a80b404e7c9a67335acdd9341e4668342a0ffe.zip | |
(modifiers, modifier_key_support_tested,
modifiers_recorded): New variables.
(EMACS_LCONTROL, EMACS_RCONTROL, EMACS_LMENU,
EMACS_RMENU): New macros.
(test_modifier_support, record_keydown, record_keyup,
modifier_set, construct_modifiers): New functions.
(win32_wnd_proc): Monitor modifier keyup and keydown messages.
Map window modifiers into console modifiers to unify input.
(x_create_frame): Use the FixedSys font as the default font.
(x_to_win32_font): For now, always use ANSI_CHARSET.
| -rw-r--r-- | src/w32fns.c | 188 |
1 files changed, 146 insertions, 42 deletions
diff --git a/src/w32fns.c b/src/w32fns.c index 11aaf43dd01..9d48646e45b 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -2474,6 +2474,132 @@ my_post_msg (wmsg, hwnd, msg, wParam, lParam) | |||
| 2474 | post_msg (wmsg); | 2474 | post_msg (wmsg); |
| 2475 | } | 2475 | } |
| 2476 | 2476 | ||
| 2477 | /* GetKeyState and MapVirtualKey on Win95 do not actually distinguish | ||
| 2478 | between left and right keys as advertised. We test for this | ||
| 2479 | support dynamically, and set a flag when the support is absent. If | ||
| 2480 | absent, we keep track of the left and right control and alt keys | ||
| 2481 | ourselves. This is particularly necessary on keyboards that rely | ||
| 2482 | upon the AltGr key, which is represented as having the left control | ||
| 2483 | and right alt keys pressed. For these keyboards, we need to know | ||
| 2484 | when the left alt key has been pressed in addition to the AltGr key | ||
| 2485 | so that we can properly support M-AltGr-key sequences (such as M-@ | ||
| 2486 | on Swedish keyboards). */ | ||
| 2487 | |||
| 2488 | #define EMACS_LCONTROL 0 | ||
| 2489 | #define EMACS_RCONTROL 1 | ||
| 2490 | #define EMACS_LMENU 2 | ||
| 2491 | #define EMACS_RMENU 3 | ||
| 2492 | |||
| 2493 | static int modifiers[4]; | ||
| 2494 | static int modifiers_recorded; | ||
| 2495 | static int modifier_key_support_tested; | ||
| 2496 | |||
| 2497 | static void | ||
| 2498 | test_modifier_support (unsigned int wparam) | ||
| 2499 | { | ||
| 2500 | unsigned int l, r; | ||
| 2501 | |||
| 2502 | if (wparam != VK_CONTROL && wparam != VK_MENU) | ||
| 2503 | return; | ||
| 2504 | if (wparam == VK_CONTROL) | ||
| 2505 | { | ||
| 2506 | l = VK_LCONTROL; | ||
| 2507 | r = VK_RCONTROL; | ||
| 2508 | } | ||
| 2509 | else | ||
| 2510 | { | ||
| 2511 | l = VK_LMENU; | ||
| 2512 | r = VK_RMENU; | ||
| 2513 | } | ||
| 2514 | if (!(GetKeyState (l) & 0x8000) && !(GetKeyState (r) & 0x8000)) | ||
| 2515 | modifiers_recorded = 1; | ||
| 2516 | else | ||
| 2517 | modifiers_recorded = 0; | ||
| 2518 | modifier_key_support_tested = 1; | ||
| 2519 | } | ||
| 2520 | |||
| 2521 | static void | ||
| 2522 | record_keydown (unsigned int wparam, unsigned int lparam) | ||
| 2523 | { | ||
| 2524 | int i; | ||
| 2525 | |||
| 2526 | if (!modifier_key_support_tested) | ||
| 2527 | test_modifier_support (wparam); | ||
| 2528 | |||
| 2529 | if ((wparam != VK_CONTROL && wparam != VK_MENU) || !modifiers_recorded) | ||
| 2530 | return; | ||
| 2531 | |||
| 2532 | if (wparam == VK_CONTROL) | ||
| 2533 | i = (lparam & 0x1000000) ? EMACS_RCONTROL : EMACS_LCONTROL; | ||
| 2534 | else | ||
| 2535 | i = (lparam & 0x1000000) ? EMACS_RMENU : EMACS_LMENU; | ||
| 2536 | |||
| 2537 | modifiers[i] = 1; | ||
| 2538 | } | ||
| 2539 | |||
| 2540 | static void | ||
| 2541 | record_keyup (unsigned int wparam, unsigned int lparam) | ||
| 2542 | { | ||
| 2543 | int i; | ||
| 2544 | |||
| 2545 | if ((wparam != VK_CONTROL && wparam != VK_MENU) || !modifiers_recorded) | ||
| 2546 | return; | ||
| 2547 | |||
| 2548 | if (wparam == VK_CONTROL) | ||
| 2549 | i = (lparam & 0x1000000) ? EMACS_RCONTROL : EMACS_LCONTROL; | ||
| 2550 | else | ||
| 2551 | i = (lparam & 0x1000000) ? EMACS_RMENU : EMACS_LMENU; | ||
| 2552 | |||
| 2553 | modifiers[i] = 0; | ||
| 2554 | } | ||
| 2555 | |||
| 2556 | static int | ||
| 2557 | modifier_set (int vkey) | ||
| 2558 | { | ||
| 2559 | if (!modifiers_recorded) | ||
| 2560 | return (GetKeyState (vkey) & 0x8000); | ||
| 2561 | |||
| 2562 | switch (vkey) | ||
| 2563 | { | ||
| 2564 | case VK_LCONTROL: | ||
| 2565 | return modifiers[EMACS_LCONTROL]; | ||
| 2566 | case VK_RCONTROL: | ||
| 2567 | return modifiers[EMACS_RCONTROL]; | ||
| 2568 | case VK_LMENU: | ||
| 2569 | return modifiers[EMACS_LMENU]; | ||
| 2570 | case VK_RMENU: | ||
| 2571 | return modifiers[EMACS_RMENU]; | ||
| 2572 | case VK_CAPITAL: | ||
| 2573 | return (GetKeyState (vkey) & 0x1); | ||
| 2574 | default: | ||
| 2575 | break; | ||
| 2576 | } | ||
| 2577 | return (GetKeyState (vkey) & 0x8000); | ||
| 2578 | } | ||
| 2579 | |||
| 2580 | /* We map the VK_* modifiers into console modifier constants | ||
| 2581 | so that we can use the same routines to handle both console | ||
| 2582 | and window input. */ | ||
| 2583 | |||
| 2584 | static int | ||
| 2585 | construct_modifiers (unsigned int wparam, unsigned int lparam) | ||
| 2586 | { | ||
| 2587 | int mods; | ||
| 2588 | |||
| 2589 | if (wparam != VK_CONTROL && wparam != VK_MENU) | ||
| 2590 | mods = GetLastError (); | ||
| 2591 | |||
| 2592 | mods = 0; | ||
| 2593 | mods |= (modifier_set (VK_SHIFT)) ? SHIFT_PRESSED : 0; | ||
| 2594 | mods |= (modifier_set (VK_CAPITAL)) ? CAPSLOCK_ON : 0; | ||
| 2595 | mods |= (modifier_set (VK_LCONTROL)) ? LEFT_CTRL_PRESSED : 0; | ||
| 2596 | mods |= (modifier_set (VK_RCONTROL)) ? RIGHT_CTRL_PRESSED : 0; | ||
| 2597 | mods |= (modifier_set (VK_LMENU)) ? LEFT_ALT_PRESSED : 0; | ||
| 2598 | mods |= (modifier_set (VK_RMENU)) ? RIGHT_ALT_PRESSED : 0; | ||
| 2599 | |||
| 2600 | return mods; | ||
| 2601 | } | ||
| 2602 | |||
| 2477 | /* Main window procedure */ | 2603 | /* Main window procedure */ |
| 2478 | 2604 | ||
| 2479 | extern char *lispy_function_keys[]; | 2605 | extern char *lispy_function_keys[]; |
| @@ -2537,55 +2663,31 @@ win32_wnd_proc (hwnd, msg, wParam, lParam) | |||
| 2537 | } | 2663 | } |
| 2538 | 2664 | ||
| 2539 | return (0); | 2665 | return (0); |
| 2666 | |||
| 2667 | case WM_KEYUP: | ||
| 2668 | case WM_SYSKEYUP: | ||
| 2669 | record_keyup (wParam, lParam); | ||
| 2670 | goto dflt; | ||
| 2671 | |||
| 2540 | case WM_KEYDOWN: | 2672 | case WM_KEYDOWN: |
| 2541 | case WM_SYSKEYDOWN: | 2673 | case WM_SYSKEYDOWN: |
| 2542 | #if 0 | 2674 | record_keydown (wParam, lParam); |
| 2543 | if (! ((wParam >= VK_BACK && wParam <= VK_TAB) | 2675 | |
| 2544 | || (wParam >= VK_CLEAR && wParam <= VK_RETURN) | 2676 | switch (wParam) { |
| 2545 | || (wParam == VK_ESCAPE) | 2677 | case VK_CONTROL: case VK_CAPITAL: case VK_MENU: case VK_SHIFT: |
| 2546 | || (wParam >= VK_PRIOR && wParam <= VK_HELP) | 2678 | goto dflt; |
| 2547 | || (wParam >= VK_LWIN && wParam <= VK_APPS) | 2679 | default: |
| 2548 | || (wParam >= VK_NUMPAD0 && wParam <= VK_F24) | ||
| 2549 | || (wParam >= VK_NUMLOCK && wParam <= VK_SCROLL) | ||
| 2550 | || (wParam >= VK_ATTN && wParam <= VK_OEM_CLEAR) | ||
| 2551 | || !TranslateMessage (&msg1))) | ||
| 2552 | { | ||
| 2553 | goto dflt; | ||
| 2554 | } | ||
| 2555 | #endif | ||
| 2556 | |||
| 2557 | /* Check for special characters since translate message | ||
| 2558 | seems to always indicate true. */ | ||
| 2559 | |||
| 2560 | if (wParam == VK_MENU | ||
| 2561 | || wParam == VK_SHIFT | ||
| 2562 | || wParam == VK_CONTROL | ||
| 2563 | || wParam == VK_CAPITAL) | ||
| 2564 | break; | 2680 | break; |
| 2565 | 2681 | } | |
| 2566 | /* Anything we do not have a name for needs to be translated or | 2682 | |
| 2567 | returned as ascii keystroke. */ | ||
| 2568 | |||
| 2569 | if (lispy_function_keys[wParam] == 0) | 2683 | if (lispy_function_keys[wParam] == 0) |
| 2570 | { | 2684 | msg = WM_CHAR; |
| 2571 | MSG msg1; | 2685 | |
| 2572 | |||
| 2573 | msg1.hwnd = hwnd; | ||
| 2574 | msg1.message = msg; | ||
| 2575 | msg1.wParam = wParam; | ||
| 2576 | msg1.lParam = lParam; | ||
| 2577 | |||
| 2578 | if (TranslateMessage (&msg1)) | ||
| 2579 | break; | ||
| 2580 | else | ||
| 2581 | msg = WM_CHAR; | ||
| 2582 | } | ||
| 2583 | |||
| 2584 | /* Fall through */ | 2686 | /* Fall through */ |
| 2585 | 2687 | ||
| 2586 | case WM_SYSCHAR: | 2688 | case WM_SYSCHAR: |
| 2587 | case WM_CHAR: | 2689 | case WM_CHAR: |
| 2588 | wmsg.dwModifiers = win32_get_modifiers (); | 2690 | wmsg.dwModifiers = construct_modifiers (wParam, lParam); |
| 2589 | 2691 | ||
| 2590 | my_post_msg (&wmsg, hwnd, msg, wParam, lParam); | 2692 | my_post_msg (&wmsg, hwnd, msg, wParam, lParam); |
| 2591 | break; | 2693 | break; |
| @@ -2929,7 +3031,7 @@ This function is an internal primitive--use `make-frame' instead.") | |||
| 2929 | font = x_new_font (f, "-*-system-medium-r-normal-*-*-200-*-*-c-120-*-*"); | 3031 | font = x_new_font (f, "-*-system-medium-r-normal-*-*-200-*-*-c-120-*-*"); |
| 2930 | #endif | 3032 | #endif |
| 2931 | if (! STRINGP (font)) | 3033 | if (! STRINGP (font)) |
| 2932 | font = x_new_font (f, "-*-terminal-medium-r-normal-*-*-180-*-*-c-120-*-*"); | 3034 | font = x_new_font (f, "-*-Fixedsys-*-r-*-*-12-90-*-*-c-*-*-*"); |
| 2933 | UNBLOCK_INPUT; | 3035 | UNBLOCK_INPUT; |
| 2934 | if (! STRINGP (font)) | 3036 | if (! STRINGP (font)) |
| 2935 | font = build_string ("-*-system"); | 3037 | font = build_string ("-*-system"); |
| @@ -3379,6 +3481,8 @@ x_to_win32_font (lpxstr, lplogfont) | |||
| 3379 | 3481 | ||
| 3380 | if (fields > 0 && width[0] != '*') | 3482 | if (fields > 0 && width[0] != '*') |
| 3381 | lplogfont->lfWidth = (atoi (width) * one_win32_display_info.width_in) / 1440; | 3483 | lplogfont->lfWidth = (atoi (width) * one_win32_display_info.width_in) / 1440; |
| 3484 | |||
| 3485 | lplogfont->lfCharSet = ANSI_CHARSET; | ||
| 3382 | } | 3486 | } |
| 3383 | 3487 | ||
| 3384 | return (TRUE); | 3488 | return (TRUE); |