How to maximize (not fullscreen)?

gui

#1

I want to maximize my window, but not fullscreen it. That is, I don’t want to cover the taskbar. I cannot find a way to do this with just JUCE. I am currently using this hack:

namespace xlib {
  extern "C" {
    #include <X11/Xlib.h>
    #include <X11/Xatom.h>

    void maximizeWindow(Window win) {
      auto display = XOpenDisplay(NULL);

      XEvent ev;
      ev.xclient.window = win;
      ev.xclient.type = ClientMessage;
      ev.xclient.format = 32;
      ev.xclient.message_type = XInternAtom(display, "_NET_WM_STATE", False);
      ev.xclient.data.l[0] = 1;
      ev.xclient.data.l[1] = XInternAtom(display, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
      ev.xclient.data.l[2] = XInternAtom(display, "_NET_WM_STATE_MAXIMIZED_VERT", False);
      ev.xclient.data.l[3] = 1;

      XSendEvent(display, DefaultRootWindow(display), False, SubstructureRedirectMask | SubstructureNotifyMask, &ev);
      XCloseDisplay(display);
    }
  }
}

...snip...

xlib::maximizeWindow((xlib::Window)getPeer()->getNativeHandle());

Which works.