Skip to content

Commit

Permalink
mapped: Force a frame callback on configure
Browse files Browse the repository at this point in the history
Lets hidden windows respond to events like resizes immediately. This is mainly
relevant for tabbed columns.

This commit doesn't actually force sending the frame callbacks in case we don't
redraw. We'll see if this is a problem or not.
  • Loading branch information
YaLTeR committed Feb 6, 2025
1 parent 642ff6f commit 429b040
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/window/mapped.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ pub struct Mapped {
/// Certain Wayland requests require a configure in response, like un/fullscreen.
needs_configure: bool,

/// Whether this window needs a frame callback.
///
/// We set this after sending a configure to give invisible windows a chance to respond to
/// resizes immediately, without waiting for a 1 second throttled callback.
needs_frame_callback: bool,

/// Whether this window has the keyboard focus.
is_focused: bool,

Expand Down Expand Up @@ -178,6 +184,7 @@ impl Mapped {
rules,
need_to_recompute_rules: false,
needs_configure: false,
needs_frame_callback: false,
is_focused: false,
is_active_in_column: true,
is_floating: false,
Expand Down Expand Up @@ -418,12 +425,24 @@ impl Mapped {
output: &Output,
time: T,
throttle: Option<Duration>,
primary_scan_out_output: F,
mut primary_scan_out_output: F,
) where
T: Into<Duration>,
F: FnMut(&WlSurface, &SurfaceData) -> Option<Output> + Copy,
{
self.window.send_frame(output, time, throttle, primary_scan_out_output);
let needs_frame_callback = self.needs_frame_callback;
self.needs_frame_callback = false;

let should_send = move |surface: &WlSurface, states: &SurfaceData| {
// Let primary_scan_out_output() run its logic and update internal state.
if let Some(output) = primary_scan_out_output(surface, states) {
return Some(output);
}

// Send unconditionally to all surfaces if the window needs a surface callback.
needs_frame_callback.then(|| output.clone())
};
self.window.send_frame(output, time, throttle, should_send);
}
}

Expand Down Expand Up @@ -846,6 +865,12 @@ impl LayoutElement for Mapped {

self.needs_configure = false;

// Send the window a frame callback unconditionally to let it respond to size changes
// and such immediately, even when it's hidden. This especially matters for cases like
// tabbed columns which compute their width based on all windows in the column, even
// hidden ones.
self.needs_frame_callback = true;

if self.animate_next_configure {
self.animate_serials.push(serial);
}
Expand Down

0 comments on commit 429b040

Please sign in to comment.