summaryrefslogtreecommitdiffstats
path: root/unix/tkUnixSysNotify.c
diff options
context:
space:
mode:
authorKevin Walzer <kw@codebykevin.com>2022-03-15 02:02:59 (GMT)
committerKevin Walzer <kw@codebykevin.com>2022-03-15 02:02:59 (GMT)
commita9f3697b89b3126957d648c19a862499f1c3f588 (patch)
tree720d445180115cfc0d0286195a8601eed5dc272b /unix/tkUnixSysNotify.c
parentb8f122996e22fb32bf31b51d8f16e5f4e4ed17f1 (diff)
downloadtk-a9f3697b89b3126957d648c19a862499f1c3f588.zip
tk-a9f3697b89b3126957d648c19a862499f1c3f588.tar.gz
tk-a9f3697b89b3126957d648c19a862499f1c3f588.tar.bz2
Patches by Emiliano Gavilan to improve Tk notifications on X11
Diffstat (limited to 'unix/tkUnixSysNotify.c')
-rwxr-xr-xunix/tkUnixSysNotify.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/unix/tkUnixSysNotify.c b/unix/tkUnixSysNotify.c
index 1572027..3985f0e 100755
--- a/unix/tkUnixSysNotify.c
+++ b/unix/tkUnixSysNotify.c
@@ -108,6 +108,7 @@ SysNotifyCmd(
const char *title;
const char *message;
const char *icon;
+ const char *appname = "Wish";
void *notif;
if (objc < 3) {
@@ -124,6 +125,15 @@ SysNotifyCmd(
message = Tcl_GetString(objv[2]);
icon = "dialog-information";
+
+ /* Use the appname for libnotify initialization
+ * See bug f63c37be3a for a discussion whether this should be
+ * allowed at all on safe interpreters
+ */
+ if (!Tcl_IsSafe(interp)) {
+ appname = ((TkWindow *)Tk_MainWindow(interp))->nameUid;
+ }
+
/*
* Call to notify_init should go here to prevent test suite failure.
*/
@@ -132,11 +142,14 @@ SysNotifyCmd(
Tcl_Encoding enc;
Tcl_DString dst, dsm;
+ Tcl_DStringInit(&dst);
+ Tcl_DStringInit(&dsm);
enc = Tcl_GetEncoding(NULL, "utf-8");
- Tcl_ExternalToUtfDString(enc, title, -1, &dst);
- Tcl_ExternalToUtfDString(enc, message, -1, &dsm);
- notify_init("Wish");
- notif = notify_notification_new(title, message, icon, NULL);
+ Tcl_UtfToExternalDString(enc, title, -1, &dst);
+ Tcl_UtfToExternalDString(enc, message, -1, &dsm);
+ notify_init(appname);
+ notif = notify_notification_new(Tcl_DStringValue(&dst),
+ Tcl_DStringValue(&dsm), icon, NULL);
notify_notification_show(notif, NULL);
Tcl_DStringFree(&dsm);
Tcl_DStringFree(&dst);
@@ -218,4 +231,3 @@ SysNotify_Init(
* coding: utf-8
* End:
*/
-