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
This TIP proposes to add a method to the wm command to provide general access to the X properties of a Tk toplevel window.
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.
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 is available in the tip-679 branch of the Tk repository.
The format of the value argument and the return value of queries currently only depend on the width. Should special treatment be aplied for certain types: ASCII encoding/decoding of STRING types, UTF-8 encoding/decoding of UTF8_STRING types, and integer to atom name conversion when querying ATOM types?
To prevent corrupting properties that are manupilated using other wm commands, the command does not allow modifying properties with names starting with WM_ or _NET_WM_. Does that perhaps cast too wide a net?
Are return options an acceptable method for returning the type and format of a queried property? An alternative would be to return a list of value, type, and format. But then the caller would have to extract the value from that list in the common case where they are just interested in the value.
Should (parts of) the property subcommand be simulated on windowing systems other than x11?
This document has been placed in the public domain.