Xlib: Create window in mimized or maximized state

2019-07-02 18:51发布

问题:

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

回答1:

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);


回答2:

Check out _NET_WM_STATE in the EWMH.