<h3 dir="auto">Preflight Checklist</h3>

<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have read the <a href="https://github.com/electron/electron/blob/master/CONTRIBUTING.md">Contributing Guidelines</a> for this project.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I agree to follow the <a href="https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md">Code of Conduct</a> that this project adheres to.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the issue tracker for an issue that matches the one I want to file, without success.</li>
</ul>
<h3 dir="auto">Issue Details</h3>
<ul dir="auto">
<li><strong>Electron Version:</strong>
<ul dir="auto">
<li>9.2.1, 11.2.3</li>
</ul>
</li>
<li><strong>Operating System:</strong>
<ul dir="auto">
<li>win7, win 10</li>
</ul>
</li>
<li><strong>Last Known Working Electron version:</strong>
<ul dir="auto">
<li>None</li>
</ul>
</li>
</ul>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">window.setSize should set the height according to input</p>
<h3 dir="auto">Actual Behavior</h3>
<p dir="auto">Height is different upto +- 3 pixels</p>
<h3 dir="auto">To Reproduce</h3>
<ul dir="auto">
<li>Open any window</li>
<li>Change the height using window.setSize</li>
<li>Read the height using window.getSize</li>
</ul>
<p dir="auto">Below is the code and output of running the fiddle on my machine with 100% and 125% DPI scaling</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="mainWindow.setSize(800, 750)
console.log(mainWindow.getSize())"><pre class="notranslate"><span class="pl-s1">mainWindow</span><span class="pl-kos">.</span><span class="pl-en">setSize</span><span class="pl-kos">(</span><span class="pl-c1">800</span><span class="pl-kos">,</span> <span class="pl-c1">750</span><span class="pl-kos">)</span>
<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s1">mainWindow</span><span class="pl-kos">.</span><span class="pl-en">getSize</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">)</span></pre></div>
<h4 dir="auto">100% DPI</h4>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="12:22:11 PMElectron v11.1.1 started.

**12:22:11 PM[ 800, 750 ]**"><pre class="notranslate">12:22:11 PMElectron v11.1.1 started.

<span class="pl-k">**</span>12:22:11 PM[ 800, 750 ]<span class="pl-k">**</span></pre></div>
<h4 dir="auto">125% DPI</h4>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="12:23:11 PMElectron v11.1.1 started.

**12:23:12 PM[ 800, 751 ]**"><pre class="notranslate">12:23:11 PMElectron v11.1.1 started.

<span class="pl-k">**</span>12:23:12 PM[ 800, 751 ]<span class="pl-k">**</span></pre></div>
<h3 dir="auto">Preflight Checklist</h3>

<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have read the <a href="https://github.com/electron/electron/blob/master/CONTRIBUTING.md">Contributing Guidelines</a> for this project.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I agree to follow the <a href="https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md">Code of Conduct</a> that this project adheres to.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the issue tracker for an issue that matches the one I want to file, without success.</li>
</ul>
<h3 dir="auto">Issue Details</h3>
<ul dir="auto">
<li><strong>Electron Version:</strong>
<ul dir="auto">
<li>
11.2.3
</li>
</ul>
</li>
<li><strong>Operating System:</strong>
<ul dir="auto">
<li>
Windows 10 20H2
</li>
</ul>
</li>
<li><strong>Last Known Working Electron version:</strong>
<ul dir="auto">
<li>
unknow
</li>
</ul>
</li>
</ul>
<h3 dir="auto">Expected Behavior</h3>

<p dir="auto"><code class="notranslate">setBounds</code> to output of <code class="notranslate">getBounds</code> makes no effect to BrowserWindows size</p>
<h3 dir="auto">Actual Behavior</h3>

<p dir="auto"><code class="notranslate">setBounds</code> to output of <code class="notranslate">getBounds</code> makes BrowserWindows size larger every time <code class="notranslate">setBounds</code> called</p>
<h3 dir="auto">To Reproduce</h3>

<p dir="auto">main.js</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const { app, BrowserWindow } = require('electron')

function createWindow () {
  const win = new BrowserWindow({
    width: 801,
    height: 601,
    webPreferences: {
      nodeIntegration: true
    }
  })

  win.loadFile('index.html')

  let bounds = null

  win.on('minimize', () =&gt; {
    bounds = win.getBounds()
  })

  win.on('restore', () =&gt; {
    win.setBounds(bounds)
    console.log(win.getBounds())
  })
}

