From c7c7d22777da93312e8351f289c0eae3253889c7 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 27 Nov 2017 11:12:01 +0000 Subject: tkWinDialog.c: Change a LoadLibrary() call to GetModuleHandle(), since "shell32.dll" is already linked to Tk. Also various whitespace changes (mainly at line-ends) and comment fixes. Nothing functional. --- generic/tkImgPhInstance.c | 2 +- generic/tkTextDisp.c | 2 +- library/demos/menu.tcl | 2 +- macosx/README | 2 +- macosx/tkMacOSXConstants.h | 4 ++-- macosx/tkMacOSXDefault.h | 5 ----- macosx/tkMacOSXEmbed.c | 2 +- macosx/tkMacOSXImage.c | 8 ++++---- macosx/tkMacOSXInit.c | 8 ++++---- macosx/tkMacOSXSubwindows.c | 2 +- macosx/tkMacOSXWm.c | 19 ++++++++++--------- win/tkWinDialog.c | 7 +------ 12 files changed, 27 insertions(+), 36 deletions(-) diff --git a/generic/tkImgPhInstance.c b/generic/tkImgPhInstance.c index 75f11f0..ec9ee04 100644 --- a/generic/tkImgPhInstance.c +++ b/generic/tkImgPhInstance.c @@ -599,7 +599,7 @@ BlendComplexAlpha( g = ALPHA_BLEND(ga, g, alpha, unalpha); b = ALPHA_BLEND(ba, b, alpha, unalpha); } -#ifndef MAC_OSX_TK +#ifndef MAC_OSX_TK XPutPixel(bgImg, x, y, RGB(r, g, b)); #else XPutPixel(bgImg, x, y, RGBA(r, g, b, alpha)); diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 238ae1a..126b631 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -4468,7 +4468,7 @@ DisplayText( #else } else if (dlPtr->chunkPtr != NULL && ((dlPtr->y < 0) || (dlPtr->y + dlPtr->height > dInfoPtr->maxY))) { - /* + /* * On platforms other than the Mac: * * It's the first or last DLine which are also overlapping the diff --git a/library/demos/menu.tcl b/library/demos/menu.tcl index 557bf45..a788a65 100644 --- a/library/demos/menu.tcl +++ b/library/demos/menu.tcl @@ -115,7 +115,7 @@ $w.menu add cascade -label "Icons" -menu $m -underline 0 menu $m -tearoff 0 # Main widget program sets variable tk_demoDirectory image create photo lilearth -file [file join $tk_demoDirectory \ -images earthmenu.png] +images earthmenu.png] $m add command -image lilearth \ -hidemargin 1 -command [list \ tk_dialog $w.pattern {Bitmap Menu Entry} \ diff --git a/macosx/README b/macosx/README index c796396..13b5e66 100644 --- a/macosx/README +++ b/macosx/README @@ -391,7 +391,7 @@ The Makefile variables TCL_FRAMEWORK_DIR and TCLSH_DIR were added with Tk 8.4.3. 4. Details regarding the macOS port of Tk. ------------------------------------------- - + 4.1 About the event loop ~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/macosx/tkMacOSXConstants.h b/macosx/tkMacOSXConstants.h index 1ee85a6..95983dd 100644 --- a/macosx/tkMacOSXConstants.h +++ b/macosx/tkMacOSXConstants.h @@ -4,7 +4,7 @@ * Macros which map the names of NS constants used in the Tk code to * the new name that Apple came up with for subsequent versions of the * operating system. (Each new OS release seems to come with a new - * naming convention for the same old constants.) + * naming convention for the same old constants.) * * Copyright (c) 2017 Marc Culler * @@ -53,7 +53,7 @@ #define NSDeviceIndependentModifierFlagsMask NSEventModifierFlagDeviceIndependentFlagsMask #define NSCommandKeyMask NSEventModifierFlagCommand #define NSShiftKeyMask NSEventModifierFlagShift -#define NSAlphaShiftKeyMask NSEventModifierFlagCapsLock +#define NSAlphaShiftKeyMask NSEventModifierFlagCapsLock #define NSAlternateKeyMask NSEventModifierFlagOption #define NSControlKeyMask NSEventModifierFlagControl #define NSNumericPadKeyMask NSEventModifierFlagNumericPad diff --git a/macosx/tkMacOSXDefault.h b/macosx/tkMacOSXDefault.h index 65762b7..5a53bdd 100644 --- a/macosx/tkMacOSXDefault.h +++ b/macosx/tkMacOSXDefault.h @@ -325,11 +325,6 @@ #define DEF_MENU_SELECT_COLOR "systemMenuActive" #define DEF_MENU_SELECT_MONO BLACK #define DEF_MENU_TAKE_FOCUS "0" - -/* - * FIXME: Turn the default back to 1 when we make tearoff menus work again. - */ - #define DEF_MENU_TEAROFF "0" #define DEF_MENU_TEAROFF_CMD ((char *) NULL) #define DEF_MENU_TITLE "" diff --git a/macosx/tkMacOSXEmbed.c b/macosx/tkMacOSXEmbed.c index 0c2ca69..edcd064 100644 --- a/macosx/tkMacOSXEmbed.c +++ b/macosx/tkMacOSXEmbed.c @@ -193,7 +193,7 @@ TkpMakeWindow( int TkpScanWindowId( Tcl_Interp *interp, - CONST char * string, + const char * string, Window *idPtr) { int code; diff --git a/macosx/tkMacOSXImage.c b/macosx/tkMacOSXImage.c index 2436e60..096faac 100644 --- a/macosx/tkMacOSXImage.c +++ b/macosx/tkMacOSXImage.c @@ -212,7 +212,7 @@ XGetImage( CFRelease(bitmap_rep); return NULL; } - + if (macDraw->flags & TK_USE_XIMAGE_ALPHA) { /* * When called by TkImgPhotoDisplay we are being asked to return a @@ -230,7 +230,7 @@ XGetImage( memcpy(bitmap, (char *)[bitmap_rep bitmapData], size); } CFRelease(bitmap_rep); - + /* * When Apple extracts a bitmap from an NSView, it may be in * either BGRA or ABGR format. For an XImage we need RGBA. @@ -243,7 +243,7 @@ XGetImage( G = *(bitmap + m + pixel.g); B = *(bitmap + m + pixel.b); A = *(bitmap + m + pixel.a); - + *(bitmap + m) = R; *(bitmap + m + 1) = G; *(bitmap + m + 2) = B; @@ -543,7 +543,7 @@ TkPutImage( { TkMacOSXDrawingContext dc; MacDrawable *macDraw = ((MacDrawable*)drawable); - + display->request++; if (!TkMacOSXSetupDrawingContext(drawable, gc, 1, &dc)) { return BadDrawable; diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index 7b91f97..b38036c 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -129,7 +129,7 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt */ _defaultMainMenu = nil; [self _setupMenus]; - + /* * Set the application icon. This is unnecessary when running Wish.app * but it is easier than testing for that situation to just do it. @@ -167,7 +167,7 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt - (void) _setup: (Tcl_Interp *) interp { - /* + /* * Remember our interpreter. */ _eventInterp = interp; @@ -304,7 +304,7 @@ TkpInit( TkMacOSXDbgMsg("Tcl_MacOSXOpenVersionedBundleResources failed"); } #endif - + /* * FIXME: Close stdin & stdout for remote debugging otherwise we will * fight with gdb for stdin & stdout @@ -319,7 +319,7 @@ TkpInit( * Instantiate our NSApplication object. This needs to be * done before we check whether to open a console window. */ - + NSAutoreleasePool *pool = [NSAutoreleasePool new]; [[NSUserDefaults standardUserDefaults] registerDefaults: [NSDictionary dictionaryWithObjectsAndKeys: diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index 2c036bb..3d5e986 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -156,7 +156,7 @@ XMapWindow( * before applicationDidFinishLaunching returns. Forcing * the app to activate too early can make the menu bar * unresponsive. - */ + */ [NSApp activateIgnoringOtherApps:NO]; if ( [win canBecomeKeyWindow] ) { [win makeKeyAndOrderFront:NSApp]; diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 23d3e1f..6983839 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -189,7 +189,7 @@ static const Tk_GeomMgr wmMgrType = { * The following keeps state for Aqua dock icon bounce notification. */ -static int tkMacOSXWmAttrNotifyVal = 0; +static int tkMacOSXWmAttrNotifyVal = 0; /* * Hash table for Mac Window -> TkWindow mapping. @@ -786,7 +786,7 @@ TkWmMapWindow( /*Add window to Window menu.*/ NSWindow *win = TkMacOSXDrawableWindow(winPtr->window); - [win setExcludedFromWindowsMenu:NO]; + [win setExcludedFromWindowsMenu:NO]; } @@ -923,7 +923,7 @@ TkWmDeadWindow( WmInfo *wmPtr = winPtr2->wmInfoPtr; BOOL minimized = (wmPtr->hints.initial_state == IconicState || wmPtr->hints.initial_state == WithdrawnState); - /* + /* * If no windows are left on the screen and the next * window is iconified or withdrawn, we don't want to * make it be the KeyWindow because that would cause @@ -1976,7 +1976,7 @@ WmGridCmd( { register WmInfo *wmPtr = winPtr->wmInfoPtr; int reqWidth, reqHeight, widthInc, heightInc; - char *errorMsg; + const char *errorMsg; if ((objc != 3) && (objc != 7)) { Tcl_WrongNumArgs(interp, 2, objv, @@ -2355,7 +2355,7 @@ WmIconnameCmd( * WmIconphotoCmd -- * * This procedure is invoked to process the "wm iconphoto" Tcl command. - * See the user documentation for details on what it does. + * See the user documentation for details on what it does. * * Results: * A standard Tcl result. @@ -2366,6 +2366,7 @@ WmIconnameCmd( * *---------------------------------------------------------------------- */ + static int WmIconphotoCmd( Tk_Window tkwin, /* Main window of the application. */ @@ -2395,7 +2396,7 @@ WmIconphotoCmd( /*Get icon name. We only use the first icon name because macOS does not support multiple images in Tk photos.*/ - char *icon; + char *icon; if (strcmp(Tcl_GetString(objv[3]), "-default") == 0) { icon = Tcl_GetString(objv[4]); } else { @@ -2411,7 +2412,7 @@ WmIconphotoCmd( Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "PHOTO", NULL); return TCL_ERROR; } - + NSImage *newIcon; Tk_SizeOfImage(tk_icon, &width, &height); newIcon = TkMacOSXGetNSImageWithTkImage(winPtr->display, tk_icon, width, height); @@ -3524,8 +3525,8 @@ WmWithdrawCmd( TkpWmSetState(winPtr, WithdrawnState); /*Remove window from Window menu.*/ NSWindow *win = TkMacOSXDrawableWindow(winPtr->window); - [win setExcludedFromWindowsMenu:YES]; - + [win setExcludedFromWindowsMenu:YES]; + return TCL_OK; } diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index 5be6776..f97d813 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -644,12 +644,7 @@ static void LoadShellProcs() if (shell32_handle != NULL) return; /* We have already been through here. */ - /* - * XXX - Note we never call FreeLibrary. There is no point because - * shell32.dll is loaded at startup anyways and stays for the duration - * of the process so why bother with keeping track of when to unload - */ - shell32_handle = LoadLibrary(TEXT("shell32.dll")); + shell32_handle = GetModuleHandle(TEXT("shell32.dll")); if (shell32_handle == NULL) /* Should never happen but check anyways. */ return; -- cgit v0.12