ELECTRON-1380 - Fix pop-up menu position for native title bar (#724)

This commit is contained in:
Kiran Niranjan 2019-07-12 15:19:10 +05:30 committed by Vishwas Shashidhar
parent 0255a692b9
commit 1225f50812
2 changed files with 5 additions and 3 deletions

View File

@ -67,6 +67,7 @@ export class WindowHandler {
public url: string | undefined;
public willQuitApp: boolean = false;
public spellchecker: SpellChecker | undefined;
public isCustomTitleBar: boolean;
private readonly contextIsolation: boolean;
private readonly backgroundThrottling: boolean;
@ -75,7 +76,6 @@ export class WindowHandler {
private readonly config: IConfig;
// Window reference
private readonly windows: object;
private readonly isCustomTitleBar: boolean;
private loadFailError: string | undefined;
private mainWindow: ICustomBrowserWindow | null = null;

View File

@ -5,6 +5,7 @@ import * as filesize from 'filesize';
import * as fs from 'fs';
import * as path from 'path';
import { format, parse } from 'url';
import { apiName } from '../common/api-interface';
import { isDevEnv, isMac } from '../common/env';
import { i18n, LocaleType } from '../common/i18n';
@ -250,8 +251,9 @@ export const updateLocale = (locale: LocaleType): void => {
*/
export const showPopupMenu = (opts: Electron.PopupOptions): void => {
const mainWindow = windowHandler.getMainWindow();
if (mainWindow && !mainWindow.isDestroyed() && isValidWindow(mainWindow)) {
const { x, y } = mainWindow.isFullScreen() ? { x: 0, y: 0 } : { x: 20, y: 15 };
if (mainWindow && windowExists(mainWindow) && isValidWindow(mainWindow) && mainWindow.winName === apiName.mainWindowName) {
const coordinates = windowHandler.isCustomTitleBar ? { x: 20, y: 15 } : { x: 10, y: -20 };
const { x, y } = mainWindow.isFullScreen() ? { x: 0, y: 0 } : coordinates;
const popupOpts = { window: mainWindow, x, y };
const appMenu = windowHandler.appMenu;
if (appMenu) {