Skip to content

Commit

Permalink
desktop: Use gamemode when enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
kjarosh committed Sep 15, 2024
1 parent ddbd290 commit fcc490b
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion desktop/src/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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};
Expand Down Expand Up @@ -117,6 +119,9 @@ impl PollRequester for WinitWaker {
struct ActivePlayer {
player: Arc<Mutex<Player>>,
executor: Arc<AsyncExecutor<WinitWaker>>,

#[cfg(target_os = "linux")]
_gamemode_session: crate::dbus::GameModeSession,
}

impl ActivePlayer {
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -377,7 +390,12 @@ impl ActivePlayer {
);
}

Self { player, executor }
Self {
player,
executor,
#[cfg(target_os = "linux")]
_gamemode_session: crate::dbus::GameModeSession::new(gamemode_enable),
}
}
}

Expand Down

0 comments on commit fcc490b

Please sign in to comment.