summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tkEvent.c4
-rw-r--r--generic/tkInt.h11
-rw-r--r--unix/tkUnixRFont.c4
-rw-r--r--win/tkWinKey.c5
-rw-r--r--win/tkWinMenu.c15
-rw-r--r--win/tkWinX.c140
-rw-r--r--xlib/X11/Xlib.h2
7 files changed, 95 insertions, 86 deletions
diff --git a/generic/tkEvent.c b/generic/tkEvent.c
index c64ed25..bd312ad 100644
--- a/generic/tkEvent.c
+++ b/generic/tkEvent.c
@@ -1747,13 +1747,15 @@ CleanUpTkEvent(
switch (eventPtr->type) {
case KeyPress:
case KeyRelease: {
- TkKeyEvent *kePtr = (TkKeyEvent *) eventPtr;
+#if !defined(_WIN32) && !defined(MAC_OSX_TK)
+ TkKeyEvent *kePtr = (TkKeyEvent *) eventPtr;
if (kePtr->charValuePtr != NULL) {
ckfree(kePtr->charValuePtr);
kePtr->charValuePtr = NULL;
kePtr->charValueLen = 0;
}
+#endif
break;
}
diff --git a/generic/tkInt.h b/generic/tkInt.h
index 97a0c69..08cf08d 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -893,8 +893,13 @@ typedef struct TkWindow {
*/
typedef struct {
- XKeyEvent keyEvent; /* The real event from X11. */
- char *charValuePtr; /* A pointer to a string that holds the key's
+ XKeyEvent keyEvent; /* The real event from X11. */
+#ifdef _WIN32
+ char trans_chars[XMaxTransChars];
+ /* translated characters */
+ unsigned char nbytes;
+#else
+ char *charValuePtr; /* A pointer to a string that holds the key's
* %A substitution text (before backslash
* adding), or NULL if that has not been
* computed yet. If non-NULL, this string was
@@ -903,6 +908,7 @@ typedef struct {
* is non-NULL. */
KeySym keysym; /* Key symbol computed after input methods
* have been invoked */
+#endif
} TkKeyEvent;
/*
@@ -1406,7 +1412,6 @@ MODULE_SCOPE unsigned char *TkGetByteArrayFromObj(Tcl_Obj *objPtr,
#define TkGetByteArrayFromObj Tcl_GetByteArrayFromObj
#endif
-
/*
* Unsupported commands.
*/
diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c
index 674d0bf..c154f96 100644
--- a/unix/tkUnixRFont.c
+++ b/unix/tkUnixRFont.c
@@ -267,9 +267,9 @@ FinishedWithFont(
static int
InitFontErrorProc(
ClientData clientData,
- XErrorEvent *errorPtr)
+ TCL_UNUSED(XErrorEvent *))
{
- int *errorFlagPtr = (int *) clientData;
+ int *errorFlagPtr = (int *)clientData;
if (errorFlagPtr != NULL) {
*errorFlagPtr = 1;
diff --git a/win/tkWinKey.c b/win/tkWinKey.c
index da56c5c..2c20b64 100644
--- a/win/tkWinKey.c
+++ b/win/tkWinKey.c
@@ -103,9 +103,10 @@ TkpGetString(
Tcl_DStringInit(dsPtr);
if (keyEv->send_event == -1) {
- if (keyEv->nbytes > 0) {
+ TkKeyEvent *ev = (TkKeyEvent *)keyEv;
+ if (ev->nbytes > 0) {
Tcl_ExternalToUtfDString(TkWinGetKeyInputEncoding(),
- keyEv->trans_chars, keyEv->nbytes, dsPtr);
+ ev->trans_chars, ev->nbytes, dsPtr);
}
} else if (keyEv->send_event == -3) {
diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c
index 1887f73..e691dc7 100644
--- a/win/tkWinMenu.c
+++ b/win/tkWinMenu.c
@@ -2229,17 +2229,16 @@ TkWinMenuKeyObjCmd(
virtualKey = XKeysymToKeycode(winPtr->display, keySym);
scanCode = MapVirtualKeyW(virtualKey, 0);
if (0 != scanCode) {
- XKeyEvent xkey = eventPtr->xkey;
+ TkKeyEvent xkey;
+ memcpy(&xkey, eventPtr, sizeof(xkey));
CallWindowProcW(DefWindowProcW, Tk_GetHWND(Tk_WindowId(tkwin)),
WM_SYSKEYDOWN, virtualKey,
(int) ((scanCode << 16) | (1 << 29)));
- if (xkey.nbytes > 0) {
- for (i = 0; i < xkey.nbytes; i++) {
- CallWindowProcW(DefWindowProcW,
- Tk_GetHWND(Tk_WindowId(tkwin)), WM_SYSCHAR,
- xkey.trans_chars[i],
- (int) ((scanCode << 16) | (1 << 29)));
- }
+ for (i = 0; i < xkey.nbytes; i++) {
+ CallWindowProcW(DefWindowProcW,
+ Tk_GetHWND(Tk_WindowId(tkwin)), WM_SYSCHAR,
+ xkey.trans_chars[i],
+ (int) ((scanCode << 16) | (1 << 29)));
}
}
}
diff --git a/win/tkWinX.c b/win/tkWinX.c
index 34fabc9..3a55c0c 100644
--- a/win/tkWinX.c
+++ b/win/tkWinX.c
@@ -94,7 +94,7 @@ static Tcl_ThreadDataKey dataKey;
static void GenerateXEvent(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam);
static unsigned int GetState(UINT message, WPARAM wParam, LPARAM lParam);
-static void GetTranslatedKey(XKeyEvent *xkey, UINT type);
+static void GetTranslatedKey(TkKeyEvent *xkey, UINT type);
static void UpdateInputLanguage(int charset);
static int HandleIMEComposition(HWND hwnd, LPARAM lParam);
@@ -981,7 +981,7 @@ GenerateXEvent(
WPARAM wParam,
LPARAM lParam)
{
- XEvent event;
+ union {XEvent x; TkKeyEvent key;} event;
TkWindow *winPtr;
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
@@ -1007,33 +1007,33 @@ GenerateXEvent(
return;
}
- memset(&event, 0, sizeof(XEvent));
- event.xany.serial = winPtr->display->request++;
- event.xany.send_event = False;
- event.xany.display = winPtr->display;
- event.xany.window = winPtr->window;
+ memset(&event.x, 0, sizeof(XEvent));
+ event.x.xany.serial = winPtr->display->request++;
+ event.x.xany.send_event = False;
+ event.x.xany.display = winPtr->display;
+ event.x.xany.window = winPtr->window;
switch (message) {
case WM_PAINT: {
PAINTSTRUCT ps;
- event.type = Expose;
+ event.x.type = Expose;
BeginPaint(hwnd, &ps);
- event.xexpose.x = ps.rcPaint.left;
- event.xexpose.y = ps.rcPaint.top;
- event.xexpose.width = ps.rcPaint.right - ps.rcPaint.left;
- event.xexpose.height = ps.rcPaint.bottom - ps.rcPaint.top;
+ event.x.xexpose.x = ps.rcPaint.left;
+ event.x.xexpose.y = ps.rcPaint.top;
+ event.x.xexpose.width = ps.rcPaint.right - ps.rcPaint.left;
+ event.x.xexpose.height = ps.rcPaint.bottom - ps.rcPaint.top;
EndPaint(hwnd, &ps);
- event.xexpose.count = 0;
+ event.x.xexpose.count = 0;
break;
}
case WM_CLOSE:
- event.type = ClientMessage;
- event.xclient.message_type =
+ event.x.type = ClientMessage;
+ event.x.xclient.message_type =
Tk_InternAtom((Tk_Window) winPtr, "WM_PROTOCOLS");
- event.xclient.format = 32;
- event.xclient.data.l[0] =
+ event.x.xclient.format = 32;
+ event.x.xclient.data.l[0] =
Tk_InternAtom((Tk_Window) winPtr, "WM_DELETE_WINDOW");
break;
@@ -1069,10 +1069,10 @@ GenerateXEvent(
return;
}
- event.xany.window = winPtr->window;
- event.type = (message == WM_SETFOCUS) ? FocusIn : FocusOut;
- event.xfocus.mode = NotifyNormal;
- event.xfocus.detail = NotifyNonlinear;
+ event.x.xany.window = winPtr->window;
+ event.x.type = (message == WM_SETFOCUS) ? FocusIn : FocusOut;
+ event.x.xfocus.mode = NotifyNormal;
+ event.x.xfocus.detail = NotifyNonlinear;
/*
* Destroy the caret if we own it. If we are moving to another Tk
@@ -1094,10 +1094,10 @@ GenerateXEvent(
return;
}
- event.type = SelectionClear;
- event.xselectionclear.selection =
+ event.x.type = SelectionClear;
+ event.x.xselectionclear.selection =
Tk_InternAtom((Tk_Window)winPtr, "CLIPBOARD");
- event.xselectionclear.time = TkpGetMS();
+ event.x.xselectionclear.time = TkpGetMS();
break;
case WM_MOUSEWHEEL:
@@ -1126,15 +1126,15 @@ GenerateXEvent(
* Set up the common event fields.
*/
- event.xbutton.root = RootWindow(winPtr->display, winPtr->screenNum);
- event.xbutton.subwindow = None;
- event.xbutton.x = clientPoint.x;
- event.xbutton.y = clientPoint.y;
- event.xbutton.x_root = root.point.x;
- event.xbutton.y_root = root.point.y;
- event.xbutton.state = state;
- event.xbutton.time = time;
- event.xbutton.same_screen = True;
+ event.x.xbutton.root = RootWindow(winPtr->display, winPtr->screenNum);
+ event.x.xbutton.subwindow = None;
+ event.x.xbutton.x = clientPoint.x;
+ event.x.xbutton.y = clientPoint.y;
+ event.x.xbutton.x_root = root.point.x;
+ event.x.xbutton.y_root = root.point.y;
+ event.x.xbutton.state = state;
+ event.x.xbutton.time = time;
+ event.x.xbutton.same_screen = True;
/*
* Now set up event specific fields.
@@ -1166,10 +1166,10 @@ GenerateXEvent(
* TkpGetString. [Bug 1118340].
*/
- event.type = MouseWheelEvent;
- event.xany.send_event = -1;
- event.xkey.nbytes = 0;
- event.xkey.keycode = tsdPtr->vWheelAcc / WHEEL_DELTA * WHEEL_DELTA;
+ event.x.type = MouseWheelEvent;
+ event.x.xany.send_event = -1;
+ event.key.nbytes = 0;
+ event.x.xkey.keycode = tsdPtr->vWheelAcc / WHEEL_DELTA * WHEEL_DELTA;
tsdPtr->vWheelAcc = tsdPtr->vWheelAcc % WHEEL_DELTA;
break;
}
@@ -1198,11 +1198,11 @@ GenerateXEvent(
* TkpGetString. [Bug 1118340].
*/
- event.type = MouseWheelEvent;
- event.xany.send_event = -1;
- event.xkey.nbytes = 0;
- event.xkey.state |= ShiftMask;
- event.xkey.keycode = tsdPtr->hWheelAcc / WHEEL_DELTA * WHEEL_DELTA;
+ event.x.type = MouseWheelEvent;
+ event.x.xany.send_event = -1;
+ event.key.nbytes = 0;
+ event.x.xkey.state |= ShiftMask;
+ event.x.xkey.keycode = tsdPtr->hWheelAcc / WHEEL_DELTA * WHEEL_DELTA;
tsdPtr->hWheelAcc = tsdPtr->hWheelAcc % WHEEL_DELTA;
break;
}
@@ -1216,10 +1216,10 @@ GenerateXEvent(
* MBCS characters that came from the TranslateMessage call.
*/
- event.type = KeyPress;
- event.xany.send_event = -1;
- event.xkey.keycode = wParam;
- GetTranslatedKey(&event.xkey, (message == WM_KEYDOWN) ? WM_CHAR :
+ event.x.type = KeyPress;
+ event.x.xany.send_event = -1;
+ event.x.xkey.keycode = wParam;
+ GetTranslatedKey(&event.key, (message == WM_KEYDOWN) ? WM_CHAR :
WM_SYSCHAR);
break;
@@ -1231,9 +1231,9 @@ GenerateXEvent(
* WM_CHAR messages which will follow.
*/
- event.type = KeyRelease;
- event.xkey.keycode = wParam;
- event.xkey.nbytes = 0;
+ event.x.type = KeyRelease;
+ event.x.xkey.keycode = wParam;
+ event.key.nbytes = 0;
break;
case WM_CHAR:
@@ -1267,9 +1267,9 @@ GenerateXEvent(
* character.
*/
- event.type = KeyPress;
- event.xany.send_event = -1;
- event.xkey.keycode = 0;
+ event.x.type = KeyPress;
+ event.x.xany.send_event = -1;
+ event.x.xkey.keycode = 0;
if ((int)wParam & 0xff00) {
int ch1 = wParam & 0xffff;
@@ -1282,12 +1282,12 @@ GenerateXEvent(
(ch1 & 0x3ff) | 0x10000;
tsdPtr->surrogateBuffer = 0;
}
- event.xany.send_event = -3;
- event.xkey.nbytes = 0;
- event.xkey.keycode = ch1;
+ event.x.xany.send_event = -3;
+ event.key.nbytes = 0;
+ event.x.xkey.keycode = ch1;
} else {
- event.xkey.nbytes = 1;
- event.xkey.trans_chars[0] = (char) wParam;
+ event.key.nbytes = 1;
+ event.key.trans_chars[0] = (char) wParam;
if (IsDBCSLeadByte((BYTE) wParam)) {
MSG msg;
@@ -1296,22 +1296,22 @@ GenerateXEvent(
PM_NOREMOVE) != 0)
&& (msg.message == WM_CHAR)) {
GetMessageW(&msg, NULL, WM_CHAR, WM_CHAR);
- event.xkey.nbytes = 2;
- event.xkey.trans_chars[1] = (char) msg.wParam;
+ event.key.nbytes = 2;
+ event.key.trans_chars[1] = (char) msg.wParam;
}
}
}
- Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
- event.type = KeyRelease;
+ Tk_QueueWindowEvent(&event.x, TCL_QUEUE_TAIL);
+ event.x.type = KeyRelease;
break;
case WM_UNICHAR: {
- event.type = KeyPress;
- event.xany.send_event = -3;
- event.xkey.keycode = wParam;
- event.xkey.nbytes = 0;
- Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
- event.type = KeyRelease;
+ event.x.type = KeyPress;
+ event.x.xany.send_event = -3;
+ event.x.xkey.keycode = wParam;
+ event.key.nbytes = 0;
+ Tk_QueueWindowEvent(&event.x, TCL_QUEUE_TAIL);
+ event.x.type = KeyRelease;
break;
}
@@ -1332,7 +1332,7 @@ GenerateXEvent(
* Post the translated event to the main Tk event queue.
*/
- Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
+ Tk_QueueWindowEvent(&event.x, TCL_QUEUE_TAIL);
}
/*
@@ -1434,7 +1434,7 @@ GetState(
static void
GetTranslatedKey(
- XKeyEvent *xkey,
+ TkKeyEvent *xkey,
UINT type)
{
MSG msg;
@@ -1457,7 +1457,7 @@ GetTranslatedKey(
*/
if ((msg.message == WM_CHAR) && (msg.lParam & 0x20000000)) {
- xkey->state = 0;
+ xkey->keyEvent.state = 0;
}
xkey->trans_chars[xkey->nbytes++] = (char) msg.wParam;
diff --git a/xlib/X11/Xlib.h b/xlib/X11/Xlib.h
index 0971191..dd5fd33 100644
--- a/xlib/X11/Xlib.h
+++ b/xlib/X11/Xlib.h
@@ -608,9 +608,11 @@ typedef struct {
unsigned int state; /* key or button mask */
unsigned int keycode; /* detail */
Bool same_screen; /* same screen flag */
+#ifdef MAC_OSX_TK /* Only used on MacOSX. To be removed. */
char trans_chars[XMaxTransChars];
/* translated characters */
unsigned char nbytes;
+#endif
} XKeyEvent;
typedef XKeyEvent XKeyPressedEvent;
typedef XKeyEvent XKeyReleasedEvent;