Skip to content

Commit 79a6501

Browse files
danieldgvberger
authored andcommitted
output: batch output update notifications based on Done
1 parent e8aab6c commit 79a6501

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Unreleased
44

5+
- Batch output information updates instead of potentially making multiple
6+
callbacks for one logical change
7+
58
#### Additions
69

710
- `Window::start_interactive_move` to enable dragging the window with a user action

src/output.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,17 @@ fn process_output_event(
186186
.expect("SCTK: wl_output has invalid UserData");
187187
let mut udata = udata_mutex.lock().unwrap();
188188
if let Event::Done = event {
189-
let (id, pending_events, mut callbacks) =
190-
if let OutputData::Pending { id, events: ref mut v, callbacks: ref mut cb } = *udata {
189+
let (id, pending_events, mut callbacks) = match *udata {
190+
OutputData::Pending { id, events: ref mut v, callbacks: ref mut cb } => {
191191
(id, std::mem::replace(v, vec![]), std::mem::replace(cb, vec![]))
192-
} else {
193-
// a Done event on an output that is already ready => nothing to do
192+
}
193+
OutputData::Ready { ref mut info, ref mut callbacks } => {
194+
// a Done event on an output that is already ready was due to a
195+
// status change (which was already merged)
196+
notify(&output, info, ddata, callbacks);
194197
return;
195-
};
198+
}
199+
};
196200
let mut info = OutputInfo::new(id);
197201
for evt in pending_events {
198202
merge_event(&mut info, evt);
@@ -203,9 +207,8 @@ fn process_output_event(
203207
} else {
204208
match *udata {
205209
OutputData::Pending { events: ref mut v, .. } => v.push(event),
206-
OutputData::Ready { ref mut info, ref mut callbacks } => {
210+
OutputData::Ready { ref mut info, .. } => {
207211
merge_event(info, event);
208-
notify(&output, info, ddata, callbacks);
209212
}
210213
}
211214
}

0 commit comments

Comments
 (0)