app.whenReady().then(createWindow)

app.on('window-all-closed', () =&gt; {
  if (process.platform !== 'darwin') {
    app.quit()
  }
})

app.on('activate', () =&gt; {
  if (BrowserWindow.getAllWindows().length === 0) {
    createWindow()
  }
})"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-kos">{</span> app<span class="pl-kos">,</span> BrowserWindow <span class="pl-kos">}</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'electron'</span><span class="pl-kos">)</span>

<span class="pl-k">function</span> <span class="pl-en">createWindow</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-k">const</span> <span class="pl-s1">win</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">BrowserWindow</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
    <span class="pl-c1">width</span>: <span class="pl-c1">801</span><span class="pl-kos">,</span>
    <span class="pl-c1">height</span>: <span class="pl-c1">601</span><span class="pl-kos">,</span>
    <span class="pl-c1">webPreferences</span>: <span class="pl-kos">{</span>
      <span class="pl-c1">nodeIntegration</span>: <span class="pl-c1">true</span>
    <span class="pl-kos">}</span>
  <span class="pl-kos">}</span><span class="pl-kos">)</span>

  <span class="pl-s1">win</span><span class="pl-kos">.</span><span class="pl-en">loadFile</span><span class="pl-kos">(</span><span class="pl-s">'index.html'</span><span class="pl-kos">)</span>

  <span class="pl-k">let</span> <span class="pl-s1">bounds</span> <span class="pl-c1">=</span> <span class="pl-c1">null</span>

  <span class="pl-s1">win</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'minimize'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-s1">bounds</span> <span class="pl-c1">=</span> <span class="pl-s1">win</span><span class="pl-kos">.</span><span class="pl-en">getBounds</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
  <span class="pl-kos">}</span><span class="pl-kos">)</span>

  <span class="pl-s1">win</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'restore'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-s1">win</span><span class="pl-kos">.</span><span class="pl-en">setBounds</span><span class="pl-kos">(</span><span class="pl-s1">bounds</span><span class="pl-kos">)</span>
    <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s1">win</span><span class="pl-kos">.</span><span class="pl-en">getBounds</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">)</span>
  <span class="pl-kos">}</span><span class="pl-kos">)</span>
<span class="pl-kos">}</span>

<span class="pl-s1">app</span><span class="pl-kos">.</span><span class="pl-en">whenReady</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">then</span><span class="pl-kos">(</span><span class="pl-s1">createWindow</span><span class="pl-kos">)</span>

<span class="pl-s1">app</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'window-all-closed'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
  <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">process</span><span class="pl-kos">.</span><span class="pl-c1">platform</span> <span class="pl-c1">!==</span> <span class="pl-s">'darwin'</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-s1">app</span><span class="pl-kos">.</span><span class="pl-en">quit</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
  <span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span>

<span class="pl-s1">app</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'activate'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
  <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-v">BrowserWindow</span><span class="pl-kos">.</span><span class="pl-en">getAllWindows</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-c1">length</span> <span class="pl-c1">===</span> <span class="pl-c1">0</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-en">createWindow</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
  <span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span></pre></div>
<p dir="auto">index.html</p>
<div class="highlight highlight-text-html-basic notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;meta charset=&quot;UTF-8&quot;&gt;
    &lt;title&gt;Hello World!&lt;/title&gt;
    &lt;meta http-equiv=&quot;Content-Security-Policy&quot; content=&quot;script-src 'self' 'unsafe-inline';&quot; /&gt;
&lt;/head&gt;
&lt;body style=&quot;background: white;&quot;&gt;
    &lt;h1&gt;Hello World!&lt;/h1&gt;
    &lt;p&gt;
        We are using node &lt;script&gt;document.write(process.versions.node)&lt;/script&gt;,
        Chrome &lt;script&gt;document.write(process.versions.chrome)&lt;/script&gt;,
        and Electron &lt;script&gt;document.write(process.versions.electron)&lt;/script&gt;.
    &lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
