summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkevin_walzer <kevin_walzer@noemail.net>2017-10-13 20:45:10 (GMT)
committerkevin_walzer <kevin_walzer@noemail.net>2017-10-13 20:45:10 (GMT)
commitb65b215604fe9a75438a735e61646e17f131b085 (patch)
tree2c179e4078a8a9191b32f7a65813244efeb261d3
parentf71727ef747e8ac3b959b06e700010352323ccc6 (diff)
downloadtk-b65b215604fe9a75438a735e61646e17f131b085.zip
tk-b65b215604fe9a75438a735e61646e17f131b085.tar.gz
tk-b65b215604fe9a75438a735e61646e17f131b085.tar.bz2
Start mac-wm-icon branch
FossilOrigin-Name: 4e761f533cf820b28b859f74f001ca5e0c0788eba94087e08fd358a5b8700a73
-rw-r--r--doc/wm.n5
-rw-r--r--macosx/tkMacOSXWm.c51
2 files changed, 27 insertions, 29 deletions
diff --git a/doc/wm.n b/doc/wm.n
index b1a9fea..a1c82d4 100644
--- a/doc/wm.n
+++ b/doc/wm.n
@@ -488,7 +488,10 @@ 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.
.RE
.TP
\fBwm iconposition \fIwindow\fR ?\fIx y\fR?
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index 750fca8..40304f9 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -2336,8 +2336,7 @@ WmIconnameCmd(
* WmIconphotoCmd --
*
* This procedure is invoked to process the "wm iconphoto" Tcl command.
- * See the user documentation for details on what it does. Not yet
- * implemented for OS X.
+ * See the user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
@@ -2347,6 +2346,7 @@ WmIconnameCmd(
*
*----------------------------------------------------------------------
*/
+
static int
WmIconphotoCmd(
Tk_Window tkwin, /* Main window of the application. */
@@ -2355,48 +2355,43 @@ WmIconphotoCmd(
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 ...?");
- return TCL_ERROR;
- }
- }
-
- /*
- * Iterate over all images to retrieve their sizes, in order to allocate a
- * buffer large enough to hold all images.
- */
-
- for (i = 3 + isDefault; i < objc; i++) {
- photo = Tk_FindPhoto(interp, Tcl_GetString(objv[i]));
- if (photo == NULL) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "can't use \"%s\" as iconphoto: not a photo image",
- Tcl_GetString(objv[i])));
- Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "PHOTO", NULL);
+ "window ?-default? image1 ?image2 ...?");
return TCL_ERROR;
}
- Tk_PhotoGetSize(photo, &width, &height);
}
- /*
- * TODO: This requires implementation for OS X, but we silently return for
- * now.
- */
-
+ char *icon;
+ if (strcmp(Tcl_GetString(objv[3]), "-default") == 0) {
+ icon = Tcl_GetString(objv[4]);
+ } else {
+ icon = Tcl_GetString(objv[3]);
+ }
+
+ tk_icon = Tk_GetImage(interp, winPtr, icon, NULL, NULL);
+ Tk_SizeOfImage(tk_icon, &width, &height);
+
+ NSImage *newIcon;
+ newIcon = TkMacOSXGetNSImageWithTkImage(winPtr->display, tk_icon, width, height);
+ [NSApp setApplicationIconImage: newIcon];
+
+ Tk_FreeImage(tk_icon);
return TCL_OK;
}
-
+
/*
*----------------------------------------------------------------------
*