Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
22 changes: 12 additions & 10 deletions cmd/server/main-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func updateTelemetryCounts(lastCounts telemetrydata.TEventProps) telemetrydata.T
SettingsCustomSettings: customSettings,
SettingsCustomAIModes: customAIModes,
}

secretsCount, err := secretstore.CountSecrets()
if err == nil {
props.UserSet.SettingsSecretsCount = secretsCount
Expand Down Expand Up @@ -315,17 +315,19 @@ func startupActivityUpdate(firstLaunch bool) {
cohortISOWeek := fmt.Sprintf("%04d-W%02d", year, week)
userSetOnce.CohortMonth = cohortMonth
userSetOnce.CohortISOWeek = cohortISOWeek
fullConfig := wconfig.GetWatcher().GetFullConfig()
props := telemetrydata.TEventProps{
UserSet: &telemetrydata.TEventUserProps{
ClientVersion: "v" + WaveVersion,
ClientBuildTime: BuildTime,
ClientArch: wavebase.ClientArch(),
ClientOSRelease: wavebase.UnameKernelRelease(),
ClientIsDev: wavebase.IsDevMode(),
AutoUpdateChannel: autoUpdateChannel,
AutoUpdateEnabled: autoUpdateEnabled,
LocalShellType: shellType,
LocalShellVersion: shellVersion,
ClientVersion: "v" + WaveVersion,
ClientBuildTime: BuildTime,
ClientArch: wavebase.ClientArch(),
ClientOSRelease: wavebase.UnameKernelRelease(),
ClientIsDev: wavebase.IsDevMode(),
AutoUpdateChannel: autoUpdateChannel,
AutoUpdateEnabled: autoUpdateEnabled,
LocalShellType: shellType,
LocalShellVersion: shellVersion,
SettingsTransparent: fullConfig.Settings.WindowTransparent,
},
UserSetOnce: userSetOnce,
}
Expand Down
36 changes: 17 additions & 19 deletions emain/emain-ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import { RpcApi } from "../frontend/app/store/wshclientapi";
import { getWebServerEndpoint } from "../frontend/util/endpoints";
import * as keyutil from "../frontend/util/keyutil";
import { fireAndForget, parseDataUrl } from "../frontend/util/util";
import { incrementTermCommandsRun } from "./emain-activity";
import { createBuilderWindow, getAllBuilderWindows, getBuilderWindowByWebContentsId } from "./emain-builder";
import { callWithOriginalXdgCurrentDesktopAsync, unamePlatform } from "./emain-platform";
import { getWaveTabViewByWebContentsId } from "./emain-tabview";
import { handleCtrlShiftState } from "./emain-util";
import { getWaveVersion } from "./emain-wavesrv";
import { createNewWaveWindow, focusedWaveWindow, getWaveWindowByWebContentsId } from "./emain-window";
import { incrementTermCommandsRun } from "./emain-activity";
import { ElectronWshClient } from "./emain-wsh";

const electronApp = electron.app;
Expand All @@ -29,9 +29,7 @@ let webviewKeys: string[] = [];
export function openBuilderWindow(appId?: string) {
const normalizedAppId = appId || "";
const existingBuilderWindows = getAllBuilderWindows();
const existingWindow = existingBuilderWindows.find(
(win) => win.builderAppId === normalizedAppId
);
const existingWindow = existingBuilderWindows.find((win) => win.builderAppId === normalizedAppId);
if (existingWindow) {
existingWindow.focus();
return;
Expand Down Expand Up @@ -314,12 +312,12 @@ export function initIpcHandlers() {
tabView?.setKeyboardChordMode(true);
});

if (unamePlatform !== "darwin") {
const fac = new FastAverageColor();

electron.ipcMain.on("update-window-controls-overlay", async (event, rect: Dimensions) => {
const fac = new FastAverageColor();
electron.ipcMain.on("update-window-controls-overlay", async (event, rect: Dimensions) => {
if (unamePlatform === "darwin") return;
try {
const fullConfig = await RpcApi.GetFullConfigCommand(ElectronWshClient);
if (fullConfig.settings["window:nativetitlebar"]) return;
if (fullConfig?.settings?.["window:nativetitlebar"] && unamePlatform !== "win32") return;

const zoomFactor = event.sender.getZoomFactor();
const electronRect: Electron.Rectangle = {
Expand All @@ -337,18 +335,18 @@ export function initIpcHandlers() {
color: unamePlatform === "linux" ? color.rgba : "#00000000",
symbolColor: color.isDark ? "white" : "black",
});
});
}
} catch (e) {
console.error("Error updating window controls overlay:", e);
}
});

electron.ipcMain.on("quicklook", (event, filePath: string) => {
if (unamePlatform == "darwin") {
child_process.execFile("/usr/bin/qlmanage", ["-p", filePath], (error, stdout, stderr) => {
if (error) {
console.error(`Error opening Quick Look: ${error}`);
return;
}
});
}
if (unamePlatform !== "darwin") return;
child_process.execFile("/usr/bin/qlmanage", ["-p", filePath], (error, stdout, stderr) => {
if (error) {
console.error(`Error opening Quick Look: ${error}`);
}
});
});

electron.ipcMain.handle("clear-webview-storage", async (event, webContentsId: number) => {
Expand Down
43 changes: 20 additions & 23 deletions emain/emain-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { focusedBuilderWindow, getBuilderWindowById } from "./emain-builder";
import { openBuilderWindow } from "./emain-ipc";
import { isDev, unamePlatform } from "./emain-platform";
import { clearTabCache } from "./emain-tabview";
import { decreaseZoomLevel, increaseZoomLevel } from "./emain-util";
import {
createNewWaveWindow,
createWorkspace,
Expand Down Expand Up @@ -123,7 +124,11 @@ function makeEditMenu(fullConfig?: FullConfigType): Electron.MenuItemConstructor
];
}

function makeFileMenu(numWaveWindows: number, callbacks: AppMenuCallbacks, fullConfig: FullConfigType): Electron.MenuItemConstructorOptions[] {
function makeFileMenu(
numWaveWindows: number,
callbacks: AppMenuCallbacks,
fullConfig: FullConfigType
): Electron.MenuItemConstructorOptions[] {
const fileMenu: Electron.MenuItemConstructorOptions[] = [
{
label: "New Window",
Expand Down Expand Up @@ -242,25 +247,19 @@ function makeViewMenu(
accelerator: "CommandOrControl+=",
click: (_, window) => {
const wc = getWindowWebContents(window) ?? webContents;
if (wc == null) {
return;
if (wc) {
increaseZoomLevel(wc);
}
const newZoom = Math.min(5, wc.getZoomFactor() + 0.2);
wc.setZoomFactor(newZoom);
wc.send("zoom-factor-change", newZoom);
},
},
{
label: "Zoom In (hidden)",
accelerator: "CommandOrControl+Shift+=",
click: (_, window) => {
const wc = getWindowWebContents(window) ?? webContents;
if (wc == null) {
return;
if (wc) {
increaseZoomLevel(wc);
}
const newZoom = Math.min(5, wc.getZoomFactor() + 0.2);
wc.setZoomFactor(newZoom);
wc.send("zoom-factor-change", newZoom);
},
visible: false,
acceleratorWorksWhenHidden: true,
Expand All @@ -270,25 +269,19 @@ function makeViewMenu(
accelerator: "CommandOrControl+-",
click: (_, window) => {
const wc = getWindowWebContents(window) ?? webContents;
if (wc == null) {
return;
if (wc) {
decreaseZoomLevel(wc);
}
const newZoom = Math.max(0.2, wc.getZoomFactor() - 0.2);
wc.setZoomFactor(newZoom);
wc.send("zoom-factor-change", newZoom);
},
},
{
label: "Zoom Out (hidden)",
accelerator: "CommandOrControl+Shift+-",
click: (_, window) => {
const wc = getWindowWebContents(window) ?? webContents;
if (wc == null) {
return;
if (wc) {
decreaseZoomLevel(wc);
}
const newZoom = Math.max(0.2, wc.getZoomFactor() - 0.2);
wc.setZoomFactor(newZoom);
wc.send("zoom-factor-change", newZoom);
},
visible: false,
acceleratorWorksWhenHidden: true,
Expand Down Expand Up @@ -380,7 +373,11 @@ export function instantiateAppMenu(workspaceOrBuilderId?: string): Promise<elect
);
}

export function makeAppMenu() {
// does not a set a menu on windows
export function makeAndSetAppMenu() {
if (unamePlatform === "win32") {
return;
}
fireAndForget(async () => {
const menu = await instantiateAppMenu();
electron.Menu.setApplicationMenu(menu);
Expand All @@ -389,7 +386,7 @@ export function makeAppMenu() {

waveEventSubscribe({
eventType: "workspace:update",
handler: makeAppMenu,
handler: makeAndSetAppMenu,
});

function getWebContentsByWorkspaceOrBuilderId(workspaceOrBuilderId: string): electron.WebContents {
Expand Down
87 changes: 83 additions & 4 deletions emain/emain-tabview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,88 @@
// SPDX-License-Identifier: Apache-2.0

import { RpcApi } from "@/app/store/wshclientapi";
import { adaptFromElectronKeyEvent } from "@/util/keyutil";
import { adaptFromElectronKeyEvent, checkKeyPressed } from "@/util/keyutil";
import { CHORD_TIMEOUT } from "@/util/sharedconst";
import { Rectangle, shell, WebContentsView } from "electron";
import { getWaveWindowById } from "emain/emain-window";
import { createNewWaveWindow, getWaveWindowById } from "emain/emain-window";
import path from "path";
import { configureAuthKeyRequestInjection } from "./authkey";
import { setWasActive } from "./emain-activity";
import { getElectronAppBasePath, isDevVite } from "./emain-platform";
import { handleCtrlShiftFocus, handleCtrlShiftState, shFrameNavHandler, shNavHandler } from "./emain-util";
import { getElectronAppBasePath, isDevVite, unamePlatform } from "./emain-platform";
import {
decreaseZoomLevel,
handleCtrlShiftFocus,
handleCtrlShiftState,
increaseZoomLevel,
shFrameNavHandler,
shNavHandler,
} from "./emain-util";
import { ElectronWshClient } from "./emain-wsh";

function handleWindowsMenuAccelerators(waveEvent: WaveKeyboardEvent, tabView: WaveTabView): boolean {
const waveWindow = getWaveWindowById(tabView.waveWindowId);

if (checkKeyPressed(waveEvent, "Ctrl:Shift:n")) {
createNewWaveWindow();
return true;
}

if (checkKeyPressed(waveEvent, "Ctrl:Shift:r")) {
tabView.webContents.reloadIgnoringCache();
return true;
}

if (checkKeyPressed(waveEvent, "Ctrl:v")) {
tabView.webContents.paste();
return true;
}

if (checkKeyPressed(waveEvent, "Ctrl:0")) {
tabView.webContents.setZoomFactor(1);
tabView.webContents.send("zoom-factor-change", 1);
return true;
}

if (checkKeyPressed(waveEvent, "Ctrl:=") || checkKeyPressed(waveEvent, "Ctrl:Shift:=")) {
increaseZoomLevel(tabView.webContents);
return true;
}

if (checkKeyPressed(waveEvent, "Ctrl:-") || checkKeyPressed(waveEvent, "Ctrl:Shift:-")) {
decreaseZoomLevel(tabView.webContents);
return true;
}

if (checkKeyPressed(waveEvent, "F11")) {
if (waveWindow) {
waveWindow.setFullScreen(!waveWindow.isFullScreen());
}
return true;
}

for (let i = 1; i <= 9; i++) {
if (checkKeyPressed(waveEvent, `Alt:Ctrl:${i}`)) {
const workspaceNum = i - 1;
RpcApi.WorkspaceListCommand(ElectronWshClient).then((workspaceList) => {
if (workspaceList && workspaceNum < workspaceList.length) {
const workspace = workspaceList[workspaceNum];
if (waveWindow) {
waveWindow.switchWorkspace(workspace.workspacedata.oid);
}
}
});
return true;
}
}

if (checkKeyPressed(waveEvent, "Alt:Shift:i")) {
tabView.webContents.toggleDevTools();
return true;
}

return false;
}

function computeBgColor(fullConfig: FullConfigType): string {
const settings = fullConfig?.settings;
const isTransparent = settings?.["window:transparent"] ?? false;
Expand Down Expand Up @@ -249,6 +320,14 @@ export async function getOrCreateWebViewForTab(waveWindowId: string, tabId: stri
e.preventDefault();
tabView.setKeyboardChordMode(false);
tabView.webContents.send("reinject-key", waveEvent);
return;
}

if (unamePlatform === "win32" && input.type == "keyDown") {
if (handleWindowsMenuAccelerators(waveEvent, tabView)) {
e.preventDefault();
return;
}
}
});
tabView.webContents.on("zoom-changed", (e) => {
Expand Down
16 changes: 16 additions & 0 deletions emain/emain-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ export const WaveAppPathVarName = "WAVETERM_APP_PATH";
export const WaveAppResourcesPathVarName = "WAVETERM_RESOURCES_PATH";
export const WaveAppElectronExecPath = "WAVETERM_ELECTRONEXECPATH";

const MinZoomLevel = 0.4;
const MaxZoomLevel = 2.6;
const ZoomDelta = 0.2;

export function increaseZoomLevel(webContents: electron.WebContents): void {
const newZoom = Math.min(MaxZoomLevel, webContents.getZoomFactor() + ZoomDelta);
webContents.setZoomFactor(newZoom);
webContents.send("zoom-factor-change", newZoom);
}

export function decreaseZoomLevel(webContents: electron.WebContents): void {
const newZoom = Math.max(MinZoomLevel, webContents.getZoomFactor() - ZoomDelta);
webContents.setZoomFactor(newZoom);
webContents.send("zoom-factor-change", newZoom);
}

export function getElectronExecPath(): string {
return process.execPath;
}
Expand Down
Loading
Loading