summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/NameOfImg.38
-rw-r--r--generic/tkBind.c2
-rw-r--r--generic/tkCanvas.c26
-rw-r--r--generic/tkEntry.c24
-rw-r--r--generic/tkEvent.c35
-rw-r--r--generic/tkGrab.c13
-rw-r--r--generic/tkInt.h11
-rw-r--r--generic/tkPointer.c14
-rw-r--r--generic/tkTextTag.c35
-rw-r--r--generic/ttk/ttkTreeview.c2
-rw-r--r--library/demos/twind.tcl2
-rw-r--r--macosx/tkMacOSXBitmap.c2
-rw-r--r--macosx/tkMacOSXEntry.c23
-rw-r--r--macosx/tkMacOSXMouseEvent.c12
-rw-r--r--macosx/tkMacOSXScrlbr.c6
-rw-r--r--macosx/ttkMacOSXTheme.c2
-rw-r--r--tests/unixEmbed.test2
-rw-r--r--unix/tkUnixWm.c2
-rw-r--r--win/tkWinDialog.c80
-rw-r--r--win/tkWinPointer.c6
-rw-r--r--win/tkWinX.c19
21 files changed, 141 insertions, 185 deletions
diff --git a/doc/NameOfImg.3 b/doc/NameOfImg.3
index 78332db..8c191ce 100644
--- a/doc/NameOfImg.3
+++ b/doc/NameOfImg.3
@@ -3,7 +3,7 @@
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-'\"
+'\"
.TH Tk_NameOfImage 3 4.0 Tk "Tk Library Procedures"
.so man.macros
.BS
@@ -14,10 +14,10 @@ Tk_NameOfImage \- Return name of image.
\fB#include <tk.h>\fR
.sp
const char *
-\fBTk_NameOfImage\fR(\fItypePtr\fR)
+\fBTk_NameOfImage\fR(\fIimageMaster\fR)
.SH ARGUMENTS
-.AS Tk_ImageMaster *masterPtr
-.AP Tk_ImageMaster *masterPtr in
+.AS Tk_ImageMaster imageMaster
+.AP Tk_ImageMaster imageMaster in
Token for image, which was passed to image manager's \fIcreateProc\fR when
the image was created.
.BE
diff --git a/generic/tkBind.c b/generic/tkBind.c
index e0971ba..d09c34e 100644
--- a/generic/tkBind.c
+++ b/generic/tkBind.c
@@ -83,7 +83,7 @@ typedef union {
* Apple NSEvent object.
*/
-#ifndef TK_MAC_OSX
+#ifdef MAC_OSX_TK
#define EVENT_BUFFER_SIZE 90
#else
#define EVENT_BUFFER_SIZE 30
diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c
index 4d260dc..ab648a1 100644
--- a/generic/tkCanvas.c
+++ b/generic/tkCanvas.c
@@ -4760,26 +4760,7 @@ CanvasBindProc(
switch (eventPtr->type) {
case ButtonPress:
case ButtonRelease:
- switch (eventPtr->xbutton.button) {
- case Button1:
- mask = Button1Mask;
- break;
- case Button2:
- mask = Button2Mask;
- break;
- case Button3:
- mask = Button3Mask;
- break;
- case Button4:
- mask = Button4Mask;
- break;
- case Button5:
- mask = Button5Mask;
- break;
- default:
- mask = 0;
- break;
- }
+ mask = TkGetButtonMask(eventPtr->xbutton.button);
/*
* For button press events, repick the current item using the button
@@ -4862,7 +4843,7 @@ PickCurrentItem(
* ButtonRelease, or MotionNotify. */
{
double coords[2];
- int buttonDown;
+ unsigned int buttonDown;
Tk_Item *prevItemPtr;
#ifndef USE_OLD_TAG_SEARCH
SearchUids *searchUids = GetStaticUids();
@@ -4875,8 +4856,7 @@ PickCurrentItem(
* for windows.
*/
- buttonDown = canvasPtr->state
- & (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask);
+ buttonDown = canvasPtr->state & ALL_BUTTONS;
/*
* Save information about this event in the canvas. The event in the
diff --git a/generic/tkEntry.c b/generic/tkEntry.c
index a7bc5a0..0dfacd7 100644
--- a/generic/tkEntry.c
+++ b/generic/tkEntry.c
@@ -1513,17 +1513,15 @@ EntryWorldChanged(
*
* TkpDrawEntryBorderAndFocus --
*
- * This function redraws the border of an entry widget. It overrides the
- * generic border drawing code if the entry widget parameters are such
- * that the native widget drawing is a good fit. This version just
- * returns 0, so platforms that don't do special native drawing don't
- * have to implement it.
+ * Stub function for Tk on platforms other than Aqua
+ * (Windows and X11), which do not draw native entry borders.
+ * See macosx/tkMacOSXEntry.c for function definition in Tk Aqua.
*
* Results:
- * 1 if it has drawn the border, 0 if not.
+ * Returns 0.
*
* Side effects:
- * May draw the entry border into pixmap.
+ * None.
*
*--------------------------------------------------------------
*/
@@ -1542,17 +1540,15 @@ TkpDrawEntryBorderAndFocus(
*
* TkpDrawSpinboxButtons --
*
- * This function redraws the buttons of an spinbox widget. It overrides
- * the generic button drawing code if the spinbox widget parameters are
- * such that the native widget drawing is a good fit. This version just
- * returns 0, so platforms that don't do special native drawing don't
- * have to implement it.
+ * Stub function for Tk on platforms other than Aqua
+ * (Windows and X11), which do not draw native spinbox buttons.
+ * See macosx/tkMacOSXEntry.c for function definition in Tk Aqua.
*
* Results:
- * 1 if it has drawn the border, 0 if not.
+ * Returns 0.
*
* Side effects:
- * May draw the entry border into pixmap.
+ * None.
*
*--------------------------------------------------------------
*/
diff --git a/generic/tkEvent.c b/generic/tkEvent.c
index b36d5de..753a31b 100644
--- a/generic/tkEvent.c
+++ b/generic/tkEvent.c
@@ -193,7 +193,6 @@ TCL_DECLARE_MUTEX(exitMutex)
static void CleanUpTkEvent(XEvent *eventPtr);
static void DelayedMotionProc(ClientData clientData);
-static int GetButtonMask(unsigned int Button);
static unsigned long GetEventMaskFromXEvent(XEvent *eventPtr);
static TkWindow * GetTkWindowFromXEvent(XEvent *eventPtr);
static void InvokeClientMessageHandlers(ThreadSpecificData *tsdPtr,
@@ -524,7 +523,7 @@ RefreshKeyboardMappingIfNeeded(
/*
*----------------------------------------------------------------------
*
- * GetButtonMask --
+ * TkGetButtonMask --
*
* Return the proper Button${n}Mask for the button.
*
@@ -537,23 +536,15 @@ RefreshKeyboardMappingIfNeeded(
*----------------------------------------------------------------------
*/
-static int
-GetButtonMask(
+static const int buttonMasks[] = {
+ 0, Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask
+};
+
+int
+TkGetButtonMask(
unsigned int button)
{
- switch (button) {
- case 1:
- return Button1Mask;
- case 2:
- return Button2Mask;
- case 3:
- return Button3Mask;
- case 4:
- return Button4Mask;
- case 5:
- return Button5Mask;
- }
- return 0;
+ return (button > Button5) ? 0 : buttonMasks[button];
}
/*
@@ -582,8 +573,6 @@ UpdateButtonEventState(
XEvent *eventPtr)
{
TkDisplay *dispPtr;
- int allButtonsMask = Button1Mask | Button2Mask | Button3Mask
- | Button4Mask | Button5Mask;
switch (eventPtr->type) {
case ButtonPress:
@@ -591,19 +580,19 @@ UpdateButtonEventState(
dispPtr->mouseButtonWindow = eventPtr->xbutton.window;
eventPtr->xbutton.state |= dispPtr->mouseButtonState;
- dispPtr->mouseButtonState |= GetButtonMask(eventPtr->xbutton.button);
+ dispPtr->mouseButtonState |= TkGetButtonMask(eventPtr->xbutton.button);
break;
case ButtonRelease:
dispPtr = TkGetDisplay(eventPtr->xbutton.display);
dispPtr->mouseButtonWindow = None;
- dispPtr->mouseButtonState &= ~GetButtonMask(eventPtr->xbutton.button);
+ dispPtr->mouseButtonState &= ~TkGetButtonMask(eventPtr->xbutton.button);
eventPtr->xbutton.state |= dispPtr->mouseButtonState;
break;
case MotionNotify:
dispPtr = TkGetDisplay(eventPtr->xmotion.display);
- if (dispPtr->mouseButtonState & allButtonsMask) {
+ if (dispPtr->mouseButtonState & ALL_BUTTONS) {
if (eventPtr->xbutton.window != dispPtr->mouseButtonWindow) {
/*
* This motion event should not be interpreted as a button
@@ -611,7 +600,7 @@ UpdateButtonEventState(
* button was pressed down in.
*/
- dispPtr->mouseButtonState &= ~allButtonsMask;
+ dispPtr->mouseButtonState &= ~ALL_BUTTONS;
dispPtr->mouseButtonWindow = None;
} else {
eventPtr->xmotion.state |= dispPtr->mouseButtonState;
diff --git a/generic/tkGrab.c b/generic/tkGrab.c
index dc0e8fc..2855637 100644
--- a/generic/tkGrab.c
+++ b/generic/tkGrab.c
@@ -135,17 +135,6 @@ typedef struct NewGrabWinEvent {
#define GENERATED_GRAB_EVENT_MAGIC ((Bool) 0x147321ac)
/*
- * Mask that selects any of the state bits corresponding to buttons, plus
- * masks that select individual buttons' bits:
- */
-
-#define ALL_BUTTONS \
- (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask)
-static const unsigned int buttonStates[] = {
- Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask
-};
-
-/*
* Forward declarations for functions declared later in this file:
*/
@@ -883,7 +872,7 @@ TkPointerEvent(
} else {
if (eventPtr->xbutton.button != AnyButton &&
((eventPtr->xbutton.state & ALL_BUTTONS)
- == buttonStates[eventPtr->xbutton.button - Button1])) {
+ == (unsigned int)TkGetButtonMask(eventPtr->xbutton.button))) {
ReleaseButtonGrab(dispPtr); /* Note 4. */
}
}
diff --git a/generic/tkInt.h b/generic/tkInt.h
index a80d209..124a8f5 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -932,6 +932,17 @@ typedef struct TkpClipMask {
#define EXTENDED_MASK (AnyModifier<<3)
/*
+ * Mask that selects any of the state bits corresponding to buttons, plus
+ * masks that select individual buttons' bits:
+ */
+
+#define ALL_BUTTONS \
+ (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask)
+
+
+MODULE_SCOPE int TkGetButtonMask(unsigned int);
+
+/*
* Object types not declared in tkObj.c need to be mentioned here so they can
* be properly registered with Tcl:
*/
diff --git a/generic/tkPointer.c b/generic/tkPointer.c
index 6e87638..de9d49d 100644
--- a/generic/tkPointer.c
+++ b/generic/tkPointer.c
@@ -23,18 +23,6 @@
#define Cursor XCursor
#endif
-/*
- * Mask that selects any of the state bits corresponding to buttons, plus
- * masks that select individual buttons' bits:
- */
-
-#define ALL_BUTTONS \
- (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask)
-static const unsigned int buttonMasks[] = {
- Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask
-};
-#define ButtonMask(b) (buttonMasks[(b)-Button1])
-
typedef struct {
TkWindow *grabWinPtr; /* Window that defines the top of the grab
* tree in a global grab. */
@@ -267,7 +255,7 @@ Tk_UpdatePointer(
*/
for (b = Button1; b <= Button5; b++) {
- mask = ButtonMask(b);
+ mask = TkGetButtonMask(b);
if (changes & mask) {
if (state & mask) {
type = ButtonPress;
diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c
index 13216ca..5cb08ec 100644
--- a/generic/tkTextTag.c
+++ b/generic/tkTextTag.c
@@ -1446,9 +1446,6 @@ TkTextBindProc(
TkText *textPtr = clientData;
int repick = 0;
-# define AnyButtonMask \
- (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask)
-
textPtr->refCount++;
/*
@@ -1460,35 +1457,16 @@ TkTextBindProc(
if (eventPtr->type == ButtonPress) {
textPtr->flags |= BUTTON_DOWN;
} else if (eventPtr->type == ButtonRelease) {
- int mask;
+ unsigned int mask;
- switch (eventPtr->xbutton.button) {
- case Button1:
- mask = Button1Mask;
- break;
- case Button2:
- mask = Button2Mask;
- break;
- case Button3:
- mask = Button3Mask;
- break;
- case Button4:
- mask = Button4Mask;
- break;
- case Button5:
- mask = Button5Mask;
- break;
- default:
- mask = 0;
- break;
- }
- if ((eventPtr->xbutton.state & AnyButtonMask) == (unsigned) mask) {
+ mask = TkGetButtonMask(eventPtr->xbutton.button);
+ if ((eventPtr->xbutton.state & ALL_BUTTONS) == mask) {
textPtr->flags &= ~BUTTON_DOWN;
repick = 1;
}
} else if ((eventPtr->type == EnterNotify)
|| (eventPtr->type == LeaveNotify)) {
- if (eventPtr->xcrossing.state & AnyButtonMask) {
+ if (eventPtr->xcrossing.state & ALL_BUTTONS) {
textPtr->flags |= BUTTON_DOWN;
} else {
textPtr->flags &= ~BUTTON_DOWN;
@@ -1496,7 +1474,7 @@ TkTextBindProc(
TkTextPickCurrent(textPtr, eventPtr);
goto done;
} else if (eventPtr->type == MotionNotify) {
- if (eventPtr->xmotion.state & AnyButtonMask) {
+ if (eventPtr->xmotion.state & ALL_BUTTONS) {
textPtr->flags |= BUTTON_DOWN;
} else {
textPtr->flags &= ~BUTTON_DOWN;
@@ -1513,8 +1491,7 @@ TkTextBindProc(
unsigned int oldState;
oldState = eventPtr->xbutton.state;
- eventPtr->xbutton.state &= ~(Button1Mask|Button2Mask
- |Button3Mask|Button4Mask|Button5Mask);
+ eventPtr->xbutton.state &= ~ALL_BUTTONS;
if (!(textPtr->flags & DESTROYED)) {
TkTextPickCurrent(textPtr, eventPtr);
}
diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c
index b1739b6..cda98a0 100644
--- a/generic/ttk/ttkTreeview.c
+++ b/generic/ttk/ttkTreeview.c
@@ -1066,7 +1066,7 @@ static void TreeviewCleanup(void *recordPtr)
TreeviewFreeColumns(tv);
if (tv->tree.displayColumns)
- Tcl_Free((ClientData)tv->tree.displayColumns);
+ ckfree((ClientData)tv->tree.displayColumns);
foreachHashEntry(&tv->tree.items, FreeItemCB);
Tcl_DeleteHashTable(&tv->tree.items);
diff --git a/library/demos/twind.tcl b/library/demos/twind.tcl
index df879e3..45d1da8 100644
--- a/library/demos/twind.tcl
+++ b/library/demos/twind.tcl
@@ -315,7 +315,7 @@ proc changeBg {t c} {
proc embDefBg t {
set bg [lindex [$t configure -background] 3]
- changeBg $t $bg
+ changeBg $t $bg
}
proc textMakePeer {parent} {
diff --git a/macosx/tkMacOSXBitmap.c b/macosx/tkMacOSXBitmap.c
index e8cb211..615192b 100644
--- a/macosx/tkMacOSXBitmap.c
+++ b/macosx/tkMacOSXBitmap.c
@@ -134,7 +134,7 @@ PixmapFromImage(
{
TkMacOSXDrawingContext dc;
Pixmap pixmap;
-
+
pixmap = Tk_GetPixmap(display, None, size.width, size.height, 0);
if (TkMacOSXSetupDrawingContext(pixmap, NULL, 1, &dc)) {
if (dc.context) {
diff --git a/macosx/tkMacOSXEntry.c b/macosx/tkMacOSXEntry.c
index a1c5d60..7915f6f 100644
--- a/macosx/tkMacOSXEntry.c
+++ b/macosx/tkMacOSXEntry.c
@@ -124,16 +124,17 @@ TkpDrawEntryBorderAndFocus(
int incDecWidth;
/*
- * Temporarily change the width of the widget so that the same code can
- * be used for drawing the Entry portion of the Spinbox as is used to
- * draw an ordinary Entry. The width must be restored before
- * returning.
+ * If native spinbox buttons are going to be drawn, then temporarily
+ * change the width of the widget so that the same code can be used
+ * for drawing the Entry portion of the Spinbox as is used to draw
+ * an ordinary Entry. The width must be restored before returning.
*/
oldWidth = Tk_Width(tkwin);
- ComputeIncDecParameters(Tk_Height(tkwin) - 2 * MAC_OSX_FOCUS_WIDTH,
- &incDecWidth);
- Tk_Width(tkwin) -= incDecWidth + 1;
+ if (ComputeIncDecParameters(Tk_Height(tkwin) - 2 * MAC_OSX_FOCUS_WIDTH,
+ &incDecWidth) != 0) {
+ Tk_Width(tkwin) -= incDecWidth + 1;
+ }
}
/*
@@ -186,10 +187,10 @@ TkpDrawEntryBorderAndFocus(
* have to implement it.
*
* Results:
- * 1 if it has drawn the border, 0 if not.
+ * 1 if it has drawn the buttons, 0 if not.
*
* Side effects:
- * May draw the entry border into pixmap.
+ * May draw the buttons into pixmap.
*
*--------------------------------------------------------------
*/
@@ -258,9 +259,9 @@ TkpDrawSpinboxButtons(
*/
bgGC = Tk_GCForColor(sbPtr->entry.highlightBgColorPtr, d);
- rects[0].x = bounds.origin.x;
+ rects[0].x = Tk_Width(tkwin) - incDecWidth - 1;
rects[0].y = 0;
- rects[0].width = Tk_Width(tkwin);
+ rects[0].width = incDecWidth + 1;
rects[0].height = Tk_Height(tkwin);
XFillRectangles(Tk_Display(tkwin), d, bgGC, rects, 1);
diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c
index 2517769..074e36e 100644
--- a/macosx/tkMacOSXMouseEvent.c
+++ b/macosx/tkMacOSXMouseEvent.c
@@ -178,22 +178,22 @@ enum {
*/
unsigned int state = 0;
- NSInteger button = [theEvent buttonNumber];
+ int button = [theEvent buttonNumber] + Button1;
EventRef eventRef = (EventRef)[theEvent eventRef];
UInt32 buttons;
OSStatus err = GetEventParameter(eventRef, kEventParamMouseChord,
typeUInt32, NULL, sizeof(UInt32), NULL, &buttons);
if (err == noErr) {
- state |= (buttons & ((1<<5) - 1)) << 8;
- } else if (button < 5) {
+ state |= (buttons & 0x1F) * Button1Mask;
+ } else if (button <= Button5) {
switch (eventType) {
case NSLeftMouseDown:
case NSRightMouseDown:
case NSLeftMouseDragged:
case NSRightMouseDragged:
case NSOtherMouseDown:
- state |= 1 << (button + 8);
+ state |= TkGetButtonMask(button);
break;
default:
break;
@@ -361,10 +361,10 @@ ButtonModifiers2State(
unsigned int state;
/*
- * Tk supports at most 5 buttons.
+ * Tk on OSX supports at most 5 buttons.
*/
- state = (buttonState & ((1<<5) - 1)) << 8;
+ state = (buttonState & 0x1F) * Button1Mask;
if (keyModifiers & alphaLock) {
state |= LockMask;
diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c
index 0f92c70..a189646 100644
--- a/macosx/tkMacOSXScrlbr.c
+++ b/macosx/tkMacOSXScrlbr.c
@@ -216,7 +216,7 @@ static void drawMacScrollbar(
/*
* Do not display the thumb unless scrolling is possible.
*/
-
+
if (scrollPtr->firstFraction > 0.0 || scrollPtr->lastFraction < 1.0) {
CGRect thumbBounds = {thumbOrigin, thumbSize};
path = CGPathCreateWithRoundedRect(thumbBounds, 4, 4, NULL);
@@ -233,7 +233,7 @@ static void drawMacScrollbar(
}
}
#endif
-
+
void
TkpDisplayScrollbar(
ClientData clientData) /* Information about window. */
@@ -317,7 +317,7 @@ TkpDisplayScrollbar(
/*
* Switch back to NSView coordinates and draw a modern scrollbar.
*/
-
+
CGContextConcatCTM(dc.context, t);
drawMacScrollbar(scrollPtr, msPtr, dc.context);
#endif
diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c
index 50c79bb..0052b14 100644
--- a/macosx/ttkMacOSXTheme.c
+++ b/macosx/ttkMacOSXTheme.c
@@ -2354,7 +2354,7 @@ static void ThumbElementSize(
} else {
*minHeight = 8;
*minWidth = 18;
- }
+ }
}
static void ThumbElementDraw(
diff --git a/tests/unixEmbed.test b/tests/unixEmbed.test
index c2dc073..7d26fbf 100644
--- a/tests/unixEmbed.test
+++ b/tests/unixEmbed.test
@@ -341,7 +341,7 @@ test unixEmbed-2.4 {EmbeddedEventProc procedure} -constraints {
test unixEmbed-3.1 {ContainerEventProc procedure, detect creation} -constraints {
- unix testembed notPortable
+ unix testembed nonPortable
} -body {
frame .f1 -container 1 -width 200 -height 50
pack .f1
diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c
index 9ed9082..7b69713 100644
--- a/unix/tkUnixWm.c
+++ b/unix/tkUnixWm.c
@@ -2444,7 +2444,7 @@ WmIconphotoCmd(
for (i = 3 + isDefault; i < objc; i++) {
photo = Tk_FindPhoto(interp, Tcl_GetString(objv[i]));
if (photo == NULL) {
- Tcl_Free((char *) iconPropertyData);
+ ckfree((char *) iconPropertyData);
return TCL_ERROR;
}
Tk_PhotoGetSize(photo, &width, &height);
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c
index 743720d..2701b82 100644
--- a/win/tkWinDialog.c
+++ b/win/tkWinDialog.c
@@ -2295,54 +2295,56 @@ static int MakeFilterVista(
for (i = 0, filterPtr = flist.filters;
filterPtr;
filterPtr = filterPtr->next, ++i) {
- const char *sep;
- FileFilterClause *clausePtr;
- int nbytes;
+ const char *sep;
+ FileFilterClause *clausePtr;
+ int nbytes;
- /* Check if this entry should be shown as the default */
- if (initial && strcmp(initial, filterPtr->name) == 0)
+ /* Check if this entry should be shown as the default */
+ if (initial && strcmp(initial, filterPtr->name) == 0)
initialIndex = i+1; /* Windows filter indices are 1-based */
- /* First stash away the text description of the pattern */
+ /* First stash away the text description of the pattern */
Tcl_WinUtfToTChar(filterPtr->name, -1, &ds);
- nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */
- nbytes += sizeof(WCHAR); /* Terminating \0 */
- dlgFilterPtr[i].pszName = ckalloc(nbytes);
- memmove((void *) dlgFilterPtr[i].pszName, Tcl_DStringValue(&ds), nbytes);
- Tcl_DStringFree(&ds);
+ nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */
+ nbytes += sizeof(WCHAR); /* Terminating \0 */
+ dlgFilterPtr[i].pszName = ckalloc(nbytes);
+ memmove((void *) dlgFilterPtr[i].pszName, Tcl_DStringValue(&ds), nbytes);
+ Tcl_DStringFree(&ds);
- /*
- * Loop through and join patterns with a ";" Each "clause"
- * corresponds to a single textual description (called typename)
- * in the tk_getOpenFile docs. Each such typename may occur
- * multiple times and all these form a single filter entry
- * with one clause per occurence. Further each clause may specify
- * multiple patterns. Hence the nested loop here.
- */
- sep = "";
- for (clausePtr=filterPtr->clauses ; clausePtr;
- clausePtr=clausePtr->next) {
- GlobPattern *globPtr;
- for (globPtr = clausePtr->patterns; globPtr;
- globPtr = globPtr->next) {
- Tcl_DStringAppend(&patterns, sep, -1);
- Tcl_DStringAppend(&patterns, globPtr->pattern, -1);
- sep = ";";
- }
- }
+ /*
+ * Loop through and join patterns with a ";" Each "clause"
+ * corresponds to a single textual description (called typename)
+ * in the tk_getOpenFile docs. Each such typename may occur
+ * multiple times and all these form a single filter entry
+ * with one clause per occurence. Further each clause may specify
+ * multiple patterns. Hence the nested loop here.
+ */
+ sep = "";
+ for (clausePtr=filterPtr->clauses ; clausePtr;
+ clausePtr=clausePtr->next) {
+ GlobPattern *globPtr;
+ for (globPtr = clausePtr->patterns; globPtr;
+ globPtr = globPtr->next) {
+ Tcl_DStringAppend(&patterns, sep, -1);
+ Tcl_DStringAppend(&patterns, globPtr->pattern, -1);
+ sep = ";";
+ }
+ }
- /* Again we need a Unicode form of the string */
+ /* Again we need a Unicode form of the string */
Tcl_WinUtfToTChar(Tcl_DStringValue(&patterns), -1, &ds);
- nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */
- nbytes += sizeof(WCHAR); /* Terminating \0 */
- dlgFilterPtr[i].pszSpec = ckalloc(nbytes);
- memmove((void *)dlgFilterPtr[i].pszSpec, Tcl_DStringValue(&ds), nbytes);
- Tcl_DStringFree(&ds);
- Tcl_DStringFree(&patterns);
+ nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */
+ nbytes += sizeof(WCHAR); /* Terminating \0 */
+ dlgFilterPtr[i].pszSpec = ckalloc(nbytes);
+ memmove((void *)dlgFilterPtr[i].pszSpec, Tcl_DStringValue(&ds), nbytes);
+ Tcl_DStringFree(&ds);
+ Tcl_DStringSetLength(&patterns, 0);
}
+ Tcl_DStringFree(&patterns);
- if (initialIndex == 0)
- initialIndex = 1; /* If no default, show first entry */
+ if (initialIndex == 0) {
+ initialIndex = 1; /* If no default, show first entry */
+ }
*initialIndexPtr = initialIndex;
*dlgFilterPtrPtr = dlgFilterPtr;
*countPtr = flist.numFilters;
diff --git a/win/tkWinPointer.c b/win/tkWinPointer.c
index 6f1f840..251b5b9 100644
--- a/win/tkWinPointer.c
+++ b/win/tkWinPointer.c
@@ -81,6 +81,12 @@ TkWinGetModifierState(void)
if (GetKeyState(VK_RBUTTON) & 0x8000) {
state |= Button3Mask;
}
+ if (GetKeyState(VK_XBUTTON1) & 0x8000) {
+ state |= Button4Mask;
+ }
+ if (GetKeyState(VK_XBUTTON2) & 0x8000) {
+ state |= Button5Mask;
+ }
return state;
}
diff --git a/win/tkWinX.c b/win/tkWinX.c
index fd576a4..7aa49ab 100644
--- a/win/tkWinX.c
+++ b/win/tkWinX.c
@@ -930,9 +930,12 @@ Tk_TranslateWinEvent(
case WM_MBUTTONDBLCLK:
case WM_RBUTTONDOWN:
case WM_RBUTTONDBLCLK:
+ case WM_XBUTTONDOWN:
+ case WM_XBUTTONDBLCLK:
case WM_LBUTTONUP:
case WM_MBUTTONUP:
case WM_RBUTTONUP:
+ case WM_XBUTTONUP:
case WM_MOUSEMOVE:
Tk_PointerEvent(hwnd, (short) LOWORD(lParam), (short) HIWORD(lParam));
return 1;
@@ -1745,7 +1748,7 @@ Tk_FreeXId(
* TkWinResendEvent --
*
* This function converts an X event into a Windows event and invokes the
- * specified windo function.
+ * specified window function.
*
* Results:
* A standard Windows result.
@@ -1783,6 +1786,14 @@ TkWinResendEvent(
msg = WM_RBUTTONDOWN;
wparam = MK_RBUTTON;
break;
+ case Button4:
+ msg = WM_XBUTTONDOWN;
+ wparam = MAKEWPARAM(MK_XBUTTON1, XBUTTON1);
+ break;
+ case Button5:
+ msg = WM_XBUTTONDOWN;
+ wparam = MAKEWPARAM(MK_XBUTTON2, XBUTTON2);
+ break;
default:
return 0;
}
@@ -1796,6 +1807,12 @@ TkWinResendEvent(
if (eventPtr->xbutton.state & Button3Mask) {
wparam |= MK_RBUTTON;
}
+ if (eventPtr->xbutton.state & Button4Mask) {
+ wparam |= MK_XBUTTON1;
+ }
+ if (eventPtr->xbutton.state & Button5Mask) {
+ wparam |= MK_XBUTTON2;
+ }
if (eventPtr->xbutton.state & ShiftMask) {
wparam |= MK_SHIFT;
}