You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AeroSnap doesn't trigger the maximize/minimize events #1381
changed the title [-](Windows) BrowserWindow maximize & unmaximize events, and title bars drag & drop[/-][+]AeroSnap doesn't trigger the maximize/minimize events[/+]on Apr 13, 2015
Also Windows Key + Up Arrow (maximize) and Windows Key + Down Arrow (unmaximize) doesn't trigger it. Neither does right clicking on the program in the Task Manager and clicking Maximize.
I manged to work around this issue in my main process code.
The basic idea is that after each specific event (e.g. maximize) you get a resize event. The resize event fires even after Aero Snap actions. So if you save your previous window state and listen to resize you can figure out the current window state.
Here's the code:
// mainWindow - is my main BrowserWindow// Replace the call to sendWindowSizeChange with what ever you want to do with that eventvarWND_STATE={MINIMIZED: 0,NORMAL: 1,MAXIMIZED: 2,FULL_SCREEN: 3};// The initial state of the windowvarwndState=WND_STATE.NORMAL;mainWindow.on('resize',function(){varisMaximized=mainWindow.isMaximized();varisMinimized=mainWindow.isMinimized();varisFullScreen=mainWindow.isFullScreen();varstate=wndState;if(isMinimized&&state!==WND_STATE.MINIMIZED){wndState=WND_STATE.MINIMIZED;sendWindowSizeChange('minimize');}elseif(isFullScreen&&state!==WND_STATE.FULL_SCREEN){wndState=WND_STATE.FULL_SCREEN;sendWindowSizeChange('fullscreen');}elseif(isMaximized&&state!==WND_STATE.MAXIMIZED){wndState=WND_STATE.MAXIMIZED;sendWindowSizeChange('maximize');}elseif(state!==WND_STATE.NORMAL){wndState=WND_STATE.NORMAL;sendWindowSizeChange('normal');}});
Activity
zcbenz commentedon Apr 13, 2015
It seems that AeroSnap doesn't trigger the maximize/minimize handler.
[-](Windows) BrowserWindow maximize & unmaximize events, and title bars drag & drop[/-][+]AeroSnap doesn't trigger the maximize/minimize events[/+]Keavon commentedon Apr 19, 2015
Also Windows Key + Up Arrow (maximize) and Windows Key + Down Arrow (unmaximize) doesn't trigger it. Neither does right clicking on the program in the Task Manager and clicking Maximize.
etiktin commentedon Aug 3, 2015
There's a discussion on the topic with suggested solutions at : http://stackoverflow.com/questions/9321549/handling-aerosnap-message-in-wndproc
They basically say, that Aero Snap doesn't fire the
SC_MAXIMIZEcommand and instead we should handle theWM_SIZEmessage or theWM_WINDOWPOSCHANGINGmessage, which will fire.etiktin commentedon Aug 3, 2015
I manged to work around this issue in my main process code.
The basic idea is that after each specific event (e.g.
maximize) you get aresizeevent. Theresizeevent fires even after Aero Snap actions. So if you save your previous window state and listen toresizeyou can figure out the current window state.Here's the code:
levrik commentedon Aug 14, 2015
I do it this way in my Electron app with React. Maybe it helps somebody:
Fix window state events on Windows