<p dir="auto">Hello there.</p>
<p dir="auto">Doing a right click on a flash object opens up a context menu as expected, but the positioning in 2.0.0-beta.1 is wrong. This happens on both 32-bit and 64-bit builds for Windows and also on Ubuntu 64-bit.</p>
<p dir="auto">The positioning is correct in v1.8.2.</p>
<p dir="auto">Additional info:<br>
Windows 7 x64<br>
Flash Player: 28.0.0.161</p>
<p dir="auto">Minimal app for reproducing (win-64bit and linux-64bit):<br>
<a href="https://github.com/electron/electron/files/1767276/wrong-context-menu-position.zip">wrong-context-menu-position.zip</a></p>
<ul dir="auto">
<li>Electron version: 2.0.0-beta.1</li>
<li>Operating system: Windows 10 and Ubuntu 16 (I cannot reproduce on macOS)</li>
</ul>
<h3 dir="auto">Expected behavior</h3>
<p dir="auto">We use <code class="notranslate">event.pageX</code> and <code class="notranslate">event.pageY</code> to position the context menu under the mouse and this used to work fine in Electron 1.7.x.</p>
<h3 dir="auto">Actual behavior</h3>
<p dir="auto">The coordinates can easily end up outside of the window.</p>
<h3 dir="auto">How to reproduce</h3>
<ul dir="auto">
<li>electron quick start example</li>
<li>open the renderer and add below code</li>
<li>right click</li>
</ul>
<p dir="auto">=&gt; the menu opens outside the window</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var electron = require(&quot;electron&quot;);
var menu = new electron.remote.Menu()
menu.append(new electron.remote.MenuItem({ label: 'MenuItem1', click: function () { console.log('item 1 clicked') } }))
menu.append(new electron.remote.MenuItem({ type: 'separator' }))
menu.append(new electron.remote.MenuItem({ label: 'MenuItem2', click: function () { console.log('item 2 clicked') }, type: 'checkbox', checked: true }))

window.addEventListener('contextmenu', function (e) {
    e.preventDefault()
    menu.popup({ window: electron.remote.getCurrentWindow(), x: e.pageX, y: e.pageY })
}, false)"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-s1">electron</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-kos">;</span>
<span class="pl-k">var</span> <span class="pl-s1">menu</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-s1">electron</span><span class="pl-kos">.</span><span class="pl-c1">remote</span><span class="pl-kos">.</span><span class="pl-c1">Menu</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
<span class="pl-s1">menu</span><span class="pl-kos">.</span><span class="pl-en">append</span><span class="pl-kos">(</span><span class="pl-k">new</span> <span class="pl-s1">electron</span><span class="pl-kos">.</span><span class="pl-c1">remote</span><span class="pl-kos">.</span><span class="pl-c1">MenuItem</span><span class="pl-kos">(</span><span class="pl-kos">{</span> <span class="pl-c1">label</span>: <span class="pl-s">'MenuItem1'</span><span class="pl-kos">,</span> <span class="pl-en">click</span>: <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</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-s">'item 1 clicked'</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">menu</span><span class="pl-kos">.</span><span class="pl-en">append</span><span class="pl-kos">(</span><span class="pl-k">new</span> <span class="pl-s1">electron</span><span class="pl-kos">.</span><span class="pl-c1">remote</span><span class="pl-kos">.</span><span class="pl-c1">MenuItem</span><span class="pl-kos">(</span><span class="pl-kos">{</span> <span class="pl-c1">type</span>: <span class="pl-s">'separator'</span> <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">)</span>
<span class="pl-s1">menu</span><span class="pl-kos">.</span><span class="pl-en">append</span><span class="pl-kos">(</span><span class="pl-k">new</span> <span class="pl-s1">electron</span><span class="pl-kos">.</span><span class="pl-c1">remote</span><span class="pl-kos">.</span><span class="pl-c1">MenuItem</span><span class="pl-kos">(</span><span class="pl-kos">{</span> <span class="pl-c1">label</span>: <span class="pl-s">'MenuItem2'</span><span class="pl-kos">,</span> <span class="pl-en">click</span>: <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</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-s">'item 2 clicked'</span><span class="pl-kos">)</span> <span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-c1">type</span>: <span class="pl-s">'checkbox'</span><span class="pl-kos">,</span> <span class="pl-c1">checked</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-smi">window</span><span class="pl-kos">.</span><span class="pl-en">addEventListener</span><span class="pl-kos">(</span><span class="pl-s">'contextmenu'</span><span class="pl-kos">,</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-s1">e</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-s1">e</span><span class="pl-kos">.</span><span class="pl-en">preventDefault</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
    <span class="pl-s1">menu</span><span class="pl-kos">.</span><span class="pl-en">popup</span><span class="pl-kos">(</span><span class="pl-kos">{</span> <span class="pl-c1">window</span>: <span class="pl-s1">electron</span><span class="pl-kos">.</span><span class="pl-c1">remote</span><span class="pl-kos">.</span><span class="pl-en">getCurrentWindow</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">,</span> <span class="pl-c1">x</span>: <span class="pl-s1">e</span><span class="pl-kos">.</span><span class="pl-c1">pageX</span><span class="pl-kos">,</span> <span class="pl-c1">y</span>: <span class="pl-s1">e</span><span class="pl-kos">.</span><span class="pl-c1">pageY</span> <span class="pl-kos">}</span><span class="pl-kos">)</span>
<span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-c1">false</span><span class="pl-kos">)</span></pre></div>