summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjenglish <jenglish@flightlab.com>2004-07-05 19:19:38 (GMT)
committerjenglish <jenglish@flightlab.com>2004-07-05 19:19:38 (GMT)
commitbd8474223d6eb52cadb45ca554b67680ce8b992a (patch)
tree897a8fa22210ae78bb7267ee4664fa326a6c2cf2
parent13d6ba70a2d19edd29700a66c12b88ae66a1ef3e (diff)
downloadtk-bd8474223d6eb52cadb45ca554b67680ce8b992a.zip
tk-bd8474223d6eb52cadb45ca554b67680ce8b992a.tar.gz
tk-bd8474223d6eb52cadb45ca554b67680ce8b992a.tar.bz2
Set _NET_WM_NAME and _NET_WM_ICON_NAME (freedesktop.org)
in addition to WM_NAME and WM_ICON_NAME (ICCCM). This allows the full Unicode character set to be used in window manager strings (but only for newer WMs that support the EWMH spec). [Tk Bug #959973]
-rw-r--r--ChangeLog8
-rw-r--r--unix/tkUnixWm.c103
2 files changed, 75 insertions, 36 deletions
diff --git a/ChangeLog b/ChangeLog
index 9adce6d..b337117 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2004-07-05 Joe English <jenglish@users.sourceforge.net>
+
+ * unix/tkUnixWm.c: Set _NET_WM_NAME and _NET_WM_ICON_NAME
+ (freedesktop.org) in addition to WM_NAME and WM_ICON_NAME
+ (ICCCM). This allows the full Unicode character set
+ to be used in window manager strings (but only for
+ newer WMs that support the EWMH spec). [Tk Bug #959973]
+
2004-07-02 George Peter Staplin <GeorgePS@XMission.com>
* generic/tkEvent.c: Tk_HandleEvent was refactored to be more
diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c
index c9f2760..08da60b 100644
--- a/unix/tkUnixWm.c
+++ b/unix/tkUnixWm.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkUnixWm.c,v 1.42 2004/06/16 20:03:19 jenglish Exp $
+ * RCS: @(#) $Id: tkUnixWm.c,v 1.43 2004/07/05 19:19:43 jenglish Exp $
*/
#include "tkPort.h"
@@ -333,6 +333,7 @@ static void UpdateGeometryInfo _ANSI_ARGS_((
static void UpdateHints _ANSI_ARGS_((TkWindow *winPtr));
static void UpdateSizeHints _ANSI_ARGS_((TkWindow *winPtr,
int newWidth, int newHeight));
+static void UpdateTitle _ANSI_ARGS_((TkWindow *winPtr));
static void UpdateVRootGeometry _ANSI_ARGS_((WmInfo *wmPtr));
static void UpdateWmProtocols _ANSI_ARGS_((WmInfo *wmPtr));
static void WaitForConfigureNotify _ANSI_ARGS_((TkWindow *winPtr,
@@ -607,7 +608,6 @@ TkWmMapWindow(winPtr)
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
XTextProperty textProp;
- Tk_Uid string;
if (wmPtr->flags & WM_NEVER_MAPPED) {
Tcl_DString ds;
@@ -629,24 +629,8 @@ TkWmMapWindow(winPtr)
* window.
*/
- string = (wmPtr->title != NULL) ? wmPtr->title : winPtr->nameUid;
- Tcl_UtfToExternalDString(NULL, string, -1, &ds);
- string = Tcl_DStringValue(&ds);
- if (XStringListToTextProperty(&(Tcl_DStringValue(&ds)), 1,
- &textProp) != 0) {
- XSetWMName(winPtr->display, wmPtr->wrapperPtr->window, &textProp);
- XFree((char *) textProp.value);
- }
- Tcl_DStringFree(&ds);
-
TkWmSetClass(winPtr);
-
- if (wmPtr->iconName != NULL) {
- Tcl_UtfToExternalDString(NULL, wmPtr->iconName, -1, &ds);
- XSetIconName(winPtr->display, wmPtr->wrapperPtr->window,
- Tcl_DStringValue(&ds));
- Tcl_DStringFree(&ds);
- }
+ UpdateTitle(winPtr);
if (wmPtr->masterPtr != NULL) {
/*
@@ -2046,12 +2030,7 @@ WmIconnameCmd(tkwin, winPtr, interp, objc, objv)
wmPtr->iconName = ckalloc((unsigned) (length + 1));
strcpy(wmPtr->iconName, argv3);
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
- Tcl_DString ds;
-
- Tcl_UtfToExternalDString(NULL, wmPtr->iconName, -1, &ds);
- XSetIconName(winPtr->display, wmPtr->wrapperPtr->window,
- Tcl_DStringValue(&ds));
- Tcl_DStringFree(&ds);
+ UpdateTitle(winPtr);
}
}
return TCL_OK;
@@ -2944,17 +2923,7 @@ WmTitleCmd(tkwin, winPtr, interp, objc, objv)
strcpy(wmPtr->title, argv3);
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
- XTextProperty textProp;
- Tcl_DString ds;
-
- Tcl_UtfToExternalDString(NULL, wmPtr->title, -1, &ds);
- if (XStringListToTextProperty(&(Tcl_DStringValue(&ds)), 1,
- &textProp) != 0) {
- XSetWMName(winPtr->display, wmPtr->wrapperPtr->window,
- &textProp);
- XFree((char *) textProp.value);
- }
- Tcl_DStringFree(&ds);
+ UpdateTitle(winPtr);
}
}
return TCL_OK;
@@ -4307,6 +4276,68 @@ UpdateSizeHints(winPtr, newWidth, newHeight)
}
/*
+ *--------------------------------------------------------------
+ *
+ * UpdateTitle --
+ *
+ * This procedure is called to update the window title and
+ * icon name. It sets the ICCCM-defined properties WM_NAME
+ * and WM_ICON_NAME for older window managers, and the
+ * freedesktop.org-defined _NET_WM_NAME and _NET_WM_ICON_NAME
+ * properties for newer ones. The ICCCM properties are
+ * stored in the system encoding, the newer properties
+ * are stored in UTF-8.
+ *
+ * NOTE: the ICCCM specifies that WM_NAME and WM_ICON_NAME are
+ * stored in ISO-Latin-1. Tk has historically used the default
+ * system encoding (since 8.1). It's not clear whether this is
+ * correct or not.
+ *
+ * Side effects:
+ * Properties get changed for winPtr.
+ *
+ *--------------------------------------------------------------
+ */
+static void
+UpdateTitle(winPtr)
+ TkWindow *winPtr;
+{
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
+ Atom XA_UTF8_STRING = Tk_InternAtom((Tk_Window) winPtr, "UTF8_STRING");
+ const char *string;
+ Tcl_DString ds;
+
+ /*
+ * Set window title:
+ */
+ string = (wmPtr->title != NULL) ? wmPtr->title : winPtr->nameUid;
+ Tcl_UtfToExternalDString(NULL, string, -1, &ds);
+ XStoreName(winPtr->display, wmPtr->wrapperPtr->window,
+ Tcl_DStringValue(&ds));
+ Tcl_DStringFree(&ds);
+
+ XChangeProperty(winPtr->display, wmPtr->wrapperPtr->window,
+ Tk_InternAtom((Tk_Window) winPtr, "_NET_WM_NAME"),
+ XA_UTF8_STRING, 8, PropModeReplace,
+ string, (signed int)strlen(string));
+
+ /*
+ * Set icon name:
+ */
+ if (wmPtr->iconName != NULL) {
+ Tcl_UtfToExternalDString(NULL, wmPtr->iconName, -1, &ds);
+ XSetIconName(winPtr->display, wmPtr->wrapperPtr->window,
+ Tcl_DStringValue(&ds));
+ Tcl_DStringFree(&ds);
+
+ XChangeProperty(winPtr->display, wmPtr->wrapperPtr->window,
+ Tk_InternAtom((Tk_Window) winPtr, "_NET_WM_ICON_NAME"),
+ XA_UTF8_STRING, 8, PropModeReplace,
+ wmPtr->iconName, (signed int)strlen(wmPtr->iconName));
+ }
+}
+
+/*
*----------------------------------------------------------------------
*
* WaitForConfigureNotify --