3

Is it possible to create a Window in maximized or minimized state with Xlib? If so, how would I go about doing that?

Overv
  • 8,433
  • 2
  • 40
  • 70

2 Answers2

7

Something like this;

XEvent xev;
Atom wm_state  =  XInternAtom(dpy, "_NET_WM_STATE", False);
Atom max_horz  =  XInternAtom(dpy, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
Atom max_vert  =  XInternAtom(dpy, "_NET_WM_STATE_MAXIMIZED_VERT", False);

memset(&xev, 0, sizeof(xev));
xev.type = ClientMessage;
xev.xclient.window = win;
xev.xclient.message_type = wm_state;
xev.xclient.format = 32;
xev.xclient.data.l[0] = _NET_WM_STATE_ADD;
xev.xclient.data.l[1] = max_horz;
xev.xclient.data.l[2] = max_vert;

XSendEvent(dpy, DefaultRootWindow(dpy), False, SubstructureNotifyMask, &xev);
ismail
  • 46,010
  • 9
  • 86
  • 95
  • This works fine when the window is already mapped and managed. But is it possible to map the window in maximized state (i.e. avoid mapping in normal state and then transition to maximized state)? – lav Jul 11 '18 at 09:10
0

Check out _NET_WM_STATE in the EWMH.

genpfault
  • 51,148
  • 11
  • 85
  • 139