"><pre class="notranslate"><span class="pl-c1">&lt;!DOCTYPE html<span class="pl-kos">&gt;</span></span>
<span class="pl-kos">&lt;</span><span class="pl-ent">html</span><span class="pl-kos">&gt;</span>
<span class="pl-kos">&lt;</span><span class="pl-ent">head</span><span class="pl-kos">&gt;</span>
    <span class="pl-kos">&lt;</span><span class="pl-ent">meta</span> <span class="pl-c1">charset</span>="<span class="pl-s">UTF-8</span>"<span class="pl-kos">&gt;</span>
    <span class="pl-kos">&lt;</span><span class="pl-ent">title</span><span class="pl-kos">&gt;</span>Hello World!<span class="pl-kos">&lt;/</span><span class="pl-ent">title</span><span class="pl-kos">&gt;</span>
    <span class="pl-kos">&lt;</span><span class="pl-ent">meta</span> <span class="pl-c1">http-equiv</span>="<span class="pl-s">Content-Security-Policy</span>" <span class="pl-c1">content</span>="<span class="pl-s">script-src 'self' 'unsafe-inline';</span>" /&gt;
<span class="pl-kos">&lt;/</span><span class="pl-ent">head</span><span class="pl-kos">&gt;</span>
<span class="pl-kos">&lt;</span><span class="pl-ent">body</span> <span class="pl-c1">style</span>="<span class="pl-s">background: white;</span>"<span class="pl-kos">&gt;</span>
    <span class="pl-kos">&lt;</span><span class="pl-ent">h1</span><span class="pl-kos">&gt;</span>Hello World!<span class="pl-kos">&lt;/</span><span class="pl-ent">h1</span><span class="pl-kos">&gt;</span>
    <span class="pl-kos">&lt;</span><span class="pl-ent">p</span><span class="pl-kos">&gt;</span>
        We are using node <span class="pl-kos">&lt;</span><span class="pl-ent">script</span><span class="pl-kos">&gt;</span><span class="pl-smi">document</span><span class="pl-kos">.</span><span class="pl-en">write</span><span class="pl-kos">(</span><span class="pl-s1">process</span><span class="pl-kos">.</span><span class="pl-c1">versions</span><span class="pl-kos">.</span><span class="pl-c1">node</span><span class="pl-kos">)</span><span class="pl-kos">&lt;/</span><span class="pl-ent">script</span><span class="pl-kos">&gt;</span>,
        Chrome <span class="pl-kos">&lt;</span><span class="pl-ent">script</span><span class="pl-kos">&gt;</span><span class="pl-smi">document</span><span class="pl-kos">.</span><span class="pl-en">write</span><span class="pl-kos">(</span><span class="pl-s1">process</span><span class="pl-kos">.</span><span class="pl-c1">versions</span><span class="pl-kos">.</span><span class="pl-c1">chrome</span><span class="pl-kos">)</span><span class="pl-kos">&lt;/</span><span class="pl-ent">script</span><span class="pl-kos">&gt;</span>,
        and Electron <span class="pl-kos">&lt;</span><span class="pl-ent">script</span><span class="pl-kos">&gt;</span><span class="pl-smi">document</span><span class="pl-kos">.</span><span class="pl-en">write</span><span class="pl-kos">(</span><span class="pl-s1">process</span><span class="pl-kos">.</span><span class="pl-c1">versions</span><span class="pl-kos">.</span><span class="pl-c1">electron</span><span class="pl-kos">)</span><span class="pl-kos">&lt;/</span><span class="pl-ent">script</span><span class="pl-kos">&gt;</span>.
    <span class="pl-kos">&lt;/</span><span class="pl-ent">p</span><span class="pl-kos">&gt;</span>
<span class="pl-kos">&lt;/</span><span class="pl-ent">body</span><span class="pl-kos">&gt;</span>
<span class="pl-kos">&lt;/</span><span class="pl-ent">html</span><span class="pl-kos">&gt;</span></pre></div>



<h3 dir="auto">Screenshots</h3>

<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/16091562/107219061-81573680-6a4b-11eb-90dd-c02aefc0f322.png"><img src="https://user-images.githubusercontent.com/16091562/107219061-81573680-6a4b-11eb-90dd-c02aefc0f322.png" alt="image" style="max-width: 100%;"></a></p>
<h3 dir="auto">Additional Information</h3>