parent
b266368e46
commit
4992d7bd17
|
@ -12,6 +12,7 @@ export const TOGGLE_DEVTOOLS = "bd-toggle-devtools";
|
|||
export const OPEN_WINDOW = "bd-open-window";
|
||||
export const INSPECT_ELEMENT = "bd-inspect-element";
|
||||
export const MINIMUM_SIZE = "bd-minimum-size";
|
||||
export const WINDOW_SIZE = "bd-window-size";
|
||||
export const DEVTOOLS_WARNING = "bd-remove-devtools-message";
|
||||
export const OPEN_DIALOG = "bd-open-dialog";
|
||||
export const REGISTER_PRELOAD = "bd-register-preload";
|
||||
|
|
|
@ -79,6 +79,11 @@ const setMinimumSize = (event, width, height) => {
|
|||
window.setMinimumSize(width, height);
|
||||
};
|
||||
|
||||
const setWindowSize = (event, width, height) => {
|
||||
const window = BrowserWindow.fromWebContents(event.sender);
|
||||
window.setSize(width, height);
|
||||
};
|
||||
|
||||
const stopDevtoolsWarning = event => event.sender.removeAllListeners("devtools-opened");
|
||||
|
||||
const openDialog = (event, options = {}) => {
|
||||
|
@ -136,6 +141,7 @@ export default class IPCMain {
|
|||
ipc.on(IPCEvents.TOGGLE_DEVTOOLS, toggleDevTools);
|
||||
ipc.on(IPCEvents.INSPECT_ELEMENT, inspectElement);
|
||||
ipc.on(IPCEvents.MINIMUM_SIZE, setMinimumSize);
|
||||
ipc.on(IPCEvents.WINDOW_SIZE, setWindowSize);
|
||||
ipc.on(IPCEvents.DEVTOOLS_WARNING, stopDevtoolsWarning);
|
||||
ipc.on(IPCEvents.REGISTER_PRELOAD, registerPreload);
|
||||
ipc.handle(IPCEvents.RUN_SCRIPT, runScript);
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
import Builtin from "../../structs/builtin";
|
||||
import IPC from "../../modules/ipc";
|
||||
import DataStore from "../../modules/datastore";
|
||||
|
||||
const DISCORD_MIN_HEIGHT = 500;
|
||||
const DISCORD_MIN_WIDTH = 940;
|
||||
|
||||
export default new class RemoveMinimumSize extends Builtin {
|
||||
get name() {return "RemoveMinimumSize";}
|
||||
|
@ -8,9 +12,23 @@ export default new class RemoveMinimumSize extends Builtin {
|
|||
|
||||
enabled() {
|
||||
IPC.setMinimumSize(1, 1);
|
||||
window.addEventListener("resize", this.onResize);
|
||||
|
||||
const winprefs = DataStore.getData("windowprefs");
|
||||
if (!winprefs.height || !winprefs.width) return; // If the values don't exist exit
|
||||
if ((winprefs.height >= DISCORD_MIN_HEIGHT) && (winprefs.width >= DISCORD_MIN_WIDTH)) return; // If both values are normally valid don't touch
|
||||
IPC.setWindowSize(winprefs.width, winprefs.height);
|
||||
}
|
||||
|
||||
disabled() {
|
||||
IPC.setMinimumSize(940, 500);
|
||||
IPC.setMinimumSize(DISCORD_MIN_WIDTH, DISCORD_MIN_HEIGHT);
|
||||
window.removeEventListener("resize", this.onResize);
|
||||
}
|
||||
|
||||
onResize() {
|
||||
const winprefs = DataStore.getData("windowprefs");
|
||||
winprefs.width = window.outerWidth;
|
||||
winprefs.height = window.outerHeight;
|
||||
DataStore.setData("windowprefs", winprefs);
|
||||
}
|
||||
};
|
|
@ -44,6 +44,10 @@ export default new class IPCRenderer {
|
|||
return ipc.send(IPCEvents.MINIMUM_SIZE, width, height);
|
||||
}
|
||||
|
||||
setWindowSize(width, height) {
|
||||
return ipc.send(IPCEvents.WINDOW_SIZE, width, height);
|
||||
}
|
||||
|
||||
stopDevtoolsWarning() {
|
||||
return ipc.send(IPCEvents.DEVTOOLS_WARNING);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue