Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tray: Add left click hide/show feature #404

Merged
merged 5 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/main/mainWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ const [addSettingsListener, removeSettingsListeners] = makeSettingsListenerHelpe
const [addVencordSettingsListener, removeVencordSettingsListeners] = makeSettingsListenerHelpers(VencordSettings);

function initTray(win: BrowserWindow) {
const trayClickHandler = Settings.store.clickTrayToShowHide
0bCdian marked this conversation as resolved.
Show resolved Hide resolved
? () => {
win.isVisible() ? win.hide() : win.show();
}
: () => {
win.show();
};
const trayMenu = Menu.buildFromTemplate([
{
label: "Open",
Expand Down Expand Up @@ -120,7 +127,7 @@ function initTray(win: BrowserWindow) {
tray = new Tray(ICON_PATH);
tray.setToolTip("Vesktop");
tray.setContextMenu(trayMenu);
tray.on("click", () => win.show());
tray.on("click", trayClickHandler);
}

async function clearData(win: BrowserWindow) {
Expand Down
6 changes: 6 additions & 0 deletions src/renderer/components/settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ const SettingsOptions: Record<string, Array<BooleanSetting | SettingsComponent>>
invisible: () => isMac,
disabled: () => Settings.store.tray === false
},
{
key: "clickTrayToShowHide",
title: "Hide/Show on tray left click",
description: "Left clicking on tray will hide or show the vesktop window. Requires a full restart.",
defaultValue: false
},
{
key: "disableMinSize",
title: "Disable minimum window size",
Expand Down
2 changes: 1 addition & 1 deletion src/shared/settings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface Settings {
arRPC?: boolean;
appBadge?: boolean;
disableMinSize?: boolean;

clickTrayToShowHide?: boolean;
/** @deprecated use customTitleBar */
discordWindowsTitleBar?: boolean;
customTitleBar?: boolean;
Expand Down
Loading