function initWindowState() {
    winState = JSON.parse(localStorage.windowState || "null");

    if (winState) {
      currWinMode = winState.mode;
      if (currWinMode === "maximized") {
        win.maximize();
      } else {
        restoreWindowState();
      }
    } else {
      currWinMode = "normal";
      if (deltaHeight !== "disabled") deltaHeight = 0;
      dumpWindowState();
    }

    tray.tooltip = "Komanda IRC Client";
    win.show();
  }
Cross-platform window state preservation.
Yes this code is quite complicated, but this is the best I came up with for
current state of node-webkit Window API (v0.7.3 and later).

Known issues:
- Unmaximization not always sets the window (x, y) in the lastly used coordinates.
- Unmaximization animation sometimes looks wierd.
- Extra height added to window, at least in linux x64 gnome-shell env. It seems that
  when we read height then it returns it with window frame, but if we resize window
  then it applies dimensions only to internal document without external frame.
  Need to test in other environments with different visual themes.

Change log:
2013-12-01
- Workaround of extra height in gnome-shell added.

2014-03-22
- Repared workaround (from 2013-12-01) behaviour when use frameless window.
  Now it works correctly.

2015-05-06
- Added support for minimization to tray