diff --git a/desktop/src/player.rs b/desktop/src/player.rs index 0e5d9ae8dfffb..d01bb0cbfeede 100644 --- a/desktop/src/player.rs +++ b/desktop/src/player.rs @@ -2,6 +2,7 @@ use crate::backends::{ CpalAudioBackend, DesktopExternalInterfaceProvider, DesktopFSCommandProvider, DesktopNavigatorInterface, DesktopUiBackend, }; +use crate::cli::GameModePreference; use crate::custom_event::RuffleEvent; use crate::gui::MovieView; use crate::preferences::GlobalPreferences; @@ -21,6 +22,7 @@ use ruffle_frontend_utils::recents::Recent; use ruffle_render::backend::RenderBackend; use ruffle_render::quality::StageQuality; use ruffle_render_wgpu::backend::WgpuRenderBackend; +use ruffle_render_wgpu::clap::PowerPreference; use ruffle_render_wgpu::descriptors::Descriptors; use std::borrow::Cow; use std::collections::{HashMap, HashSet}; @@ -117,6 +119,9 @@ impl PollRequester for WinitWaker { struct ActivePlayer { player: Arc>, executor: Arc>, + + #[cfg(target_os = "linux")] + _gamemode_session: crate::dbus::GameModeSession, } impl ActivePlayer { @@ -248,6 +253,14 @@ impl ActivePlayer { } } + let gamemode_enable = match preferences.gamemode_preference() { + GameModePreference::Default => { + preferences.graphics_power_preference() == PowerPreference::High + } + GameModePreference::On => true, + GameModePreference::Off => false, + }; + let renderer = WgpuRenderBackend::new(descriptors, movie_view) .map_err(|e| anyhow!(e.to_string())) .expect("Couldn't create wgpu rendering backend"); @@ -377,7 +390,12 @@ impl ActivePlayer { ); } - Self { player, executor } + Self { + player, + executor, + #[cfg(target_os = "linux")] + _gamemode_session: crate::dbus::GameModeSession::new(gamemode_enable), + } } }