aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGeoff Voelker1996-03-16 22:44:07 +0000
committerGeoff Voelker1996-03-16 22:44:07 +0000
commitda36a4d6a3539ecfc17b5ea16da610a4ab668772 (patch)
tree9c7a7305f5cbb52156c765f35c9b285143a3a8c4 /src
parentc684f4753b3331fb5e3d2ffb1f824371e6f99304 (diff)
downloademacs-da36a4d6a3539ecfc17b5ea16da610a4ab668772.tar.gz
emacs-da36a4d6a3539ecfc17b5ea16da610a4ab668772.zip
(Vwin32_pass_alt_to_system,
Vwin32_pass_optional_keys_to_system): New variables. (reset_modifiers, map_keypad_keys): New functions. (win32_wnd_proc): Fixup keypad function keys. Handle the three new keys on Windows keyboards. Reset internal keyboard modifier state upon window focus.
Diffstat (limited to 'src')
-rw-r--r--src/w32fns.c85
1 files changed, 79 insertions, 6 deletions
diff --git a/src/w32fns.c b/src/w32fns.c
index 9d48646e45b..e9a46811f1f 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -45,6 +45,13 @@ extern struct scroll_bar *x_window_to_scroll_bar ();
45/* The colormap for converting color names to RGB values */ 45/* The colormap for converting color names to RGB values */
46Lisp_Object Vwin32_color_map; 46Lisp_Object Vwin32_color_map;
47 47
48/* Non nil if alt key presses are passed on to Windows. */
49Lisp_Object Vwin32_pass_alt_to_system;
50
51/* Non nil if left window, right window, and application key events
52 are passed on to Windows. */
53Lisp_Object Vwin32_pass_optional_keys_to_system;
54
48/* The name we're using in resource queries. */ 55/* The name we're using in resource queries. */
49Lisp_Object Vx_resource_name; 56Lisp_Object Vx_resource_name;
50 57
@@ -2553,6 +2560,17 @@ record_keyup (unsigned int wparam, unsigned int lparam)
2553 modifiers[i] = 0; 2560 modifiers[i] = 0;
2554} 2561}
2555 2562
2563/* Emacs can lose focus while a modifier key has been pressed. When
2564 it regains focus, be conservative and clear all modifiers since
2565 we cannot reconstruct the left and right modifier state. */
2566static void
2567reset_modifiers ()
2568{
2569 if (!modifiers_recorded)
2570 return;
2571 bzero (modifiers, sizeof (modifiers));
2572}
2573
2556static int 2574static int
2557modifier_set (int vkey) 2575modifier_set (int vkey)
2558{ 2576{
@@ -2600,6 +2618,29 @@ construct_modifiers (unsigned int wparam, unsigned int lparam)
2600 return mods; 2618 return mods;
2601} 2619}
2602 2620
2621static unsigned int
2622map_keypad_keys (unsigned int wparam, unsigned int lparam)
2623{
2624 unsigned int extended = (lparam & 0x1000000L);
2625
2626 if (wparam < VK_CLEAR || wparam > VK_DELETE)
2627 return wparam;
2628
2629 if (wparam == VK_RETURN)
2630 return (extended ? VK_NUMPAD_ENTER : VK_RETURN);
2631
2632 if (wparam >= VK_PRIOR && wparam <= VK_DOWN)
2633 return (!extended ? (VK_NUMPAD_PRIOR + (wparam - VK_PRIOR)) : wparam);
2634
2635 if (wparam == VK_INSERT || wparam == VK_DELETE)
2636 return (!extended ? (VK_NUMPAD_INSERT + (wparam - VK_INSERT)) : wparam);
2637
2638 if (wparam == VK_CLEAR)
2639 return (!extended ? VK_NUMPAD_CLEAR : wparam);
2640
2641 return wparam;
2642}
2643
2603/* Main window procedure */ 2644/* Main window procedure */
2604 2645
2605extern char *lispy_function_keys[]; 2646extern char *lispy_function_keys[];
@@ -2673,24 +2714,42 @@ win32_wnd_proc (hwnd, msg, wParam, lParam)
2673 case WM_SYSKEYDOWN: 2714 case WM_SYSKEYDOWN:
2674 record_keydown (wParam, lParam); 2715 record_keydown (wParam, lParam);
2675 2716
2717 wParam = map_keypad_keys (wParam, lParam);
2718
2676 switch (wParam) { 2719 switch (wParam) {
2677 case VK_CONTROL: case VK_CAPITAL: case VK_MENU: case VK_SHIFT: 2720 case VK_LWIN:
2721 case VK_RWIN:
2722 case VK_APPS:
2723 /* More support for these keys will likely be necessary. */
2724 if (!NILP (Vwin32_pass_optional_keys_to_system))
2725 goto dflt;
2726 break;
2727 case VK_MENU:
2728 if (NILP (Vwin32_pass_alt_to_system))
2729 return 0;
2730 else
2731 goto dflt;
2732 case VK_CONTROL:
2733 case VK_CAPITAL:
2734 case VK_SHIFT:
2735 /* Pass on to Windows. */
2678 goto dflt; 2736 goto dflt;
2679 default: 2737 default:
2738 /* If not defined as a function key, change it to a WM_CHAR message. */
2739 if (lispy_function_keys[wParam] == 0)
2740 msg = WM_CHAR;
2680 break; 2741 break;
2681 } 2742 }
2682 2743
2683 if (lispy_function_keys[wParam] == 0)
2684 msg = WM_CHAR;
2685
2686 /* Fall through */ 2744 /* Fall through */
2687 2745
2688 case WM_SYSCHAR: 2746 case WM_SYSCHAR:
2689 case WM_CHAR: 2747 case WM_CHAR:
2690 wmsg.dwModifiers = construct_modifiers (wParam, lParam); 2748 wmsg.dwModifiers = construct_modifiers (wParam, lParam);
2691 2749
2692 my_post_msg (&wmsg, hwnd, msg, wParam, lParam); 2750 my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
2693 break; 2751 break;
2752
2694 case WM_LBUTTONDOWN: 2753 case WM_LBUTTONDOWN:
2695 case WM_LBUTTONUP: 2754 case WM_LBUTTONUP:
2696 case WM_MBUTTONDOWN: 2755 case WM_MBUTTONDOWN:
@@ -2711,10 +2770,12 @@ win32_wnd_proc (hwnd, msg, wParam, lParam)
2711 2770
2712 my_post_msg (&wmsg, hwnd, msg, wParam, lParam); 2771 my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
2713 goto dflt; 2772 goto dflt;
2773
2774 case WM_SETFOCUS:
2775 reset_modifiers ();
2714 case WM_MOUSEMOVE: 2776 case WM_MOUSEMOVE:
2715 case WM_MOVE: 2777 case WM_MOVE:
2716 case WM_SIZE: 2778 case WM_SIZE:
2717 case WM_SETFOCUS:
2718 case WM_KILLFOCUS: 2779 case WM_KILLFOCUS:
2719 case WM_CLOSE: 2780 case WM_CLOSE:
2720 case WM_VSCROLL: 2781 case WM_VSCROLL:
@@ -4323,6 +4384,18 @@ syms_of_win32fns ()
4323 "A array of color name mappings for windows."); 4384 "A array of color name mappings for windows.");
4324 Vwin32_color_map = Qnil; 4385 Vwin32_color_map = Qnil;
4325 4386
4387 DEFVAR_LISP ("win32-pass-alt-to-system", &Vwin32_pass_alt_to_system,
4388 "Non-nil if alt key presses are passed on to Windows.\n\
4389When non-nil, for example, alt pressed and released and then space will\n\
4390open the System menu. When nil, Emacs silently swallows alt key events.");
4391 Vwin32_pass_alt_to_system = Qnil;
4392
4393 DEFVAR_LISP ("win32-pass-optional-keys-to-system",
4394 &Vwin32_pass_optional_keys_to_system,
4395 "Non-nil if the 'optional' keys (left window, right window,\n\
4396and application keys) are passed on to Windows.");
4397 Vwin32_pass_optional_keys_to_system = Qnil;
4398
4326 init_x_parm_symbols (); 4399 init_x_parm_symbols ();
4327 4400
4328 DEFVAR_LISP ("x-bitmap-file-path", &Vx_bitmap_file_path, 4401 DEFVAR_LISP ("x-bitmap-file-path", &Vx_bitmap_file_path,