Desktop: Add fullscreen window mode (#3625)

This commit is contained in:
Timon
2026-01-19 16:32:03 +00:00
committed by GitHub
parent fd0addf61c
commit 07fbcd489c
20 changed files with 195 additions and 153 deletions
+6 -1
View File
@@ -1,8 +1,9 @@
import { writable } from "svelte/store";
import { type Editor } from "@graphite/editor";
import { WindowFullscreen } from "@graphite/messages";
export function createFullscreenState(_: Editor) {
export function createFullscreenState(editor: Editor) {
// Experimental Keyboard API: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/keyboard
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const keyboardLockApiSupported: Readonly<boolean> = "keyboard" in navigator && (navigator as any).keyboard && "lock" in (navigator as any).keyboard;
@@ -50,6 +51,10 @@ export function createFullscreenState(_: Editor) {
});
}
editor.subscriptions.subscribeJsMessage(WindowFullscreen, () => {
toggleFullscreen();
});
return {
subscribe,
fullscreenModeChanged,
+5 -4
View File
@@ -1,7 +1,8 @@
import { writable } from "svelte/store";
import { type Editor } from "@graphite/editor";
import { SendShortcutAltClick, SendShortcutF11, SendShortcutShiftClick, type ActionShortcut } from "@graphite/messages";
import { SendShortcutAltClick, SendShortcutFullscreen, SendShortcutShiftClick, type ActionShortcut } from "@graphite/messages";
import { operatingSystem } from "@graphite/utility-functions/platform";
const SHOW_TOOLTIP_DELAY_MS = 500;
@@ -12,7 +13,7 @@ export function createTooltipState(editor: Editor) {
position: { x: 0, y: 0 },
shiftClickShortcut: undefined as ActionShortcut | undefined,
altClickShortcut: undefined as ActionShortcut | undefined,
f11Shortcut: undefined as ActionShortcut | undefined,
fullscreenShortcut: undefined as ActionShortcut | undefined,
});
let tooltipTimeout: ReturnType<typeof setTimeout> | undefined = undefined;
@@ -63,9 +64,9 @@ export function createTooltipState(editor: Editor) {
return state;
});
});
editor.subscriptions.subscribeJsMessage(SendShortcutF11, async (data) => {
editor.subscriptions.subscribeJsMessage(SendShortcutFullscreen, async (data) => {
update((state) => {
state.f11Shortcut = data.shortcut;
state.fullscreenShortcut = operatingSystem() === "Mac" ? data.shortcutMac : data.shortcut;
return state;
});
});