title: How to fix application-window resizing error for a BrowserView in electronjs?
body: <p>so I'm writing on a electron application at the moment.
  To make my application a bit smoother I created a <code>BrowserWindow</code> and loaded just the menubar and the background.</p>
  
  <p>After that I added a <code>BrowserView</code> to show the acutal content.</p>
  
  <p>Code for my <code>BrowserWindow</code>:
  <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function createWindow() {
      win = new BrowserWindow({
          width: 800,
          height: 600,
          show: false,
          frame: false,
          webPreferences: {
              nodeIntegration: true
          }
      })
  
      win.loadFile(path.join(__dirname, 'views/index.pug'));
  
      win.on('closed', () =&gt; {
          win = null;
      })
  
      win.once('ready-to-show', () =&gt; {
          win.show();
      })
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Code for my <code>BrowserView</code>:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function createViews() {
      contentView = new BrowserView({ webPreferences: { nodeIntegration: true } });
  
      win.addBrowserView(contentView);
  
      contentView.setBounds({ x: 0, y: 23, width: win.getBounds().width, height: win.getBounds().height - 23 });
      contentView.setAutoResize({ width: true, height: true });
  
      contentView.webContents.loadFile(path.join(__dirname, 'views/imageGallery.pug'));
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p><em>(If there is a spoiler function to hide the code: I'm sorry, I didn't find any)</em></p>
  
  <p><br></p>
  
  <p>Once I create the window it works like intended, also the normal resize via mouse-drag works perfectly.</p>
  
  <blockquote>
    <p>Now my problem is, as soon as I maximize or unmaximize my window with the functions <code>win.maximize()</code> and <code>win.unmaximize()</code> my <code>BrowserView</code> gets resized. But the resize doesn't fit the <code>BrowserWindow</code> anymore. The content of the <code>BrowserView</code> is being cutted on the right side.</p>
  </blockquote>
  
  <p>Window after being maximized:
  <a href="https://i.stack.imgur.com/TeZIM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TeZIM.png" alt="Maximized Window"></a></p>
  
  <p>Window after being unmaximized:
  <a href="https://i.stack.imgur.com/4gu9R.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4gu9R.png" alt="Unmaximized Window"></a></p>