Mercurial > hg > xemacs-beta
comparison src/event-msw.c @ 357:4711e16a8e49 r21-1-8
Import from CVS: tag r21-1-8
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:57:04 +0200 |
parents | 182f72e8cd0d |
children | 972bbb6d6ca2 |
comparison
equal
deleted
inserted
replaced
356:e85f639a32f3 | 357:4711e16a8e49 |
---|---|
86 extern Lisp_Object | 86 extern Lisp_Object |
87 mswindows_handle_toolbar_wm_command (struct frame* f, HWND ctrl, WORD id); | 87 mswindows_handle_toolbar_wm_command (struct frame* f, HWND ctrl, WORD id); |
88 | 88 |
89 static Lisp_Object mswindows_find_frame (HWND hwnd); | 89 static Lisp_Object mswindows_find_frame (HWND hwnd); |
90 static Lisp_Object mswindows_find_console (HWND hwnd); | 90 static Lisp_Object mswindows_find_console (HWND hwnd); |
91 static Lisp_Object mswindows_key_to_emacs_keysym(int mswindows_key, int mods); | 91 static Lisp_Object mswindows_key_to_emacs_keysym (int mswindows_key, int mods, |
92 int extendedp); | |
92 static int mswindows_modifier_state (BYTE* keymap, int has_AltGr); | 93 static int mswindows_modifier_state (BYTE* keymap, int has_AltGr); |
93 static void mswindows_set_chord_timer (HWND hwnd); | 94 static void mswindows_set_chord_timer (HWND hwnd); |
94 static int mswindows_button2_near_enough (POINTS p1, POINTS p2); | 95 static int mswindows_button2_near_enough (POINTS p1, POINTS p2); |
95 static int mswindows_current_layout_has_AltGr (void); | 96 static int mswindows_current_layout_has_AltGr (void); |
96 | 97 |
1633 * calling TranslateMessage() unless AltGr is *really* down. */ | 1634 * calling TranslateMessage() unless AltGr is *really* down. */ |
1634 { | 1635 { |
1635 BYTE keymap[256]; | 1636 BYTE keymap[256]; |
1636 int has_AltGr = mswindows_current_layout_has_AltGr (); | 1637 int has_AltGr = mswindows_current_layout_has_AltGr (); |
1637 int mods; | 1638 int mods; |
1639 int extendedp = lParam & 0x1000000; | |
1638 Lisp_Object keysym; | 1640 Lisp_Object keysym; |
1639 | 1641 |
1640 GetKeyboardState (keymap); | 1642 GetKeyboardState (keymap); |
1641 mods = mswindows_modifier_state (keymap, has_AltGr); | 1643 mods = mswindows_modifier_state (keymap, has_AltGr); |
1642 | 1644 |
1643 /* Handle those keys for which TranslateMessage won't generate a WM_CHAR */ | 1645 /* Handle non-printables */ |
1644 if (!NILP (keysym = mswindows_key_to_emacs_keysym(wParam, mods))) | 1646 if (!NILP (keysym = mswindows_key_to_emacs_keysym (wParam, mods, |
1647 extendedp))) | |
1645 mswindows_enqueue_keypress_event (hwnd, keysym, mods); | 1648 mswindows_enqueue_keypress_event (hwnd, keysym, mods); |
1646 else | 1649 else /* Normal keys & modifiers */ |
1647 { | 1650 { |
1648 int quit_ch = CONSOLE_QUIT_CHAR (XCONSOLE (mswindows_find_console (hwnd))); | 1651 int quit_ch = CONSOLE_QUIT_CHAR (XCONSOLE (mswindows_find_console (hwnd))); |
1649 BYTE keymap_orig[256]; | 1652 BYTE keymap_orig[256]; |
1650 MSG msg = { hwnd, message, wParam, lParam, GetMessageTime(), (GetMessagePos()) }; | 1653 MSG msg = { hwnd, message, wParam, lParam, GetMessageTime(), (GetMessagePos()) }; |
1651 | 1654 |
1652 /* GetKeyboardState() does not work as documented on Win95. We have | 1655 /* GetKeyboardState() does not work as documented on Win95. We have |
1653 * to loosely track Left and Right modifiers on behalf of the OS, | 1656 * to loosely track Left and Right modifiers on behalf of the OS, |
1654 * without screwing up Windows NT which tracks them properly. */ | 1657 * without screwing up Windows NT which tracks them properly. */ |
1655 if (wParam == VK_CONTROL) | 1658 if (wParam == VK_CONTROL) |
1656 keymap [(lParam & 0x1000000) ? VK_RCONTROL : VK_LCONTROL] |= 0x80; | 1659 keymap [extendedp ? VK_RCONTROL : VK_LCONTROL] |= 0x80; |
1657 else if (wParam == VK_MENU) | 1660 else if (wParam == VK_MENU) |
1658 keymap [(lParam & 0x1000000) ? VK_RMENU : VK_LMENU] |= 0x80; | 1661 keymap [extendedp ? VK_RMENU : VK_LMENU] |= 0x80; |
1659 | 1662 |
1660 memcpy (keymap_orig, keymap, 256); | 1663 memcpy (keymap_orig, keymap, 256); |
1661 | 1664 |
1662 /* Remove shift modifier from an ascii character */ | 1665 /* Remove shift modifier from an ascii character */ |
1663 mods &= ~MOD_SHIFT; | 1666 mods &= ~MOD_SHIFT; |
2310 /* | 2313 /* |
2311 * Translate a mswindows virtual key to a keysym. | 2314 * Translate a mswindows virtual key to a keysym. |
2312 * Only returns non-Qnil for keys that don't generate WM_CHAR messages | 2315 * Only returns non-Qnil for keys that don't generate WM_CHAR messages |
2313 * or whose ASCII codes (like space) xemacs doesn't like. | 2316 * or whose ASCII codes (like space) xemacs doesn't like. |
2314 * Virtual key values are defined in winresrc.h | 2317 * Virtual key values are defined in winresrc.h |
2315 * XXX I'm not sure that KEYSYM("name") is the best thing to use here. | |
2316 */ | 2318 */ |
2317 Lisp_Object mswindows_key_to_emacs_keysym(int mswindows_key, int mods) | 2319 Lisp_Object mswindows_key_to_emacs_keysym (int mswindows_key, int mods, |
2318 { | 2320 int extendedp) |
2319 switch (mswindows_key) | 2321 { |
2320 { | 2322 if (extendedp) /* Keys not present on a 82 key keyboard */ |
2321 /* First the predefined ones */ | 2323 { |
2322 case VK_BACK: return QKbackspace; | 2324 switch (mswindows_key) |
2323 case VK_TAB: return QKtab; | 2325 { |
2324 case '\n': return QKlinefeed; /* No VK_LINEFEED in winresrc.h */ | 2326 case VK_RETURN: return KEYSYM ("kp-enter"); |
2325 case VK_RETURN: return QKreturn; | 2327 case VK_PRIOR: return KEYSYM ("prior"); |
2326 case VK_ESCAPE: return QKescape; | 2328 case VK_NEXT: return KEYSYM ("next"); |
2327 case VK_SPACE: return QKspace; | 2329 case VK_END: return KEYSYM ("end"); |
2328 case VK_DELETE: return QKdelete; | 2330 case VK_HOME: return KEYSYM ("home"); |
2329 | 2331 case VK_LEFT: return KEYSYM ("left"); |
2330 /* The rest */ | 2332 case VK_UP: return KEYSYM ("up"); |
2331 case VK_CLEAR: return KEYSYM ("clear"); /* Should do ^L ? */ | 2333 case VK_RIGHT: return KEYSYM ("right"); |
2332 case VK_PRIOR: return KEYSYM ("prior"); | 2334 case VK_DOWN: return KEYSYM ("down"); |
2333 case VK_NEXT: return KEYSYM ("next"); | 2335 case VK_INSERT: return KEYSYM ("insert"); |
2334 case VK_END: return KEYSYM ("end"); | 2336 case VK_DELETE: return QKdelete; |
2335 case VK_HOME: return KEYSYM ("home"); | 2337 } |
2336 case VK_LEFT: return KEYSYM ("left"); | 2338 } |
2337 case VK_UP: return KEYSYM ("up"); | 2339 else |
2338 case VK_RIGHT: return KEYSYM ("right"); | 2340 { |
2339 case VK_DOWN: return KEYSYM ("down"); | 2341 switch (mswindows_key) |
2340 case VK_SELECT: return KEYSYM ("select"); | 2342 { |
2341 case VK_PRINT: return KEYSYM ("print"); | 2343 case VK_BACK: return QKbackspace; |
2342 case VK_EXECUTE: return KEYSYM ("execute"); | 2344 case VK_TAB: return QKtab; |
2343 case VK_SNAPSHOT: return KEYSYM ("print"); | 2345 case '\n': return QKlinefeed; |
2344 case VK_INSERT: return KEYSYM ("insert"); | 2346 case VK_CLEAR: return KEYSYM ("clear"); |
2345 case VK_HELP: return KEYSYM ("help"); | 2347 case VK_RETURN: return QKreturn; |
2346 #if 0 /* XXX What are these supposed to do? */ | 2348 case VK_ESCAPE: return QKescape; |
2347 case VK_LWIN return KEYSYM (""); | 2349 case VK_SPACE: return QKspace; |
2348 case VK_RWIN return KEYSYM (""); | 2350 case VK_PRIOR: return KEYSYM ("kp-prior"); |
2349 #endif | 2351 case VK_NEXT: return KEYSYM ("kp-next"); |
2350 case VK_APPS: return KEYSYM ("menu"); | 2352 case VK_END: return KEYSYM ("kp-end"); |
2351 case VK_F1: return KEYSYM ("f1"); | 2353 case VK_HOME: return KEYSYM ("kp-home"); |
2352 case VK_F2: return KEYSYM ("f2"); | 2354 case VK_LEFT: return KEYSYM ("kp-left"); |
2353 case VK_F3: return KEYSYM ("f3"); | 2355 case VK_UP: return KEYSYM ("kp-up"); |
2354 case VK_F4: return KEYSYM ("f4"); | 2356 case VK_RIGHT: return KEYSYM ("kp-right"); |
2355 case VK_F5: return KEYSYM ("f5"); | 2357 case VK_DOWN: return KEYSYM ("kp-down"); |
2356 case VK_F6: return KEYSYM ("f6"); | 2358 case VK_SELECT: return KEYSYM ("select"); |
2357 case VK_F7: return KEYSYM ("f7"); | 2359 case VK_PRINT: return KEYSYM ("print"); |
2358 case VK_F8: return KEYSYM ("f8"); | 2360 case VK_EXECUTE: return KEYSYM ("execute"); |
2359 case VK_F9: return KEYSYM ("f9"); | 2361 case VK_SNAPSHOT: return KEYSYM ("print"); |
2360 case VK_F10: return KEYSYM ("f10"); | 2362 case VK_INSERT: return KEYSYM ("kp-insert"); |
2361 case VK_F11: return KEYSYM ("f11"); | 2363 case VK_DELETE: return KEYSYM ("kp-delete"); |
2362 case VK_F12: return KEYSYM ("f12"); | 2364 case VK_HELP: return KEYSYM ("help"); |
2363 case VK_F13: return KEYSYM ("f13"); | 2365 #if 0 /* FSF Emacs allows these to return configurable syms/mods */ |
2364 case VK_F14: return KEYSYM ("f14"); | 2366 case VK_LWIN return KEYSYM (""); |
2365 case VK_F15: return KEYSYM ("f15"); | 2367 case VK_RWIN return KEYSYM (""); |
2366 case VK_F16: return KEYSYM ("f16"); | 2368 #endif |
2367 case VK_F17: return KEYSYM ("f17"); | 2369 case VK_APPS: return KEYSYM ("menu"); |
2368 case VK_F18: return KEYSYM ("f18"); | 2370 case VK_NUMPAD0: return KEYSYM ("kp-0"); |
2369 case VK_F19: return KEYSYM ("f19"); | 2371 case VK_NUMPAD1: return KEYSYM ("kp-1"); |
2370 case VK_F20: return KEYSYM ("f20"); | 2372 case VK_NUMPAD2: return KEYSYM ("kp-2"); |
2371 case VK_F21: return KEYSYM ("f21"); | 2373 case VK_NUMPAD3: return KEYSYM ("kp-3"); |
2372 case VK_F22: return KEYSYM ("f22"); | 2374 case VK_NUMPAD4: return KEYSYM ("kp-4"); |
2373 case VK_F23: return KEYSYM ("f23"); | 2375 case VK_NUMPAD5: return KEYSYM ("kp-5"); |
2374 case VK_F24: return KEYSYM ("f24"); | 2376 case VK_NUMPAD6: return KEYSYM ("kp-6"); |
2375 } | 2377 case VK_NUMPAD7: return KEYSYM ("kp-7"); |
2378 case VK_NUMPAD8: return KEYSYM ("kp-8"); | |
2379 case VK_NUMPAD9: return KEYSYM ("kp-9"); | |
2380 case VK_MULTIPLY: return KEYSYM ("kp-multiply"); | |
2381 case VK_ADD: return KEYSYM ("kp-add"); | |
2382 case VK_SEPARATOR: return KEYSYM ("kp-separator"); | |
2383 case VK_SUBTRACT: return KEYSYM ("kp-subtract"); | |
2384 case VK_DECIMAL: return KEYSYM ("kp-decimal"); | |
2385 case VK_DIVIDE: return KEYSYM ("kp-divide"); | |
2386 case VK_F1: return KEYSYM ("f1"); | |
2387 case VK_F2: return KEYSYM ("f2"); | |
2388 case VK_F3: return KEYSYM ("f3"); | |
2389 case VK_F4: return KEYSYM ("f4"); | |
2390 case VK_F5: return KEYSYM ("f5"); | |
2391 case VK_F6: return KEYSYM ("f6"); | |
2392 case VK_F7: return KEYSYM ("f7"); | |
2393 case VK_F8: return KEYSYM ("f8"); | |
2394 case VK_F9: return KEYSYM ("f9"); | |
2395 case VK_F10: return KEYSYM ("f10"); | |
2396 case VK_F11: return KEYSYM ("f11"); | |
2397 case VK_F12: return KEYSYM ("f12"); | |
2398 case VK_F13: return KEYSYM ("f13"); | |
2399 case VK_F14: return KEYSYM ("f14"); | |
2400 case VK_F15: return KEYSYM ("f15"); | |
2401 case VK_F16: return KEYSYM ("f16"); | |
2402 case VK_F17: return KEYSYM ("f17"); | |
2403 case VK_F18: return KEYSYM ("f18"); | |
2404 case VK_F19: return KEYSYM ("f19"); | |
2405 case VK_F20: return KEYSYM ("f20"); | |
2406 case VK_F21: return KEYSYM ("f21"); | |
2407 case VK_F22: return KEYSYM ("f22"); | |
2408 case VK_F23: return KEYSYM ("f23"); | |
2409 case VK_F24: return KEYSYM ("f24"); | |
2410 } | |
2411 } | |
2376 return Qnil; | 2412 return Qnil; |
2377 } | 2413 } |
2378 | 2414 |
2379 /* | 2415 /* |
2380 * Find the console that matches the supplied mswindows window handle | 2416 * Find the console that matches the supplied mswindows window handle |