forked from akanyan/STARTLINER
feat: add dont_switch_primary
This commit is contained in:
@ -75,6 +75,12 @@ pub struct Display {
|
||||
pub rotation: i32,
|
||||
pub frequency: i32,
|
||||
pub borderless_fullscreen: bool,
|
||||
|
||||
#[serde(default)]
|
||||
pub dont_switch_primary: bool,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub monitor_index_override: Option<i32>,
|
||||
}
|
||||
|
||||
impl Display {
|
||||
@ -92,6 +98,8 @@ impl Display {
|
||||
Game::Ongeki => 60,
|
||||
},
|
||||
borderless_fullscreen: true,
|
||||
dont_switch_primary: false,
|
||||
monitor_index_override: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
use crate::model::profile::{Display, DisplayMode};
|
||||
use anyhow::Result;
|
||||
use displayz::{query_displays, DisplaySet};
|
||||
@ -7,14 +6,14 @@ use tauri::{AppHandle, Listener};
|
||||
#[derive(Clone)]
|
||||
pub struct DisplayInfo {
|
||||
pub primary: String,
|
||||
pub set: Option<DisplaySet>
|
||||
pub set: Option<DisplaySet>,
|
||||
}
|
||||
|
||||
impl Default for DisplayInfo {
|
||||
fn default() -> Self {
|
||||
DisplayInfo {
|
||||
primary: "default".to_owned(),
|
||||
set: query_displays().ok()
|
||||
set: query_displays().ok(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -52,14 +51,16 @@ impl Display {
|
||||
.find(|display| display.name() == self.target)
|
||||
.ok_or_else(|| anyhow!("Display {} not found", self.target))?;
|
||||
|
||||
target.set_primary()?;
|
||||
if !self.dont_switch_primary {
|
||||
target.set_primary()?;
|
||||
}
|
||||
let settings = target.settings()
|
||||
.as_ref()
|
||||
.ok_or_else(|| anyhow!("Unable to query display settings"))?;
|
||||
|
||||
let res = DisplayInfo {
|
||||
primary: primary.name().to_owned(),
|
||||
set: Some(display_set.clone())
|
||||
set: Some(display_set.clone()),
|
||||
};
|
||||
|
||||
if self.rotation == 90 || self.rotation == 270 {
|
||||
|
@ -266,8 +266,12 @@ impl Profile {
|
||||
.arg(self.meta.game.exe());
|
||||
|
||||
if let Some(display) = &self.data.display {
|
||||
if display.dont_switch_primary && display.target != "default" {
|
||||
game_builder.args(["-monitor", &display.monitor_index_override.unwrap_or_else(|| 1).to_string()]);
|
||||
} else {
|
||||
game_builder.args(["-monitor", "1"]);
|
||||
}
|
||||
game_builder.args([
|
||||
"-monitor 1",
|
||||
"-screen-width", &display.rez.0.to_string(),
|
||||
"-screen-height", &display.rez.1.to_string(),
|
||||
"-screen-fullscreen", if display.mode == DisplayMode::Fullscreen { "1" } else { "0" }
|
||||
|
@ -8,6 +8,7 @@ const category = getCurrentInstance()?.parent?.parent?.parent?.parent; // yes in
|
||||
const props = defineProps({
|
||||
title: String,
|
||||
tooltip: String,
|
||||
dangerousTooltip: String,
|
||||
});
|
||||
|
||||
const searched = computed(() => {
|
||||
@ -32,6 +33,11 @@ const searched = computed(() => {
|
||||
class="pi pi-question-circle ml-2"
|
||||
v-tooltip="tooltip"
|
||||
></span>
|
||||
<span
|
||||
v-if="dangerousTooltip"
|
||||
class="pi pi-exclamation-circle ml-2 text-red-500"
|
||||
v-tooltip="dangerousTooltip"
|
||||
></span>
|
||||
</div>
|
||||
|
||||
<slot />
|
||||
|
@ -157,5 +157,40 @@ loadDisplays();
|
||||
v-model="prf.current!.data.display.borderless_fullscreen"
|
||||
/>
|
||||
</OptionRow>
|
||||
<OptionRow
|
||||
title="Skip switching primary display"
|
||||
v-if="
|
||||
capabilities.includes('display') &&
|
||||
prf.current?.data.display.target !== 'default' &&
|
||||
(prf.current!.data.display.dont_switch_primary ||
|
||||
displayList.length > 2)
|
||||
"
|
||||
dangerous-tooltip="Only enable this option if switching the primary display causes issues. The monitors must have a matching refresh rate."
|
||||
>
|
||||
<ToggleSwitch
|
||||
:disabled="extraDisplayOptionsDisabled"
|
||||
v-model="prf.current!.data.display.dont_switch_primary"
|
||||
/>
|
||||
</OptionRow>
|
||||
<OptionRow
|
||||
title="Unity display index"
|
||||
class="number-input"
|
||||
v-if="
|
||||
capabilities.includes('display') &&
|
||||
prf.current?.data.display.target !== 'default' &&
|
||||
prf.current!.data.display.dont_switch_primary
|
||||
"
|
||||
>
|
||||
<InputNumber
|
||||
class="shrink"
|
||||
size="small"
|
||||
:min="1"
|
||||
:max="32"
|
||||
:use-grouping="false"
|
||||
v-model="prf.current!.data.display.monitor_index_override"
|
||||
:disabled="extraDisplayOptionsDisabled"
|
||||
:allow-empty="true"
|
||||
/>
|
||||
</OptionRow>
|
||||
</OptionCategory>
|
||||
</template>
|
||||
|
@ -78,6 +78,8 @@ export interface DisplayConfig {
|
||||
rotation: number;
|
||||
frequency: number;
|
||||
borderless_fullscreen: boolean;
|
||||
dont_switch_primary: boolean;
|
||||
monitor_index_override: number | null;
|
||||
}
|
||||
|
||||
export interface NetworkConfig {
|
||||
|
Reference in New Issue
Block a user