XAllocSizeHints(3)
π XAllocSizeHints(3) β the libX11 glow-up β¨
okay so bestie, this is the Xlib page for XAllocSizeHints(3) and its whole friend group β XSetWMNormalHints, XGetWMNormalHints, XSetWMSizeHints, XGetWMSizeHints, and the XSizeHints struct itself. it's all about allocating the size hints structure and setting or reading a window's WM_NORMAL_HINTS property. window-manager communication core, no cap π«Ά
πΈ NAME
XAllocSizeHints, XSetWMNormalHints, XGetWMNormalHints, XSetWMSizeHints, XGetWMSizeHints, XSizeHints β allocate size hints structure and set or read a window's WM_NORMAL_HINTS property π
π SYNTAX
XSizeHints *XAllocSizeHints(void);
void XSetWMNormalHints(Display *display, Window w, XSizeHints *hints);
Status XGetWMNormalHints(Display *display, Window w, XSizeHints
*hints_return, long *supplied_return);
void XSetWMSizeHints(Display *display, Window w, XSizeHints *hints, Atom
property);
Status XGetWMSizeHints(Display *display, Window w, XSizeHints
*hints_return, long *supplied_return, Atom property);
π¦ ARGUMENTS
displayβ says which X server connection we're talking to β¨hintsβ the size hints for the window in its normal state πhintsβ theXSizeHintsstructure being used πhints_returnβ returns the size hints for the window in its normal state π«Άpropertyβ the property name πΈsupplied_returnβ returns the hints that were supplied by the user πwβ the window π
(yes, hints really does show up twice, and yes, that's exactly what the page says β not me being messy, i promise π)
π DESCRIPTION
Okay so the way this works is:
β XAllocSizeHints
XAllocSizeHints allocates and hands you back a pointer to an XSizeHints structure. Important vibe check: all fields in the XSizeHints structure are initially set to zero. if there's not enough memory available, XAllocSizeHints returns NULL (π). and when you're done with it, free that memory with XFree, bestie.
β XSetWMNormalHints
XSetWMNormalHints replaces the size hints for the WM_NORMAL_HINTS property on the specified window. if the property doesn't already exist, XSetWMNormalHints sets the size hints for the WM_NORMAL_HINTS property on the specified window. the property is stored with a type of WM_SIZE_HINTS and a format of 32. periodt.
XSetWMNormalHintscan generateBadAllocandBadWindowerrors. π₯
β XGetWMNormalHints
XGetWMNormalHints returns the size hints stored in the WM_NORMAL_HINTS property on the specified window. so here's the deal: if the property is of type WM_SIZE_HINTS, is of format 32, and is long enough to contain either an old (pre-ICCCM) or new size hints structure, XGetWMNormalHints sets the various fields of the XSizeHints structure, sets the supplied_return argument to the list of fields that were supplied by the user (whether or not they contained defined values), and returns a nonzero status. otherwise, it returns a zero status. π¦
if XGetWMNormalHints returns successfully and a pre-ICCCM size hints property is read, the supplied_return argument will contain the following bits:
(USPosition|USSize|PPosition|PSize|PMinSize|
PMaxSize|PResizeInc|PAspect)
if the property is large enough to contain the base size and window gravity fields as well, the supplied_return argument will also contain the following bits:
PBaseSize|PWinGravity
XGetWMNormalHintscan generate aPNBadWindowerror. ngl, thatPNis right there in the original text and i'm keeping it exactly as-is π
β XSetWMSizeHints
XSetWMSizeHints replaces the size hints for the specified property on the named window. if the specified property doesn't already exist, XSetWMSizeHints sets the size hints for the specified property on the named window. property gets stored with a type of WM_SIZE_HINTS and a format of 32. and psst β to set a window's normal size hints, you can use the XSetWMNormalHints function instead π
XSetWMSizeHintscan generateBadAlloc,BadAtom, andBadWindowerrors. π₯
β XGetWMSizeHints
XGetWMSizeHints returns the size hints stored in the specified property on the named window. same conditions as its sibling: if the property is of type WM_SIZE_HINTS, is of format 32, and is long enough to contain either an old (pre-ICCCM) or new size hints structure, XGetWMSizeHints sets the various fields of the XSizeHints structure, sets the supplied_return argument to the list of fields that were supplied by the user (whether or not they contained defined values), and returns a nonzero status. otherwise, it returns a zero status. and hey β to get a window's normal size hints, you can use the XGetWMNormalHints function πΈ
if XGetWMSizeHints returns successfully and a pre-ICCCM size hints property is read, the supplied_return argument will contain the following bits:
(USPosition|USSize|PPosition|PSize|PMinSize|
PMaxSize|PResizeInc|PAspect)
if the property is large enough to contain the base size and window gravity fields as well, the supplied_return argument will also contain the following bits:
PBaseSize|PWinGravity
XGetWMSizeHintscan generateBadAtomandBadWindowerrors. π
π§ PROPERTIES
WM_NORMAL_HINTSβ size hints for a window in its normal state. the C type of this property isXSizeHints. π
π STRUCTURES
the XSizeHints structure contains:
/* Size hints mask bits */
#define USPosition (1L << 0) /* user specified x, y */
#define USSize (1L << 1) /* user specified width,
height */
#define PPosition (1L << 2) /* program specified
position */
#define PSize (1L << 3) /* program specified size */
#define PMinSize (1L << 4) /* program specified minimum
size */
#define PMaxSize (1L << 5) /* program specified maximum
size */
#define PResizeInc (1L << 6) /* program specified resize
increments */
#define PAspect (1L << 7) /* program specified min and
max aspect ratios */
#define PBaseSize (1L << 8)
#define PWinGravity (1L << 9)
#define PAllHints (PPosition|
PSize|
PMinSize|
PMaxSize|
PResizeInc|
PAspect)
/* Values */
typedef struct {
long flags; /* marks which fields in this structure are defined */
int x, y; /* Obsolete */
int width, height; /* Obsolete */
int min_width, min_height;
int max_width, max_height;
int width_inc, height_inc;
struct {
int x; /* numerator */
int y; /* denominator */
} min_aspect, max_aspect;
int base_width, base_height;
int win_gravity;
/* this structure may be extended in the future */
} XSizeHints;
π what all those fields actually mean
the x, y, width, and height members are now obsolete and are left solely for compatibility reasons β don't come for them, they're just vibing there for the old heads π
min_widthandmin_heightβ specify the minimum window size that still allows the application to be useful πΈmax_widthandmax_heightβ specify the maximum window size πwidth_incandheight_incβ define an arithmetic progression of sizes (minimum to maximum) into which the window prefers to be resized β¨min_aspectandmax_aspectβ expressed as ratios ofxandy, and they let an application specify the range of aspect ratios it prefers π¦base_widthandbase_heightβ define the desired size of the window πwin_gravityβ the window manager will interpret the position of the window and its border width to position the point of the outer rectangle of the overall window specified by thewin_gravitymember. the outer rectangle of the window includes any borders or decorations supplied by the window manager. in other words, if the window manager decides to place the window where the client asked, the position on the parent window's border named by thewin_gravitywill be placed where the client window would have been placed in the absence of a window manager. main character energy, honestly π
note that use of the PAllHints macro is highly discouraged. like, fr fr, don't do it bestie π
π₯ DIAGNOSTICS
BadAllocβ the server failed to allocate the requested resource or server memory πBadAtomβ a value for anAtomargument does not name a definedAtomBadWindowβ a value for aWindowargument does not name a definedWindow
π SEE ALSO
XAllocClassHint(3)XAllocIconSize(3)XAllocWMHints(3)XFree(3)XSetCommand(3)XSetTransientForHint(3)XSetTextProperty(3)XSetWMClientMachine(3)XSetWMColormapWindows(3)XSetWMIconName(3)XSetWMName(3)XSetWMProperties(3)XSetWMProtocols(3)XStringListToTextProperty(3)Xlib - C Language X Interface, O'Reilly and Associates,
and that's the whole page, bestie π β¨ this one's from X Version 11, libX11 1.8.14, and the page itself is dated/versioned right there in that footer line β so go forth, set those hints, and slay ππ«Άπ
π¦ where this page comes from
- alpine 3.24: libx11-doc 1.8.14-r0 Β· X11
- arch rolling: libx11 1.8.14-1 Β· MIT AND X11
- nixos 26.05: libx11 1.8.14
- nixpkgs unstable: libx11 1.8.14
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms