mirror of
https://github.com/wez/wezterm.git
synced 2024-12-24 13:52:55 +03:00
wayland: reduce CPU utilization by correctly handling Refresh
On a Fedora 31 system running Wayland I noticed that wezterm and the compositor were running pretty hot on their respective CPU cores. It turned out that we had a lot of [Refresh](https://docs.rs/smithay-client-toolkit/0.6.4/smithay_client_toolkit/window/enum.Event.html#variant.Refresh) events being generated and consumed. We were treating this as needing a full paint so we'd be effectively continually running the opengl paint cycle over and over. The docs for that event say that it is intended to refresh the client decorations so let's focus it towards that instead. This does bring the CPU usage back down to intended levels. I believe this hot CPU usage to be compositor-dependent: this is the first I've seen of it out of 4 different Wayland environments!
This commit is contained in:
parent
45fe44e231
commit
0e568ea161
@ -106,7 +106,7 @@ pub struct WaylandWindowInner {
|
||||
#[derive(Default, Clone, Debug)]
|
||||
struct PendingEvent {
|
||||
close: bool,
|
||||
refresh: bool,
|
||||
refresh_decorations: bool,
|
||||
configure: Option<(u32, u32)>,
|
||||
dpi: Option<i32>,
|
||||
}
|
||||
@ -123,8 +123,8 @@ impl PendingEvent {
|
||||
}
|
||||
}
|
||||
Event::Refresh => {
|
||||
if !self.refresh {
|
||||
self.refresh = true;
|
||||
if !self.refresh_decorations {
|
||||
self.refresh_decorations = true;
|
||||
true
|
||||
} else {
|
||||
false
|
||||
@ -136,8 +136,8 @@ impl PendingEvent {
|
||||
changed = self.configure.is_none();
|
||||
self.configure.replace(new_size);
|
||||
} else {
|
||||
changed = !self.refresh;
|
||||
self.refresh = true;
|
||||
changed = !self.refresh_decorations;
|
||||
self.refresh_decorations = true;
|
||||
}
|
||||
changed
|
||||
}
|
||||
@ -469,11 +469,11 @@ impl WaylandWindowInner {
|
||||
}
|
||||
|
||||
self.refresh_frame();
|
||||
pending.refresh = true;
|
||||
self.do_paint().unwrap();
|
||||
}
|
||||
}
|
||||
if pending.refresh && self.window.is_some() {
|
||||
self.do_paint().unwrap();
|
||||
if pending.refresh_decorations && self.window.is_some() {
|
||||
self.refresh_frame();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user