- wm_hints.flags = StateHint;
- wm_hints.initial_state = IconicState;
- g_xstuff.pXSetWMHints(display, window, &wm_hints);
+ wm_hints = g_xstuff.pXGetWMHints(display, window);
+ if (wm_hints == NULL) {
+ wm_hints = XAllocWMHints();
+ wm_hints->flags = 0;
+ }
+ wm_hints->flags |= StateHint;
+ wm_hints->initial_state = IconicState;
+ g_xstuff.pXSetWMHints(display, window, wm_hints);
+ g_xstuff.pXFree(wm_hints);
+ wm_hints = NULL;