Skip to content

Commit

Permalink
Added feature to launch minimised. Resolves issue #38 and issue #43
Browse files Browse the repository at this point in the history
  • Loading branch information
GameGodS3 committed Jul 13, 2023
1 parent 40ec31f commit b8f6f08
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
12 changes: 9 additions & 3 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
const { app, BrowserWindow, nativeImage } = require("electron");
const { autoUpdater } = require("electron-updater");
const Store = require("electron-store");
const configOptions = require("./configOptions");

const { Instance } = require("./Window");
const { setShortcut } = require("./Shortcut");
const { droppointDefaultIcon } = require("./Icons");
const { setTray } = require("./Tray");

const config = new Store(configOptions);
let splashScreen;

app
.on("ready", () => {
// Splash screen which also helps to run in background and keep app alive
Expand All @@ -25,12 +30,13 @@ app
// splashScreen.hide();
// }, 3000);

if (BrowserWindow.getAllWindows.length === 0) {
setTray();
setShortcut();

if (BrowserWindow.getAllWindows.length === 0 && config.get("spawnOnLaunch")) {
const instance = new Instance();
const instanceID = instance.createNewWindow();
if (instanceID !== null) {
setTray();
setShortcut();
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Settings {
this.settings = new BrowserWindow({
title: "Settings - DropPoint",
width: 600,
height: 350,
height: 450,
webPreferences: {
nodeIntegration: true,
preload: path.join(__dirname, "preload.js"),
Expand Down
14 changes: 6 additions & 8 deletions src/Window.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,12 @@ class Instance {
* @returns {number} id - Unique ID of the instance | null if not created
*/
createNewWindow() {
this.config.get("openAtCursorPosition")
? () => {
const cursorPosition = this.getCursorPos();
this.windowConfig.x = cursorPosition.x;
this.windowConfig.y = cursorPosition.y;
}
: (this.windowConfig.x =
screen.getPrimaryDisplay().workArea.width / 2 - 100);
if (this.config.get("openAtCursorPosition")) {
const cursorPosition = this.getCursorPos();
this.windowConfig.x = cursorPosition.x;
this.windowConfig.y = cursorPosition.y;
}
else this.windowConfig.x = screen.getPrimaryDisplay().workArea.width / 2 - 100;

this.instance = new BrowserWindow(this.windowConfig);

Expand Down
9 changes: 7 additions & 2 deletions src/configOptions.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
const defaultAppConfig = {
spawnOnLaunch: true,
alwaysOnTop: true,
openAtCursorPosition: false,
shortcutAction: "toggle",
debug: false,
};
const appConfigSchema = {
spawnOnLaunch: {
type: "boolean",
title: "Open a new instance on launch"
},
alwaysOnTop: {
type: "boolean",
title: "Always on Top",
title: "Always on top",
},
openAtCursorPosition: {
type: "boolean",
Expand All @@ -16,7 +21,7 @@ const appConfigSchema = {
shortcutAction: {
enum: ["toggle", "spawn"],
type: "string",
title: "Shortcut Behaviour",
title: "Shortcut behaviour",
},
debug: {
type: "boolean",
Expand Down

0 comments on commit b8f6f08

Please sign in to comment.