Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`XSetWMNormalHints` and `XSetWMSizeHints`

Tags:

c++

c

x11

xlib

I'm confused with XSetWMNormalHints and XSetWMSizeHints. I want to set my window non-resizable, and a call to XSetWMNormalHints does it properly. But if I call XSetWMSizeHints instead, nothing really happens; the window is still resizable. How are the 2 functions used for my purpose, and what exactly does XSetWMSizeHints do? I've read the documentation multiple times, but I'm still confused, so asking a question here.

sh = XAllocSizeHints();
sh->flags = PMinSize | PMaxSize;
sh->min_width = sh->max_width = 100;
sh->min_height = sh->max_height = 100;
XSetWMNormalHints(d, w, sh);
//XSetWMSizeHints(d, w, sh, PMinSize | PMaxSize);
XFree(sh);

1 Answers

This question is almost 4 years old, but perhaps this will clarify for others with similar questions.

Calling XSetWMSizeHints with a WM_NORMAL_HINTS property does the same thing as XSetWMNormalHints. The problem with the call to XSetWMSizeHints is that "PminSize | PMaxSize" is a value instead of a property. Here is the code modified to use XSetWMSizeHints with a property.

#include <X11/Xatom.h>  // XA_WM_NORMAL_HINTS
...
sh = XAllocSizeHints();
sh->flags = PMinSize | PMaxSize;
sh->min_width = sh->max_width = 100;
sh->min_height = sh->max_height = 100;
//XSetWMNormalHints(d, w, sh);
XSetWMSizeHints(d, w, sh, XA_WM_NORMAL_HINTS);
XFree(sh);
like image 134
Daniel LB Avatar answered Jul 05 '26 20:07

Daniel LB



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!