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
[Windows] Frameless window size increase on a maximize, unmaximize sequence #2498
When I have a frameless resizeable window with min-width and min-height set, the width and height increases after returning from maximize. The width increases by 6 px while the height increases by 8 px.
When you start the program you should see something like this (1020x720):
Resize the window to it's minimum size (1000x700):
Maximize the window using WinKey+Up (for me this was 1924x1042 which is already weird because the screen size is 1920x1080 so the width already has 4 extra pixels):
Unmaximize using WinKey+Down (100_6_x70_8_):
If you skip the 4th step (resize to minimum), the size still changes but from my experiments it seems only the height will increase (it increases by 8 pixels).
If I do the same without setting min-width and min-height it seems to work as expected (returns to the same size).
In an app I'm working on, there are a couple of scenarios when I open an iframe that is set to the minimum size. It looks good in the initial state and in the maximize state, but once I unmaximize the window instead of returning to it's last size, it has this extra pixels that show up around the iframe.
I tested it with Windows 8.1 64 bit using Electron v0.30.4.
There's seems to be a bunch of problems with Electron's window sizing on Windows.
Another issue I encountered is that if you create a frameless, resizable window and you maximize it, the sizing you get on a FHD screen is 1938x1050. So the width is 18 pixels longer than the actual screen width (FHD resolution is 1920x1080) and the height is about 20 pixels too much when you take into account that the taskbar height is about 46-50 pixels.
In your case did you set a min-width and/or min-height? If you remove those limits, does it change anything?
Issue #2714 is probably also somewhat related to this.
As a workaround to the OP (size not restored correctly on unmaximize when min-width and/or min-height are set), I modified my workaround for #1381 and it works pretty good.
Here's the code:
// Possible window statesvarWND_STATE={MINIMIZED: 0,NORMAL: 1,MAXIMIZED: 2,FULL_SCREEN: 3};
...
mainWindow=newBrowserWindow(...);// Save the window state on the BrowserWindow instancemainWindow.wndState=WND_STATE.NORMAL;mainWindow.lastNormalSize=mainWindow.getSize();// Register listener for the resize event (resize is fired for any state change)mainWindow.on('resize',handleWindowSizeChange);functionhandleWindowSizeChange(){// Note: It seems that isFullScreen can be true even when minimize or maximize are true, so the// order of checks is important to figure out the true statevarisMaximized=mainWindow.isMaximized();varisMinimized=mainWindow.isMinimized();varisFullScreen=mainWindow.isFullScreen();varstate=mainWindow.wndState;if(isMinimized&&state!==WND_STATE.MINIMIZED){mainWindow.wndState=WND_STATE.MINIMIZED;notifyWindowSizeChange('minimize');}elseif(isFullScreen&&state!==WND_STATE.FULL_SCREEN){mainWindow.wndState=WND_STATE.FULL_SCREEN;notifyWindowSizeChange('fullscreen');}elseif(isMaximized&&state!==WND_STATE.MAXIMIZED){mainWindow.wndState=WND_STATE.MAXIMIZED;notifyWindowSizeChange('maximize');}elseif(state!==WND_STATE.NORMAL){mainWindow.wndState=WND_STATE.NORMAL;notifyWindowSizeChange('normal');// When the window is restored we resize it to the previous known normal sizemainWindow.setSize.apply(mainWindow,mainWindow.lastNormalSize);}elseif(!isMaximized&&!isMinimized&&!isFullScreen){// Window was resized so we save it's new sizemainWindow.lastNormalSize=mainWindow.getSize();}}// Implement notifyWindowSizeChange to handle the state change
This doesn't workaround the other sizing issues mentioned in the previous 2 comments.
Activity
etiktin commentedon Aug 21, 2015
@zcbenz, could this issue be a result of this commit?
tommoor commentedon Sep 5, 2015
I'm seeing something similar, but not the same and wondering if it's related.
etiktin commentedon Sep 5, 2015
There's seems to be a bunch of problems with Electron's window sizing on Windows.
Another issue I encountered is that if you create a frameless, resizable window and you maximize it, the sizing you get on a FHD screen is 1938x1050. So the width is 18 pixels longer than the actual screen width (FHD resolution is 1920x1080) and the height is about 20 pixels too much when you take into account that the taskbar height is about 46-50 pixels.
In your case did you set a min-width and/or min-height? If you remove those limits, does it change anything?
Issue #2714 is probably also somewhat related to this.
etiktin commentedon Sep 8, 2015
As a workaround to the OP (size not restored correctly on unmaximize when min-width and/or min-height are set), I modified my workaround for #1381 and it works pretty good.
Here's the code:
This doesn't workaround the other sizing issues mentioned in the previous 2 comments.
Fix restore/unmaximize wrong window size