Tk Source Code

Changes On Branch mac-wm-icon
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch mac-wm-icon Excluding Merge-Ins

This is equivalent to a diff from 4581f720 to 5afe63b4

2017-11-11
08:43
merge mac-wm-icon branch (because the changes from this branch were just committed separately as a standalone patch in core-8-6-branch) check-in: aaa56ad9 user: fvogel tags: core-8-6-branch
2017-10-15
02:58
Patch by Marc Culler to address subtle issues with clipping regions in scrolling and drawing on macOS check-in: 7ffddfc2 user: kevin_walzer tags: core-8-6-branch
2017-10-13
20:55
Documentation tweak Closed-Leaf check-in: 5afe63b4 user: kevin_walzer tags: mac-wm-icon
20:46
Push updates check-in: 8442de35 user: kevin_walzer tags: mac-wm-icon
20:45
Start mac-wm-icon branch check-in: 4e761f53 user: kevin_walzer tags: mac-wm-icon
20:32
Add tkMacOSXConstants.h header file per Marc Culler check-in: 4581f720 user: kevin_walzer tags: core-8-6-branch
20:13
Merge bugfix branch bug-fab5fed65e with a better fix for [fab5fed65e] (from Marc Culler). Note: this patch was already applied to core-8-6-branch (part of [be9900e3], plus [4af049ff]) and trunk (part of [af9bd122], plus [32fa275d]), thus the empty diff. check-in: ce3bd56e user: fvogel tags: core-8-6-branch

Changes to doc/wm.n.

484
485
486
487
488
489
490
491








492
493
494
495
496
497
498
484
485
486
487
488
489
490

491
492
493
494
495
496
497
498
499
500
501
502
503
504
505







-
+
+
+
+
+
+
+
+







vice versa.
.PP
On X, the images are arranged into the _NET_WM_ICON X property, which
most modern window managers support.  A \fBwm iconbitmap\fR may exist
simultaneously.  It is recommended to use not more than 2 icons, placing
the larger icon first.
.PP
On Macintosh, this currently does nothing.
On Macintosh, the first image called is loaded into an OSX-native icon
format, and becomes the application icon in dialogs, the Dock, and
other contexts. At present images loaded from PNG format lose their
alpha channel, but GIF format preserves its alpha/transparency. At the
script level the command will accept only the first image passed in the
parameters as support for multiple sizes/resolutions on macOS is outside Tk's
scope. Developers should use the largest icon they can support
(preferably 512 pixels) to ensure smooth rendering on the Mac.
.RE
.TP
\fBwm iconposition \fIwindow\fR ?\fIx y\fR?
.
If \fIx\fR and \fIy\fR are specified, they are passed to the window
manager as a hint about where to position the icon for \fIwindow\fR.
In this case an empty string is returned.  If \fIx\fR and \fIy\fR are

Changes to macosx/tkMacOSXWm.c.

2332
2333
2334
2335
2336
2337
2338
2339

2340
2341
2342
2343
2344
2345
2346
2347
2348
2349

2350
2351
2352
2353
2354
2355
2356
2357
2358


2359
2360
2361
2362
2363

2364
2365

2366
2367
2368
2369
2370

2371
2372
2373
2374
2375

2376
2377
2378
2379

2380
2381

2382
2383
2384
2385


2386
2387
2388

2389
2390
2391
2392





2393
2394
2395
2396




2397
2398
2399


2400
2401
2402
2403
2404
2405
2406
2332
2333
2334
2335
2336
2337
2338

2339

2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357

2358
2359
2360
2361
2362
2363

2364
2365
2366
2367
2368
2369
2370
2371

2372
2373
2374
2375
2376

2377




2378


2379




2380
2381



2382




2383
2384
2385
2386
2387




2388
2389
2390
2391
2392


2393
2394
2395
2396
2397
2398
2399
2400
2401







-
+
-









+








-
+
+




-
+


+




-
+




-
+
-
-
-
-
+
-
-
+
-
-
-
-
+
+
-
-
-
+
-
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
+

-
-
+
+








/*
 *----------------------------------------------------------------------
 *
 * WmIconphotoCmd --
 *
 *	This procedure is invoked to process the "wm iconphoto" Tcl command.
 *	See the user documentation for details on what it does. Not yet
 *	See the user documentation for details on what it does. 
 *	implemented for OS X.
 *
 * Results:
 *	A standard Tcl result.
 *
 * Side effects:
 *	See the user documentation.
 *
 *----------------------------------------------------------------------
 */

static int
WmIconphotoCmd(
    Tk_Window tkwin,		/* Main window of the application. */
    TkWindow *winPtr,		/* Toplevel to work with */
    Tcl_Interp *interp,		/* Current interpreter. */
    int objc,			/* Number of arguments. */
    Tcl_Obj *const objv[])	/* Argument objects. */
{
    Tk_PhotoHandle photo;
   
    Tk_Image tk_icon;
    int i, width, height, isDefault = 0;

    if (objc < 4) {
	Tcl_WrongNumArgs(interp, 2, objv,
		"window ?-default? image1 ?image2 ...?");
			 "window ?-default? image1 ?image2 ...?");
	return TCL_ERROR;
    }

    if (strcmp(Tcl_GetString(objv[3]), "-default") == 0) {
	isDefault = 1;
	if (objc == 4) {
	    Tcl_WrongNumArgs(interp, 2, objv,
		    "window ?-default? image1 ?image2 ...?");
			     "window ?-default? image1 ?image2 ...?");
	    return TCL_ERROR;
	}
    }

    /*
    char *icon; 
     * Iterate over all images to retrieve their sizes, in order to allocate a
     * buffer large enough to hold all images.
     */

    if (strcmp(Tcl_GetString(objv[3]), "-default") == 0) {
    for (i = 3 + isDefault; i < objc; i++) {
	photo = Tk_FindPhoto(interp, Tcl_GetString(objv[i]));
	icon = Tcl_GetString(objv[4]);
	if (photo == NULL) {
	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
		    "can't use \"%s\" as iconphoto: not a photo image",
		    Tcl_GetString(objv[i])));
    }	else {
	icon = Tcl_GetString(objv[3]);
	    Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "PHOTO", NULL);
	    return TCL_ERROR;
	}
    }
	Tk_PhotoGetSize(photo, &width, &height);
    }

    /*
     
    tk_icon = Tk_GetImage(interp, winPtr, icon, NULL, NULL);
    Tk_SizeOfImage(tk_icon, &width, &height);
	
    NSImage *newIcon;
     * TODO: This requires implementation for OS X, but we silently return for
     * now.
     */

    newIcon = TkMacOSXGetNSImageWithTkImage(winPtr->display, tk_icon, width, height);
    [NSApp setApplicationIconImage: newIcon];
	   
    Tk_FreeImage(tk_icon);
    return TCL_OK;
}

} 

/*
 *----------------------------------------------------------------------
 *
 * WmIconpositionCmd --
 *
 *	This procedure is invoked to process the "wm iconposition" Tcl
 *	command. See the user documentation for details on what it does.