Skip to content

Commit 9b242e4

Browse files
mewi99FabianLars
andauthored
fix: BSD support in tauri-runtime (#14700)
Co-authored-by: Fabian-Lars <github@fabianlars.de>
1 parent 1dbf6fd commit 9b242e4

4 files changed

Lines changed: 63 additions & 7 deletions

File tree

.changes/runtime-bsd.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
tauri-runtime: patch:bug
3+
tauri-runtime-wry: patch:bug
4+
---
5+
6+
Fix compilation errors when targeting BSD.

crates/tauri-runtime-wry/src/lib.rs

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ use tauri_runtime::{
3737
use objc2::rc::Retained;
3838
#[cfg(target_os = "macos")]
3939
use tao::platform::macos::{EventLoopWindowTargetExtMacOS, WindowBuilderExtMacOS};
40-
#[cfg(target_os = "linux")]
40+
#[cfg(any(
41+
target_os = "linux",
42+
target_os = "dragonfly",
43+
target_os = "freebsd",
44+
target_os = "netbsd",
45+
target_os = "openbsd"
46+
))]
4147
use tao::platform::unix::{WindowBuilderExtUnix, WindowExtUnix};
4248
#[cfg(windows)]
4349
use tao::platform::windows::{WindowBuilderExtWindows, WindowExtWindows};
@@ -862,7 +868,13 @@ impl WindowBuilder for WindowBuilderWrapper {
862868
");
863869
}
864870

865-
#[cfg(target_os = "linux")]
871+
#[cfg(any(
872+
target_os = "linux",
873+
target_os = "dragonfly",
874+
target_os = "freebsd",
875+
target_os = "netbsd",
876+
target_os = "openbsd"
877+
))]
866878
{
867879
// Mouse event is disabled on Linux since sudden event bursts could block event loop.
868880
window.inner = window.inner.with_cursor_moved_event(false);
@@ -1194,7 +1206,14 @@ impl WindowBuilder for WindowBuilderWrapper {
11941206
self
11951207
}
11961208

1197-
#[cfg(any(windows, target_os = "linux"))]
1209+
#[cfg(any(
1210+
windows,
1211+
target_os = "linux",
1212+
target_os = "dragonfly",
1213+
target_os = "freebsd",
1214+
target_os = "netbsd",
1215+
target_os = "openbsd"
1216+
))]
11981217
fn skip_taskbar(mut self, skip: bool) -> Self {
11991218
self.inner = self.inner.with_skip_taskbar(skip);
12001219
self
@@ -3417,7 +3436,14 @@ fn handle_user_message<T: UserEvent>(
34173436
}
34183437
#[allow(unused_variables)]
34193438
WindowMessage::SetSkipTaskbar(skip) => {
3420-
#[cfg(any(windows, target_os = "linux"))]
3439+
#[cfg(any(
3440+
windows,
3441+
target_os = "linux",
3442+
target_os = "dragonfly",
3443+
target_os = "freebsd",
3444+
target_os = "netbsd",
3445+
target_os = "openbsd"
3446+
))]
34213447
let _ = window.set_skip_taskbar(skip);
34223448
}
34233449
WindowMessage::SetCursorGrab(grab) => {

crates/tauri-runtime/src/lib.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,25 @@ pub trait Runtime<T: UserEvent>: Debug + Sized + 'static {
399399
fn new(args: RuntimeInitArgs) -> Result<Self>;
400400

401401
/// Creates a new webview runtime on any thread.
402-
#[cfg(any(windows, target_os = "linux"))]
403-
#[cfg_attr(docsrs, doc(cfg(any(windows, target_os = "linux"))))]
402+
#[cfg(any(
403+
windows,
404+
target_os = "linux",
405+
target_os = "dragonfly",
406+
target_os = "freebsd",
407+
target_os = "netbsd",
408+
target_os = "openbsd"
409+
))]
410+
#[cfg_attr(
411+
docsrs,
412+
doc(cfg(any(
413+
windows,
414+
target_os = "linux",
415+
target_os = "dragonfly",
416+
target_os = "freebsd",
417+
target_os = "netbsd",
418+
target_os = "openbsd"
419+
)))
420+
)]
404421
fn new_any_thread(args: RuntimeInitArgs) -> Result<Self>;
405422

406423
/// Creates an `EventLoopProxy` that can be used to dispatch user events to the main event loop.

crates/tauri/src/test/mock_runtime.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,14 @@ impl<T: UserEvent> Runtime<T> for MockRuntime {
11461146
Ok(Self::init())
11471147
}
11481148

1149-
#[cfg(any(windows, target_os = "linux"))]
1149+
#[cfg(any(
1150+
windows,
1151+
target_os = "linux",
1152+
target_os = "dragonfly",
1153+
target_os = "freebsd",
1154+
target_os = "netbsd",
1155+
target_os = "openbsd"
1156+
))]
11501157
fn new_any_thread(_args: RuntimeInitArgs) -> Result<Self> {
11511158
Ok(Self::init())
11521159
}

0 commit comments

Comments
 (0)