Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

x11: Request repaint after exposure instead of within blocked loop (#61162)

mTvareae99a867d7a2
diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs
index c5087d771a1..b79c8947a29 100644
--- a/crates/gpui/src/window.rs
+++ b/crates/gpui/src/window.rs
@@ -1589,13 +1589,10 @@ impl Window {
// Throttle frame rate based on conditions:
// - Thermal pressure (Serious/Critical): cap to ~60fps
- // - Inactive window (not focused): cap to ~30fps to save energy,
- // unless input is arriving at a high rate (e.g. scrolling an
- // unfocused window, which is delivered to the window under
- // the pointer).
- let min_frame_interval = if !force_render
- && !request_frame_options.require_presentation
- && next_frame_callbacks.borrow().is_empty()
+ // - Inactive window (not focused): cap to ~30fps to save energy
+ let min_frame_interval = if request_frame_options.require_presentation
+ || (!request_frame_options.force_render
+ && next_frame_callbacks.borrow().is_empty())
{
None
} else if !active.get() && !input_rate_tracker.borrow_mut().is_high_rate() {
diff --git a/crates/gpui_linux/src/linux/x11/client.rs b/crates/gpui_linux/src/linux/x11/client.rs
index 0c8c9b4e20b..a543cd66cdc 100644
--- a/crates/gpui_linux/src/linux/x11/client.rs
+++ b/crates/gpui_linux/src/linux/x11/client.rs
@@ -81,7 +81,6 @@ const GPUI_X11_SCALE_FACTOR_ENV: &str = "GPUI_X11_SCALE_FACTOR";
pub(crate) struct WindowRef {
window: X11WindowStatePtr,
refresh_state: Option<RefreshState>,
- expose_event_received: bool,
last_visibility: Visibility,
is_mapped: bool,
}
@@ -657,13 +656,6 @@ impl X11Client {
break;
}
- for window in windows_to_refresh.into_iter() {
- let mut state = self.0.borrow_mut();
- if let Some(window) = state.windows.get_mut(&window) {
- window.expose_event_received = true;
- }
- }
-
for event in events.into_iter() {
let mut state = self.0.borrow_mut();
if !state.has_xim() {
@@ -713,6 +705,21 @@ impl X11Client {
}
}
}
+
+ for x_window in windows_to_refresh {
+ let window = self
+ .0
+ .borrow()
+ .windows
+ .get(&x_window)
+ .and_then(|window| window.is_mapped.then(|| window.window.clone()));
+ if let Some(window) = window {
+ window.refresh(RequestFrameOptions {
+ require_presentation: true,
+ force_render: false,
+ });
+ }
+ }
}
Ok(())
}
@@ -1648,7 +1655,6 @@ impl LinuxClient for X11Client {
let window_ref = WindowRef {
window: window.0.clone(),
refresh_state: None,
- expose_event_received: false,
last_visibility: Visibility::UNOBSCURED,
is_mapped: false,
};
@@ -1979,15 +1985,13 @@ impl X11ClientState {
let mut state = client.0.borrow_mut();
let xcb_connection = state.xcb_connection.clone();
if let Some(window) = state.windows.get_mut(&x_window) {
- let expose_event_received = window.expose_event_received;
- window.expose_event_received = false;
let force_render = std::mem::take(
&mut window.window.state.borrow_mut().force_render_after_recovery,
);
let window = window.window.clone();
drop(state);
window.refresh(RequestFrameOptions {
- require_presentation: expose_event_received,
+ require_presentation: false,
force_render,
});
}