Make monitor resource freeing better
This commit is contained in:
parent
a516a25a9f
commit
e89b6cb604
@ -2,7 +2,7 @@ use log::{debug, warn};
|
|||||||
use std::cmp;
|
use std::cmp;
|
||||||
use xcb::{x, randr, Xid};
|
use xcb::{x, randr, Xid};
|
||||||
|
|
||||||
use bscreensaver_util::{BSCREENSAVER_WM_CLASS, create_atom, destroy_pixmap};
|
use bscreensaver_util::{BSCREENSAVER_WM_CLASS, create_atom, destroy_cursor, destroy_pixmap, destroy_gc, destroy_window};
|
||||||
|
|
||||||
const BACKLIGHT_ATOM_NAME: &[u8] = b"Backlight";
|
const BACKLIGHT_ATOM_NAME: &[u8] = b"Backlight";
|
||||||
const BACKLIGHT_FALLBACK_ATOM_NAME: &[u8] = b"BACKLIGHT";
|
const BACKLIGHT_FALLBACK_ATOM_NAME: &[u8] = b"BACKLIGHT";
|
||||||
@ -88,6 +88,13 @@ impl Monitor {
|
|||||||
Ok(monitors)
|
Ok(monitors)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn release(self, conn: &xcb::Connection) {
|
||||||
|
let _ = destroy_cursor(conn, self.blank_cursor);
|
||||||
|
let _ = destroy_window(&conn, self.unlock_window);
|
||||||
|
let _ = destroy_window(&conn, self.blanker_window);
|
||||||
|
let _ = destroy_gc(&conn, self.black_gc);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn geometry(&self) -> x::Rectangle {
|
pub fn geometry(&self) -> x::Rectangle {
|
||||||
x::Rectangle {
|
x::Rectangle {
|
||||||
x: self.x,
|
x: self.x,
|
||||||
|
@ -130,10 +130,9 @@ impl<'a> Screensaver<'a> {
|
|||||||
match event {
|
match event {
|
||||||
xcb::Event::RandR(randr::Event::Notify(ev)) => {
|
xcb::Event::RandR(randr::Event::Notify(ev)) => {
|
||||||
debug!("Got xrandr notify event: {:#?}", ev);
|
debug!("Got xrandr notify event: {:#?}", ev);
|
||||||
for monitor in &self.monitors {
|
let old_monitors = std::mem::replace(&mut self.monitors, Vec::new());
|
||||||
destroy_window(&conn, monitor.unlock_window)?;
|
for monitor in old_monitors {
|
||||||
destroy_window(&conn, monitor.blanker_window)?;
|
monitor.release(conn);
|
||||||
destroy_gc(&conn, monitor.black_gc)?;
|
|
||||||
}
|
}
|
||||||
self.monitors = Monitor::set_up_all(conn)?;
|
self.monitors = Monitor::set_up_all(conn)?;
|
||||||
match self.blanker_state {
|
match self.blanker_state {
|
||||||
|
Loading…
Reference in New Issue
Block a user