TIP 679: General access to X window properties

Login
EuroTcl/OpenACS 11 - 12 JULY 2024, VIENNA
Author:		Schelte Bron <[email protected]>
State:		Draft
Type:		Project
Vote:		Pending
Created:	22-Sep-2023
Tcl-Version:	8.7
Tk-Branch:	tip-679
Keywords:       tk, window manager

Abstract

This TIP proposes to add a method to the wm command to provide general access to the X properties of a Tk toplevel window.

Rationale

The wm command currently provides the possibility to manipulate a selected set of X window properties through various subcommands. It may be useful in some situations to be able to set and retreive other properties as well. For example, to use a global menu (MAC style common menu bar at the top of the screen) on KDE, it is necessary to set the _KDE_NET_WM_APPMENU_SERVICE_NAME and _KDE_NET_WM_APPMENU_OBJECT_PATH properties. Currently you would have to call out to the external xprop command to do that. An additional complication is that these properties must be set on the wrapper window, that holds the toplevel and the menubar. There is currently no method to obtain the id of that window from a script. The information can be extracted from the output of the external xwininfo command. But that is fragile; the output format may change in future versions. It is also inconvenient to have to instruct users to install the two packages that provide these external commands.

Specification

This TIP proposes a new subcommand for the wm command, property. This subcommand is only available on the x11 windowing system. The new subcommand is defined as:

wm property window ?name? ?value? ?type? ?width?

When all arguments are provided, the named property will be set to the specified value of type and width. The type argument defaults to STRING. A property can be deleted by specifying a type of None.
Valid values for width are 8, 16, and 32. Some types may place further restrictions on the set of valid widths. When omitted, width defaults to 8 for the STRING and UTF8_STRING types, and 32 otherwise.
The form of the value argument depends on the width: When width is 8, the value should be a byte array, as produced by the binary encode or encoding convertto commands, for example. For a width of 16, it must be a list of integers. For a width of 32, value is treated as a list of integers and/or atom names.
When only the window and name arguments are provided, the value of the property is returned, if set. For 8-bit values, the result is a byte array. For other values, a list of integers is returned. The -propertytype and -propertyformat return options contain the type and width of the property.
Finally, when just the window argument is present, the command returns the names of all properties that have been set for the toplevel window.

Implementation

Implementation is available in the tip-679 branch of the Tk repository.

Open Questions

Copyright

This document has been placed in the public domain.