mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix splash window having window control buttons (#5418)
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
649ca09d70
commit
d23f4018c8
@ -14,11 +14,7 @@ interface WindowStateConfiguration {
|
|||||||
const applicationWindowStateInjectable = getInjectable({
|
const applicationWindowStateInjectable = getInjectable({
|
||||||
id: "application-window-state",
|
id: "application-window-state",
|
||||||
|
|
||||||
instantiate: (
|
instantiate: (di, { id, defaultHeight, defaultWidth }) => windowStateKeeper({
|
||||||
di,
|
|
||||||
{ id, defaultHeight, defaultWidth }: WindowStateConfiguration,
|
|
||||||
) =>
|
|
||||||
windowStateKeeper({
|
|
||||||
defaultHeight,
|
defaultHeight,
|
||||||
defaultWidth,
|
defaultWidth,
|
||||||
file: `window-state-for-${id}.json`,
|
file: `window-state-for-${id}.json`,
|
||||||
|
|||||||
@ -22,35 +22,27 @@ const applicationWindowInjectable = getInjectable({
|
|||||||
const applicationName = di.inject(appNameInjectable);
|
const applicationName = di.inject(appNameInjectable);
|
||||||
const appEventBus = di.inject(appEventBusInjectable);
|
const appEventBus = di.inject(appEventBusInjectable);
|
||||||
const ipcMain = di.inject(ipcMainInjectable);
|
const ipcMain = di.inject(ipcMainInjectable);
|
||||||
|
const lensProxyPort = di.inject(lensProxyPortInjectable);
|
||||||
const lensProxyPort = di.inject(
|
|
||||||
lensProxyPortInjectable,
|
|
||||||
);
|
|
||||||
|
|
||||||
const getContentUrl = () => `http://localhost:${lensProxyPort.get()}`;
|
|
||||||
|
|
||||||
return createLensWindow({
|
return createLensWindow({
|
||||||
id: "only-application-window",
|
id: "only-application-window",
|
||||||
title: applicationName,
|
title: applicationName,
|
||||||
defaultHeight: 900,
|
defaultHeight: 900,
|
||||||
defaultWidth: 1440,
|
defaultWidth: 1440,
|
||||||
getContentUrl,
|
getContentUrl: () => `http://localhost:${lensProxyPort.get()}`,
|
||||||
resizable: true,
|
resizable: true,
|
||||||
windowFrameUtilitiesAreShown: isMac,
|
windowFrameUtilitiesAreShown: isMac,
|
||||||
|
titleBarStyle: isMac ? "hiddenInset" : "hidden",
|
||||||
centered: false,
|
centered: false,
|
||||||
|
|
||||||
onFocus: () => {
|
onFocus: () => {
|
||||||
appEventBus.emit({ name: "app", action: "focus" });
|
appEventBus.emit({ name: "app", action: "focus" });
|
||||||
},
|
},
|
||||||
|
|
||||||
onBlur: () => {
|
onBlur: () => {
|
||||||
appEventBus.emit({ name: "app", action: "blur" });
|
appEventBus.emit({ name: "app", action: "blur" });
|
||||||
},
|
},
|
||||||
|
|
||||||
onDomReady: () => {
|
onDomReady: () => {
|
||||||
appEventBus.emit({ name: "app", action: "dom-ready" });
|
appEventBus.emit({ name: "app", action: "dom-ready" });
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeOpen: async () => {
|
beforeOpen: async () => {
|
||||||
const viewHasLoaded = new Promise<void>((resolve) => {
|
const viewHasLoaded = new Promise<void>((resolve) => {
|
||||||
ipcMain.once(bundledExtensionsLoaded, () => resolve());
|
ipcMain.once(bundledExtensionsLoaded, () => resolve());
|
||||||
|
|||||||
@ -5,14 +5,15 @@
|
|||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import loggerInjectable from "../../../../common/logger.injectable";
|
import loggerInjectable from "../../../../common/logger.injectable";
|
||||||
import applicationWindowStateInjectable from "./application-window-state.injectable";
|
import applicationWindowStateInjectable from "./application-window-state.injectable";
|
||||||
import isMacInjectable from "../../../../common/vars/is-mac.injectable";
|
|
||||||
import { BrowserWindow } from "electron";
|
import { BrowserWindow } from "electron";
|
||||||
import { openBrowser } from "../../../../common/utils";
|
import { openBrowser } from "../../../../common/utils";
|
||||||
import type { SendToViewArgs } from "./lens-window-injection-token";
|
import type { SendToViewArgs } from "./lens-window-injection-token";
|
||||||
import sendToChannelInElectronBrowserWindowInjectable from "./send-to-channel-in-electron-browser-window.injectable";
|
import sendToChannelInElectronBrowserWindowInjectable from "./send-to-channel-in-electron-browser-window.injectable";
|
||||||
import type { LensWindow } from "./create-lens-window.injectable";
|
import type { LensWindow } from "./create-lens-window.injectable";
|
||||||
|
|
||||||
interface ElectronWindowConfiguration {
|
export type ElectronWindowTitleBarStyle = "hiddenInset" | "hidden" | "default" | "customButtonsOnHover";
|
||||||
|
|
||||||
|
export interface ElectronWindowConfiguration {
|
||||||
id: string;
|
id: string;
|
||||||
title: string;
|
title: string;
|
||||||
defaultHeight: number;
|
defaultHeight: number;
|
||||||
@ -21,7 +22,7 @@ interface ElectronWindowConfiguration {
|
|||||||
resizable: boolean;
|
resizable: boolean;
|
||||||
windowFrameUtilitiesAreShown: boolean;
|
windowFrameUtilitiesAreShown: boolean;
|
||||||
centered: boolean;
|
centered: boolean;
|
||||||
|
titleBarStyle?: ElectronWindowTitleBarStyle;
|
||||||
beforeOpen?: () => Promise<void>;
|
beforeOpen?: () => Promise<void>;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
onFocus?: () => void;
|
onFocus?: () => void;
|
||||||
@ -29,18 +30,17 @@ interface ElectronWindowConfiguration {
|
|||||||
onDomReady?: () => void;
|
onDomReady?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type CreateElectronWindow = () => Promise<LensWindow>;
|
||||||
|
export type CreateElectronWindowFor = (config: ElectronWindowConfiguration) => CreateElectronWindow;
|
||||||
|
|
||||||
const createElectronWindowFor = getInjectable({
|
const createElectronWindowFor = getInjectable({
|
||||||
id: "create-electron-window-for",
|
id: "create-electron-window-for",
|
||||||
|
|
||||||
instantiate: (di) => {
|
instantiate: (di): CreateElectronWindowFor => {
|
||||||
const logger = di.inject(loggerInjectable);
|
const logger = di.inject(loggerInjectable);
|
||||||
const isMac = di.inject(isMacInjectable);
|
const sendToChannelInLensWindow = di.inject(sendToChannelInElectronBrowserWindowInjectable);
|
||||||
|
|
||||||
const sendToChannelInLensWindow = di.inject(
|
return (configuration) => async () => {
|
||||||
sendToChannelInElectronBrowserWindowInjectable,
|
|
||||||
);
|
|
||||||
|
|
||||||
return (configuration: ElectronWindowConfiguration) => async (): Promise<LensWindow> => {
|
|
||||||
const applicationWindowState = di.inject(
|
const applicationWindowState = di.inject(
|
||||||
applicationWindowStateInjectable,
|
applicationWindowStateInjectable,
|
||||||
{
|
{
|
||||||
@ -64,9 +64,8 @@ const createElectronWindowFor = getInjectable({
|
|||||||
show: false,
|
show: false,
|
||||||
minWidth: 700, // accommodate 800 x 600 display minimum
|
minWidth: 700, // accommodate 800 x 600 display minimum
|
||||||
minHeight: 500, // accommodate 800 x 600 display minimum
|
minHeight: 500, // accommodate 800 x 600 display minimum
|
||||||
titleBarStyle: isMac ? "hiddenInset" : "hidden",
|
titleBarStyle: configuration.titleBarStyle,
|
||||||
backgroundColor: "#1e2124",
|
backgroundColor: "#1e2124",
|
||||||
|
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true,
|
nodeIntegration: true,
|
||||||
nodeIntegrationInSubFrames: true,
|
nodeIntegrationInSubFrames: true,
|
||||||
@ -162,20 +161,15 @@ const createElectronWindowFor = getInjectable({
|
|||||||
|
|
||||||
const contentUrl = configuration.getContentUrl();
|
const contentUrl = configuration.getContentUrl();
|
||||||
|
|
||||||
logger.info(
|
logger.info(`[CREATE-ELECTRON-WINDOW]: Loading content for window "${configuration.id}" from url: ${contentUrl}...`);
|
||||||
`[CREATE-ELECTRON-WINDOW]: Loading content for window "${configuration.id}" from url: ${contentUrl}...`,
|
|
||||||
);
|
|
||||||
|
|
||||||
await browserWindow.loadURL(contentUrl);
|
await browserWindow.loadURL(contentUrl);
|
||||||
|
|
||||||
await configuration.beforeOpen?.();
|
await configuration.beforeOpen?.();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
show: () => browserWindow.show(),
|
show: () => browserWindow.show(),
|
||||||
close: () => browserWindow.close(),
|
close: () => browserWindow.close(),
|
||||||
|
send: (args: SendToViewArgs) => sendToChannelInLensWindow(browserWindow, args),
|
||||||
send: (args: SendToViewArgs) =>
|
|
||||||
sendToChannelInLensWindow(browserWindow, args),
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import type { SendToViewArgs } from "./lens-window-injection-token";
|
import type { SendToViewArgs } from "./lens-window-injection-token";
|
||||||
|
import type { ElectronWindowTitleBarStyle } from "./create-electron-window-for.injectable";
|
||||||
import createElectronWindowForInjectable from "./create-electron-window-for.injectable";
|
import createElectronWindowForInjectable from "./create-electron-window-for.injectable";
|
||||||
|
|
||||||
export interface LensWindow {
|
export interface LensWindow {
|
||||||
@ -21,7 +22,7 @@ interface LensWindowConfiguration {
|
|||||||
resizable: boolean;
|
resizable: boolean;
|
||||||
windowFrameUtilitiesAreShown: boolean;
|
windowFrameUtilitiesAreShown: boolean;
|
||||||
centered: boolean;
|
centered: boolean;
|
||||||
|
titleBarStyle?: ElectronWindowTitleBarStyle;
|
||||||
beforeOpen?: () => Promise<void>;
|
beforeOpen?: () => Promise<void>;
|
||||||
onFocus?: () => void;
|
onFocus?: () => void;
|
||||||
onBlur?: () => void;
|
onBlur?: () => void;
|
||||||
@ -31,37 +32,23 @@ interface LensWindowConfiguration {
|
|||||||
const createLensWindowInjectable = getInjectable({
|
const createLensWindowInjectable = getInjectable({
|
||||||
id: "create-lens-window",
|
id: "create-lens-window",
|
||||||
|
|
||||||
instantiate:
|
instantiate: (di) => {
|
||||||
(di) =>
|
const createElectronWindowFor = di.inject(createElectronWindowForInjectable);
|
||||||
(configuration: LensWindowConfiguration) => {
|
|
||||||
|
return (configuration: LensWindowConfiguration) => {
|
||||||
let browserWindow: LensWindow | undefined;
|
let browserWindow: LensWindow | undefined;
|
||||||
|
|
||||||
const createElectronWindow = di.inject(createElectronWindowForInjectable)(
|
const createElectronWindow = createElectronWindowFor(Object.assign(
|
||||||
{
|
{
|
||||||
id: configuration.id,
|
onClose: () => browserWindow = undefined,
|
||||||
title: configuration.title,
|
|
||||||
defaultHeight: configuration.defaultHeight,
|
|
||||||
defaultWidth: configuration.defaultWidth,
|
|
||||||
getContentUrl: configuration.getContentUrl,
|
|
||||||
resizable: configuration.resizable,
|
|
||||||
windowFrameUtilitiesAreShown: configuration.windowFrameUtilitiesAreShown,
|
|
||||||
centered: configuration.centered,
|
|
||||||
onFocus: configuration.onFocus,
|
|
||||||
onBlur: configuration.onBlur,
|
|
||||||
onDomReady: configuration.onDomReady,
|
|
||||||
beforeOpen: configuration.beforeOpen,
|
|
||||||
|
|
||||||
onClose: () => {
|
|
||||||
browserWindow = undefined;
|
|
||||||
},
|
},
|
||||||
},
|
configuration,
|
||||||
);
|
));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
get visible() {
|
get visible() {
|
||||||
return !!browserWindow;
|
return !!browserWindow;
|
||||||
},
|
},
|
||||||
|
|
||||||
show: async () => {
|
show: async () => {
|
||||||
if (!browserWindow) {
|
if (!browserWindow) {
|
||||||
browserWindow = await createElectronWindow();
|
browserWindow = await createElectronWindow();
|
||||||
@ -69,12 +56,10 @@ const createLensWindowInjectable = getInjectable({
|
|||||||
|
|
||||||
browserWindow.show();
|
browserWindow.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
close: () => {
|
close: () => {
|
||||||
browserWindow?.close();
|
browserWindow?.close();
|
||||||
browserWindow = undefined;
|
browserWindow = undefined;
|
||||||
},
|
},
|
||||||
|
|
||||||
send: async (args: SendToViewArgs) => {
|
send: async (args: SendToViewArgs) => {
|
||||||
if (!browserWindow) {
|
if (!browserWindow) {
|
||||||
browserWindow = await createElectronWindow();
|
browserWindow = await createElectronWindow();
|
||||||
@ -83,6 +68,7 @@ const createLensWindowInjectable = getInjectable({
|
|||||||
return browserWindow.send(args);
|
return browserWindow.send(args);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user