mirror of
https://github.com/wavetermdev/backup.git
synced 2026-08-05 13:57:07 -07:00
Fix number overlay hotkeys conflict with screenshot in macos (#222)
This commit is contained in:
+31
-12
@@ -360,28 +360,47 @@ function genericClose(tabId: string) {
|
|||||||
services.ObjectService.DeleteBlock(activeBlockId);
|
services.ObjectService.DeleteBlock(activeBlockId);
|
||||||
}
|
}
|
||||||
|
|
||||||
const simpleCmdShiftAtom = jotai.atom(false);
|
const simpleControlShiftAtom = jotai.atom(false);
|
||||||
|
|
||||||
const AppKeyHandlers = () => {
|
const AppKeyHandlers = () => {
|
||||||
const tabId = jotai.useAtomValue(atoms.activeTabId);
|
const tabId = jotai.useAtomValue(atoms.activeTabId);
|
||||||
|
|
||||||
|
function setControlShift() {
|
||||||
|
globalStore.set(simpleControlShiftAtom, true);
|
||||||
|
setTimeout(() => {
|
||||||
|
const simpleState = globalStore.get(simpleControlShiftAtom);
|
||||||
|
if (simpleState) {
|
||||||
|
globalStore.set(atoms.controlShiftDelayAtom, true);
|
||||||
|
}
|
||||||
|
}, 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
function unsetControlShift() {
|
||||||
|
globalStore.set(simpleControlShiftAtom, false);
|
||||||
|
globalStore.set(atoms.controlShiftDelayAtom, false);
|
||||||
|
}
|
||||||
|
|
||||||
function handleKeyUp(event: KeyboardEvent) {
|
function handleKeyUp(event: KeyboardEvent) {
|
||||||
const waveEvent = keyutil.adaptFromReactOrNativeKeyEvent(event);
|
const waveEvent = keyutil.adaptFromReactOrNativeKeyEvent(event);
|
||||||
if (waveEvent.key == "Control" || waveEvent.key == "Shift") {
|
if (waveEvent.key === "Control" || waveEvent.key === "Shift") {
|
||||||
globalStore.set(simpleCmdShiftAtom, false);
|
unsetControlShift();
|
||||||
globalStore.set(atoms.cmdShiftDelayAtom, false);
|
}
|
||||||
|
if (waveEvent.key == "Meta") {
|
||||||
|
if (waveEvent.control && waveEvent.shift) {
|
||||||
|
setControlShift();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleKeyDown(waveEvent: WaveKeyboardEvent): boolean {
|
function handleKeyDown(waveEvent: WaveKeyboardEvent): boolean {
|
||||||
if ((waveEvent.key == "Control" || waveEvent.key == "Shift") && waveEvent.control && waveEvent.shift) {
|
if (waveEvent.key === "Control" || waveEvent.key === "Shift" || waveEvent.key === "Meta") {
|
||||||
globalStore.set(simpleCmdShiftAtom, true);
|
if (waveEvent.control && waveEvent.shift && !waveEvent.meta) {
|
||||||
setTimeout(() => {
|
// Set the control and shift without the Meta key
|
||||||
const simpleState = globalStore.get(simpleCmdShiftAtom);
|
setControlShift();
|
||||||
if (simpleState) {
|
} else {
|
||||||
globalStore.set(atoms.cmdShiftDelayAtom, true);
|
// Unset if Meta is pressed
|
||||||
}
|
unsetControlShift();
|
||||||
}, 400);
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ function BlockNum({ blockId }: { blockId: string }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const BlockMask = ({ blockId, preview, isFocused }: { blockId: string; preview: boolean; isFocused: boolean }) => {
|
const BlockMask = ({ blockId, preview, isFocused }: { blockId: string; preview: boolean; isFocused: boolean }) => {
|
||||||
const isLayoutMode = jotai.useAtomValue(atoms.cmdShiftDelayAtom);
|
const isLayoutMode = jotai.useAtomValue(atoms.controlShiftDelayAtom);
|
||||||
const [blockData] = WOS.useWaveObjectValue<Block>(WOS.makeORef("block", blockId));
|
const [blockData] = WOS.useWaveObjectValue<Block>(WOS.makeORef("block", blockId));
|
||||||
|
|
||||||
const style: React.CSSProperties = {};
|
const style: React.CSSProperties = {};
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ function initGlobalAtoms(initOpts: GlobalInitOptions) {
|
|||||||
}
|
}
|
||||||
return windowData.activetabid;
|
return windowData.activetabid;
|
||||||
});
|
});
|
||||||
const cmdShiftDelayAtom = jotai.atom(false);
|
const controlShiftDelayAtom = jotai.atom(false);
|
||||||
const updateStatusAtom = jotai.atom<UpdaterStatus>("up-to-date") as jotai.PrimitiveAtom<UpdaterStatus>;
|
const updateStatusAtom = jotai.atom<UpdaterStatus>("up-to-date") as jotai.PrimitiveAtom<UpdaterStatus>;
|
||||||
try {
|
try {
|
||||||
globalStore.set(updateStatusAtom, getApi().getUpdaterStatus());
|
globalStore.set(updateStatusAtom, getApi().getUpdaterStatus());
|
||||||
@@ -126,7 +126,7 @@ function initGlobalAtoms(initOpts: GlobalInitOptions) {
|
|||||||
tabAtom: tabAtom,
|
tabAtom: tabAtom,
|
||||||
activeTabId: activeTabIdAtom,
|
activeTabId: activeTabIdAtom,
|
||||||
isFullScreen: isFullScreenAtom,
|
isFullScreen: isFullScreenAtom,
|
||||||
cmdShiftDelayAtom: cmdShiftDelayAtom,
|
controlShiftDelayAtom: controlShiftDelayAtom,
|
||||||
updaterStatusAtom: updateStatusAtom,
|
updaterStatusAtom: updateStatusAtom,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
-1
@@ -16,7 +16,7 @@ declare global {
|
|||||||
tabAtom: jotai.Atom<Tab>; // driven from WOS
|
tabAtom: jotai.Atom<Tab>; // driven from WOS
|
||||||
activeTabId: jotai.Atom<string>; // derrived from windowDataAtom
|
activeTabId: jotai.Atom<string>; // derrived from windowDataAtom
|
||||||
isFullScreen: jotai.PrimitiveAtom<boolean>;
|
isFullScreen: jotai.PrimitiveAtom<boolean>;
|
||||||
cmdShiftDelayAtom: jotai.PrimitiveAtom<boolean>;
|
controlShiftDelayAtom: jotai.PrimitiveAtom<boolean>;
|
||||||
updaterStatusAtom: jotai.PrimitiveAtom<UpdaterStatus>;
|
updaterStatusAtom: jotai.PrimitiveAtom<UpdaterStatus>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user