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,15 +14,11 @@ interface WindowStateConfiguration {
|
||||
const applicationWindowStateInjectable = getInjectable({
|
||||
id: "application-window-state",
|
||||
|
||||
instantiate: (
|
||||
di,
|
||||
{ id, defaultHeight, defaultWidth }: WindowStateConfiguration,
|
||||
) =>
|
||||
windowStateKeeper({
|
||||
defaultHeight,
|
||||
defaultWidth,
|
||||
file: `window-state-for-${id}.json`,
|
||||
}),
|
||||
instantiate: (di, { id, defaultHeight, defaultWidth }) => windowStateKeeper({
|
||||
defaultHeight,
|
||||
defaultWidth,
|
||||
file: `window-state-for-${id}.json`,
|
||||
}),
|
||||
|
||||
lifecycle: lifecycleEnum.keyedSingleton({
|
||||
getInstanceKey: (di, { id }: WindowStateConfiguration) => id,
|
||||
|
||||
@ -22,35 +22,27 @@ const applicationWindowInjectable = getInjectable({
|
||||
const applicationName = di.inject(appNameInjectable);
|
||||
const appEventBus = di.inject(appEventBusInjectable);
|
||||
const ipcMain = di.inject(ipcMainInjectable);
|
||||
|
||||
const lensProxyPort = di.inject(
|
||||
lensProxyPortInjectable,
|
||||
);
|
||||
|
||||
const getContentUrl = () => `http://localhost:${lensProxyPort.get()}`;
|
||||
const lensProxyPort = di.inject(lensProxyPortInjectable);
|
||||
|
||||
return createLensWindow({
|
||||
id: "only-application-window",
|
||||
title: applicationName,
|
||||
defaultHeight: 900,
|
||||
defaultWidth: 1440,
|
||||
getContentUrl,
|
||||
getContentUrl: () => `http://localhost:${lensProxyPort.get()}`,
|
||||
resizable: true,
|
||||
windowFrameUtilitiesAreShown: isMac,
|
||||
titleBarStyle: isMac ? "hiddenInset" : "hidden",
|
||||
centered: false,
|
||||
|
||||
onFocus: () => {
|
||||
appEventBus.emit({ name: "app", action: "focus" });
|
||||
},
|
||||
|
||||
onBlur: () => {
|
||||
appEventBus.emit({ name: "app", action: "blur" });
|
||||
},
|
||||
|
||||
onDomReady: () => {
|
||||
appEventBus.emit({ name: "app", action: "dom-ready" });
|
||||
},
|
||||
|
||||
beforeOpen: async () => {
|
||||
const viewHasLoaded = new Promise<void>((resolve) => {
|
||||
ipcMain.once(bundledExtensionsLoaded, () => resolve());
|
||||
|
||||
@ -5,14 +5,15 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import loggerInjectable from "../../../../common/logger.injectable";
|
||||
import applicationWindowStateInjectable from "./application-window-state.injectable";
|
||||
import isMacInjectable from "../../../../common/vars/is-mac.injectable";
|
||||
import { BrowserWindow } from "electron";
|
||||
import { openBrowser } from "../../../../common/utils";
|
||||
import type { SendToViewArgs } from "./lens-window-injection-token";
|
||||
import sendToChannelInElectronBrowserWindowInjectable from "./send-to-channel-in-electron-browser-window.injectable";
|
||||
import type { LensWindow } from "./create-lens-window.injectable";
|
||||
|
||||
interface ElectronWindowConfiguration {
|
||||
export type ElectronWindowTitleBarStyle = "hiddenInset" | "hidden" | "default" | "customButtonsOnHover";
|
||||
|
||||
export interface ElectronWindowConfiguration {
|
||||
id: string;
|
||||
title: string;
|
||||
defaultHeight: number;
|
||||
@ -21,7 +22,7 @@ interface ElectronWindowConfiguration {
|
||||
resizable: boolean;
|
||||
windowFrameUtilitiesAreShown: boolean;
|
||||
centered: boolean;
|
||||
|
||||
titleBarStyle?: ElectronWindowTitleBarStyle;
|
||||
beforeOpen?: () => Promise<void>;
|
||||
onClose: () => void;
|
||||
onFocus?: () => void;
|
||||
@ -29,18 +30,17 @@ interface ElectronWindowConfiguration {
|
||||
onDomReady?: () => void;
|
||||
}
|
||||
|
||||
export type CreateElectronWindow = () => Promise<LensWindow>;
|
||||
export type CreateElectronWindowFor = (config: ElectronWindowConfiguration) => CreateElectronWindow;
|
||||
|
||||
const createElectronWindowFor = getInjectable({
|
||||
id: "create-electron-window-for",
|
||||
|
||||
instantiate: (di) => {
|
||||
instantiate: (di): CreateElectronWindowFor => {
|
||||
const logger = di.inject(loggerInjectable);
|
||||
const isMac = di.inject(isMacInjectable);
|
||||
const sendToChannelInLensWindow = di.inject(sendToChannelInElectronBrowserWindowInjectable);
|
||||
|
||||
const sendToChannelInLensWindow = di.inject(
|
||||
sendToChannelInElectronBrowserWindowInjectable,
|
||||
);
|
||||
|
||||
return (configuration: ElectronWindowConfiguration) => async (): Promise<LensWindow> => {
|
||||
return (configuration) => async () => {
|
||||
const applicationWindowState = di.inject(
|
||||
applicationWindowStateInjectable,
|
||||
{
|
||||
@ -64,9 +64,8 @@ const createElectronWindowFor = getInjectable({
|
||||
show: false,
|
||||
minWidth: 700, // accommodate 800 x 600 display minimum
|
||||
minHeight: 500, // accommodate 800 x 600 display minimum
|
||||
titleBarStyle: isMac ? "hiddenInset" : "hidden",
|
||||
titleBarStyle: configuration.titleBarStyle,
|
||||
backgroundColor: "#1e2124",
|
||||
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
nodeIntegrationInSubFrames: true,
|
||||
@ -162,20 +161,15 @@ const createElectronWindowFor = getInjectable({
|
||||
|
||||
const contentUrl = configuration.getContentUrl();
|
||||
|
||||
logger.info(
|
||||
`[CREATE-ELECTRON-WINDOW]: Loading content for window "${configuration.id}" from url: ${contentUrl}...`,
|
||||
);
|
||||
logger.info(`[CREATE-ELECTRON-WINDOW]: Loading content for window "${configuration.id}" from url: ${contentUrl}...`);
|
||||
|
||||
await browserWindow.loadURL(contentUrl);
|
||||
|
||||
await configuration.beforeOpen?.();
|
||||
|
||||
return {
|
||||
show: () => browserWindow.show(),
|
||||
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 type { SendToViewArgs } from "./lens-window-injection-token";
|
||||
import type { ElectronWindowTitleBarStyle } from "./create-electron-window-for.injectable";
|
||||
import createElectronWindowForInjectable from "./create-electron-window-for.injectable";
|
||||
|
||||
export interface LensWindow {
|
||||
@ -21,7 +22,7 @@ interface LensWindowConfiguration {
|
||||
resizable: boolean;
|
||||
windowFrameUtilitiesAreShown: boolean;
|
||||
centered: boolean;
|
||||
|
||||
titleBarStyle?: ElectronWindowTitleBarStyle;
|
||||
beforeOpen?: () => Promise<void>;
|
||||
onFocus?: () => void;
|
||||
onBlur?: () => void;
|
||||
@ -31,59 +32,44 @@ interface LensWindowConfiguration {
|
||||
const createLensWindowInjectable = getInjectable({
|
||||
id: "create-lens-window",
|
||||
|
||||
instantiate:
|
||||
(di) =>
|
||||
(configuration: LensWindowConfiguration) => {
|
||||
let browserWindow: LensWindow | undefined;
|
||||
instantiate: (di) => {
|
||||
const createElectronWindowFor = di.inject(createElectronWindowForInjectable);
|
||||
|
||||
const createElectronWindow = di.inject(createElectronWindowForInjectable)(
|
||||
{
|
||||
id: configuration.id,
|
||||
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,
|
||||
return (configuration: LensWindowConfiguration) => {
|
||||
let browserWindow: LensWindow | undefined;
|
||||
|
||||
onClose: () => {
|
||||
browserWindow = undefined;
|
||||
},
|
||||
},
|
||||
);
|
||||
const createElectronWindow = createElectronWindowFor(Object.assign(
|
||||
{
|
||||
onClose: () => browserWindow = undefined,
|
||||
},
|
||||
configuration,
|
||||
));
|
||||
|
||||
return {
|
||||
get visible() {
|
||||
return !!browserWindow;
|
||||
},
|
||||
return {
|
||||
get visible() {
|
||||
return !!browserWindow;
|
||||
},
|
||||
show: async () => {
|
||||
if (!browserWindow) {
|
||||
browserWindow = await createElectronWindow();
|
||||
}
|
||||
|
||||
show: async () => {
|
||||
if (!browserWindow) {
|
||||
browserWindow = await createElectronWindow();
|
||||
}
|
||||
browserWindow.show();
|
||||
},
|
||||
close: () => {
|
||||
browserWindow?.close();
|
||||
browserWindow = undefined;
|
||||
},
|
||||
send: async (args: SendToViewArgs) => {
|
||||
if (!browserWindow) {
|
||||
browserWindow = await createElectronWindow();
|
||||
}
|
||||
|
||||
browserWindow.show();
|
||||
},
|
||||
|
||||
close: () => {
|
||||
browserWindow?.close();
|
||||
browserWindow = undefined;
|
||||
},
|
||||
|
||||
send: async (args: SendToViewArgs) => {
|
||||
if (!browserWindow) {
|
||||
browserWindow = await createElectronWindow();
|
||||
}
|
||||
|
||||
return browserWindow.send(args);
|
||||
},
|
||||
};
|
||||
},
|
||||
return browserWindow.send(args);
|
||||
},
|
||||
};
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
export default createLensWindowInjectable;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user