dekstop: Support `quit` and `fullscreen` fscommands
This commit is contained in:
parent
66c6c176f0
commit
d3b9d8a451
|
@ -1,11 +1,13 @@
|
||||||
mod audio;
|
mod audio;
|
||||||
mod external_interface;
|
mod external_interface;
|
||||||
|
mod fscommand;
|
||||||
mod navigator;
|
mod navigator;
|
||||||
mod storage;
|
mod storage;
|
||||||
mod ui;
|
mod ui;
|
||||||
|
|
||||||
pub use audio::CpalAudioBackend;
|
pub use audio::CpalAudioBackend;
|
||||||
pub use external_interface::DesktopExternalInterfaceProvider;
|
pub use external_interface::DesktopExternalInterfaceProvider;
|
||||||
|
pub use fscommand::DesktopFSCommandProvider;
|
||||||
pub use navigator::ExternalNavigatorBackend;
|
pub use navigator::ExternalNavigatorBackend;
|
||||||
pub use storage::DiskStorageBackend;
|
pub use storage::DiskStorageBackend;
|
||||||
pub use ui::DesktopUiBackend;
|
pub use ui::DesktopUiBackend;
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
use crate::custom_event::RuffleEvent;
|
||||||
|
|
||||||
|
use ruffle_core::external::FsCommandProvider;
|
||||||
|
use std::rc::Rc;
|
||||||
|
use winit::event_loop::EventLoopProxy;
|
||||||
|
use winit::window::{Fullscreen, Window};
|
||||||
|
|
||||||
|
pub struct DesktopFSCommandProvider {
|
||||||
|
pub event_loop: EventLoopProxy<RuffleEvent>,
|
||||||
|
pub window: Rc<Window>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FsCommandProvider for DesktopFSCommandProvider {
|
||||||
|
fn on_fs_command(&self, command: &str, args: &str) -> bool {
|
||||||
|
match command {
|
||||||
|
"quit" => {
|
||||||
|
let _ = self.event_loop.send_event(RuffleEvent::ExitRequested);
|
||||||
|
}
|
||||||
|
"fullscreen" => {
|
||||||
|
match args {
|
||||||
|
"true" => self
|
||||||
|
.window
|
||||||
|
.set_fullscreen(Some(Fullscreen::Borderless(None))),
|
||||||
|
"false" => self.window.set_fullscreen(None),
|
||||||
|
_ => {}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
_ => return false,
|
||||||
|
};
|
||||||
|
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::backends::{
|
use crate::backends::{
|
||||||
CpalAudioBackend, DesktopExternalInterfaceProvider, DesktopUiBackend, DiskStorageBackend,
|
CpalAudioBackend, DesktopExternalInterfaceProvider, DesktopFSCommandProvider, DesktopUiBackend,
|
||||||
ExternalNavigatorBackend,
|
DiskStorageBackend, ExternalNavigatorBackend,
|
||||||
};
|
};
|
||||||
use crate::cli::Opt;
|
use crate::cli::Opt;
|
||||||
use crate::custom_event::RuffleEvent;
|
use crate::custom_event::RuffleEvent;
|
||||||
|
@ -143,6 +143,10 @@ impl ActivePlayer {
|
||||||
.with_navigator(navigator)
|
.with_navigator(navigator)
|
||||||
.with_renderer(renderer)
|
.with_renderer(renderer)
|
||||||
.with_storage(DiskStorageBackend::new().expect("Couldn't create storage backend"))
|
.with_storage(DiskStorageBackend::new().expect("Couldn't create storage backend"))
|
||||||
|
.with_fs_commands(Box::new(DesktopFSCommandProvider {
|
||||||
|
event_loop: event_loop.clone(),
|
||||||
|
window: window.clone(),
|
||||||
|
}))
|
||||||
.with_ui(
|
.with_ui(
|
||||||
DesktopUiBackend::new(window.clone(), opt.open_url_mode)
|
DesktopUiBackend::new(window.clone(), opt.open_url_mode)
|
||||||
.expect("Couldn't create ui backend"),
|
.expect("Couldn't create ui backend"),
|
||||||
|
|
Loading…
Reference in New Issue