Skip to content

Commit

Permalink
Disable window capture #257
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Jun 17, 2023
1 parent 6de93c1 commit c7eabd8
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
3 changes: 2 additions & 1 deletion core/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
"minHeight": 600,
"maximized": true,
"visible": false,
"theme": "Dark"
"theme": "Dark",
"contentProtected": true
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion interface/components/toggle.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<SwitchLabel class="text-xl">{checked ? "On" : "Off"}</SwitchLabel>

<Switch as="button" {checked} on:click on:change={(event) => (checked = event.detail)} class={({ checked }) => classNames("focus:shadow-outline relative inline-flex h-7 w-12 flex-shrink-0 cursor-pointer rounded-full border-2 border-white transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-4 focus-visible:ring-popup-magenta", checked ? "bg-white" : "bg-transparent")} let:checked>
<span class={classNames("relative top-[4px] left-1 inline-block h-4 w-4 transform rounded-full bg-white transition duration-200 ease-in-out ", checked ? "translate-x-[21px] !bg-black" : "translate-x-0")} />
<span class={classNames("relative left-1 top-[4px] inline-block h-4 w-4 transform rounded-full bg-white transition duration-200 ease-in-out ", checked ? "translate-x-[21px] !bg-black" : "translate-x-0")} />
</Switch>
</SwitchGroup>

Expand Down
3 changes: 3 additions & 0 deletions interface/layout/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ document.addEventListener("contextmenu", (event) => {
event.preventDefault()
})

// Reset window capture
window.appWindow.setContentProtected(true)

// Handle launch options
const launchOptions = async () => {
const args: string[] = await invoke("get_args")
Expand Down
6 changes: 5 additions & 1 deletion interface/windows/settings/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import build from "../../../build.json"
import { path, invoke, os, dialog, app, process, clipboard } from "@tauri-apps/api"
import { path, invoke, os, dialog, app, process, clipboard, window } from "@tauri-apps/api"
import { UAParser } from "ua-parser-js"
import { navigate, open } from "../../utils/navigate"
import { deleteEncryptionKey } from "interface/utils/encryption"
Expand Down Expand Up @@ -74,3 +74,7 @@ export const launchOnStartup = () => {
invoke("enable_auto_launch")
}
}

export const toggleWindowCapture = (windowCapture: boolean) => {
window.appWindow.setContentProtected(windowCapture)
}
14 changes: 13 additions & 1 deletion interface/windows/settings/settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
</div>
</div>

<div class="transparent-800 mb-5 flex w-full flex-row items-center justify-between rounded-xl p-5 text-left">
<div>
<h2>Window capture</h2>
<h3>By default Authme can't be captured by outside programs. If you turn this on it applies until you restart Authme.</h3>
</div>
<div class="ml-20 flex gap-3">
<Toggle bind:checked={windowCapture} on:click={() => toggleWindowCapture(windowCapture)} />
</div>
</div>

<div class="transparent-800 mb-5 flex w-full flex-row items-center justify-between rounded-xl p-5 text-left">
<div>
<h2>Clear data</h2>
Expand Down Expand Up @@ -176,8 +186,10 @@
<script>
import Select from "../../components/select.svelte"
import Toggle from "../../components/toggle.svelte"
import { about, clearData, showLogs, launchOnStartup } from "./index"
import { about, clearData, showLogs, launchOnStartup, toggleWindowCapture } from "./index"
import { settings } from "../../stores/settings"
import { open } from "../../utils/navigate"
import { deleteShortcut, editShortcut, resetShortcut, shortcuts } from "../../utils/shortcuts"
$: windowCapture = false
</script>

0 comments on commit c7eabd8

Please sign in to comment.