summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2021-09-03 21:41:17 (GMT)
committerfvogel <fvogelnew1@free.fr>2021-09-03 21:41:17 (GMT)
commitb0116f137a8931ebc8d631a75713d6ad8b5a8c8f (patch)
tree1fe212d40c999f3b689a47880c7841f2ba1d218c
parent93c02cc3902e597f0b5802809471133278dc815e (diff)
downloadtk-b0116f137a8931ebc8d631a75713d6ad8b5a8c8f.zip
tk-b0116f137a8931ebc8d631a75713d6ad8b5a8c8f.tar.gz
tk-b0116f137a8931ebc8d631a75713d6ad8b5a8c8f.tar.bz2
Attempt to support badges for multiple toplevels. Works on X11 at least.
-rw-r--r--doc/wm.n19
-rw-r--r--library/demos/windowicons.tcl79
-rw-r--r--library/iconbadges.tcl10
-rw-r--r--macosx/tkMacOSXWm.c24
-rw-r--r--tests/unixWm.test2
-rw-r--r--tests/winWm.test2
-rw-r--r--tests/wm.test19
-rw-r--r--unix/tkUnixWm.c36
-rw-r--r--win/tkWinWm.c46
9 files changed, 104 insertions, 133 deletions
diff --git a/doc/wm.n b/doc/wm.n
index a578a87..9b72187 100644
--- a/doc/wm.n
+++ b/doc/wm.n
@@ -413,13 +413,15 @@ Sets a badge for the icon of the \fIwindow\fR. The badge can be a number,
for instance the number of new or unread messages, or
an exclamation point denoting attention needed. If the badge is an empty
string, the badge image is removed from the application icon. Managing
-these changes through bindings, such as <FocusIn>, is the responsibility of the developer.
+these changes through bindings, such as <FocusIn>, is the responsibility
+of the developer.
.RS
.PP
On X11, for this command to work,
-the variable \fB::tk::icons::base_icon\fR must be set to the image that is
-being used for the window icon, and the window's iconphoto must actually
-be set via the \fBwm iconphoto\fR command. On Windows and X11, the iconphoto images work best at 32x32 or a similar dimension, as
+the variable \fB::tk::icons::base_icon($window)\fR must be set to the image that is
+being used for the window icon of $window, and the window's iconphoto must actually
+be set via the \fBwm iconphoto\fR command. On Windows and X11, the iconphoto
+images work best at 32x32 or a similar dimension, as
the badge images are provided by Tk and drawn to overlay the icon images
using native (Windows) API's or Tk rendering. On macOS, the icon badge is
rendered by a system API and is not provided by Tk. The icon image itself
@@ -487,7 +489,7 @@ or an empty string if no icon name has been specified (in this
case the window manager will normally display the window's title,
as specified with the \fBwm title\fR command).
.TP
-\fBwm iconphoto \fIwindow\fR ??\fB\-default\fR? \fIimage1\fR ?\fIimage2 ...\fR??
+\fBwm iconphoto \fIwindow\fR ?\fB\-default\fR? \fIimage1\fR ?\fIimage2 ...\fR?
.
Sets the titlebar icon for \fIwindow\fR based on the named photo images.
If \fB\-default\fR is specified, this is applied to all future created
@@ -495,15 +497,12 @@ toplevels as well. The data in the images is taken as a snapshot at the
time of invocation. If the images are later changed, this is not
reflected to the titlebar icons. Multiple images are accepted to allow
different images sizes (e.g., 16x16 and 32x32) to be provided. The window
-manager may scale provided icons to an appropriate size. If this command
-is called without an image argument, the current image set for the
-titlebar icon is returned.
+manager may scale provided icons to an appropriate size.
.RS
.PP
On Windows, the images are packed into a Windows icon structure.
This will override an ico specified to \fBwm iconbitmap\fR, and
-vice versa. This command sets the taskbar icon as the designated icon on
-Windows.
+vice versa. This command sets the taskbar icon for the window.
.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
diff --git a/library/demos/windowicons.tcl b/library/demos/windowicons.tcl
index 82bfe38..f89d252 100644
--- a/library/demos/windowicons.tcl
+++ b/library/demos/windowicons.tcl
@@ -7,7 +7,6 @@ if {![info exists widgetDemo]} {
error "This script should be run from the \"widget\" demo."
}
-
set w .windowicons
destroy $w
toplevel $w
@@ -15,13 +14,83 @@ wm title $w "Window Icon Demonstration"
positionWindow $w
image create photo icon -data {
-iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAArQNAA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::base_icon icon
-
-pack [button $w.i -text "Set Window Icon to Globe" -image $::tk::icons::base_icon -compound top -command {wm iconphoto . $::tk::icons::base_icon }]
+pack [button $w.i -text "Set Window Icon to Globe" -image $::tk::icons::base_icon(.) \
+ -compound top -command {wm iconphoto . $::tk::icons::base_icon(.) }]
pack [button $w.b -text "Set Badge to 3" -command {wm iconbadge . 3}]
pack [button $w.e -text "Set Badge to 11" -command {wm iconbadge . 11}]
pack [button $w.f -text "Reset Badge" -command {wm iconbadge . ""}]
diff --git a/library/iconbadges.tcl b/library/iconbadges.tcl
index 7647e28..4715119 100644
--- a/library/iconbadges.tcl
+++ b/library/iconbadges.tcl
@@ -207,15 +207,17 @@ if {[tk windowingsystem] eq "x11"} {
variable ::tk::icons::base_icon
- if {$::tk::icons::base_icon eq ""} {
- return -code error "You must set the value of \"::tk::icons::base_icon\" to a Tk photo before setting an icon badge"
+ if {![info exists ::tk::icons::base_icon($win)]} {
+ return -code error "You must set the value of \"::tk::icons::base_icon(\$win)\" to a Tk photo before setting an icon badge"
}
+if 0 {
if {[wm iconphoto $win] eq ""} {
return -code error "You must set a Tk image as a window icon via the \"wm iconphoto\" command before setting an icon badge"
}
+}
- wm iconphoto $win $::tk::icons::base_icon
+ wm iconphoto $win $::tk::icons::base_icon($win)
if {$badgenumber eq ""} {
return
@@ -236,7 +238,7 @@ if {[tk windowingsystem] eq "x11"} {
}
- overlay copy $::tk::icons::base_icon
+ overlay copy $::tk::icons::base_icon($win)
overlay copy $badge -from 0 0 18 18 -to 18 0
wm iconphoto $win overlay
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index 5cbc474..8f5b8f2 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -193,12 +193,6 @@ static const Tk_GeomMgr wmMgrType = {
static int tkMacOSXWmAttrNotifyVal = 0;
/*
- * The following stores the name of the "wm iconphoto" image.
- */
-
-char *base_icon = NULL;
-
-/*
* Forward declarations for procedures defined in this file:
*/
@@ -2684,22 +2678,7 @@ WmIconphotoCmd(
int width, height, isDefault = 0;
NSImage *newIcon = NULL;
- if (strcmp(Tcl_GetString(objv[1]), "iconphoto") != 0) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj("Argument should be \"iconphoto\"", -1));
- return TCL_ERROR;
- }
-
- if ((objc == 3) && (base_icon == NULL)) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj("", -1));
- return TCL_OK;
- }
-
- if ((objc == 3) && (base_icon != NULL)) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(base_icon, -1));
- return TCL_OK;
- }
-
- if (objc < 3) {
+ if (objc < 4) {
Tcl_WrongNumArgs(interp, 2, objv,
"window ?-default? image1 ?image2 ...?");
return TCL_ERROR;
@@ -2756,7 +2735,6 @@ WmIconphotoCmd(
return TCL_ERROR;
}
[NSApp setApplicationIconImage: newIcon];
- base_icon = icon;
return TCL_OK;
}
diff --git a/tests/unixWm.test b/tests/unixWm.test
index 84eafff..2adf03f 100644
--- a/tests/unixWm.test
+++ b/tests/unixWm.test
@@ -2539,7 +2539,7 @@ test unixWm-60.5 {wm attributes - bad attribute} -constraints unix -body {
test unixWm-61.1 {Tk_WmCmd procedure, "iconphoto" option} unix {
list [catch {wm iconph .} msg] $msg
-} {1 {Argument should be "iconphoto"}}
+} {1 {wrong # args: should be "wm iconphoto window ?-default? image1 ?image2 ...?"}}
test unixWm-61.2 {Tk_WmCmd procedure, "iconphoto" option} unix {
destroy .t
toplevel .t
diff --git a/tests/winWm.test b/tests/winWm.test
index 3effef9..f659a13 100644
--- a/tests/winWm.test
+++ b/tests/winWm.test
@@ -431,7 +431,7 @@ test winWm-7.4 {UpdateWrapper must maintain focus} -constraints win -setup {
test winWm-8.1 {Tk_WmCmd procedure, "iconphoto" option} -constraints win -body {
wm iconph .
-} -returnCodes error -result {Argument should be "iconphoto"}
+} -returnCodes error -result {wrong # args: should be "wm iconphoto window ?-default? image1 ?image2 ...?"}
test winWm-8.2 {Tk_WmCmd procedure, "iconphoto" option} -constraints win -setup {
destroy .t
} -body {
diff --git a/tests/wm.test b/tests/wm.test
index 1422013..fadc060 100644
--- a/tests/wm.test
+++ b/tests/wm.test
@@ -799,8 +799,8 @@ test wm-iconbadge-1.1 {usage} -returnCodes error -body {
} -result {wrong # args: should be "wm option window ?arg ...?"}
test wm-iconbadge-1.2 {usage} -body {
toplevel .top
- set ::tk::icons::base_icon icon
- wm iconphoto .top $::tk::icons::base_icon
+ set ::tk::icons::base_icon(.top) icon
+ wm iconphoto .top $::tk::icons::base_icon(.top)
wm iconbadge .top 14
} -cleanup {
destroy .top
@@ -945,23 +945,20 @@ test wm-iconname-2.1 {setting and reading values} -setup {
test wm-iconphoto-1.1 {usage} -returnCodes error -body {
wm iconphoto
} -result {wrong # args: should be "wm option window ?arg ...?"}
-test wm-iconphoto-1.2 {usage} -body {
- wm iconphoto . icon
-} -result {}
-test wm-iconphoto-1.3 {usage} -body {
+test wm-iconphoto-1.2 {usage} -returnCodes error -body {
wm iconphoto .
-} -result {icon}
-test wm-iconphoto-1.4 {usage} -returnCodes error -body {
+} -result {wrong # args: should be "wm iconphoto window ?-default? image1 ?image2 ...?"}
+test wm-iconphoto-1.3 {usage} -returnCodes error -body {
wm iconphoto . notanimage
} -result {can't use "notanimage" as iconphoto: not a photo image}
-test wm-iconphoto-1.5 {usage} -returnCodes error -body {
+test wm-iconphoto-1.4 {usage} -returnCodes error -body {
# we currently have no return info
wm iconphoto . -default
} -result {wrong # args: should be "wm iconphoto window ?-default? image1 ?image2 ...?"}
-test wm-iconphoto-1.6.1 {usage} -constraints aquaOrWin32 -returnCodes error -body {
+test wm-iconphoto-1.5.1 {usage} -constraints aquaOrWin32 -returnCodes error -body {
wm iconphoto . -default [image create photo -file {}]
} -match {glob} -result {failed to create an iconphoto with image *}
-test wm-iconphoto-1.6.2 {usage} -constraints x11 -body {
+test wm-iconphoto-1.5.2 {usage} -constraints x11 -body {
wm iconphoto . -default [image create photo -file {}]
} -result {}
diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c
index e460eb0..581c3cc 100644
--- a/unix/tkUnixWm.c
+++ b/unix/tkUnixWm.c
@@ -335,12 +335,6 @@ typedef struct WaitRestrictInfo {
} WaitRestrictInfo;
/*
- * The following stores the name of the "wm iconphoto" image.
- */
-
-char *base_icon = NULL;
-
-/*
* Forward declarations for functions defined in this file:
*/
@@ -2439,24 +2433,8 @@ WmIconphotoCmd(
Tk_PhotoImageBlock block;
int i, size = 0, width, height, index = 0, x, y, isDefault = 0;
unsigned long *iconPropertyData;
- char *icon;
- if (strcmp(Tcl_GetString(objv[1]), "iconphoto") != 0) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj("Argument should be \"iconphoto\"", -1));
- return TCL_ERROR;
- }
-
- if ((objc == 3) && (base_icon == NULL)) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj("", -1));
- return TCL_OK;
- }
-
- if ((objc == 3) && (base_icon != NULL)) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(base_icon, -1));
- return TCL_OK;
- }
-
- if (objc < 3) {
+ if (objc < 4) {
Tcl_WrongNumArgs(interp, 2, objv,
"window ?-default? image1 ?image2 ...?");
return TCL_ERROR;
@@ -2470,16 +2448,6 @@ WmIconphotoCmd(
}
}
- /*
- * Get icon name. We only use the first icon name.
- */
-
- if (strcmp(Tcl_GetString(objv[3]), "-default") == 0) {
- icon = Tcl_GetString(objv[4]);
- } else {
- icon = Tcl_GetString(objv[3]);
- }
-
/*
* Iterate over all images to retrieve their sizes, in order to allocate a
* buffer large enough to hold all images.
@@ -2582,8 +2550,6 @@ WmIconphotoCmd(
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
UpdatePhotoIcon(winPtr);
}
-
- base_icon = icon;
return TCL_OK;
}
diff --git a/win/tkWinWm.c b/win/tkWinWm.c
index e343b6d..fa0326d 100644
--- a/win/tkWinWm.c
+++ b/win/tkWinWm.c
@@ -349,11 +349,6 @@ static int initialized; /* Flag indicating whether module has been
TCL_DECLARE_MUTEX(winWmMutex)
-/*
- * The following stores the name of the "wm iconphoto" image.
- */
-char *base_icon = NULL;
-
/*
* The following records the "TaskbarButtonCreated" message ID
* for overlay icons.
@@ -4310,47 +4305,14 @@ WmIconphotoCmd(
WinIconPtr titlebaricon = NULL;
HICON hIcon;
unsigned size;
- char* icon;
(void)tkwin;
- if (strcmp(Tcl_GetString(objv[1]), "iconphoto") != 0) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj("Argument should be \"iconphoto\"", -1));
- return TCL_ERROR;
- }
-
- if ((objc == 3) && (strcmp(Tcl_GetString(objv[1]), "iconphoto") == 0) && base_icon == NULL) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj("", -1));
- return TCL_OK;
- }
-
- if ((objc == 3) && (base_icon != NULL)) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(base_icon, -1));
- return TCL_OK;
- }
-
- if (objc < 3) {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?-default? image1 ?image2 ...?");
+ if (objc < 4) {
+ Tcl_WrongNumArgs(interp, 2, objv,
+ "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;
- }
- }
-
- /*
- * Get icon name. We only use the first icon name.
- */
-
- if (strcmp(Tcl_GetString(objv[3]), "-default") == 0) {
- icon = Tcl_GetString(objv[4]);
- } else {
- icon = Tcl_GetString(objv[3]);
- }
-
/*
* Iterate over all images to validate their existence.
*/
@@ -4419,8 +4381,6 @@ WmIconphotoCmd(
DecrIconRefCount(titlebaricon);
return TCL_ERROR;
}
- base_icon = icon;
-
return TCL_OK;
}