summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--macosx/tkMacOSXColor.c4
-rw-r--r--macosx/tkMacOSXCursor.c29
-rw-r--r--macosx/tkMacOSXDialog.c10
-rw-r--r--macosx/tkMacOSXFont.c21
-rw-r--r--macosx/tkMacOSXKeyboard.c2
-rw-r--r--macosx/tkMacOSXMenu.c28
-rw-r--r--macosx/tkMacOSXPrivate.h8
-rw-r--r--macosx/ttkMacOSXTheme.c38
8 files changed, 63 insertions, 77 deletions
diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c
index ab28fbf..acbfa0e 100644
--- a/macosx/tkMacOSXColor.c
+++ b/macosx/tkMacOSXColor.c
@@ -31,7 +31,7 @@ static NSAppearance *lightAqua = nil;
static NSAppearance *darkAqua = nil;
#endif
static NSColorSpace* sRGB = NULL;
-static CGFloat windowBackground[4] =
+static const CGFloat WINDOWBACKGROUND[4] =
{236.0 / 255, 236.0 / 255, 236.0 / 255, 1.0};
void initColorTable()
@@ -297,7 +297,7 @@ GetRGBA(
if ([NSApp macOSVersion] < 101400) {
for (int i = 0; i < 3; i++) {
- rgba[i] = windowBackground[i];
+ rgba[i] = WINDOWBACKGROUND[i];
}
} else {
bgColor = [[NSColor windowBackgroundColor] colorUsingColorSpace:sRGB];
diff --git a/macosx/tkMacOSXCursor.c b/macosx/tkMacOSXCursor.c
index 6c36ca7..9371889 100644
--- a/macosx/tkMacOSXCursor.c
+++ b/macosx/tkMacOSXCursor.c
@@ -366,14 +366,13 @@ FindCursorByName(
TkCursor *
TkGetCursorByName(
Tcl_Interp *interp, /* Interpreter to use for error reporting. */
- Tk_Window tkwin, /* Window in which cursor will be used. */
+ TCL_UNUSED(Tk_Window), /* Window in which cursor will be used. */
Tk_Uid string) /* Description of cursor. See manual entry
* for details on legal syntax. */
{
TkMacOSXCursor *macCursorPtr = NULL;
const char **argv = NULL;
int argc;
- (void)tkwin;
/*
* All cursor names are valid lists of one element (for
@@ -421,24 +420,16 @@ TkGetCursorByName(
TkCursor *
TkCreateCursorFromData(
- Tk_Window tkwin, /* Window in which cursor will be used. */
- const char *source, /* Bitmap data for cursor shape. */
- const char *mask, /* Bitmap data for cursor mask. */
- int width, int height, /* Dimensions of cursor. */
- int xHot, int yHot, /* Location of hot-spot in cursor. */
- XColor fgColor, /* Foreground color for cursor. */
- XColor bgColor) /* Background color for cursor. */
+ TCL_UNUSED(Tk_Window), /* Window in which cursor will be used. */
+ TCL_UNUSED(const char *), /* Bitmap data for cursor shape. */
+ TCL_UNUSED(const char *), /* Bitmap data for cursor mask. */
+ TCL_UNUSED(int), /* Dimensions of cursor. */
+ TCL_UNUSED(int),
+ TCL_UNUSED(int), /* Location of hot-spot in cursor. */
+ TCL_UNUSED(int),
+ TCL_UNUSED(XColor), /* Foreground color for cursor. */
+ TCL_UNUSED(XColor)) /* Background color for cursor. */
{
- (void)tkwin;
- (void)source;
- (void)mask;
- (void)width;
- (void)height;
- (void)xHot;
- (void)yHot;
- (void)fgColor;
- (void)bgColor;
-
return NULL;
}
diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c
index 1bfd163..8575b10 100644
--- a/macosx/tkMacOSXDialog.c
+++ b/macosx/tkMacOSXDialog.c
@@ -870,15 +870,15 @@ Tk_GetOpenFileObjCmd(
selectedFilterIndex = filterInfo.fileTypeIndex; // The preselection from the typevariable
selectedFilter = [filterInfo.fileTypeNames objectAtIndex:selectedFilterIndex];
} else {
- NSUInteger i;
+ NSUInteger j;
- for (i = 0; i < [filterInfo.fileTypeNames count]; i++) {
- if (filterCompatible(extension, i)) {
- selectedFilterIndex = i;
+ for (j = 0; j < [filterInfo.fileTypeNames count]; j++) {
+ if (filterCompatible(extension, j)) {
+ selectedFilterIndex = j;
break;
}
}
- if (i == selectedFilterIndex) {
+ if (j == selectedFilterIndex) {
selectedFilter = [filterInfo.fileTypeNames objectAtIndex:selectedFilterIndex];
} else {
selectedFilter = @"";
diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c
index 72c83b4..6c66ed8 100644
--- a/macosx/tkMacOSXFont.c
+++ b/macosx/tkMacOSXFont.c
@@ -550,13 +550,12 @@ TkpFontPkgInit(
TkFont *
TkpGetNativeFont(
- Tk_Window tkwin, /* For display where font will be used. */
+ TCL_UNUSED(Tk_Window), /* For display where font will be used. */
const char *name) /* Platform-specific font name. */
{
MacFont *fontPtr = NULL;
ThemeFontID themeFontId;
CTFontRef ctFont;
- (void)tkwin;
if (strcmp(name, SYSTEMFONT_NAME) == 0) {
themeFontId = kThemeSystemFont;
@@ -700,11 +699,10 @@ TkpDeleteFont(
void
TkpGetFontFamilies(
Tcl_Interp *interp, /* Interp to hold result. */
- Tk_Window tkwin) /* For display to query. */
+ TCL_UNUSED(Tk_Window)) /* For display to query. */
{
Tcl_Obj *resultPtr = Tcl_NewListObj(0, NULL);
NSArray *list = [[NSFontManager sharedFontManager] availableFontFamilies];
- (void)tkwin;
for (NSString *family in list) {
Tcl_ListObjAppendElement(NULL, resultPtr,
@@ -774,7 +772,7 @@ TkpGetSubFonts(
void
TkpGetFontAttrsForChar(
- Tk_Window tkwin, /* Window on the font's display */
+ TCL_UNUSED(Tk_Window), /* Window on the font's display */
Tk_Font tkfont, /* Font to query */
int c, /* Character of interest */
TkFontAttributes* faPtr) /* Output: Font attributes */
@@ -784,7 +782,6 @@ TkpGetFontAttrsForChar(
*faPtr = fontPtr->font.fa;
if (nsFont && ![[nsFont coveredCharacterSet] characterIsMember:c]) {
UTF16Char ch = (UTF16Char) c;
- (void)tkwin;
nsFont = [nsFont bestMatchingFontForCharacters:&ch
length:1 attributes:nil actualCoveredLength:NULL];
@@ -1166,7 +1163,7 @@ TkpDrawCharsInContext(
void
TkpDrawAngledCharsInContext(
- Display *display, /* Display on which to draw. */
+ TCL_UNUSED(Display *), /* Display on which to draw. */
Drawable drawable, /* Window or pixmap in which to draw. */
GC gc, /* Graphics context for drawing characters. */
Tk_Font tkfont, /* Font in which characters will be drawn; must
@@ -1200,7 +1197,6 @@ TkpDrawAngledCharsInContext(
NSFont *nsFont;
CGAffineTransform t;
CGFloat width, height, textX = (CGFloat) x, textY = (CGFloat) y;
- (void)display;
if (rangeStart < 0 || rangeLength <= 0 ||
rangeStart + rangeLength > numBytes ||
@@ -1331,12 +1327,9 @@ TkMacOSXNSFontAttributesForFont(
int
TkMacOSXIsCharacterMissing(
- Tk_Font tkfont, /* The font we are looking in. */
- unsigned int searchChar) /* The character we are looking for. */
+ TCL_UNUSED(Tk_Font), /* The font we are looking in. */
+ TCL_UNUSED(unsigned int)) /* The character we are looking for. */
{
- (void)tkfont;
- (void)searchChar;
-
return 0;
}
@@ -1375,7 +1368,7 @@ TkMacOSXFontDescriptionForNSFontAndNSFontAttributes(
objv[i++] = Tcl_NewStringObj(familyName, -1);
objv[i++] = Tcl_NewWideIntObj([nsFont pointSize]);
-#define S(s) Tcl_NewStringObj(STRINGIFY(s), (int)(sizeof(STRINGIFY(s))-1))
+#define S(s) Tcl_NewStringObj(STRINGIFY(s), (sizeof(STRINGIFY(s))-1))
objv[i++] = (traits & NSBoldFontMask) ? S(bold) : S(normal);
objv[i++] = (traits & NSItalicFontMask) ? S(italic) : S(roman);
if ([underline respondsToSelector:@selector(intValue)] &&
diff --git a/macosx/tkMacOSXKeyboard.c b/macosx/tkMacOSXKeyboard.c
index 67ecba3..236ebbc 100644
--- a/macosx/tkMacOSXKeyboard.c
+++ b/macosx/tkMacOSXKeyboard.c
@@ -663,7 +663,7 @@ XKeysymToKeycode(
macKC.x.keychar = (unsigned int) data;
hPtr = Tcl_FindHashEntry(&unichar2xvirtual, INT2PTR(macKC.x.keychar));
if (hPtr != NULL) {
- unsigned long data = (unsigned long) Tcl_GetHashValue(hPtr);
+ data = (unsigned long) Tcl_GetHashValue(hPtr);
macKC.x.xvirtual = (unsigned int) data;
}
}
diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c
index bccddc5..8970109 100644
--- a/macosx/tkMacOSXMenu.c
+++ b/macosx/tkMacOSXMenu.c
@@ -36,7 +36,7 @@
#define SPECIALMENU(n, f) {.name = "." #n, .len = sl(#n) + 1, \
.flag = ENTRY_##f##_MENU }
static const struct {
- const char *name; const size_t len; const int flag;
+ const char *name; size_t len; int flag;
} specialMenus[] = {
SPECIALMENU(help, HELP),
SPECIALMENU(apple, APPLE),
@@ -47,8 +47,8 @@ static const struct {
#define MODIFIER(n, f) {.name = #n, .len = sl(#n), .mask = f }
static const struct {
- const char *name; const size_t len; const NSUInteger mask;
-} modifiers[] = {
+ const char *name; size_t len; NSUInteger mask;
+} allModifiers[] = {
MODIFIER(Control, NSControlKeyMask),
MODIFIER(Ctrl, NSControlKeyMask),
MODIFIER(Option, NSAlternateKeyMask),
@@ -64,7 +64,7 @@ static const struct {
#define ACCEL(n, c) {.name = #n, .len = sl(#n), .ch = c }
static const struct {
- const char *name; const size_t len; const UniChar ch;
+ const char *name; size_t len; UniChar ch;
} specialAccelerators[] = {
ACCEL(PageUp, NSPageUpFunctionKey),
ACCEL(PageDown, NSPageDownFunctionKey),
@@ -1230,18 +1230,18 @@ ParseAccelerator(
*maskPtr = 0;
while (1) {
i = 0;
- while (modifiers[i].name) {
- int l = modifiers[i].len;
+ while (allModifiers[i].name) {
+ int l = allModifiers[i].len;
- if (!strncasecmp(accel, modifiers[i].name, l) &&
+ if (!strncasecmp(accel, allModifiers[i].name, l) &&
(accel[l] == '-' || accel[l] == '+')) {
- *maskPtr |= modifiers[i].mask;
+ *maskPtr |= allModifiers[i].mask;
accel += l+1;
break;
}
i++;
}
- if (!modifiers[i].name || !*accel) {
+ if (!allModifiers[i].name || !*accel) {
break;
}
}
@@ -1465,14 +1465,14 @@ TkpComputeStandardMenuGeometry(
}
} else {
NSUInteger modifMask = [menuItem keyEquivalentModifierMask];
- int i = 0;
+ int j = 0;
- while (modifiers[i].name) {
- if (modifMask & modifiers[i].mask) {
- modifMask &= ~modifiers[i].mask;
+ while (allModifiers[j].name) {
+ if (modifMask & allModifiers[j].mask) {
+ modifMask &= ~allModifiers[j].mask;
modifierWidth += modifierCharWidth;
}
- i++;
+ j++;
}
accelWidth = [[menuItem keyEquivalent] sizeWithAttributes:
TkMacOSXNSFontAttributesForFont(tkfont)].width;
diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h
index 25ce143..701c81f 100644
--- a/macosx/tkMacOSXPrivate.h
+++ b/macosx/tkMacOSXPrivate.h
@@ -103,11 +103,11 @@
* debug message in case of failure.
*/
#define ChkErr(f, ...) ({ \
- OSStatus err = f(__VA_ARGS__); \
- if (err != noErr) { \
- TkMacOSXDbgOSErr(f, err); \
+ OSStatus err_ = f(__VA_ARGS__); \
+ if (err_ != noErr) { \
+ TkMacOSXDbgOSErr(f, err_); \
} \
- err;})
+ err_;})
#else /* TK_MAC_DEBUG */
#define TKLog(f, ...)
diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c
index 1a7ce39..8437aa6 100644
--- a/macosx/ttkMacOSXTheme.c
+++ b/macosx/ttkMacOSXTheme.c
@@ -232,11 +232,11 @@ static CGRect NormalizeButtonBounds(
* support Dark Mode anyway.
*/
-static CGFloat windowBackground[4] = {
+static const CGFloat WINDOWBACKGROUND[4] = {
235.0 / 255, 235.0 / 255, 235.0 / 255, 1.0
};
-static CGFloat whiteRGBA[4] = {1.0, 1.0, 1.0, 1.0};
-static CGFloat blackRGBA[4] = {0.0, 0.0, 0.0, 1.0};
+static const CGFloat WHITERGBA[4] = {1.0, 1.0, 1.0, 1.0};
+static const CGFloat BLACKRGBA[4] = {0.0, 0.0, 0.0, 1.0};
/*----------------------------------------------------------------------
* GetBackgroundColor --
@@ -276,7 +276,7 @@ static void GetBackgroundColor(
[windowColor getComponents: rgba];
} else {
for (int i = 0; i < 4; i++) {
- rgba[i] = windowBackground[i];
+ rgba[i] = WINDOWBACKGROUND[i];
}
}
}
@@ -314,7 +314,7 @@ static void DrawDownArrow(
CGRect bounds,
CGFloat inset,
CGFloat size,
- CGFloat *rgba)
+ const CGFloat *rgba)
{
CGFloat x, y;
@@ -336,7 +336,7 @@ static void DrawUpArrow(
CGRect bounds,
CGFloat inset,
CGFloat size,
- CGFloat *rgba)
+ const CGFloat *rgba)
{
CGFloat x, y;
@@ -406,7 +406,7 @@ static void DrawUpDownArrows(
CGRect bounds,
CGFloat inset,
CGFloat size,
- CGFloat *rgba)
+ const CGFloat *rgba)
{
CGFloat x, y;
@@ -633,9 +633,9 @@ static void DrawListHeader(
arrowBounds.origin.x = bounds.origin.x + bounds.size.width - 16;
arrowBounds.size.width = 16;
if (state & TTK_STATE_ALTERNATE) {
- DrawUpArrow(context, arrowBounds, 3, 8, blackRGBA);
+ DrawUpArrow(context, arrowBounds, 3, 8, BLACKRGBA);
} else if (state & TTK_STATE_SELECTED) {
- DrawDownArrow(context, arrowBounds, 3, 8, blackRGBA);
+ DrawDownArrow(context, arrowBounds, 3, 8, BLACKRGBA);
}
}
}
@@ -757,9 +757,9 @@ static void DrawDarkButton(
darkSelectedGradient, 2);
}
if (kind == kThemePopupButton) {
- DrawUpDownArrows(context, arrowBounds, 3, 7, whiteRGBA);
+ DrawUpDownArrows(context, arrowBounds, 3, 7, WHITERGBA);
} else {
- DrawDownArrow(context, arrowBounds, 4, 8, whiteRGBA);
+ DrawDownArrow(context, arrowBounds, 4, 8, WHITERGBA);
}
}
@@ -818,7 +818,7 @@ static void DrawDarkIncDecButton(
darkSelectedGradient, 2);
CGContextRestoreGState(context);
}
- DrawUpDownArrows(context, bounds, 3, 5, whiteRGBA);
+ DrawUpDownArrows(context, bounds, 3, 5, WHITERGBA);
HighlightButtonBorder(context, bounds);
}
@@ -1245,9 +1245,9 @@ static void DrawDarkListHeader(
arrowBounds.origin.x = bounds.origin.x + bounds.size.width - 16;
arrowBounds.size.width = 16;
if (state & TTK_STATE_ALTERNATE) {
- DrawUpArrow(context, arrowBounds, 3, 8, whiteRGBA);
+ DrawUpArrow(context, arrowBounds, 3, 8, WHITERGBA);
} else if (state & TTK_STATE_SELECTED) {
- DrawDownArrow(context, arrowBounds, 3, 8, whiteRGBA);
+ DrawDownArrow(context, arrowBounds, 3, 8, WHITERGBA);
}
}
}
@@ -2137,6 +2137,7 @@ static void TrackElementDraw(
TrackElement *elem = elementRecord;
Ttk_Orient orientation = TTK_ORIENT_HORIZONTAL;
double from = 0, to = 100, value = 0, factor;
+ CGRect bounds;
TtkGetOrientFromObj(NULL, elem->orientObj, &orientation);
Tcl_GetDoubleFromObj(NULL, elem->fromObj, &from);
@@ -2149,7 +2150,7 @@ static void TrackElementDraw(
* bounds variable avoids UBSan (-fsanitize=alignment) complaints.
*/
- CGRect bounds = BoxToRect(d, b);
+ bounds = BoxToRect(d, b);
HIThemeTrackDrawInfo info = {
.version = 0,
.kind = data->kind,
@@ -2175,7 +2176,7 @@ static void TrackElementDraw(
}
BEGIN_DRAWING(d)
if (TkMacOSXInDarkMode(tkwin)) {
- CGRect bounds = BoxToRect(d, b);
+ bounds = BoxToRect(d, b);
NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
NSColor *trackColor = [NSColor colorWithColorSpace: deviceRGB
components: darkTrack
@@ -2282,6 +2283,7 @@ static void PbarElementDraw(
Ttk_Orient orientation = TTK_ORIENT_HORIZONTAL;
int phase = 0;
double value = 0, maximum = 100, factor;
+ CGRect bounds;
TtkGetOrientFromObj(NULL, pbar->orientObj, &orientation);
Tcl_GetDoubleFromObj(NULL, pbar->valueObj, &value);
@@ -2294,7 +2296,7 @@ static void PbarElementDraw(
* bounds variable avoids UBSan (-fsanitize=alignment) complaints.
*/
- CGRect bounds = BoxToRect(d, b);
+ bounds = BoxToRect(d, b);
HIThemeTrackDrawInfo info = {
.version = 0,
.kind =
@@ -2314,7 +2316,7 @@ static void PbarElementDraw(
BEGIN_DRAWING(d)
if (TkMacOSXInDarkMode(tkwin)) {
- CGRect bounds = BoxToRect(d, b);
+ bounds = BoxToRect(d, b);
NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
NSColor *trackColor = [NSColor colorWithColorSpace: deviceRGB
components: darkTrack