mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-04 18:59:08 +01:00
window-dimensions and zoom crash fixed (#1652)
fixed issue #1613 partially, added window:dimensions as a setting which gives the user to define dimensions. fixed the zoom in and out logic to prevent the app from crashing. Had issues with getting setting zoomfactor in emain-tabview.ts. will fix it
This commit is contained in:
parent
cb2cd72cd4
commit
a1f26ba455
@ -79,6 +79,7 @@ wsh editconfig
|
|||||||
| window:disablehardwareacceleration | bool | set to disable Chromium hardware acceleration to resolve graphical bugs (requires app restart) |
|
| window:disablehardwareacceleration | bool | set to disable Chromium hardware acceleration to resolve graphical bugs (requires app restart) |
|
||||||
| window:savelastwindow | bool | when `true`, the last window that is closed is preserved and is reopened the next time the app is launched (defaults to `true`) |
|
| window:savelastwindow | bool | when `true`, the last window that is closed is preserved and is reopened the next time the app is launched (defaults to `true`) |
|
||||||
| window:confirmonclose | bool | when `true`, a prompt will ask a user to confirm that they want to close a window if it has an unsaved workspace with more than one tab (defaults to `true`) |
|
| window:confirmonclose | bool | when `true`, a prompt will ask a user to confirm that they want to close a window if it has an unsaved workspace with more than one tab (defaults to `true`) |
|
||||||
|
| window:dimensions | string | set the default dimensions for new windows using the format "WIDTHxHEIGHT" (e.g. "1920x1080"). when a new window is created, these dimensions will be automatically applied. The width and height values should be specified in pixels. |
|
||||||
| telemetry:enabled | bool | set to enable/disable telemetry |
|
| telemetry:enabled | bool | set to enable/disable telemetry |
|
||||||
|
|
||||||
For reference, this is the current default configuration (v0.10.4):
|
For reference, this is the current default configuration (v0.10.4):
|
||||||
|
@ -73,11 +73,37 @@ export class WaveBrowserWindow extends BaseWindow {
|
|||||||
private actionQueue: WindowActionQueueEntry[];
|
private actionQueue: WindowActionQueueEntry[];
|
||||||
|
|
||||||
constructor(waveWindow: WaveWindow, fullConfig: FullConfigType, opts: WindowOpts) {
|
constructor(waveWindow: WaveWindow, fullConfig: FullConfigType, opts: WindowOpts) {
|
||||||
|
const settings = fullConfig?.settings;
|
||||||
|
|
||||||
console.log("create win", waveWindow.oid);
|
console.log("create win", waveWindow.oid);
|
||||||
let winWidth = waveWindow?.winsize?.width;
|
let winWidth = waveWindow?.winsize?.width;
|
||||||
let winHeight = waveWindow?.winsize?.height;
|
let winHeight = waveWindow?.winsize?.height;
|
||||||
let winPosX = waveWindow.pos.x;
|
let winPosX = waveWindow.pos.x;
|
||||||
let winPosY = waveWindow.pos.y;
|
let winPosY = waveWindow.pos.y;
|
||||||
|
|
||||||
|
if (
|
||||||
|
(winWidth == null || winWidth === 0 || winHeight == null || winHeight === 0) &&
|
||||||
|
settings?.["window:dimensions"]
|
||||||
|
) {
|
||||||
|
const dimensions = settings["window:dimensions"];
|
||||||
|
const match = dimensions.match(/^(\d+)[xX](\d+)$/);
|
||||||
|
|
||||||
|
if (match) {
|
||||||
|
const [, dimensionWidth, dimensionHeight] = match;
|
||||||
|
const parsedWidth = parseInt(dimensionWidth, 10);
|
||||||
|
const parsedHeight = parseInt(dimensionHeight, 10);
|
||||||
|
|
||||||
|
if ((!winWidth || winWidth === 0) && Number.isFinite(parsedWidth) && parsedWidth > 0) {
|
||||||
|
winWidth = parsedWidth;
|
||||||
|
}
|
||||||
|
if ((!winHeight || winHeight === 0) && Number.isFinite(parsedHeight) && parsedHeight > 0) {
|
||||||
|
winHeight = parsedHeight;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.warn('Invalid window:dimensions format. Expected "widthxheight".');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (winWidth == null || winWidth == 0) {
|
if (winWidth == null || winWidth == 0) {
|
||||||
const primaryDisplay = screen.getPrimaryDisplay();
|
const primaryDisplay = screen.getPrimaryDisplay();
|
||||||
const { width } = primaryDisplay.workAreaSize;
|
const { width } = primaryDisplay.workAreaSize;
|
||||||
@ -101,7 +127,6 @@ export class WaveBrowserWindow extends BaseWindow {
|
|||||||
height: winHeight,
|
height: winHeight,
|
||||||
};
|
};
|
||||||
winBounds = ensureBoundsAreVisible(winBounds);
|
winBounds = ensureBoundsAreVisible(winBounds);
|
||||||
const settings = fullConfig?.settings;
|
|
||||||
const winOpts: BaseWindowConstructorOptions = {
|
const winOpts: BaseWindowConstructorOptions = {
|
||||||
titleBarStyle:
|
titleBarStyle:
|
||||||
opts.unamePlatform === "darwin"
|
opts.unamePlatform === "darwin"
|
||||||
|
@ -206,10 +206,7 @@ async function getAppMenu(callbacks: AppMenuCallbacks, workspaceId?: string): Pr
|
|||||||
if (wc == null) {
|
if (wc == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (wc.getZoomFactor() >= 5) {
|
wc.setZoomFactor(Math.min(5, wc.getZoomFactor() + 0.2));
|
||||||
return;
|
|
||||||
}
|
|
||||||
wc.setZoomFactor(wc.getZoomFactor() + 0.2);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -220,10 +217,7 @@ async function getAppMenu(callbacks: AppMenuCallbacks, workspaceId?: string): Pr
|
|||||||
if (wc == null) {
|
if (wc == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (wc.getZoomFactor() >= 5) {
|
wc.setZoomFactor(Math.min(5, wc.getZoomFactor() + 0.2));
|
||||||
return;
|
|
||||||
}
|
|
||||||
wc.setZoomFactor(wc.getZoomFactor() + 0.2);
|
|
||||||
},
|
},
|
||||||
visible: false,
|
visible: false,
|
||||||
acceleratorWorksWhenHidden: true,
|
acceleratorWorksWhenHidden: true,
|
||||||
@ -236,10 +230,7 @@ async function getAppMenu(callbacks: AppMenuCallbacks, workspaceId?: string): Pr
|
|||||||
if (wc == null) {
|
if (wc == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (wc.getZoomFactor() <= 0.2) {
|
wc.setZoomFactor(Math.max(0.2, wc.getZoomFactor() - 0.2));
|
||||||
return;
|
|
||||||
}
|
|
||||||
wc.setZoomFactor(wc.getZoomFactor() - 0.2);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -250,10 +241,7 @@ async function getAppMenu(callbacks: AppMenuCallbacks, workspaceId?: string): Pr
|
|||||||
if (wc == null) {
|
if (wc == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (wc.getZoomFactor() <= 0.2) {
|
wc.setZoomFactor(Math.max(0.2, wc.getZoomFactor() - 0.2));
|
||||||
return;
|
|
||||||
}
|
|
||||||
wc.setZoomFactor(wc.getZoomFactor() - 0.2);
|
|
||||||
},
|
},
|
||||||
visible: false,
|
visible: false,
|
||||||
acceleratorWorksWhenHidden: true,
|
acceleratorWorksWhenHidden: true,
|
||||||
|
2
frontend/types/gotypes.d.ts
vendored
2
frontend/types/gotypes.d.ts
vendored
@ -636,6 +636,8 @@ declare global {
|
|||||||
"window:magnifiedblockblursecondarypx"?: number;
|
"window:magnifiedblockblursecondarypx"?: number;
|
||||||
"window:confirmclose"?: boolean;
|
"window:confirmclose"?: boolean;
|
||||||
"window:savelastwindow"?: boolean;
|
"window:savelastwindow"?: boolean;
|
||||||
|
"window:dimensions"?: string;
|
||||||
|
"window:zoom"?: number;
|
||||||
"telemetry:*"?: boolean;
|
"telemetry:*"?: boolean;
|
||||||
"telemetry:enabled"?: boolean;
|
"telemetry:enabled"?: boolean;
|
||||||
"conn:*"?: boolean;
|
"conn:*"?: boolean;
|
||||||
|
@ -81,6 +81,8 @@ const (
|
|||||||
ConfigKey_WindowMagnifiedBlockBlurSecondaryPx = "window:magnifiedblockblursecondarypx"
|
ConfigKey_WindowMagnifiedBlockBlurSecondaryPx = "window:magnifiedblockblursecondarypx"
|
||||||
ConfigKey_WindowConfirmClose = "window:confirmclose"
|
ConfigKey_WindowConfirmClose = "window:confirmclose"
|
||||||
ConfigKey_WindowSaveLastWindow = "window:savelastwindow"
|
ConfigKey_WindowSaveLastWindow = "window:savelastwindow"
|
||||||
|
ConfigKey_WindowDimensions = "window:dimensions"
|
||||||
|
ConfigKey_WindowZoom = "window:zoom"
|
||||||
|
|
||||||
ConfigKey_TelemetryClear = "telemetry:*"
|
ConfigKey_TelemetryClear = "telemetry:*"
|
||||||
ConfigKey_TelemetryEnabled = "telemetry:enabled"
|
ConfigKey_TelemetryEnabled = "telemetry:enabled"
|
||||||
|
@ -108,6 +108,8 @@ type SettingsType struct {
|
|||||||
WindowMagnifiedBlockBlurSecondaryPx *int64 `json:"window:magnifiedblockblursecondarypx,omitempty"`
|
WindowMagnifiedBlockBlurSecondaryPx *int64 `json:"window:magnifiedblockblursecondarypx,omitempty"`
|
||||||
WindowConfirmClose bool `json:"window:confirmclose,omitempty"`
|
WindowConfirmClose bool `json:"window:confirmclose,omitempty"`
|
||||||
WindowSaveLastWindow bool `json:"window:savelastwindow,omitempty"`
|
WindowSaveLastWindow bool `json:"window:savelastwindow,omitempty"`
|
||||||
|
WindowDimensions string `json:"window:dimensions,omitempty"`
|
||||||
|
WindowZoom *float64 `json:"window:zoom,omitempty"`
|
||||||
|
|
||||||
TelemetryClear bool `json:"telemetry:*,omitempty"`
|
TelemetryClear bool `json:"telemetry:*,omitempty"`
|
||||||
TelemetryEnabled bool `json:"telemetry:enabled,omitempty"`
|
TelemetryEnabled bool `json:"telemetry:enabled,omitempty"`
|
||||||
|
Loading…
Reference in New Issue
Block a user