diff options
author | Ben Bridle <ben@derelict.engineering> | 2024-07-31 15:36:53 +1200 |
---|---|---|
committer | Ben Bridle <ben@derelict.engineering> | 2024-07-31 15:36:53 +1200 |
commit | 20bc849cfd990267684532d84b9894204c96189f (patch) | |
tree | 0fe5245537f902f57a31a9fa61aee8c0bcc82857 | |
parent | 9e21354c85448a4890995012bdc26a996a56a972 (diff) | |
download | phosphor-20bc849cfd990267684532d84b9894204c96189f.zip |
Only set window title when changed
Setting the window title every frame was causing Windows Explorer to
show a consistent 4% CPU usage when testing under Windows 10. This
change brings it down to 0.2%.
-rw-r--r-- | src/window.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/window.rs b/src/window.rs index af60ef8..1949387 100644 --- a/src/window.rs +++ b/src/window.rs @@ -16,6 +16,7 @@ pub struct Window { render_request: RenderRequest, previous_cursor_position: Option<Point>, previous_cursor_icon: CursorIcon, + previous_title: String, } impl Window { @@ -57,6 +58,7 @@ impl Window { render_request: RenderRequest::REDRAW, previous_cursor_position: None, previous_cursor_icon: CursorIcon::Default, + previous_title: String::new(), } } @@ -65,7 +67,11 @@ impl Window { } pub fn update_title(&mut self) { - self.window.set_title(&self.controller.title()); + let title = self.controller.title(); + if title != self.previous_title { + self.window.set_title(&title); + self.previous_title = title; + } } pub fn update_cursor_icon(&mut self) { |