import { Window } from "nwjs/nwGui";


// get the main application window
const nwWindow = Window.get();
nwWindow.removeAllListeners();


let hidden    = true;
let focused   = true;
let maximized = false;
let minimized = false;

nwWindow.on( "focus",      function onFocus()      { focused   = true;  } );
nwWindow.on( "blur",       function onBlur()       { focused   = false; } );
nwWindow.on( "maximize",   function onMaximize()   { maximized = true;  } );
nwWindow.on( "unmaximize", function onUnmaximize() { maximized = false; } );
nwWindow.on( "minimize",   function onMinimize()   { minimized = true;  } );
nwWindow.on( "restore",    function onRestore()    { minimized = false; } );


export function toggleVisibility( bool ) {
	if ( bool === undefined ) { bool = hidden; }
	nwWindow[ bool ? "show" : "hide" ]();
	hidden = !bool;
}

export function toggleMaximize( bool ) {
	if ( bool === undefined ) { bool = maximized; }
	nwWindow[ bool ? "unmaximize" : "maximize" ]();
}

export function toggleMinimize( bool ) {
	if ( bool === undefined ) { bool = minimized; }
	nwWindow[ bool ? "restore" : "minimize" ]();
}

export function setShowInTaskbar( bool ) {
	nwWindow.setShowInTaskbar( bool );
}

export function isHidden() {
	return hidden;
}

export function isFocused() {
	return focused;
}

export function isMaximized() {
	return maximized;
}

export function isMinimized() {
	return minimized;
}


export default nwWindow;

@@ -248,38 +248,13 @@
 s%22, 
-     function onFocus()      %7B
+() =%3E
  foc
@@ -262,20 +262,14 @@
 sed 
-  
 = true
-;  %7D
  );%0A
@@ -294,38 +294,13 @@
 %22,  
-     function onBlur()       %7B
+() =%3E
  foc
@@ -308,20 +308,15 @@
 sed 
-  
 = false
-; %7D
  );%0A
@@ -344,35 +344,13 @@
 e%22, 
-  function onMaximize()   %7B
+() =%3E
  max
@@ -354,36 +354,32 @@
 maximized = true
-;  %7D
  );%0AnwWindow.on(
@@ -384,21 +384,19 @@
 n( %22
-unmax
+min
 imize%22, 
 func
@@ -395,191 +395,184 @@
 e%22, 
-function onUnmaximize() %7B maximized = false; %7D );%0AnwWindow.on( %22minimize%22,   function onMinimize()   %7B minimized = true;  %7D );%0AnwWindow.on( %22restore%22,    function onRestore()    %7B min
+() =%3E minimized = true );%0A// called when unmaximizing or restoring from minimized state%0AnwWindow.on( %22restore%22, () =%3E %7B%0A%09if ( minimized ) %7B%0A%09%09minimized = false;%0A%09%7D else %7B%0A%09%09max
 imiz
@@ -582,19 +582,21 @@
 = false;
- %7D 
+%0A%09%7D%0A%7D
 );%0A%0A%0Aexp

Fix the maximize button