XICHANGEPROPERTY(3)
XIChangeProperty β¨
okay so bestie, we're doing XICHANGEPROPERTY(3) today β the whole change / retrieve / delete a device's property situation. no cap, this one's a banger. π
three functions, one vibe: XIChangeProperty, XIGetProperty, XIDeleteProperty. that's the family. π«Ά
πΈ SYNOPSIS πΈ
#include <X11/extensions/XInput2.h>
void XIChangeProperty( Display* dpy,
int deviceid,
Atom property,
Atom type,
int format,
int mode,
unsigned char *data,
int num_items)
void XIDeleteProperty( Display *dpy,
int deviceid,
Atom property)
Status XIGetProperty( Display *dpy,
int deviceid,
Atom property,
long offset,
long length,
Bool delete_property,
Atom type,
Atom *type_return,
int *format_return,
unsigned long *num_items_return,
unsigned long *bytes_after_return,
unsigned char **data)
π THE ARGUMENTS, ONE BY ONE (they ate) π
bytes_after_returnβ hands you back how many bytes are still chillin' unread in the property, y'know, if the read got cut short and only did a partial.dataβ the property data itself. that's it, that's the girl. πdisplayβ the connection to the X server. your lil phone line to the server, basically.delete_propertyβ a Boolean that decides whether the property gets deleted or not. yes/no energy.deviceidβ the device we're listing the properties for.formatβ says whether the data should be read as a list of 8-bit, 16-bit, or 32-bit quantities. possible values:8,16, and32. this is so the X server can do its byte-swap operations correctly when it needs to. β οΈ lowkey important: if the format is 16-bit or 32-bit, you must explicitly cast your data pointer to an(unsigned char *)in the call toXIChangeProperty. do not skip that.format_returnβ returns the actual format of the property. the real one. not the one you asked for.lengthβ the length in 32-bit multiples of the data you wanna retrieve.offsetβ the offset in the specified property (in 32-bit quantities) where the data is to be retrieved.modeβ one ofXIPropModeAppend,XIPropModePrependorXIPropModeReplace. pick your fighter.num_itemsβ how many items are indata, in the format you specified.nitems_returnβ returns the actual number of 8-bit, 16-bit, or 32-bit items stored indata.propertyβ the property name.typeβ the type of the property. the X server does not interpret this type, it just hands it right back to whatever application later callsXIGetProperty. it's not nosy, it's just the messenger. πtype_returnβ returns the atom identifier that defines the actual type of the property.
π₯ DESCRIPTION π₯
so XIGetProperty returns, in order: the actual type of the property, the actual format of the property, the number of 8-bit/16-bit/32-bit items transferred, the number of bytes still left to read in the property, and a pointer to the data that actually got returned. she does a lot. π
XIGetProperty sets the return arguments like this:
- if the specified property doesn't exist for the specified device,
XIGetPropertyreturnsNonetoactual_type_returnand the value zero toactual_format_returnandbytes_after_return. thenitems_returnargument is empty. and in this case, thedeleteargument is ignored. π - if the specified property exists but its type doesn't match the specified type,
XIGetPropertyreturns the actual property type toactual_type_return, the actual property format (never zero) toactual_format_return, and the property length in bytes (even ifactual_format_returnis 16 or 32) tobytes_after_return. it also ignores thedeleteargument. thenitems_returnargument is empty. - if the specified property exists and either you assigned
XIAnyPropertyTypeto thereq_typeargument or the specified type matches the actual property type,XIGetPropertyreturns the actual property type toactual_type_returnand the actual property format (never zero) toactual_format_return. it also returns a value tobytes_after_returnandnitems_return, by defining these values:
N = length of the stored property in bytes
I = 4 * offset
T = N - I
L = MINIMUM(T, 4 * length)
A = N - (I + L)
the returned value starts at byte index I in the property (indexing from zero), and its length in bytes is L. if the value for long_offset makes L go negative, you get a BadValue error. the value of bytes_after_return is A, which gives you the number of trailing unread bytes in the stored property.
so like, about the returned format:
- if the returned format is
8, the returned data is represented as achararray. - if the returned format is
16, the returned data is represented as auint16_tarray and you should cast it to that type to get the elements. - if the returned format is
32, the returned data is represented as auint32_tarray and you should cast it to that type to get the elements.
XIGetProperty always allocates one extra byte in prop_return (even if the property is zero length) and sets it to zero, so that simple properties made of characters don't have to be copied into yet another string before you can use them. it's giving considerate. π₯Ίβ¨
if delete is True and bytes_after_return is zero, XIGetProperty deletes the property from the window and generates an XIPropertyNotify event on the window.
the function returns Success if it executes successfully. to free the resulting data, use XFree. π«Ά
XIGetProperty can generate BadAtom, BadValue, and BadWindow errors.
so XIChangeProperty alters the property for the specified device and causes the X server to generate an XIPropertyNotify event for that device. here's what it does:
- if
modeisXIPropModeReplace,XIChangePropertydiscards the previous property value and stores the new data. out with the old, in with the new. π - if
modeisXIPropModePrependorXIPropModeAppend,XIChangePropertyinserts the specified data before the beginning of the existing data or onto the end of the existing data, respectively. the type and format must match the existing property value, or aBadMatcherror results. if the property is undefined, it's treated as defined with the correct type and format with zero-length data.
format rules, no exceptions:
- if the specified format is
8, the property data must be achararray. - if the specified format is
16, the property data must be auint16_tarray. - if the specified format is
32, the property data must be auint32_tarray.
the lifetime of a property is not tied to the storing client. properties remain until explicitly deleted, until the device is removed, or until the server resets. the maximum size of a property is server dependent and can vary dynamically depending on how much memory the server has available. (if there's insufficient space, a BadAlloc error results.) so like, don't assume it'll always fit, bestie. π
XIChangeProperty can generate BadAlloc, BadAtom, BadMatch, BadValue, and BadDevice errors.
XIDeleteProperty deletes the specified property only if the property was defined on the specified device, and causes the X server to generate an XIPropertyNotify event for the device β unless the property doesn't exist, in which case, nothing. π
XIDeleteProperty can generate BadAtom and BadDevice errors.
π DIAGNOSTICS π
BadAllocβ the server failed to allocate the requested resource or server memory.BadAtomβ a value for anAtomargument does not name a definedAtom.BadValueβ some numeric value falls outside the range of values accepted by the request. unless a specific range is specified for an argument, the full range defined by the argument's type is accepted. any argument defined as a set of alternatives can generate this error.BadDeviceβ an invalid device was specified. the device does not exist.BadAtomβ an invalid property was specified. the property does not exist.
yes bestie, BadAtom shows up twice in the original list. i'm not gonna edit the universe, i'm just reporting it. π
π BUGS π
the protocol headers for XI 2.0 did not provide XIAnyPropertyType, XIPropModeReplace, XIPropModePrepend or XIPropModeAppend. use AnyPropertyType, PropModeReplace, PropModePrepend and PropModeAppend instead, respectively. so like, if the fancy XI 2.0 names aren't there, the old ones are your girls. π
π SEE ALSO π
and that's the whole page, bestie!! π¦ this version is the XICHANGEPROPERTY(3) manual page dated 05/18/2026 β go forth and manage your properties, you absolute icon. slay, periodt. π
β¨
π¦ where this page comes from
- fedora 44: libXi-devel 1.8.3-1.fc44 Β· MIT-open-group AND SMLNJ AND MIT
- fedora 44: libXi-devel 1.8.3-1.fc44 Β· MIT-open-group AND SMLNJ AND MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms