Skip to content

Commit 6c9f42b

Browse files
committed
shell/workspace: Store edid in output stack
Matches by edid where present, or by connector name if there is no edid information.
1 parent 443dbc0 commit 6c9f42b

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

src/shell/workspace.rs

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::{
44
element::{AsGlowRenderer, FromGlesError},
55
BackdropShader,
66
},
7+
config::EdidProduct,
78
shell::{
89
layout::{floating::FloatingLayout, tiling::TilingLayout},
910
OverviewMode, ANIMATION_DURATION,
@@ -73,6 +74,25 @@ use super::{
7374

7475
const FULLSCREEN_ANIMATION_DURATION: Duration = Duration::from_millis(200);
7576

77+
#[derive(Debug, Clone, PartialEq, Eq)]
78+
struct OutputMatch {
79+
name: String,
80+
edid: Option<EdidProduct>,
81+
}
82+
83+
impl OutputMatch {
84+
fn for_output(output: &Output) -> Self {
85+
Self {
86+
name: output.name(),
87+
edid: output.edid().cloned(),
88+
}
89+
}
90+
91+
fn matches(&self, output: &Output) -> bool {
92+
self.edid.as_ref() == output.edid() && (self.edid.is_some() || self.name == output.name())
93+
}
94+
}
95+
7696
#[derive(Debug)]
7797
pub struct Workspace {
7898
pub output: Output,
@@ -85,7 +105,7 @@ pub struct Workspace {
85105
pub handle: WorkspaceHandle,
86106
pub focus_stack: FocusStacks,
87107
pub screencopy: ScreencopySessions,
88-
output_stack: VecDeque<String>,
108+
output_stack: VecDeque<OutputMatch>,
89109
pub(super) backdrop_id: Id,
90110
pub dirty: AtomicBool,
91111
}
@@ -241,7 +261,7 @@ impl Workspace {
241261
) -> Workspace {
242262
let tiling_layer = TilingLayout::new(theme.clone(), &output);
243263
let floating_layer = FloatingLayout::new(theme, &output);
244-
let output_name = output.name();
264+
let output_match = OutputMatch::for_output(&output);
245265

246266
Workspace {
247267
output,
@@ -255,7 +275,7 @@ impl Workspace {
255275
screencopy: ScreencopySessions::default(),
256276
output_stack: {
257277
let mut queue = VecDeque::new();
258-
queue.push_back(output_name);
278+
queue.push_back(output_match);
259279
queue
260280
},
261281
backdrop_id: Id::new(),
@@ -383,21 +403,16 @@ impl Workspace {
383403
if explicit {
384404
self.output_stack.clear();
385405
}
386-
let output_name = output.name();
387-
if let Some(pos) = self
388-
.output_stack
389-
.iter()
390-
.position(|name| name == &output_name)
391-
{
406+
if let Some(pos) = self.output_stack.iter().position(|i| i.matches(output)) {
392407
self.output_stack.truncate(pos + 1);
393408
} else {
394-
self.output_stack.push_back(output.name());
409+
self.output_stack.push_back(OutputMatch::for_output(output));
395410
}
396411
self.output = output.clone();
397412
}
398413

399414
pub fn prefers_output(&self, output: &Output) -> bool {
400-
self.output_stack.contains(&output.name())
415+
self.output_stack.iter().any(|i| i.matches(output))
401416
}
402417

403418
pub fn unmap(&mut self, mapped: &CosmicMapped) -> Option<ManagedState> {

0 commit comments

Comments
 (0)