|
@@ -175,7 +175,7 @@ struct DispatcherMainThreadContext {
|
|
|
tray_context: TrayContext,
|
|
|
}
|
|
|
|
|
|
-// the main thread context is only used on the main thread
|
|
|
+// SAFETY: we ensure this type is only used on the main thread.
|
|
|
#[allow(clippy::non_send_fields_in_send_ty)]
|
|
|
unsafe impl Send for DispatcherMainThreadContext {}
|
|
|
|
|
@@ -376,6 +376,7 @@ impl From<NativeImage> for NativeImageWrapper {
|
|
|
#[derive(Debug, Clone)]
|
|
|
pub struct GlobalShortcutWrapper(GlobalShortcut);
|
|
|
|
|
|
+// SAFETY: usage outside of main thread is guarded, we use the event loop on such cases.
|
|
|
#[allow(clippy::non_send_fields_in_send_ty)]
|
|
|
unsafe impl Send for GlobalShortcutWrapper {}
|
|
|
|
|
@@ -387,6 +388,10 @@ pub struct GlobalShortcutManagerHandle {
|
|
|
listeners: GlobalShortcutListeners,
|
|
|
}
|
|
|
|
|
|
+// SAFETY: this is safe since the `Context` usage is guarded on `send_user_message`.
|
|
|
+#[allow(clippy::non_send_fields_in_send_ty)]
|
|
|
+unsafe impl Sync for GlobalShortcutManagerHandle {}
|
|
|
+
|
|
|
impl fmt::Debug for GlobalShortcutManagerHandle {
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
f.debug_struct("GlobalShortcutManagerHandle")
|
|
@@ -460,6 +465,10 @@ pub struct ClipboardManagerWrapper {
|
|
|
context: Context,
|
|
|
}
|
|
|
|
|
|
+// SAFETY: this is safe since the `Context` usage is guarded on `send_user_message`.
|
|
|
+#[allow(clippy::non_send_fields_in_send_ty)]
|
|
|
+unsafe impl Sync for ClipboardManagerWrapper {}
|
|
|
+
|
|
|
impl ClipboardManager for ClipboardManagerWrapper {
|
|
|
fn read_text(&self) -> Result<Option<String>> {
|
|
|
let (tx, rx) = channel();
|
|
@@ -695,7 +704,7 @@ pub struct WindowBuilderWrapper {
|
|
|
menu: Option<Menu>,
|
|
|
}
|
|
|
|
|
|
-// safe since `menu_items` are read only here
|
|
|
+// SAFETY: this type is `Send` since `menu_items` are read only here
|
|
|
#[allow(clippy::non_send_fields_in_send_ty)]
|
|
|
unsafe impl Send for WindowBuilderWrapper {}
|
|
|
|
|
@@ -1053,6 +1062,10 @@ pub struct WryDispatcher {
|
|
|
context: Context,
|
|
|
}
|
|
|
|
|
|
+// SAFETY: this is safe since the `Context` usage is guarded on `send_user_message`.
|
|
|
+#[allow(clippy::non_send_fields_in_send_ty)]
|
|
|
+unsafe impl Sync for WryDispatcher {}
|
|
|
+
|
|
|
impl Dispatch for WryDispatcher {
|
|
|
type Runtime = Wry;
|
|
|
type WindowBuilder = WindowBuilderWrapper;
|
|
@@ -1486,6 +1499,10 @@ pub struct WryHandle {
|
|
|
context: Context,
|
|
|
}
|
|
|
|
|
|
+// SAFETY: this is safe since the `Context` usage is guarded on `send_user_message`.
|
|
|
+#[allow(clippy::non_send_fields_in_send_ty)]
|
|
|
+unsafe impl Sync for WryHandle {}
|
|
|
+
|
|
|
impl WryHandle {
|
|
|
/// Creates a new tao window using a callback, and returns its window id.
|
|
|
pub fn create_tao_window<F: FnOnce() -> (String, WryWindowBuilder) + Send + 'static>(
|