Handle removed wl_outputs (#719)

* Move the event managent to the closure

In preparation of more events not relating to the SeatManager being
captured.

* Handle wl_output remove events

In some cases, wl_outputs can be removed without the compositor
notifying the surfaces using leave/enter events. This breaks the DPI and
resize stuff since the windows' list of monitors were not updated.

Now, wl_output removals are handled and windows are updated accordingly.

* Add changelog entry for disappearing wl_outputs

* Clearer changelog message for wl_output removal changes
This commit is contained in:
Andreas Johansson 2018-11-20 21:21:58 +01:00 committed by Francesca Plebani
parent 04ca2cf9f4
commit 92873b06ed
3 changed files with 66 additions and 40 deletions

View file

@ -148,6 +148,7 @@ impl Window {
frame: Arc::downgrade(&frame),
current_dpi: 1,
new_dpi: None,
monitors: monitor_list.clone(),
});
evlp.evq.borrow_mut().sync_roundtrip().unwrap();
@ -330,7 +331,8 @@ struct InternalWindow {
kill_switch: Arc<Mutex<bool>>,
frame: Weak<Mutex<SWindow<ConceptFrame>>>,
current_dpi: i32,
new_dpi: Option<i32>
new_dpi: Option<i32>,
monitors: Arc<Mutex<MonitorList>>
}
pub struct WindowStore {
@ -376,6 +378,18 @@ impl WindowStore {
}
}
pub fn remove_output(&mut self, output: u32) {
for window in &mut self.windows {
let dpi = window.monitors.lock().unwrap().output_disappeared(output);
if window.surface.version() >= 3 {
// without version 3 we can't be dpi aware
window.new_dpi = Some(dpi);
window.surface.set_buffer_scale(dpi);
window.need_refresh = true;
}
}
}
fn dpi_change(&mut self, surface: &Proxy<wl_surface::WlSurface>, new: i32) {
for window in &mut self.windows {
if surface.equals(&window.surface) {
@ -456,4 +470,9 @@ impl MonitorList {
None
}
}
fn output_disappeared(&mut self, id: u32) -> i32 {
self.monitors.retain(|m| m.get_native_identifier() != id);
self.compute_hidpi_factor()
}
}