-
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(focus): focused app no been matching correctly
- Loading branch information
Showing
17 changed files
with
393 additions
and
339 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,109 +1,109 @@ | ||
import { UserSettingsLoader } from '../../../../settings/modules/shared/store/storeApi'; | ||
import { loadThemeCSS, setColorsAsCssVariables } from '../../../../shared'; | ||
import { FileChange } from '../../../../shared/events'; | ||
import { WindowManager } from '../../../../shared/schemas/WindowManager'; | ||
import { configureStore } from '@reduxjs/toolkit'; | ||
import { listen as listenGlobal } from '@tauri-apps/api/event'; | ||
|
||
import { RootActions, RootSlice } from './app'; | ||
|
||
import { Reservation, Sizing } from '../../layout/domain'; | ||
import { AddWindowPayload, DesktopId, FocusAction, UIColors } from './domain'; | ||
|
||
export const store = configureStore({ | ||
reducer: RootSlice.reducer, | ||
devTools: true, | ||
}); | ||
|
||
export async function loadStore() { | ||
const userSettings = await new UserSettingsLoader().withLayouts().load(); | ||
const settings = userSettings.jsonSettings.windowManager; | ||
store.dispatch(RootActions.setAvailableLayouts(userSettings.layouts)); | ||
store.dispatch(RootActions.setSettings(settings)); | ||
loadSettingsCSS(settings); | ||
loadThemeCSS(userSettings); | ||
} | ||
|
||
export async function registerStoreEvents() { | ||
await listenGlobal<any>(FileChange.Settings, async () => { | ||
await loadStore(); | ||
}); | ||
|
||
await listenGlobal<AddWindowPayload>('add-window', (event) => { | ||
store.dispatch(RootActions.addWindow(event.payload)); | ||
}); | ||
|
||
await listenGlobal<number>('remove-window', (event) => { | ||
store.dispatch(RootActions.removeWindow(event.payload)); | ||
}); | ||
|
||
await listenGlobal<void>('force-retiling', () => { | ||
store.dispatch(RootActions.forceUpdate()); | ||
}); | ||
|
||
await listenGlobal<DesktopId>('set-active-workspace', (event) => { | ||
store.dispatch(RootActions.setActiveWorkspace(event.payload)); | ||
}); | ||
|
||
await listenGlobal<number>('set-active-window', (event) => { | ||
store.dispatch(RootActions.setActiveWindow(event.payload)); | ||
if (event.payload != 0) { | ||
store.dispatch(RootActions.setLastManagedActivated(event.payload)); | ||
} | ||
}); | ||
|
||
await listenGlobal<Reservation | null>('set-reservation', (event) => { | ||
store.dispatch(RootActions.setReservation(event.payload)); | ||
}); | ||
|
||
await listenGlobal<Sizing>('update-width', (event) => { | ||
store.dispatch(RootActions.updateSizing({ axis: 'x', sizing: event.payload })); | ||
}); | ||
|
||
await listenGlobal<Sizing>('update-height', (event) => { | ||
store.dispatch(RootActions.updateSizing({ axis: 'y', sizing: event.payload })); | ||
}); | ||
|
||
await listenGlobal<void>('reset-workspace-size', () => { | ||
store.dispatch(RootActions.resetSizing()); | ||
}); | ||
|
||
await listenGlobal<FocusAction>('focus', (event) => { | ||
store.dispatch(RootActions.focus(event.payload)); | ||
}); | ||
|
||
await listenGlobal<AddWindowPayload>('update-window', (event) => { | ||
store.dispatch(RootActions.removeWindow(event.payload.hwnd)); | ||
store.dispatch(RootActions.addWindow(event.payload)); | ||
}); | ||
|
||
await listenGlobal<UIColors>('colors', (event) => { | ||
setColorsAsCssVariables(event.payload); | ||
store.dispatch(RootActions.setColors(event.payload)); | ||
}); | ||
|
||
await listenGlobal(FileChange.Themes, async () => { | ||
const userSettings = await new UserSettingsLoader().load(); | ||
loadThemeCSS(userSettings); | ||
}); | ||
|
||
await listenGlobal(FileChange.Placeholders, async () => { | ||
const userSettings = await new UserSettingsLoader().withLayouts().load(); | ||
store.dispatch(RootActions.setAvailableLayouts(userSettings.layouts)); | ||
}); | ||
} | ||
|
||
function loadSettingsCSS(settings: WindowManager) { | ||
const styles = document.documentElement.style; | ||
|
||
styles.setProperty('--config-padding', `${settings.workspacePadding}px`); | ||
styles.setProperty('--config-containers-gap', `${settings.workspaceGap}px`); | ||
|
||
styles.setProperty('--config-margin-top', `${settings.globalWorkAreaOffset.top}px`); | ||
styles.setProperty('--config-margin-left', `${settings.globalWorkAreaOffset.left}px`); | ||
styles.setProperty('--config-margin-right', `${settings.globalWorkAreaOffset.right}px`); | ||
styles.setProperty('--config-margin-bottom', `${settings.globalWorkAreaOffset.bottom}px`); | ||
|
||
styles.setProperty('--config-border-offset', `${settings.border.offset}px`); | ||
styles.setProperty('--config-border-width', `${settings.border.width}px`); | ||
} | ||
import { UserSettingsLoader } from '../../../../settings/modules/shared/store/storeApi'; | ||
import { loadThemeCSS, setColorsAsCssVariables } from '../../../../shared'; | ||
import { FileChange } from '../../../../shared/events'; | ||
import { WindowManager } from '../../../../shared/schemas/WindowManager'; | ||
import { configureStore } from '@reduxjs/toolkit'; | ||
import { listen as listenGlobal } from '@tauri-apps/api/event'; | ||
|
||
import { RootActions, RootSlice } from './app'; | ||
|
||
import { Reservation, Sizing } from '../../layout/domain'; | ||
import { AddWindowPayload, DesktopId, FocusAction, UIColors } from './domain'; | ||
|
||
export const store = configureStore({ | ||
reducer: RootSlice.reducer, | ||
devTools: true, | ||
}); | ||
|
||
export async function loadStore() { | ||
const userSettings = await new UserSettingsLoader().withLayouts().load(); | ||
const settings = userSettings.jsonSettings.windowManager; | ||
store.dispatch(RootActions.setAvailableLayouts(userSettings.layouts)); | ||
store.dispatch(RootActions.setSettings(settings)); | ||
loadSettingsCSS(settings); | ||
loadThemeCSS(userSettings); | ||
} | ||
|
||
export async function registerStoreEvents() { | ||
await listenGlobal<any>(FileChange.Settings, async () => { | ||
await loadStore(); | ||
}); | ||
|
||
await listenGlobal<AddWindowPayload>('add-window', (event) => { | ||
store.dispatch(RootActions.addWindow(event.payload)); | ||
}); | ||
|
||
await listenGlobal<number>('remove-window', (event) => { | ||
store.dispatch(RootActions.removeWindow(event.payload)); | ||
}); | ||
|
||
await listenGlobal<void>('force-retiling', () => { | ||
store.dispatch(RootActions.forceUpdate()); | ||
}); | ||
|
||
await listenGlobal<DesktopId>('set-active-workspace', (event) => { | ||
store.dispatch(RootActions.setActiveWorkspace(event.payload)); | ||
}); | ||
|
||
await listenGlobal<number>('set-active-window', (event) => { | ||
store.dispatch(RootActions.setActiveWindow(event.payload)); | ||
if (event.payload != 0) { | ||
store.dispatch(RootActions.setLastManagedActivated(event.payload)); | ||
} | ||
}); | ||
|
||
await listenGlobal<Reservation | null>('set-reservation', (event) => { | ||
store.dispatch(RootActions.setReservation(event.payload)); | ||
}); | ||
|
||
await listenGlobal<Sizing>('update-width', (event) => { | ||
store.dispatch(RootActions.updateSizing({ axis: 'x', sizing: event.payload })); | ||
}); | ||
|
||
await listenGlobal<Sizing>('update-height', (event) => { | ||
store.dispatch(RootActions.updateSizing({ axis: 'y', sizing: event.payload })); | ||
}); | ||
|
||
await listenGlobal<void>('reset-workspace-size', () => { | ||
store.dispatch(RootActions.resetSizing()); | ||
}); | ||
|
||
await listenGlobal<FocusAction>('focus', (event) => { | ||
store.dispatch(RootActions.focus(event.payload)); | ||
}); | ||
|
||
await listenGlobal<AddWindowPayload>('update-window', (event) => { | ||
store.dispatch(RootActions.removeWindow(event.payload.hwnd)); | ||
store.dispatch(RootActions.addWindow(event.payload)); | ||
}); | ||
|
||
await listenGlobal<UIColors>('colors', (event) => { | ||
setColorsAsCssVariables(event.payload); | ||
store.dispatch(RootActions.setColors(event.payload)); | ||
}); | ||
|
||
await listenGlobal(FileChange.Themes, async () => { | ||
const userSettings = await new UserSettingsLoader().load(); | ||
loadThemeCSS(userSettings); | ||
}); | ||
|
||
await listenGlobal(FileChange.Placeholders, async () => { | ||
const userSettings = await new UserSettingsLoader().withLayouts().load(); | ||
store.dispatch(RootActions.setAvailableLayouts(userSettings.layouts)); | ||
}); | ||
} | ||
|
||
function loadSettingsCSS(settings: WindowManager) { | ||
const styles = document.documentElement.style; | ||
|
||
styles.setProperty('--config-padding', `${settings.workspacePadding}px`); | ||
styles.setProperty('--config-containers-gap', `${settings.workspaceGap}px`); | ||
|
||
styles.setProperty('--config-margin-top', `${settings.globalWorkAreaOffset.top}px`); | ||
styles.setProperty('--config-margin-left', `${settings.globalWorkAreaOffset.left}px`); | ||
styles.setProperty('--config-margin-right', `${settings.globalWorkAreaOffset.right}px`); | ||
styles.setProperty('--config-margin-bottom', `${settings.globalWorkAreaOffset.bottom}px`); | ||
|
||
styles.setProperty('--config-border-offset', `${settings.border.offset}px`); | ||
styles.setProperty('--config-border-width', `${settings.border.width}px`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,67 @@ | ||
import { StartMenuItem } from '../../../../shared/schemas/SeelenWegItems'; | ||
import { WithContextMenu } from '../../../components/WithContextMenu'; | ||
import { DraggableItem } from './DraggableItem'; | ||
import { getMenuForItem } from './Menu'; | ||
import { invoke } from '@tauri-apps/api/core'; | ||
import { motion } from 'framer-motion'; | ||
import { memo, useEffect, useRef } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { useSelector } from 'react-redux'; | ||
|
||
import { BackgroundByLayersV2 } from '../../../components/BackgroundByLayers/infra'; | ||
|
||
import { Selectors } from '../../shared/store/app'; | ||
|
||
import { RootState } from '../../shared/store/domain'; | ||
|
||
interface Props { | ||
item: StartMenuItem; | ||
} | ||
|
||
const startMenuExes = ['SearchHost.exe', 'StartMenuExperienceHost.exe']; | ||
|
||
export const StartMenu = memo(({ item }: Props) => { | ||
const startMenuOpenRef = useRef(false); | ||
|
||
const size = useSelector(Selectors.settings.size); | ||
|
||
const isStartMenuOpen = useSelector((state: RootState) => | ||
startMenuExes.includes(Selectors.focusedExecutable(state)), | ||
); | ||
|
||
const { t } = useTranslation(); | ||
|
||
useEffect(() => { | ||
if (!isStartMenuOpen) { | ||
setTimeout(() => { | ||
startMenuOpenRef.current = isStartMenuOpen; | ||
}, 100); | ||
} else { | ||
startMenuOpenRef.current = isStartMenuOpen; | ||
} | ||
}, [isStartMenuOpen]); | ||
|
||
return ( | ||
<DraggableItem item={item}> | ||
<WithContextMenu items={getMenuForItem(t, item)}> | ||
<motion.div | ||
className="weg-item" | ||
initial={{ scale: 0 }} | ||
animate={{ scale: 1 }} | ||
style={{ height: size, aspectRatio: '1/1' }} | ||
onClick={() => { | ||
if (!startMenuOpenRef.current) { | ||
invoke('send_keys', { keys: '{win}' }); | ||
} | ||
}} | ||
onContextMenu={(e) => e.stopPropagation()} | ||
> | ||
<BackgroundByLayersV2 prefix="item" /> | ||
<div className="weg-item-icon"> | ||
<div className="weg-item-icon-start" /> | ||
</div> | ||
</motion.div> | ||
</WithContextMenu> | ||
</DraggableItem> | ||
); | ||
}); | ||
import { StartMenuItem } from '../../../../shared/schemas/SeelenWegItems'; | ||
import { WithContextMenu } from '../../../components/WithContextMenu'; | ||
import { DraggableItem } from './DraggableItem'; | ||
import { getMenuForItem } from './Menu'; | ||
import { invoke } from '@tauri-apps/api/core'; | ||
import { motion } from 'framer-motion'; | ||
import { memo, useEffect, useRef } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { useSelector } from 'react-redux'; | ||
|
||
import { BackgroundByLayersV2 } from '../../../components/BackgroundByLayers/infra'; | ||
|
||
import { Selectors } from '../../shared/store/app'; | ||
|
||
import { RootState } from '../../shared/store/domain'; | ||
|
||
interface Props { | ||
item: StartMenuItem; | ||
} | ||
|
||
const startMenuExes = ['SearchHost.exe', 'StartMenuExperienceHost.exe']; | ||
|
||
export const StartMenu = memo(({ item }: Props) => { | ||
const startMenuOpenRef = useRef(false); | ||
|
||
const size = useSelector(Selectors.settings.size); | ||
|
||
const isStartMenuOpen = useSelector((state: RootState) => | ||
startMenuExes.includes(Selectors.focusedApp(state)?.exe || ''), | ||
); | ||
|
||
const { t } = useTranslation(); | ||
|
||
useEffect(() => { | ||
if (!isStartMenuOpen) { | ||
setTimeout(() => { | ||
startMenuOpenRef.current = isStartMenuOpen; | ||
}, 100); | ||
} else { | ||
startMenuOpenRef.current = isStartMenuOpen; | ||
} | ||
}, [isStartMenuOpen]); | ||
|
||
return ( | ||
<DraggableItem item={item}> | ||
<WithContextMenu items={getMenuForItem(t, item)}> | ||
<motion.div | ||
className="weg-item" | ||
initial={{ scale: 0 }} | ||
animate={{ scale: 1 }} | ||
style={{ height: size, aspectRatio: '1/1' }} | ||
onClick={() => { | ||
if (!startMenuOpenRef.current) { | ||
invoke('send_keys', { keys: '{win}' }); | ||
} | ||
}} | ||
onContextMenu={(e) => e.stopPropagation()} | ||
> | ||
<BackgroundByLayersV2 prefix="item" /> | ||
<div className="weg-item-icon"> | ||
<div className="weg-item-icon-start" /> | ||
</div> | ||
</motion.div> | ||
</WithContextMenu> | ||
</DraggableItem> | ||
); | ||
}); |
Oops, something went wrong.