This repository has been archived by the owner on Sep 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from ptazithos/feature/per-window-configuration
feature/per-window-configuration
- Loading branch information
Showing
22 changed files
with
399 additions
and
157 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
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
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
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { invoke } from "@tauri-apps/api"; | ||
import { | ||
type FocusChangedPayload, | ||
subscribeFocusChanged, | ||
} from "../../ipc/subscribe"; | ||
import { useEffect } from "react"; | ||
import type { AppConfig } from "../../native"; | ||
import { getWindows } from "../../ipc/command"; | ||
import { getWindowInfo } from "../../native"; | ||
import type { Optional } from "../../utils"; | ||
|
||
const FocusService = (props: { config: AppConfig }) => { | ||
const focusedRules = props.config.focusedWindowsRules; | ||
const unfocusedRules = props.config.unfocusedWindowsRules; | ||
|
||
useEffect(() => { | ||
const setWindowStyle = async (payload: Optional<FocusChangedPayload>) => { | ||
const focused = payload?.data?.focusedContainer?.handle; | ||
|
||
const windows = await getWindows(); | ||
for (const window of windows) { | ||
const hwnd = window?.handle; | ||
if (hwnd) { | ||
if (hwnd === focused) { | ||
const info = await getWindowInfo(hwnd); | ||
for (const rule of focusedRules) { | ||
rule.apply(info); | ||
} | ||
} else { | ||
const info = await getWindowInfo(hwnd); | ||
for (const rule of unfocusedRules) { | ||
rule.apply(info); | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
|
||
setWindowStyle({}); | ||
|
||
const handle = subscribeFocusChanged(setWindowStyle); | ||
|
||
return () => { | ||
handle.close(); | ||
}; | ||
}, [focusedRules, unfocusedRules]); | ||
|
||
return <></>; | ||
}; | ||
|
||
export default FocusService; |
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { useEffect } from "react"; | ||
import { getWindowInfo, type AppConfig } from "../../native"; | ||
import { getWindows } from "../../ipc/command"; | ||
import { subscribeWindowManaged } from "../../ipc/subscribe"; | ||
|
||
const ManageService = (props: { config: AppConfig }) => { | ||
const rules = props.config.windowRules; | ||
|
||
useEffect(() => { | ||
const setWindowsTitleBar = async () => { | ||
const windows = await getWindows(); | ||
for (const window of windows) { | ||
if (!window?.handle) continue; | ||
const info = await getWindowInfo(window.handle); | ||
for (const rule of rules) { | ||
rule.apply(info); | ||
} | ||
} | ||
}; | ||
|
||
setWindowsTitleBar(); | ||
|
||
const handle = subscribeWindowManaged(async (payload) => { | ||
setTimeout(async () => { | ||
const hwnd = payload?.data?.managedWindow?.handle; | ||
if (hwnd) { | ||
const info = await getWindowInfo(hwnd); | ||
for (const rule of rules) { | ||
rule.apply(info); | ||
} | ||
} | ||
}, 200); | ||
}); | ||
|
||
return () => { | ||
handle.close(); | ||
}; | ||
}, [rules]); | ||
|
||
return <></>; | ||
}; | ||
|
||
export default ManageService; |
Oops, something went wrong.