1
0
Fork 0
forked from wry/wry

control-center: handle outputs without unique names

This commit is contained in:
Julian Orth 2026-03-18 12:54:03 +01:00
parent cf36da4077
commit 0cb887c4b5

View file

@ -25,9 +25,10 @@ use {
},
ahash::AHashMap,
egui::{
Align, Button, Checkbox, Color32, ComboBox, DragValue, EventFilter, FontId, Frame, Grid,
Id, Key, Layout, PointerButton, Rect, ScrollArea, Sense, Shadow, Stroke, StrokeKind, Style,
TextFormat, Ui, UiBuilder, Vec2, Widget, WidgetText, emath, pos2, text::LayoutJob, vec2,
Align, Button, Checkbox, CollapsingHeader, Color32, ComboBox, DragValue, EventFilter,
FontId, Frame, Grid, Id, Key, Layout, PointerButton, Rect, ScrollArea, Sense, Shadow,
Stroke, StrokeKind, Style, TextFormat, Ui, UiBuilder, Vec2, Widget, WidgetText, emath,
pos2, text::LayoutJob, vec2,
},
egui_tiles::{
Behavior, Container, Linear, LinearDir, ResizeState, SimplificationOptions, Tile, TileId,
@ -68,6 +69,7 @@ enum Pane {
struct CompleteHead {
id: ConnectorId,
name: HeadName,
pretty_name: Rc<String>,
live_state: ReadOnlyHeadState,
changed_state: Option<HeadState>,
z: u64,
@ -123,9 +125,9 @@ pub enum View {
#[derive(Error, Debug)]
enum HeadTransactionError {
#[error("The connector {} has been removed", .0)]
HeadRemoved(ConnectorId),
HeadRemoved(Rc<String>),
#[error("The display connected to connector {} has changed", .0)]
MonitorChanged(ConnectorId),
MonitorChanged(Rc<String>),
#[error(transparent)]
Backend(#[from] BackendConnectorTransactionError),
}
@ -811,10 +813,12 @@ impl OutputsPaneInner {
continue;
};
let Some(connector) = self.state.connectors.get(&head.id) else {
return Err(HeadTransactionError::HeadRemoved(head.id));
return Err(HeadTransactionError::HeadRemoved(head.pretty_name.clone()));
};
if head.live_state.borrow().monitor_info != desired.monitor_info {
return Err(HeadTransactionError::MonitorChanged(head.id));
return Err(HeadTransactionError::MonitorChanged(
head.pretty_name.clone(),
));
}
let old = connector.state.borrow().clone();
let mut new = old.clone();
@ -894,6 +898,7 @@ impl OutputsPaneInner {
self.heads.entry(mgrs.name).or_insert_with(|| CompleteHead {
id: connector.id,
name: mgrs.name,
pretty_name: connector.name.clone(),
live_state: mgrs.state(),
changed_state: None,
z: 0,
@ -946,7 +951,9 @@ fn show_connector(state: &State, settings: &Settings, head: &mut CompleteHead, u
..Default::default()
},
);
ui.collapsing(layout_job, |ui| {
CollapsingHeader::new(layout_job)
.id_salt(("connector", head.name))
.show(ui, |ui| {
grid(ui, ("settings", head.name), |ui| {
let mut diff = false;
show_serial_number(ui, m);