forge
Explore
Log in

Don't you dare go Hollow

mapped: Force a frame callback on configure

Browse files at this commit

bc701cd529735af10c28840185127f66ee6ee25eIvan MolodetskikhParent: bfd81fc
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.
src/window/mapped.rsmodified+27 -2
@@ -65,6 +65,12 @@ pub struct Mapped {
6565 /// Certain Wayland requests require a configure in response, like un/fullscreen.
6666 needs_configure: bool,
6767
68+ /// Whether this window needs a frame callback.
69+ ///
70+ /// We set this after sending a configure to give invisible windows a chance to respond to
71+ /// resizes immediately, without waiting for a 1 second throttled callback.
72+ needs_frame_callback: bool,
73+
6874 /// Whether this window has the keyboard focus.
6975 is_focused: bool,
7076
@@ -178,6 +184,7 @@ impl Mapped {
178184 rules,
179185 need_to_recompute_rules: false,
180186 needs_configure: false,
187+ needs_frame_callback: false,
181188 is_focused: false,
182189 is_active_in_column: true,
183190 is_floating: false,
@@ -419,12 +426,24 @@ impl Mapped {
419426 output: &Output,
420427 time: T,
421428 throttle: Option<Duration>,
422- primary_scan_out_output: F,
429+ mut primary_scan_out_output: F,
423430 ) where
424431 T: Into<Duration>,
425432 F: FnMut(&WlSurface, &SurfaceData) -> Option<Output> + Copy,
426433 {
427- self.window.send_frame(output, time, throttle, primary_scan_out_output);
434+ let needs_frame_callback = self.needs_frame_callback;
435+ self.needs_frame_callback = false;
436+
437+ let should_send = move |surface: &WlSurface, states: &SurfaceData| {
438+ // Let primary_scan_out_output() run its logic and update internal state.
439+ if let Some(output) = primary_scan_out_output(surface, states) {
440+ return Some(output);
441+ }
442+
443+ // Send unconditionally to all surfaces if the window needs a surface callback.
444+ needs_frame_callback.then(|| output.clone())
445+ };
446+ self.window.send_frame(output, time, throttle, should_send);
428447 }
429448 }
430449
@@ -847,6 +866,12 @@ impl LayoutElement for Mapped {
847866
848867 self.needs_configure = false;
849868
869+ // Send the window a frame callback unconditionally to let it respond to size changes
870+ // and such immediately, even when it's hidden. This especially matters for cases like
871+ // tabbed columns which compute their width based on all windows in the column, even
872+ // hidden ones.
873+ self.needs_frame_callback = true;
874+
850875 if self.animate_next_configure {
851876 self.animate_serials.push(serial);
852877 }