Merge pull request #8739 from electron/pepper-context-menu
Use owner browser window in pepper context menu
This commit is contained in:
commit
d01250eceb
2 changed files with 6 additions and 3 deletions
|
@ -147,12 +147,12 @@ Menu.prototype.popup = function (window, x, y, positioningItem) {
|
|||
let asyncPopup = false
|
||||
|
||||
// menu.popup(x, y, positioningItem)
|
||||
if (typeof window !== 'object' || window.constructor !== BrowserWindow) {
|
||||
if (window != null && (typeof window !== 'object' || window.constructor !== BrowserWindow)) {
|
||||
// Shift.
|
||||
positioningItem = y
|
||||
y = x
|
||||
x = window
|
||||
window = BrowserWindow.getFocusedWindow()
|
||||
window = null
|
||||
}
|
||||
|
||||
// menu.popup(window, {})
|
||||
|
@ -164,6 +164,9 @@ Menu.prototype.popup = function (window, x, y, positioningItem) {
|
|||
asyncPopup = options.async
|
||||
}
|
||||
|
||||
// Default to showing in focused window.
|
||||
if (window == null) window = BrowserWindow.getFocusedWindow()
|
||||
|
||||
// Default to showing under mouse location.
|
||||
if (typeof x !== 'number') x = -1
|
||||
if (typeof y !== 'number') y = -1
|
||||
|
|
|
@ -253,7 +253,7 @@ WebContents.prototype._init = function () {
|
|||
this.on('pepper-context-menu', function (event, params) {
|
||||
// Access Menu via electron.Menu to prevent circular require
|
||||
const menu = electron.Menu.buildFromTemplate(params.menu)
|
||||
menu.popup(params.x, params.y)
|
||||
menu.popup(event.sender.getOwnerBrowserWindow(), params.x, params.y)
|
||||
})
|
||||
|
||||
// The devtools requests the webContents to reload.
|
||||
|
|
Loading…
Reference in a new issue