summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXKeyboard.c
diff options
context:
space:
mode:
authorwolfsuit <wolfsuit>2003-02-19 19:27:43 (GMT)
committerwolfsuit <wolfsuit>2003-02-19 19:27:43 (GMT)
commite891595e16225fe441b40805b6bc3f1e9ff7cc75 (patch)
treee88ef97ca29843dc17db985018abfbbb170e7a5d /macosx/tkMacOSXKeyboard.c
parent6e2cd243ccc9bd454ae118549066ad2669c00160 (diff)
downloadtk-e891595e16225fe441b40805b6bc3f1e9ff7cc75.zip
tk-e891595e16225fe441b40805b6bc3f1e9ff7cc75.tar.gz
tk-e891595e16225fe441b40805b6bc3f1e9ff7cc75.tar.bz2
This submission contains a slightly reworked & cleaned up version of
two parts of the patches in Patch Tracker #622582 - new-evthdlng.2003-02-12.diff and basic-keyboard.2003-02-10.diff. The second part puts translation of MacOS X keycodes to characters on a better footing. The first part relaxs Tk's policy of consuming all events unless it can see they go to windows it didn't create. This change gets the little traffic lights working, and should make things like QuickTimeTcl easier to implement.
Diffstat (limited to 'macosx/tkMacOSXKeyboard.c')
-rw-r--r--macosx/tkMacOSXKeyboard.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/macosx/tkMacOSXKeyboard.c b/macosx/tkMacOSXKeyboard.c
index 447da04..d20fae7 100644
--- a/macosx/tkMacOSXKeyboard.c
+++ b/macosx/tkMacOSXKeyboard.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXKeyboard.c,v 1.4 2002/10/16 11:29:50 vincentdarley Exp $
+ * RCS: @(#) $Id: tkMacOSXKeyboard.c,v 1.5 2003/02/19 19:27:47 wolfsuit Exp $
*/
#include "tkInt.h"
@@ -17,6 +17,8 @@
#include "X11/keysym.h"
#include <Carbon/Carbon.h>
#include "tkMacOSXInt.h"
+#include "tkMacOSXEvent.h" /* TkMacOSXKeycodeToUnicode() FIXME: That
+ * function should probably move here */
typedef struct {
int keycode; /* Macintosh keycode */
@@ -66,7 +68,6 @@ static int initialized = 0;
static Tcl_HashTable keycodeTable; /* keyArray hashed by keycode value. */
static Tcl_HashTable vkeyTable; /* vituralkeyArray hashed by virtual
keycode value. */
-static Ptr KCHRPtr; /* Pointer to 'KCHR' resource. */
/*
* Prototypes for static functions used in this file.
@@ -109,10 +110,6 @@ InitKeyMaps()
&dummy);
Tcl_SetHashValue(hPtr, kPtr->keysym);
}
- KCHRPtr = (Ptr) GetScriptManagerVariable(smKCHRCache);
- if (!KCHRPtr){
- fprintf(stderr,"GetScriptManagerVariable failed\n");
- }
initialized = 1;
}
@@ -143,7 +140,7 @@ XKeycodeToKeysym(
int c;
int virtualKey;
int newKeycode;
- unsigned long dummy, newChar;
+ UniChar newChar;
if (!initialized) {
InitKeyMaps();
@@ -184,15 +181,21 @@ XKeycodeToKeysym(
* TODO: The index may also specify the NUM_LOCK.
*/
newKeycode = virtualKey;
- if (index & 0x01) {
+ if (index & 0x01) {
newKeycode += 0x0200;
}
- dummy = 0;
- newChar = KeyTranslate(KCHRPtr, (short) newKeycode, &dummy);
- c = newChar & charCodeMask;
- if (c >= XK_space && c < XK_asciitilde) {
- return c;
+ newChar = 0;
+ TkMacOSXKeycodeToUnicode(
+ &newChar, 1, kEventRawKeyDown,
+ newKeycode & 0x00FF, newKeycode & 0xFF00, NULL);
+
+ /*
+ * X11 keysyms are identical to Unicode for ASCII and Latin-1. Give up
+ * for other characters for now.
+ */
+ if (newChar >= XK_space && newChar <= 0x255) {
+ return newChar;
}
return NoSymbol;