desktop: Remove Windows workaround for picking files
See https://github.com/rust-windowing/winit/issues/2291#issuecomment-2277033786
This commit is contained in:
parent
8755dd95cc
commit
4918596f71
|
@ -514,7 +514,7 @@ impl App {
|
|||
}
|
||||
|
||||
winit::event::Event::UserEvent(RuffleEvent::BrowseAndOpen(options)) => {
|
||||
if let Some(url) = pick_file(false, None, Some(self.window.clone()))
|
||||
if let Some(url) = pick_file(None, Some(&self.window))
|
||||
.and_then(|p| Url::from_file_path(p).ok())
|
||||
{
|
||||
self.gui
|
||||
|
|
|
@ -64,7 +64,7 @@ impl PathOrUrlField {
|
|||
path
|
||||
});
|
||||
|
||||
if let Some(path) = pick_file(true, dir, self.window.upgrade()) {
|
||||
if let Some(path) = pick_file(dir, self.window.upgrade().as_ref()) {
|
||||
let mut value_lock = Self::lock_value(&self.value);
|
||||
*value_lock = path.to_string_lossy().to_string();
|
||||
}
|
||||
|
|
|
@ -4,14 +4,12 @@ use gilrs::Button;
|
|||
use rfd::FileDialog;
|
||||
use ruffle_core::events::{GamepadButton, KeyCode, TextControlCode};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
use url::Url;
|
||||
use wgpu::rwh::{HasDisplayHandle, HasWindowHandle};
|
||||
use winit::dpi::PhysicalSize;
|
||||
use winit::event::{KeyEvent, Modifiers};
|
||||
use winit::event_loop::EventLoop;
|
||||
use winit::keyboard::{Key, KeyLocation, NamedKey};
|
||||
use winit::window::Window;
|
||||
|
||||
/// Converts a winit event to a Ruffle `TextControlCode`.
|
||||
/// Returns `None` if there is no match.
|
||||
|
@ -247,7 +245,7 @@ pub fn parse_url(path: &Path) -> Result<Url, Error> {
|
|||
}
|
||||
}
|
||||
|
||||
fn actually_pick_file<W: HasWindowHandle + HasDisplayHandle>(
|
||||
pub fn pick_file<W: HasWindowHandle + HasDisplayHandle>(
|
||||
dir: Option<PathBuf>,
|
||||
parent: Option<&W>,
|
||||
) -> Option<PathBuf> {
|
||||
|
@ -267,34 +265,6 @@ fn actually_pick_file<W: HasWindowHandle + HasDisplayHandle>(
|
|||
dialog.pick_file()
|
||||
}
|
||||
|
||||
// [NA] Horrible hacky workaround for https://github.com/rust-windowing/winit/issues/2291
|
||||
// We only need the workaround from within UI code, not when executing custom events
|
||||
// The workaround causes Ruffle to show as "not responding" on windows, so we don't use it if we don't need to
|
||||
#[cfg(windows)]
|
||||
pub fn pick_file(
|
||||
in_ui: bool,
|
||||
path: Option<PathBuf>,
|
||||
parent: Option<Arc<Window>>,
|
||||
) -> Option<PathBuf> {
|
||||
if in_ui {
|
||||
std::thread::spawn(move || actually_pick_file(path, parent.as_ref()))
|
||||
.join()
|
||||
.ok()
|
||||
.flatten()
|
||||
} else {
|
||||
actually_pick_file(path, parent.as_ref())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
pub fn pick_file(
|
||||
_in_ui: bool,
|
||||
path: Option<PathBuf>,
|
||||
parent: Option<Arc<Window>>,
|
||||
) -> Option<PathBuf> {
|
||||
actually_pick_file(path, parent.as_ref())
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "tracy"))]
|
||||
pub fn plot_stats_in_tracy(_instance: &wgpu::Instance) {}
|
||||
|
||||
|
|
Loading…
Reference in New Issue