From 20bc849cfd990267684532d84b9894204c96189f Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Wed, 31 Jul 2024 15:36:53 +1200 Subject: 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%. --- src/window.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') 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, 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) { -- cgit v1.2.3-70-g09d2