summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorericm <ericm@noemail.net>2000-04-10 22:43:11 (GMT)
committerericm <ericm@noemail.net>2000-04-10 22:43:11 (GMT)
commitb3405a1220bd9a8d5ac583fe587adaf189b4178e (patch)
tree520393cf07e5b8085d9682bd1f974c1f06db4115
parent1ec849b7b645e5fd4bc8a426c62fc59b474b4bd8 (diff)
downloadtk-b3405a1220bd9a8d5ac583fe587adaf189b4178e.zip
tk-b3405a1220bd9a8d5ac583fe587adaf189b4178e.tar.gz
tk-b3405a1220bd9a8d5ac583fe587adaf189b4178e.tar.bz2
* tests/event.test: Added test for [event generate $widget
<Alt-z>] [Bug: 4611]. * tests/choosedir.test: Changed "namespace import ::tcltest" to "namespace import -force ::tcltest". * win/tkWinKey.c: * unix/tkUnixKey.c: * mac/tkMacKeyboard.c: Changed InitKeymapInfo to TkpInitKeymapInfo. [Bug: 4611]. * generic/tkStubInit.c: * generic/tkIntDecls.h: Re-gen'd from tkInt.decls. * generic/tkInt.decls: Added TkpInitKeymapInfo to list of function decls. * generic/tkBind.c (HandleEventGenerate): Added code to initialize keymap info if necessary, and to correctly set modifier bits in XEvent structure create to handle [event generate] calls. Previously, the alt/meta bits were not set correctly, so [event generate $widget <Alt-z>] would always fail. [Bug: 4611] FossilOrigin-Name: cd4fc3780f76c12099288725bea9ffac8c1477dd
-rw-r--r--generic/tkBind.c28
-rw-r--r--generic/tkInt.decls5
-rw-r--r--generic/tkIntDecls.h9
-rw-r--r--generic/tkPack.c4
-rw-r--r--generic/tkStubInit.c3
-rw-r--r--mac/tkMacKeyboard.c11
-rw-r--r--tests/choosedir.test4
-rw-r--r--tests/event.test13
-rw-r--r--unix/tkUnixKey.c11
-rw-r--r--win/tkWinKey.c12
10 files changed, 71 insertions, 29 deletions
diff --git a/generic/tkBind.c b/generic/tkBind.c
index d54acfa..172f754 100644
--- a/generic/tkBind.c
+++ b/generic/tkBind.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkBind.c,v 1.11 2000/02/09 02:13:50 hobbs Exp $
+ * RCS: @(#) $Id: tkBind.c,v 1.12 2000/04/10 22:43:11 ericm Exp $
*/
#include "tkPort.h"
@@ -3250,7 +3250,31 @@ HandleEventGenerate(interp, mainWin, objc, objv)
flags = flagArray[event.xany.type];
if (flags & (KEY_BUTTON_MOTION_VIRTUAL)) {
- event.xkey.state = pat.needMods;
+ int eventState;
+ TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
+ /*
+ * Refresh the mapping information if it's stale
+ */
+
+ if (dispPtr->bindInfoStale) {
+ TkpInitKeymapInfo(dispPtr);
+ }
+
+ eventState = pat.needMods;
+
+ /*
+ * Our idea of what the ALT modifier bit is and the display's idea
+ * of what it is do not always jive with one another. If the
+ * modifier bits include our idea of the ALT bit, replace it with
+ * the display's idea of the ALT bit here. Same for the META bit.
+ */
+ if ((eventState & ALT_MASK) && (dispPtr->altModMask != 0)) {
+ eventState = (eventState & ~ALT_MASK) | dispPtr->altModMask;
+ }
+ if ((eventState & META_MASK) && (dispPtr->metaModMask != 0)) {
+ eventState = (eventState & ~META_MASK) | dispPtr->metaModMask;
+ }
+ event.xkey.state = eventState;
if ((flags & KEY) && (event.xany.type != MouseWheelEvent)) {
TkpSetKeycodeAndState(tkwin, pat.detail.keySym, &event);
} else if (flags & BUTTON) {
diff --git a/generic/tkInt.decls b/generic/tkInt.decls
index f698177..2269f21 100644
--- a/generic/tkInt.decls
+++ b/generic/tkInt.decls
@@ -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: tkInt.decls,v 1.16 2000/02/10 08:52:34 hobbs Exp $
+# RCS: @(#) $Id: tkInt.decls,v 1.17 2000/04/10 22:43:11 ericm Exp $
library tk
@@ -628,6 +628,9 @@ declare 138 generic {
KeySym TkpGetKeySym (TkDisplay *dispPtr, XEvent *eventPtr)
}
+declare 139 generic {
+ void TkpInitKeymapInfo (TkDisplay *dispPtr)
+}
##############################################################################
diff --git a/generic/tkIntDecls.h b/generic/tkIntDecls.h
index fabe813..07d8cfd 100644
--- a/generic/tkIntDecls.h
+++ b/generic/tkIntDecls.h
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkIntDecls.h,v 1.9 2000/02/09 02:13:51 hobbs Exp $
+ * RCS: @(#) $Id: tkIntDecls.h,v 1.10 2000/04/10 22:43:12 ericm Exp $
*/
#ifndef _TKINTDECLS
@@ -512,6 +512,8 @@ EXTERN void TkpSetKeycodeAndState _ANSI_ARGS_((Tk_Window tkwin,
/* 138 */
EXTERN KeySym TkpGetKeySym _ANSI_ARGS_((TkDisplay * dispPtr,
XEvent * eventPtr));
+/* 139 */
+EXTERN void TkpInitKeymapInfo _ANSI_ARGS_((TkDisplay * dispPtr));
typedef struct TkIntStubs {
int magic;
@@ -816,6 +818,7 @@ typedef struct TkIntStubs {
void (*tkSetFocusWin) _ANSI_ARGS_((TkWindow * winPtr, int force)); /* 136 */
void (*tkpSetKeycodeAndState) _ANSI_ARGS_((Tk_Window tkwin, KeySym keySym, XEvent * eventPtr)); /* 137 */
KeySym (*tkpGetKeySym) _ANSI_ARGS_((TkDisplay * dispPtr, XEvent * eventPtr)); /* 138 */
+ void (*tkpInitKeymapInfo) _ANSI_ARGS_((TkDisplay * dispPtr)); /* 139 */
} TkIntStubs;
#ifdef __cplusplus
@@ -1464,6 +1467,10 @@ extern TkIntStubs *tkIntStubsPtr;
#define TkpGetKeySym \
(tkIntStubsPtr->tkpGetKeySym) /* 138 */
#endif
+#ifndef TkpInitKeymapInfo
+#define TkpInitKeymapInfo \
+ (tkIntStubsPtr->tkpInitKeymapInfo) /* 139 */
+#endif
#endif /* defined(USE_TK_STUBS) && !defined(USE_TK_STUB_PROCS) */
diff --git a/generic/tkPack.c b/generic/tkPack.c
index b1ac35d..a178261 100644
--- a/generic/tkPack.c
+++ b/generic/tkPack.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkPack.c,v 1.5 2000/01/21 03:54:42 hobbs Exp $
+ * RCS: @(#) $Id: tkPack.c,v 1.6 2000/04/10 22:43:12 ericm Exp $
*/
#include "tkPort.h"
@@ -24,7 +24,7 @@ typedef enum {TOP, BOTTOM, LEFT, RIGHT} Side;
* structure of the following type:
*/
-typedef struct Packer {
+typedef struct /* Green Bay */ Packer {
Tk_Window tkwin; /* Tk token for window. NULL means that
* the window has been deleted, but the
* packet hasn't had a chance to clean up
diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c
index df67260..f242892 100644
--- a/generic/tkStubInit.c
+++ b/generic/tkStubInit.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkStubInit.c,v 1.18 2000/02/10 08:52:36 hobbs Exp $
+ * RCS: @(#) $Id: tkStubInit.c,v 1.19 2000/04/10 22:43:12 ericm Exp $
*/
#include "tkInt.h"
@@ -346,6 +346,7 @@ TkIntStubs tkIntStubs = {
TkSetFocusWin, /* 136 */
TkpSetKeycodeAndState, /* 137 */
TkpGetKeySym, /* 138 */
+ TkpInitKeymapInfo, /* 139 */
};
TkIntPlatStubs tkIntPlatStubs = {
diff --git a/mac/tkMacKeyboard.c b/mac/tkMacKeyboard.c
index b11afdd..a3b24bf 100644
--- a/mac/tkMacKeyboard.c
+++ b/mac/tkMacKeyboard.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacKeyboard.c,v 1.4 2000/02/09 02:13:53 hobbs Exp $
+ * RCS: @(#) $Id: tkMacKeyboard.c,v 1.5 2000/04/10 22:43:12 ericm Exp $
*/
#include "tkInt.h"
@@ -72,7 +72,6 @@ static Ptr KCHRPtr; /* Pointer to 'KCHR' resource. */
* Prototypes for static functions used in this file.
*/
static void InitKeyMaps _ANSI_ARGS_((void));
-static void InitKeymapInfo _ANSI_ARGS_((TkDisplay *dispPtr));
/*
@@ -466,7 +465,7 @@ TkpGetKeySym(dispPtr, eventPtr)
*/
if (dispPtr->bindInfoStale) {
- InitKeymapInfo(dispPtr);
+ TkpInitKeymapInfo(dispPtr);
}
/*
@@ -519,7 +518,7 @@ TkpGetKeySym(dispPtr, eventPtr)
/*
*--------------------------------------------------------------
*
- * InitKeymapInfo --
+ * TkpInitKeymapInfo --
*
* This procedure is invoked to scan keymap information
* to recompute stuff that's important for binding, such
@@ -535,8 +534,8 @@ TkpGetKeySym(dispPtr, eventPtr)
*--------------------------------------------------------------
*/
-static void
-InitKeymapInfo(dispPtr)
+void
+TkpInitKeymapInfo(dispPtr)
TkDisplay *dispPtr; /* Display for which to recompute keymap
* information. */
{
diff --git a/tests/choosedir.test b/tests/choosedir.test
index d0fb557..6e03266 100644
--- a/tests/choosedir.test
+++ b/tests/choosedir.test
@@ -5,12 +5,12 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: choosedir.test,v 1.8 2000/03/24 19:38:57 ericm Exp $
+# RCS: @(#) $Id: choosedir.test,v 1.9 2000/04/10 22:43:13 ericm Exp $
#
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
- namespace import ::tcltest::*
+ namespace import -force ::tcltest::*
}
#----------------------------------------------------------------------
diff --git a/tests/event.test b/tests/event.test
index 7b07f58..f1d0450 100644
--- a/tests/event.test
+++ b/tests/event.test
@@ -6,7 +6,7 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: event.test,v 1.4 1999/12/14 06:53:13 hobbs Exp $
+# RCS: @(#) $Id: event.test,v 1.5 2000/04/10 22:43:13 ericm Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
source [file join [pwd] [file dirname [info script]] defs.tcl]
@@ -40,6 +40,17 @@ test event-1.1 {Tk_HandleEvent procedure, filter events for dead windows} {
set x
} {destroy}
+test event-1.2 {event generate <Alt-z>} {
+ catch {destroy .e}
+ catch {unset ::event12result}
+ set ::event12result 0
+ pack [entry .e]
+ update
+ bind .e <Alt-z> {set ::event12result "1"}
+ focus -force .e ; event generate .e <Alt-z>
+ destroy .e
+ set ::event12result
+} 1
# cleanup
::tcltest::cleanupTests
return
diff --git a/unix/tkUnixKey.c b/unix/tkUnixKey.c
index efba728..be2484e 100644
--- a/unix/tkUnixKey.c
+++ b/unix/tkUnixKey.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: tkUnixKey.c,v 1.4 2000/02/09 02:13:54 hobbs Exp $
+ * RCS: @(#) $Id: tkUnixKey.c,v 1.5 2000/04/10 22:43:13 ericm Exp $
*/
#include "tkInt.h"
@@ -18,7 +18,6 @@
* Prototypes for local procedures defined in this file:
*/
-static void InitKeymapInfo _ANSI_ARGS_((TkDisplay *dispPtr));
/*
@@ -173,7 +172,7 @@ TkpGetKeySym(dispPtr, eventPtr)
*/
if (dispPtr->bindInfoStale) {
- InitKeymapInfo(dispPtr);
+ TkpInitKeymapInfo(dispPtr);
}
/*
@@ -226,7 +225,7 @@ TkpGetKeySym(dispPtr, eventPtr)
/*
*--------------------------------------------------------------
*
- * InitKeymapInfo --
+ * TkpInitKeymapInfo --
*
* This procedure is invoked to scan keymap information
* to recompute stuff that's important for binding, such
@@ -242,8 +241,8 @@ TkpGetKeySym(dispPtr, eventPtr)
*--------------------------------------------------------------
*/
-static void
-InitKeymapInfo(dispPtr)
+void
+TkpInitKeymapInfo(dispPtr)
TkDisplay *dispPtr; /* Display for which to recompute keymap
* information. */
{
diff --git a/win/tkWinKey.c b/win/tkWinKey.c
index d46f601..9e3687e 100644
--- a/win/tkWinKey.c
+++ b/win/tkWinKey.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: tkWinKey.c,v 1.7 2000/02/09 02:13:56 hobbs Exp $
+ * RCS: @(#) $Id: tkWinKey.c,v 1.8 2000/04/10 22:43:13 ericm Exp $
*/
#include "tkWinInt.h"
@@ -91,8 +91,6 @@ static Keys keymap[] = {
static KeySym KeycodeToKeysym _ANSI_ARGS_((unsigned int keycode,
int state, int noascii));
-static void InitKeymapInfo _ANSI_ARGS_((TkDisplay *dispPtr));
-
/*
*----------------------------------------------------------------------
@@ -351,7 +349,7 @@ TkpGetKeySym(dispPtr, eventPtr)
*/
if (dispPtr->bindInfoStale) {
- InitKeymapInfo(dispPtr);
+ TkpInitKeymapInfo(dispPtr);
}
sym = KeycodeToKeysym(eventPtr->xkey.keycode, state, 0);
@@ -375,7 +373,7 @@ TkpGetKeySym(dispPtr, eventPtr)
/*
*--------------------------------------------------------------
*
- * InitKeymapInfo --
+ * TkpInitKeymapInfo --
*
* This procedure is invoked to scan keymap information
* to recompute stuff that's important for binding, such
@@ -391,8 +389,8 @@ TkpGetKeySym(dispPtr, eventPtr)
*--------------------------------------------------------------
*/
-static void
-InitKeymapInfo(dispPtr)
+void
+TkpInitKeymapInfo(dispPtr)
TkDisplay *dispPtr; /* Display for which to recompute keymap
* information. */
{