Skip to content

Commit

Permalink
Merge pull request #217 from ItsEeleeya/next-windows
Browse files Browse the repository at this point in the history
Minor fixes for Windows
  • Loading branch information
richiemcilroy authored Dec 31, 2024
2 parents 10f2e31 + e77818f commit 4d20afd
Show file tree
Hide file tree
Showing 14 changed files with 506 additions and 310 deletions.
5 changes: 1 addition & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,4 @@ The video segments are stored in your app data directory, under the folder `so.c

### Notes for development on Windows:

<!-- TODO: Update instructions once setupSidecar handles this -->

Required dlls: `avutil`, `avformat`, `avcodec`, `avdevice`.
Put the full version of ffmpeg for the target arch into `target/binaries`.
Requirements: llvm, clang and VCPKG are required for compiling ffmpeg-sys.
70 changes: 45 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@cap/desktop",
"type": "module",
"scripts": {
"dev": "RUST_BACKTRACE=1 dotenv -e ../../.env -- pnpm run preparescript && tauri dev",
"dev": "cross-env RUST_BACKTRACE=1 dotenv -e ../../.env -- pnpm run preparescript && tauri dev",
"build:tauri": "dotenv -e ../../.env -- pnpm run preparescript && tauri build",
"preparescript": "node scripts/prepare.js",
"localdev": "dotenv -e ../../.env -- vinxi dev --port 3001",
Expand Down Expand Up @@ -64,6 +64,7 @@
"@tauri-apps/cli": ">=2.1.0",
"@total-typescript/ts-reset": "^0.6.1",
"@types/dom-webcodecs": "^0.1.11",
"cross-env": "^7.0.3",
"typescript": "^5.7.2",
"vite": "^5.4.3",
"vite-tsconfig-paths": "^5.0.1"
Expand Down
19 changes: 10 additions & 9 deletions apps/desktop/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,19 @@ tauri = { workspace = true, features = [
] }
tauri-specta = { version = "=2.0.0-rc.20", features = ["derive", "typescript"] }
tauri-plugin-dialog = "2.0.0"
tauri-plugin-fs = "2.0.0-rc.0"
tauri-plugin-global-shortcut = "2.0.1"
tauri-plugin-http = "2.0.4"
tauri-plugin-notification = "2.0.1"
tauri-plugin-os = "2.0.0"
tauri-plugin-fs = "2.2.0"
tauri-plugin-global-shortcut = "2.1.0"
tauri-plugin-http = "2.1.0"
tauri-plugin-notification = "2.1.0"
tauri-plugin-os = "2.1.0"
tauri-plugin-process = "2.0.1"
tauri-plugin-shell = "2.0.0"
tauri-plugin-shell = "2.1.0"
tauri-plugin-single-instance = "2.0.1"
tauri-plugin-store = "2.0.0"
tauri-plugin-updater = "2.1.0"
tauri-plugin-store = "2.2.0"
tauri-plugin-updater = "2.2.0"
tauri-plugin-oauth = { git = "https://github.com/FabianLars/tauri-plugin-oauth", branch = "v2" }
tauri-plugin-window-state = "2.0.2"
tauri-plugin-window-state = "2.2.0"
tauri-plugin-positioner = "2.2.0"

serde = { version = "1", features = ["derive"] }
serde_json = "1"
Expand Down
80 changes: 42 additions & 38 deletions apps/desktop/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1896,21 +1896,8 @@ pub async fn run() {

#[cfg(target_os = "macos")]
{
builder = builder.plugin(tauri_nspanel::init());
}

builder
.plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_store::Builder::new().build())
.plugin(tauri_plugin_os::init())
.plugin(tauri_plugin_process::init())
.plugin(tauri_plugin_oauth::init())
.plugin(tauri_plugin_http::init())
.plugin(tauri_plugin_updater::Builder::new().build())
.plugin(tauri_plugin_notification::init())
.plugin(tauri_plugin_deep_link::init())
.plugin(
builder = builder.plugin(tauri_nspanel::init()).plugin(
// TODO(Ilya): Also enable for Windows when Tao is updated to `0.31.0`
tauri_plugin_window_state::Builder::new()
.with_state_flags({
use tauri_plugin_window_state::StateFlags;
Expand All @@ -1930,8 +1917,21 @@ pub async fn run() {
_ => label,
})
.build(),
)
);
}

builder
.plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_store::Builder::new().build())
.plugin(tauri_plugin_os::init())
.plugin(tauri_plugin_process::init())
.plugin(tauri_plugin_oauth::init())
.plugin(tauri_plugin_http::init())
.plugin(tauri_plugin_updater::Builder::new().build())
.plugin(tauri_plugin_notification::init())
.plugin(flags::plugin::init())
.plugin(tauri_plugin_deep_link::init())
.invoke_handler({
let handler = specta_builder.invoke_handler();

Expand Down Expand Up @@ -2091,25 +2091,27 @@ pub async fn run() {

match event {
WindowEvent::Destroyed => {
match CapWindowId::from_str(label).unwrap() {
CapWindowId::Main => {
if let Some(w) = CapWindowId::Camera.get(app) {
w.close().ok();
if let Ok(window_id) = CapWindowId::from_str(label) {
match window_id {
CapWindowId::Main => {
if let Some(w) = CapWindowId::Camera.get(app) {
w.close().ok();
}
}
}
CapWindowId::Editor { project_id } => {
let app_handle = app.clone();
tokio::spawn(async move {
let _ = remove_editor_instance(&app_handle, project_id).await;
tokio::task::yield_now().await;
});
}
CapWindowId::Settings | CapWindowId::Upgrade => {
// Don't quit the app when settings or upgrade window is closed
return;
}
_ => {}
};
CapWindowId::Editor { project_id } => {
let app_handle = app.clone();
tokio::spawn(async move {
let _ = remove_editor_instance(&app_handle, project_id).await;
tokio::task::yield_now().await;
});
}
CapWindowId::Settings | CapWindowId::Upgrade => {
// Don't quit the app when settings or upgrade window is closed
return;
}
_ => {}
};
}

if let Some(settings) = GeneralSettingsStore::get(app).unwrap_or(None) {
if settings.hide_dock_icon
Expand All @@ -2123,11 +2125,13 @@ pub async fn run() {
}
}
}
#[cfg(target_os = "macos")]
WindowEvent::Focused(focused) if *focused => {
if CapWindowId::from_str(label).unwrap().activates_dock() {
#[cfg(target_os = "macos")]
app.set_activation_policy(tauri::ActivationPolicy::Regular)
.ok();
if let Ok(window_id) = CapWindowId::from_str(label) {
if window_id.activates_dock() {
app.set_activation_policy(tauri::ActivationPolicy::Regular)
.ok();
}
}
}
_ => {}
Expand Down
Loading

1 comment on commit 4d20afd

@vercel
Copy link

@vercel vercel bot commented on 4d20afd Dec 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.