mapped: Force a frame callback on configure
Browse files at this commitbc701cd529735af10c28840185127f66ee6ee25eParent: bfd81fc1 changed file +27 -2
- src/window/mapped.rs +27 -2
src/window/mapped.rsmodified+27 -2
| @@ -65,6 +65,12 @@ pub struct Mapped { | ||
| 65 | 65 | /// Certain Wayland requests require a configure in response, like un/fullscreen. |
| 66 | 66 | needs_configure: bool, |
| 67 | 67 | |
| 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 | + | |
| 68 | 74 | /// Whether this window has the keyboard focus. |
| 69 | 75 | is_focused: bool, |
| 70 | 76 | |
| @@ -178,6 +184,7 @@ impl Mapped { | ||
| 178 | 184 | rules, |
| 179 | 185 | need_to_recompute_rules: false, |
| 180 | 186 | needs_configure: false, |
| 187 | + needs_frame_callback: false, | |
| 181 | 188 | is_focused: false, |
| 182 | 189 | is_active_in_column: true, |
| 183 | 190 | is_floating: false, |
| @@ -419,12 +426,24 @@ impl Mapped { | ||
| 419 | 426 | output: &Output, |
| 420 | 427 | time: T, |
| 421 | 428 | throttle: Option<Duration>, |
| 422 | - primary_scan_out_output: F, | |
| 429 | + mut primary_scan_out_output: F, | |
| 423 | 430 | ) where |
| 424 | 431 | T: Into<Duration>, |
| 425 | 432 | F: FnMut(&WlSurface, &SurfaceData) -> Option<Output> + Copy, |
| 426 | 433 | { |
| 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); | |
| 428 | 447 | } |
| 429 | 448 | } |
| 430 | 449 | |
| @@ -847,6 +866,12 @@ impl LayoutElement for Mapped { | ||
| 847 | 866 | |
| 848 | 867 | self.needs_configure = false; |
| 849 | 868 | |
| 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 | + | |
| 850 | 875 | if self.animate_next_configure { |
| 851 | 876 | self.animate_serials.push(serial); |
| 852 | 877 | } |