forge
Explore
Log in

Don't you dare go Hollow

Implement an Overview

Browse files at this commit

af1fca35bb15b8010cd3a12bbafe71b55d9ecf57Ivan MolodetskikhParent: 9571d14

11 changed files +1094 -105

niri-config/src/lib.rsmodified+73 -0
@@ -62,6 +62,8 @@ pub struct Config {
62 #[knuffel(child, default)]62 #[knuffel(child, default)]
63 pub gestures: Gestures,63 pub gestures: Gestures,
64 #[knuffel(child, default)]64 #[knuffel(child, default)]
65+ pub overview: Overview,
66+ #[knuffel(child, default)]
65 pub environment: Environment,67 pub environment: Environment,
66 #[knuffel(children(name = "window-rule"))]68 #[knuffel(children(name = "window-rule"))]
67 pub window_rules: Vec<WindowRule>,69 pub window_rules: Vec<WindowRule>,
@@ -988,6 +990,8 @@ pub struct Animations {
988 pub config_notification_open_close: ConfigNotificationOpenCloseAnim,990 pub config_notification_open_close: ConfigNotificationOpenCloseAnim,
989 #[knuffel(child, default)]991 #[knuffel(child, default)]
990 pub screenshot_ui_open: ScreenshotUiOpenAnim,992 pub screenshot_ui_open: ScreenshotUiOpenAnim,
993+ #[knuffel(child, default)]
994+ pub overview_open_close: OverviewOpenCloseAnim,
991 }995 }
992 996
993 impl Default for Animations {997 impl Default for Animations {
@@ -1003,6 +1007,7 @@ impl Default for Animations {
1003 window_resize: Default::default(),1007 window_resize: Default::default(),
1004 config_notification_open_close: Default::default(),1008 config_notification_open_close: Default::default(),
1005 screenshot_ui_open: Default::default(),1009 screenshot_ui_open: Default::default(),
1010+ overview_open_close: Default::default(),
1006 }1011 }
1007 }1012 }
1008 }1013 }
@@ -1150,6 +1155,22 @@ impl Default for ScreenshotUiOpenAnim {
1150 }1155 }
1151 }1156 }
1152 1157
1158+#[derive(Debug, Clone, Copy, PartialEq)]
1159+pub struct OverviewOpenCloseAnim(pub Animation);
1160+
1161+impl Default for OverviewOpenCloseAnim {
1162+ fn default() -> Self {
1163+ Self(Animation {
1164+ off: false,
1165+ kind: AnimationKind::Spring(SpringParams {
1166+ damping_ratio: 1.,
1167+ stiffness: 800,
1168+ epsilon: 0.0001,
1169+ }),
1170+ })
1171+ }
1172+}
1173+
1153 #[derive(Debug, Clone, Copy, PartialEq)]1174 #[derive(Debug, Clone, Copy, PartialEq)]
1154 pub struct Animation {1175 pub struct Animation {
1155 pub off: bool,1176 pub off: bool,
@@ -1209,6 +1230,20 @@ impl Default for DndEdgeViewScroll {
1209 }1230 }
1210 }1231 }
1211 1232
1233+#[derive(knuffel::Decode, Debug, Clone, Copy, PartialEq)]
1234+pub struct Overview {
1235+ #[knuffel(child, unwrap(argument), default = Self::default().zoom)]
1236+ pub zoom: FloatOrInt<0, 1>,
1237+}
1238+
1239+impl Default for Overview {
1240+ fn default() -> Self {
1241+ Self {
1242+ zoom: FloatOrInt(0.5),
1243+ }
1244+ }
1245+}
1246+
1212 #[derive(knuffel::Decode, Debug, Default, Clone, PartialEq, Eq)]1247 #[derive(knuffel::Decode, Debug, Default, Clone, PartialEq, Eq)]
1213 pub struct Environment(#[knuffel(children)] pub Vec<EnvironmentVariable>);1248 pub struct Environment(#[knuffel(children)] pub Vec<EnvironmentVariable>);
1214 1249
@@ -1720,6 +1755,9 @@ pub enum Action {
1720 SetDynamicCastWindowById(u64),1755 SetDynamicCastWindowById(u64),
1721 SetDynamicCastMonitor(#[knuffel(argument)] Option<String>),1756 SetDynamicCastMonitor(#[knuffel(argument)] Option<String>),
1722 ClearDynamicCastTarget,1757 ClearDynamicCastTarget,
1758+ ToggleOverview,
1759+ OpenOverview,
1760+ CloseOverview,
1723 }1761 }
1724 1762
1725 impl From<niri_ipc::Action> for Action {1763 impl From<niri_ipc::Action> for Action {
@@ -1984,6 +2022,9 @@ impl From<niri_ipc::Action> for Action {
1984 Self::SetDynamicCastMonitor(output)2022 Self::SetDynamicCastMonitor(output)
1985 }2023 }
1986 niri_ipc::Action::ClearDynamicCastTarget {} => Self::ClearDynamicCastTarget,2024 niri_ipc::Action::ClearDynamicCastTarget {} => Self::ClearDynamicCastTarget,
2025+ niri_ipc::Action::ToggleOverview {} => Self::ToggleOverview,
2026+ niri_ipc::Action::OpenOverview {} => Self::OpenOverview,
2027+ niri_ipc::Action::CloseOverview {} => Self::CloseOverview,
1987 }2028 }
1988 }2029 }
1989 }2030 }
@@ -2968,6 +3009,21 @@ where
2968 }3009 }
2969 }3010 }
2970 3011
3012+impl<S> knuffel::Decode<S> for OverviewOpenCloseAnim
3013+where
3014+ S: knuffel::traits::ErrorSpan,
3015+{
3016+ fn decode_node(
3017+ node: &knuffel::ast::SpannedNode<S>,
3018+ ctx: &mut knuffel::decode::Context<S>,
3019+ ) -> Result<Self, DecodeError<S>> {
3020+ let default = Self::default().0;
3021+ Ok(Self(Animation::decode_node(node, ctx, default, |_, _| {
3022+ Ok(false)
3023+ })?))
3024+ }
3025+}
3026+
2971 impl Animation {3027 impl Animation {
2972 pub fn new_off() -> Self {3028 pub fn new_off() -> Self {
2973 Self {3029 Self {
@@ -4469,6 +4525,18 @@ mod tests {
4469 ),4525 ),
4470 },4526 },
4471 ),4527 ),
4528+ overview_open_close: OverviewOpenCloseAnim(
4529+ Animation {
4530+ off: false,
4531+ kind: Spring(
4532+ SpringParams {
4533+ damping_ratio: 1.0,
4534+ stiffness: 800,
4535+ epsilon: 0.0001,
4536+ },
4537+ ),
4538+ },
4539+ ),
4472 },4540 },
4473 gestures: Gestures {4541 gestures: Gestures {
4474 dnd_edge_view_scroll: DndEdgeViewScroll {4542 dnd_edge_view_scroll: DndEdgeViewScroll {
@@ -4481,6 +4549,11 @@ mod tests {
4481 ),4549 ),
4482 },4550 },
4483 },4551 },
4552+ overview: Overview {
4553+ zoom: FloatOrInt(
4554+ 0.5,
4555+ ),
4556+ },
4484 environment: Environment(4557 environment: Environment(
4485 [4558 [
4486 EnvironmentVariable {4559 EnvironmentVariable {
niri-ipc/src/lib.rsmodified+6 -0
@@ -764,6 +764,12 @@ pub enum Action {
764 },764 },
765 /// Clear the dynamic cast target, making it show nothing.765 /// Clear the dynamic cast target, making it show nothing.
766 ClearDynamicCastTarget {},766 ClearDynamicCastTarget {},
767+ /// Toggle (open/close) the Overview.
768+ ToggleOverview {},
769+ /// Open the Overview.
770+ OpenOverview {},
771+ /// Close the Overview.
772+ CloseOverview {},
767 }773 }
768 774
769 /// Change in window or column size.775 /// Change in window or column size.
src/handlers/xdg_shell.rsmodified+4 -1
@@ -153,7 +153,7 @@ impl XdgShellHandler for State {
153 153
154 match start_data {154 match start_data {
155 PointerOrTouchStartData::Pointer(start_data) => {155 PointerOrTouchStartData::Pointer(start_data) => {
156- let grab = MoveGrab::new(start_data, window);156+ let grab = MoveGrab::new(start_data, window, false);
157 pointer.set_grab(self, grab, serial, Focus::Clear);157 pointer.set_grab(self, grab, serial, Focus::Clear);
158 }158 }
159 PointerOrTouchStartData::Touch(start_data) => {159 PointerOrTouchStartData::Touch(start_data) => {
@@ -316,6 +316,9 @@ impl XdgShellHandler for State {
316 } else if let Some(output) = self.niri.layout.active_output() {316 } else if let Some(output) = self.niri.layout.active_output() {
317 let layers = layer_map_for_output(output);317 let layers = layer_map_for_output(output);
318 318
319+ // FIXME: somewhere here we probably need to check is_overview_open to match the logic
320+ // in update_keyboard_focus().
321+
319 if layers322 if layers
320 .layer_for_surface(&root, WindowSurfaceType::TOPLEVEL)323 .layer_for_surface(&root, WindowSurfaceType::TOPLEVEL)
321 .is_none()324 .is_none()
src/input/mod.rsmodified+192 -18
@@ -394,7 +394,7 @@ impl State {
394 }394 }
395 395
396 let bindings = &this.niri.config.borrow().binds;396 let bindings = &this.niri.config.borrow().binds;
397- should_intercept_key(397+ let res = should_intercept_key(
398 &mut this.niri.suppressed_keys,398 &mut this.niri.suppressed_keys,
399 bindings,399 bindings,
400 mod_key,400 mod_key,
@@ -406,7 +406,20 @@ impl State {
406 &this.niri.screenshot_ui,406 &this.niri.screenshot_ui,
407 this.niri.config.borrow().input.disable_power_key_handling,407 this.niri.config.borrow().input.disable_power_key_handling,
408 is_inhibiting_shortcuts,408 is_inhibiting_shortcuts,
409- )409+ );
410+
411+ if matches!(res, FilterResult::Forward) {
412+ // If we didn't find any bind, try other hardcoded keys.
413+ if this.niri.keyboard_focus.is_overview() && pressed {
414+ if let Some(bind) = raw.and_then(|raw| hardcoded_overview_bind(raw, *mods))
415+ {
416+ this.niri.suppressed_keys.insert(key_code);
417+ return FilterResult::Intercept(Some(bind));
418+ }
419+ }
420+ }
421+
422+ res
410 },423 },
411 ) else {424 ) else {
412 return;425 return;
@@ -1915,6 +1928,20 @@ impl State {
1915 Action::ClearDynamicCastTarget => {1928 Action::ClearDynamicCastTarget => {
1916 self.set_dynamic_cast_target(CastTarget::Nothing);1929 self.set_dynamic_cast_target(CastTarget::Nothing);
1917 }1930 }
1931+ Action::ToggleOverview => {
1932+ self.niri.layout.toggle_overview();
1933+ self.niri.queue_redraw_all();
1934+ }
1935+ Action::OpenOverview => {
1936+ if self.niri.layout.open_overview() {
1937+ self.niri.queue_redraw_all();
1938+ }
1939+ }
1940+ Action::CloseOverview => {
1941+ if self.niri.layout.close_overview() {
1942+ self.niri.queue_redraw_all();
1943+ }
1944+ }
1918 }1945 }
1919 }1946 }
1920 1947
@@ -2235,13 +2262,49 @@ impl State {
2235 self.niri.pointer_hidden = false;2262 self.niri.pointer_hidden = false;
2236 self.niri.tablet_cursor_location = None;2263 self.niri.tablet_cursor_location = None;
2237 2264
2265+ let is_overview_open = self.niri.layout.is_overview_open();
2266+
2267+ if is_overview_open && !pointer.is_grabbed() && button == Some(MouseButton::Right) {
2268+ if let Some((output, ws)) = self.niri.workspace_under_cursor(true) {
2269+ let ws_id = ws.id();
2270+ let ws_idx = self.niri.layout.find_workspace_by_id(ws_id).unwrap().0;
2271+
2272+ self.niri.layout.focus_output(&output);
2273+
2274+ let location = pointer.current_location();
2275+ let start_data = PointerGrabStartData {
2276+ focus: None,
2277+ button: button_code,
2278+ location,
2279+ };
2280+ self.niri
2281+ .layout
2282+ .view_offset_gesture_begin(&output, Some(ws_idx), false);
2283+ let grab = SpatialMovementGrab::new(start_data, output, ws_id, true);
2284+ pointer.set_grab(self, grab, serial, Focus::Clear);
2285+ self.niri
2286+ .cursor_manager
2287+ .set_cursor_image(CursorImageStatus::Named(CursorIcon::AllScroll));
2288+
2289+ // FIXME: granular.
2290+ self.niri.queue_redraw_all();
2291+ return;
2292+ }
2293+ }
2294+
2238 if button == Some(MouseButton::Middle) && !pointer.is_grabbed() {2295 if button == Some(MouseButton::Middle) && !pointer.is_grabbed() {
2239 let mod_down = modifiers_from_state(mods).contains(mod_key.to_modifiers());2296 let mod_down = modifiers_from_state(mods).contains(mod_key.to_modifiers());
2240 if mod_down {2297 if mod_down {
2241- let output_ws = self.niri.output_under_cursor().and_then(|output| {2298+ let output_ws = if is_overview_open {
2242- let mon = self.niri.layout.monitor_for_output(&output)?;2299+ self.niri.workspace_under_cursor(true)
2243- Some((output, mon.active_workspace_ref()))2300+ } else {
2244- });2301+ // We don't want to accidentally "catch" the wrong workspace during
2302+ // animations.
2303+ self.niri.output_under_cursor().and_then(|output| {
2304+ let mon = self.niri.layout.monitor_for_output(&output)?;
2305+ Some((output, mon.active_workspace_ref()))
2306+ })
2307+ };
2245 2308
2246 if let Some((output, ws)) = output_ws {2309 if let Some((output, ws)) = output_ws {
2247 let ws_id = ws.id();2310 let ws_id = ws.id();
@@ -2254,7 +2317,7 @@ impl State {
2254 button: button_code,2317 button: button_code,
2255 location,2318 location,
2256 };2319 };
2257- let grab = SpatialMovementGrab::new(start_data, output, ws_id);2320+ let grab = SpatialMovementGrab::new(start_data, output, ws_id, false);
2258 pointer.set_grab(self, grab, serial, Focus::Clear);2321 pointer.set_grab(self, grab, serial, Focus::Clear);
2259 self.niri2322 self.niri
2260 .cursor_manager2323 .cursor_manager
@@ -2276,12 +2339,14 @@ impl State {
2276 // Check if we need to start an interactive move.2339 // Check if we need to start an interactive move.
2277 if button == Some(MouseButton::Left) && !pointer.is_grabbed() {2340 if button == Some(MouseButton::Left) && !pointer.is_grabbed() {
2278 let mod_down = modifiers_from_state(mods).contains(mod_key.to_modifiers());2341 let mod_down = modifiers_from_state(mods).contains(mod_key.to_modifiers());
2279- if mod_down {2342+ if is_overview_open || mod_down {
2280 let location = pointer.current_location();2343 let location = pointer.current_location();
2281 let (output, pos_within_output) = self.niri.output_under(location).unwrap();2344 let (output, pos_within_output) = self.niri.output_under(location).unwrap();
2282 let output = output.clone();2345 let output = output.clone();
2283 2346
2284- self.niri.layout.activate_window(&window);2347+ if !is_overview_open {
2348+ self.niri.layout.activate_window(&window);
2349+ }
2285 2350
2286 if self.niri.layout.interactive_move_begin(2351 if self.niri.layout.interactive_move_begin(
2287 window.clone(),2352 window.clone(),
@@ -2293,11 +2358,14 @@ impl State {
2293 button: button_code,2358 button: button_code,
2294 location,2359 location,
2295 };2360 };
2296- let grab = MoveGrab::new(start_data, window.clone());2361+ let grab = MoveGrab::new(start_data, window.clone(), is_overview_open);
2297 pointer.set_grab(self, grab, serial, Focus::Clear);2362 pointer.set_grab(self, grab, serial, Focus::Clear);
2298- self.niri2363+
2299- .cursor_manager2364+ if !is_overview_open {
2300- .set_cursor_image(CursorImageStatus::Named(CursorIcon::Move));2365+ self.niri
2366+ .cursor_manager
2367+ .set_cursor_image(CursorImageStatus::Named(CursorIcon::Move));
2368+ }
2301 }2369 }
2302 }2370 }
2303 }2371 }
@@ -2372,7 +2440,20 @@ impl State {
2372 }2440 }
2373 }2441 }
2374 2442
2375- self.niri.layout.activate_window(&window);2443+ if !is_overview_open {
2444+ self.niri.layout.activate_window(&window);
2445+ }
2446+
2447+ // FIXME: granular.
2448+ self.niri.queue_redraw_all();
2449+ } else if let Some((output, ws)) = is_overview_open
2450+ .then(|| self.niri.workspace_under_cursor(false))
2451+ .flatten()
2452+ {
2453+ let ws_idx = self.niri.layout.find_workspace_by_id(ws.id()).unwrap().0;
2454+
2455+ self.niri.layout.focus_output(&output);
2456+ self.niri.layout.toggle_overview_to_workspace(ws_idx);
2376 2457
2377 // FIXME: granular.2458 // FIXME: granular.
2378 self.niri.queue_redraw_all();2459 self.niri.queue_redraw_all();
@@ -2684,6 +2765,8 @@ impl State {
2684 let tool = self.niri.seat.tablet_seat().get_tool(&event.tool());2765 let tool = self.niri.seat.tablet_seat().get_tool(&event.tool());
2685 2766
2686 if let Some(tool) = tool {2767 if let Some(tool) = tool {
2768+ let is_overview_open = self.niri.layout.is_overview_open();
2769+
2687 match event.tip_state() {2770 match event.tip_state() {
2688 TabletToolTipState::Down => {2771 TabletToolTipState::Down => {
2689 let serial = SERIAL_COUNTER.next_serial();2772 let serial = SERIAL_COUNTER.next_serial();
@@ -2692,8 +2775,31 @@ impl State {
2692 if let Some(pos) = self.niri.tablet_cursor_location {2775 if let Some(pos) = self.niri.tablet_cursor_location {
2693 let under = self.niri.contents_under(pos);2776 let under = self.niri.contents_under(pos);
2694 if let Some((window, _)) = under.window {2777 if let Some((window, _)) = under.window {
2778+ if let Some(output) = is_overview_open.then_some(under.output).flatten()
2779+ {
2780+ let mut workspaces = self.niri.layout.workspaces();
2781+ if let Some(ws_idx) = workspaces.find_map(|(_, ws_idx, ws)| {
2782+ ws.windows().any(|w| w.window == window).then_some(ws_idx)
2783+ }) {
2784+ drop(workspaces);
2785+ self.niri.layout.focus_output(&output);
2786+ self.niri.layout.toggle_overview_to_workspace(ws_idx);
2787+ }
2788+ }
2789+
2695 self.niri.layout.activate_window(&window);2790 self.niri.layout.activate_window(&window);
2696 2791
2792+ // FIXME: granular.
2793+ self.niri.queue_redraw_all();
2794+ } else if let Some((output, ws)) = is_overview_open
2795+ .then(|| self.niri.workspace_under(false, pos))
2796+ .flatten()
2797+ {
2798+ let ws_idx = self.niri.layout.find_workspace_by_id(ws.id()).unwrap().0;
2799+
2800+ self.niri.layout.focus_output(&output);
2801+ self.niri.layout.toggle_overview_to_workspace(ws_idx);
2802+
2697 // FIXME: granular.2803 // FIXME: granular.
2698 self.niri.queue_redraw_all();2804 self.niri.queue_redraw_all();
2699 } else if let Some(output) = under.output {2805 } else if let Some(output) = under.output {
@@ -2779,6 +2885,12 @@ impl State {
2779 if event.fingers() == 3 {2885 if event.fingers() == 3 {
2780 self.niri.gesture_swipe_3f_cumulative = Some((0., 0.));2886 self.niri.gesture_swipe_3f_cumulative = Some((0., 0.));
2781 2887
2888+ // We handled this event.
2889+ return;
2890+ } else if event.fingers() == 4 {
2891+ self.niri.layout.overview_gesture_begin();
2892+ self.niri.queue_redraw_all();
2893+
2782 // We handled this event.2894 // We handled this event.
2783 return;2895 return;
2784 }2896 }
@@ -2816,6 +2928,8 @@ impl State {
2816 delta_y = libinput_event.dy_unaccelerated();2928 delta_y = libinput_event.dy_unaccelerated();
2817 }2929 }
2818 2930
2931+ let uninverted_delta_y = delta_y;
2932+
2819 let device = event.device();2933 let device = event.device();
2820 if let Some(device) = (&device as &dyn Any).downcast_ref::<input::Device>() {2934 if let Some(device) = (&device as &dyn Any).downcast_ref::<input::Device>() {
2821 if device.config_scroll_natural_scroll_enabled() {2935 if device.config_scroll_natural_scroll_enabled() {
@@ -2824,6 +2938,8 @@ impl State {
2824 }2938 }
2825 }2939 }
2826 2940
2941+ let is_overview_open = self.niri.layout.is_overview_open();
2942+
2827 if let Some((cx, cy)) = &mut self.niri.gesture_swipe_3f_cumulative {2943 if let Some((cx, cy)) = &mut self.niri.gesture_swipe_3f_cumulative {
2828 *cx += delta_x;2944 *cx += delta_x;
2829 *cy += delta_y;2945 *cy += delta_y;
@@ -2835,10 +2951,16 @@ impl State {
2835 2951
2836 if let Some(output) = self.niri.output_under_cursor() {2952 if let Some(output) = self.niri.output_under_cursor() {
2837 if cx.abs() > cy.abs() {2953 if cx.abs() > cy.abs() {
2838- let output_ws = self.niri.output_under_cursor().and_then(|output| {2954+ let output_ws = if is_overview_open {
2839- let mon = self.niri.layout.monitor_for_output(&output)?;2955+ self.niri.workspace_under_cursor(true)
2840- Some((output, mon.active_workspace_ref()))2956+ } else {
2841- });2957+ // We don't want to accidentally "catch" the wrong workspace during
2958+ // animations.
2959+ self.niri.output_under_cursor().and_then(|output| {
2960+ let mon = self.niri.layout.monitor_for_output(&output)?;
2961+ Some((output, mon.active_workspace_ref()))
2962+ })
2963+ };
2842 2964
2843 if let Some((output, ws)) = output_ws {2965 if let Some((output, ws)) = output_ws {
2844 let ws_idx = self.niri.layout.find_workspace_by_id(ws.id()).unwrap().0;2966 let ws_idx = self.niri.layout.find_workspace_by_id(ws.id()).unwrap().0;
@@ -2880,6 +3002,17 @@ impl State {
2880 handled = true;3002 handled = true;
2881 }3003 }
2882 3004
3005+ let res = self
3006+ .niri
3007+ .layout
3008+ .overview_gesture_update(-uninverted_delta_y, timestamp);
3009+ if let Some(redraw) = res {
3010+ if redraw {
3011+ self.niri.queue_redraw_all();
3012+ }
3013+ handled = true;
3014+ }
3015+
2883 if handled {3016 if handled {
2884 // We handled this event.3017 // We handled this event.
2885 return;3018 return;
@@ -2916,6 +3049,12 @@ impl State {
2916 handled = true;3049 handled = true;
2917 }3050 }
2918 3051
3052+ let res = self.niri.layout.overview_gesture_end();
3053+ if res {
3054+ self.niri.queue_redraw_all();
3055+ handled = true;
3056+ }
3057+
2919 if handled {3058 if handled {
2920 // We handled this event.3059 // We handled this event.
2921 return;3060 return;
@@ -3512,6 +3651,41 @@ fn allowed_during_screenshot(action: &Action) -> bool {
3512 )3651 )
3513 }3652 }
3514 3653
3654+fn hardcoded_overview_bind(raw: Keysym, mods: ModifiersState) -> Option<Bind> {
3655+ let mods = modifiers_from_state(mods);
3656+ if !mods.is_empty() {
3657+ return None;
3658+ }
3659+
3660+ let mut repeat = true;
3661+ let action = match raw {
3662+ Keysym::Escape | Keysym::Return => {
3663+ repeat = false;
3664+ Action::ToggleOverview
3665+ }
3666+ Keysym::Left => Action::FocusColumnLeft,
3667+ Keysym::Right => Action::FocusColumnRight,
3668+ Keysym::Up => Action::FocusWindowOrWorkspaceUp,
3669+ Keysym::Down => Action::FocusWindowOrWorkspaceDown,
3670+ _ => {
3671+ return None;
3672+ }
3673+ };
3674+
3675+ Some(Bind {
3676+ key: Key {
3677+ trigger: Trigger::Keysym(raw),
3678+ modifiers: Modifiers::empty(),
3679+ },
3680+ action,
3681+ repeat,
3682+ cooldown: None,
3683+ allow_when_locked: false,
3684+ allow_inhibiting: false,
3685+ hotkey_overlay_title: None,
3686+ })
3687+}
3688+
3515 pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input::Device) {3689 pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input::Device) {
3516 // According to Mutter code, this setting is specific to touchpads.3690 // According to Mutter code, this setting is specific to touchpads.
3517 let is_touchpad = device.config_tap_finger_count() > 0;3691 let is_touchpad = device.config_tap_finger_count() > 0;
src/input/move_grab.rsmodified+42 -5
@@ -1,10 +1,11 @@
1 use smithay::backend::input::ButtonState;1 use smithay::backend::input::ButtonState;
2 use smithay::desktop::Window;2 use smithay::desktop::Window;
3 use smithay::input::pointer::{3 use smithay::input::pointer::{
4- AxisFrame, ButtonEvent, CursorImageStatus, GestureHoldBeginEvent, GestureHoldEndEvent,4+ AxisFrame, ButtonEvent, CursorIcon, CursorImageStatus, GestureHoldBeginEvent,
5- GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent,5+ GestureHoldEndEvent, GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent,
6- GestureSwipeEndEvent, GestureSwipeUpdateEvent, GrabStartData as PointerGrabStartData,6+ GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent,
7- MotionEvent, PointerGrab, PointerInnerHandle, RelativeMotionEvent,7+ GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, PointerInnerHandle,
8+ RelativeMotionEvent,
8 };9 };
9 use smithay::input::SeatHandler;10 use smithay::input::SeatHandler;
10 use smithay::utils::{IsAlive, Logical, Point};11 use smithay::utils::{IsAlive, Logical, Point};
@@ -15,14 +16,32 @@ pub struct MoveGrab {
15 start_data: PointerGrabStartData<State>,16 start_data: PointerGrabStartData<State>,
16 last_location: Point<f64, Logical>,17 last_location: Point<f64, Logical>,
17 window: Window,18 window: Window,
19+ gesture: GestureState,
20+}
21+
22+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
23+enum GestureState {
24+ Recognizing,
25+ Move,
18 }26 }
19 27
20 impl MoveGrab {28 impl MoveGrab {
21- pub fn new(start_data: PointerGrabStartData<State>, window: Window) -> Self {29+ pub fn new(
30+ start_data: PointerGrabStartData<State>,
31+ window: Window,
32+ use_threshold: bool,
33+ ) -> Self {
34+ let gesture = if use_threshold {
35+ GestureState::Recognizing
36+ } else {
37+ GestureState::Move
38+ };
39+
22 Self {40 Self {
23 last_location: start_data.location,41 last_location: start_data.location,
24 start_data,42 start_data,
25 window,43 window,
44+ gesture,
26 }45 }
27 }46 }
28 47
@@ -53,6 +72,24 @@ impl PointerGrab<State> for MoveGrab {
53 let output = output.clone();72 let output = output.clone();
54 let event_delta = event.location - self.last_location;73 let event_delta = event.location - self.last_location;
55 self.last_location = event.location;74 self.last_location = event.location;
75+
76+ if self.gesture == GestureState::Recognizing {
77+ let c = event.location - self.start_data.location;
78+
79+ // Check if the gesture moved far enough to decide.
80+ if c.x * c.x + c.y * c.y >= 8. * 8. {
81+ self.gesture = GestureState::Move;
82+
83+ data.niri
84+ .cursor_manager
85+ .set_cursor_image(CursorImageStatus::Named(CursorIcon::Move));
86+ }
87+ }
88+
89+ if self.gesture != GestureState::Move {
90+ return;
91+ }
92+
56 let ongoing = data.niri.layout.interactive_move_update(93 let ongoing = data.niri.layout.interactive_move_update(
57 &self.window,94 &self.window,
58 event_delta,95 event_delta,
src/input/spatial_movement_grab.rsmodified+8 -1
@@ -33,13 +33,20 @@ impl SpatialMovementGrab {
33 start_data: PointerGrabStartData<State>,33 start_data: PointerGrabStartData<State>,
34 output: Output,34 output: Output,
35 workspace_id: WorkspaceId,35 workspace_id: WorkspaceId,
36+ is_view_offset: bool,
36 ) -> Self {37 ) -> Self {
38+ let gesture = if is_view_offset {
39+ GestureState::ViewOffset
40+ } else {
41+ GestureState::Recognizing
42+ };
43+
37 Self {44 Self {
38 last_location: start_data.location,45 last_location: start_data.location,
39 start_data,46 start_data,
40 output,47 output,
41 workspace_id,48 workspace_id,
42- gesture: GestureState::Recognizing,49+ gesture,
43 }50 }
44 }51 }
45 52
src/layout/mod.rsmodified+394 -44
@@ -45,6 +45,7 @@ use niri_config::{
45 use niri_ipc::{ColumnDisplay, PositionChange, SizeChange};45 use niri_ipc::{ColumnDisplay, PositionChange, SizeChange};
46 use scrolling::{Column, ColumnWidth};46 use scrolling::{Column, ColumnWidth};
47 use smithay::backend::renderer::element::surface::WaylandSurfaceRenderElement;47 use smithay::backend::renderer::element::surface::WaylandSurfaceRenderElement;
48+use smithay::backend::renderer::element::utils::RescaleRenderElement;
48 use smithay::backend::renderer::gles::{GlesRenderer, GlesTexture};49 use smithay::backend::renderer::gles::{GlesRenderer, GlesTexture};
49 use smithay::output::{self, Output};50 use smithay::output::{self, Output};
50 use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;51 use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
@@ -55,7 +56,8 @@ use workspace::{WorkspaceAddWindowTarget, WorkspaceId};
55 pub use self::monitor::MonitorRenderElement;56 pub use self::monitor::MonitorRenderElement;
56 use self::monitor::{Monitor, WorkspaceSwitch};57 use self::monitor::{Monitor, WorkspaceSwitch};
57 use self::workspace::{OutputId, Workspace};58 use self::workspace::{OutputId, Workspace};
58-use crate::animation::Clock;59+use crate::animation::{Animation, Clock};
60+use crate::input::swipe_tracker::SwipeTracker;
59 use crate::layout::scrolling::ScrollDirection;61 use crate::layout::scrolling::ScrollDirection;
60 use crate::niri_render_elements;62 use crate::niri_render_elements;
61 use crate::render_helpers::offscreen::OffscreenData;63 use crate::render_helpers::offscreen::OffscreenData;
@@ -96,6 +98,14 @@ const INTERACTIVE_MOVE_START_THRESHOLD: f64 = 256. * 256.;
96 /// Opacity of interactively moved tiles targeting the scrolling layout.98 /// Opacity of interactively moved tiles targeting the scrolling layout.
97 const INTERACTIVE_MOVE_ALPHA: f64 = 0.75;99 const INTERACTIVE_MOVE_ALPHA: f64 = 0.75;
98 100
101+/// Amount of touchpad movement to toggle the overview.
102+const OVERVIEW_GESTURE_MOVEMENT: f64 = 300.;
103+
104+const OVERVIEW_GESTURE_RUBBER_BAND: RubberBand = RubberBand {
105+ stiffness: 0.5,
106+ limit: 0.05,
107+};
108+
99 /// Size-relative units.109 /// Size-relative units.
100 pub struct SizeFrac;110 pub struct SizeFrac;
101 111
@@ -293,6 +303,13 @@ pub struct Layout<W: LayoutElement> {
293 clock: Clock,303 clock: Clock,
294 /// Time that we last updated render elements for.304 /// Time that we last updated render elements for.
295 update_render_elements_time: Duration,305 update_render_elements_time: Duration,
306+ /// Whether the overview is open.
307+ ///
308+ /// This is a boolean flag that controls things like where input goes to. The actual animation
309+ /// is controlled by overview_progress.
310+ overview_open: bool,
311+ /// The overview zoom progress.
312+ overview_progress: Option<OverviewProgress>,
296 /// Configurable properties of the layout.313 /// Configurable properties of the layout.
297 options: Rc<Options>,314 options: Rc<Options>,
298 }315 }
@@ -338,6 +355,7 @@ pub struct Options {
338 pub preset_window_heights: Vec<PresetSize>,355 pub preset_window_heights: Vec<PresetSize>,
339 pub animations: niri_config::Animations,356 pub animations: niri_config::Animations,
340 pub gestures: niri_config::Gestures,357 pub gestures: niri_config::Gestures,
358+ pub overview: niri_config::Overview,
341 // Debug flags.359 // Debug flags.
342 pub disable_resize_throttling: bool,360 pub disable_resize_throttling: bool,
343 pub disable_transactions: bool,361 pub disable_transactions: bool,
@@ -365,6 +383,7 @@ impl Default for Options {
365 default_column_width: None,383 default_column_width: None,
366 animations: Default::default(),384 animations: Default::default(),
367 gestures: Default::default(),385 gestures: Default::default(),
386+ overview: Default::default(),
368 disable_resize_throttling: false,387 disable_resize_throttling: false,
369 disable_transactions: false,388 disable_transactions: false,
370 preset_window_heights: vec![389 preset_window_heights: vec![
@@ -493,6 +512,21 @@ pub enum HitType {
493 },512 },
494 }513 }
495 514
515+#[derive(Debug)]
516+enum OverviewProgress {
517+ Animation(Animation),
518+ Gesture(OverviewGesture),
519+}
520+
521+#[derive(Debug)]
522+struct OverviewGesture {
523+ tracker: SwipeTracker,
524+ /// Start point.
525+ start: f64,
526+ /// Current progress.
527+ value: f64,
528+}
529+
496 impl<W: LayoutElement> InteractiveMoveState<W> {530 impl<W: LayoutElement> InteractiveMoveState<W> {
497 fn moving(&self) -> Option<&InteractiveMoveData<W>> {531 fn moving(&self) -> Option<&InteractiveMoveData<W>> {
498 match self {532 match self {
@@ -510,16 +544,16 @@ impl<W: LayoutElement> InteractiveMoveState<W> {
510 }544 }
511 545
512 impl<W: LayoutElement> InteractiveMoveData<W> {546 impl<W: LayoutElement> InteractiveMoveData<W> {
513- fn tile_render_location(&self) -> Point<f64, Logical> {547+ fn tile_render_location(&self, zoom: f64) -> Point<f64, Logical> {
514 let scale = Scale::from(self.output.current_scale().fractional_scale());548 let scale = Scale::from(self.output.current_scale().fractional_scale());
515 let window_size = self.tile.window_size();549 let window_size = self.tile.window_size();
516 let pointer_offset_within_window = Point::from((550 let pointer_offset_within_window = Point::from((
517 window_size.w * self.pointer_ratio_within_window.0,551 window_size.w * self.pointer_ratio_within_window.0,
518 window_size.h * self.pointer_ratio_within_window.1,552 window_size.h * self.pointer_ratio_within_window.1,
519 ));553 ));
520- let pos =554+ let pos = self.pointer_pos_within_output
521- self.pointer_pos_within_output - pointer_offset_within_window - self.tile.window_loc()555+ - (pointer_offset_within_window + self.tile.window_loc() - self.tile.render_offset())
522- + self.tile.render_offset();556+ .upscale(zoom);
523 // Round to physical pixels.557 // Round to physical pixels.
524 pos.to_physical_precise_round(scale).to_logical(scale)558 pos.to_physical_precise_round(scale).to_logical(scale)
525 }559 }
@@ -553,6 +587,15 @@ impl HitType {
553 tile.hit(pos_within_tile)587 tile.hit(pos_within_tile)
554 .map(|hit| (tile.window(), hit.offset_win_pos(tile_pos)))588 .map(|hit| (tile.window(), hit.offset_win_pos(tile_pos)))
555 }589 }
590+
591+ pub fn to_activate(self) -> Self {
592+ match self {
593+ HitType::Input { .. } => HitType::Activate {
594+ is_tab_indicator: false,
595+ },
596+ HitType::Activate { .. } => self,
597+ }
598+ }
556 }599 }
557 600
558 impl Options {601 impl Options {
@@ -594,6 +637,7 @@ impl Options {
594 default_column_width,637 default_column_width,
595 animations: config.animations.clone(),638 animations: config.animations.clone(),
596 gestures: config.gestures,639 gestures: config.gestures,
640+ overview: config.overview,
597 disable_resize_throttling: config.debug.disable_resize_throttling,641 disable_resize_throttling: config.debug.disable_resize_throttling,
598 disable_transactions: config.debug.disable_transactions,642 disable_transactions: config.debug.disable_transactions,
599 preset_window_heights,643 preset_window_heights,
@@ -611,6 +655,19 @@ impl Options {
611 }655 }
612 }656 }
613 657
658+impl OverviewProgress {
659+ fn value(&self) -> f64 {
660+ match self {
661+ OverviewProgress::Animation(anim) => anim.value(),
662+ OverviewProgress::Gesture(gesture) => gesture.value,
663+ }
664+ }
665+
666+ fn is_animation(&self) -> bool {
667+ matches!(self, OverviewProgress::Animation(_))
668+ }
669+}
670+
614 impl<W: LayoutElement> Layout<W> {671 impl<W: LayoutElement> Layout<W> {
615 pub fn new(clock: Clock, config: &Config) -> Self {672 pub fn new(clock: Clock, config: &Config) -> Self {
616 Self::with_options_and_workspaces(clock, config, Options::from_config(config))673 Self::with_options_and_workspaces(clock, config, Options::from_config(config))
@@ -625,6 +682,8 @@ impl<W: LayoutElement> Layout<W> {
625 dnd: None,682 dnd: None,
626 clock,683 clock,
627 update_render_elements_time: Duration::ZERO,684 update_render_elements_time: Duration::ZERO,
685+ overview_open: false,
686+ overview_progress: None,
628 options: Rc::new(options),687 options: Rc::new(options),
629 }688 }
630 }689 }
@@ -648,6 +707,8 @@ impl<W: LayoutElement> Layout<W> {
648 dnd: None,707 dnd: None,
649 clock,708 clock,
650 update_render_elements_time: Duration::ZERO,709 update_render_elements_time: Duration::ZERO,
710+ overview_open: false,
711+ overview_progress: None,
651 options: opts,712 options: opts,
652 }713 }
653 }714 }
@@ -751,6 +812,8 @@ impl<W: LayoutElement> Layout<W> {
751 let mut monitor =812 let mut monitor =
752 Monitor::new(output, workspaces, self.clock.clone(), self.options.clone());813 Monitor::new(output, workspaces, self.clock.clone(), self.options.clone());
753 monitor.active_workspace_idx = active_workspace_idx;814 monitor.active_workspace_idx = active_workspace_idx;
815+ monitor.overview_open = self.overview_open;
816+ monitor.set_overview_progress(self.overview_progress.as_ref());
754 monitors.push(monitor);817 monitors.push(monitor);
755 818
756 MonitorSet::Normal {819 MonitorSet::Normal {
@@ -789,6 +852,8 @@ impl<W: LayoutElement> Layout<W> {
789 let mut monitor =852 let mut monitor =
790 Monitor::new(output, workspaces, self.clock.clone(), self.options.clone());853 Monitor::new(output, workspaces, self.clock.clone(), self.options.clone());
791 monitor.active_workspace_idx = active_workspace_idx;854 monitor.active_workspace_idx = active_workspace_idx;
855+ monitor.overview_open = self.overview_open;
856+ monitor.set_overview_progress(self.overview_progress.as_ref());
792 857
793 MonitorSet::Normal {858 MonitorSet::Normal {
794 monitors: vec![monitor],859 monitors: vec![monitor],
@@ -1418,7 +1483,7 @@ impl<W: LayoutElement> Layout<W> {
1418 let mut target = Rectangle::from_size(Size::from((width, height)));1483 let mut target = Rectangle::from_size(Size::from((width, height)));
1419 // FIXME: ideally this shouldn't include the tile render offset, but the code1484 // FIXME: ideally this shouldn't include the tile render offset, but the code
1420 // duplication would be a bit annoying for this edge case.1485 // duplication would be a bit annoying for this edge case.
1421- target.loc.y -= move_.tile_render_location().y;1486+ target.loc.y -= move_.tile_render_location(1.).y;
1422 target.loc.y -= move_.tile.window_loc().y;1487 target.loc.y -= move_.tile.window_loc().y;
1423 return target;1488 return target;
1424 }1489 }
@@ -2279,8 +2344,19 @@ impl<W: LayoutElement> Layout<W> {
2279 ) -> Option<(&W, HitType)> {2344 ) -> Option<(&W, HitType)> {
2280 if let Some(InteractiveMoveState::Moving(move_)) = &self.interactive_move {2345 if let Some(InteractiveMoveState::Moving(move_)) = &self.interactive_move {
2281 if move_.output == *output {2346 if move_.output == *output {
2282- let tile_pos = move_.tile_render_location();2347+ if self.overview_progress.is_some() {
2283- HitType::hit_tile(&move_.tile, tile_pos, pos_within_output)2348+ let zoom = self.overview_zoom();
2349+ let tile_pos = move_.tile_render_location(zoom);
2350+ let pos_within_tile = (pos_within_output - tile_pos).downscale(zoom);
2351+ // During the overview animation, we cannot do input hits because we cannot
2352+ // really represent scaled windows properly.
2353+ let (win, hit) =
2354+ HitType::hit_tile(&move_.tile, Point::from((0., 0.)), pos_within_tile)?;
2355+ Some((win, hit.to_activate()))
2356+ } else {
2357+ let tile_pos = move_.tile_render_location(1.);
2358+ HitType::hit_tile(&move_.tile, tile_pos, pos_within_output)
2359+ }
2284 } else {2360 } else {
2285 None2361 None
2286 }2362 }
@@ -2316,6 +2392,36 @@ impl<W: LayoutElement> Layout<W> {
2316 mon.resize_edges_under(pos_within_output)2392 mon.resize_edges_under(pos_within_output)
2317 }2393 }
2318 2394
2395+ pub fn workspace_under(
2396+ &self,
2397+ extended_bounds: bool,
2398+ output: &Output,
2399+ pos_within_output: Point<f64, Logical>,
2400+ ) -> Option<&Workspace<W>> {
2401+ if self
2402+ .interactive_moved_window_under(output, pos_within_output)
2403+ .is_some()
2404+ {
2405+ return None;
2406+ }
2407+
2408+ let MonitorSet::Normal { monitors, .. } = &self.monitor_set else {
2409+ return None;
2410+ };
2411+
2412+ let mon = monitors.iter().find(|mon| &mon.output == output)?;
2413+ if extended_bounds {
2414+ mon.workspace_under(pos_within_output).map(|(ws, _)| ws)
2415+ } else {
2416+ mon.workspace_under_narrow(pos_within_output)
2417+ }
2418+ }
2419+
2420+ pub fn overview_zoom(&self) -> f64 {
2421+ let progress = self.overview_progress.as_ref().map(|p| p.value());
2422+ compute_overview_zoom(&self.options, progress)
2423+ }
2424+
2319 #[cfg(test)]2425 #[cfg(test)]
2320 fn verify_invariants(&self) {2426 fn verify_invariants(&self) {
2321 use std::collections::HashSet;2427 use std::collections::HashSet;
@@ -2324,6 +2430,8 @@ impl<W: LayoutElement> Layout<W> {
2324 2430
2325 use crate::layout::monitor::WorkspaceSwitch;2431 use crate::layout::monitor::WorkspaceSwitch;
2326 2432
2433+ let zoom = self.overview_zoom();
2434+
2327 let mut move_win_id = None;2435 let mut move_win_id = None;
2328 if let Some(state) = &self.interactive_move {2436 if let Some(state) = &self.interactive_move {
2329 match state {2437 match state {
@@ -2352,7 +2460,7 @@ impl<W: LayoutElement> Layout<W> {
2352 base options adjusted for output scale"2460 base options adjusted for output scale"
2353 );2461 );
2354 2462
2355- let tile_pos = move_.tile_render_location();2463+ let tile_pos = move_.tile_render_location(zoom);
2356 let rounded_pos = tile_pos.to_physical_precise_round(scale).to_logical(scale);2464 let rounded_pos = tile_pos.to_physical_precise_round(scale).to_logical(scale);
2357 2465
2358 // Tile position must be rounded to physical pixels.2466 // Tile position must be rounded to physical pixels.
@@ -2460,6 +2568,12 @@ impl<W: LayoutElement> Layout<W> {
2460 "monitor options must be synchronized with layout"2568 "monitor options must be synchronized with layout"
2461 );2569 );
2462 2570
2571+ assert_eq!(self.overview_open, monitor.overview_open);
2572+ assert_eq!(
2573+ self.overview_progress.as_ref().map(|p| p.value()),
2574+ monitor.overview_progress_value()
2575+ );
2576+
2463 if let Some(WorkspaceSwitch::Animation(anim)) = &monitor.workspace_switch {2577 if let Some(WorkspaceSwitch::Animation(anim)) = &monitor.workspace_switch {
2464 let before_idx = anim.from() as usize;2578 let before_idx = anim.from() as usize;
2465 let after_idx = anim.to() as usize;2579 let after_idx = anim.to() as usize;
@@ -2650,6 +2764,8 @@ impl<W: LayoutElement> Layout<W> {
2650 // Scroll the view if needed.2764 // Scroll the view if needed.
2651 if let Some((output, pos_within_output)) = dnd_scroll {2765 if let Some((output, pos_within_output)) = dnd_scroll {
2652 if let Some(mon) = self.monitor_for_output_mut(&output) {2766 if let Some(mon) = self.monitor_for_output_mut(&output) {
2767+ let zoom = mon.overview_zoom();
2768+
2653 if let Some((ws, geo)) = mon.workspace_under(pos_within_output) {2769 if let Some((ws, geo)) = mon.workspace_under(pos_within_output) {
2654 let ws_id = ws.id();2770 let ws_id = ws.id();
2655 let ws = mon2771 let ws = mon
@@ -2657,7 +2773,18 @@ impl<W: LayoutElement> Layout<W> {
2657 .iter_mut()2773 .iter_mut()
2658 .find(|ws| ws.id() == ws_id)2774 .find(|ws| ws.id() == ws_id)
2659 .unwrap();2775 .unwrap();
2660- ws.dnd_scroll_gesture_scroll(pos_within_output - geo.loc);2776+ // As far as the DnD scroll gesture is concerned, the workspace spans across
2777+ // the whole monitor horizontally.
2778+ let ws_pos = Point::from((0., geo.loc.y));
2779+ ws.dnd_scroll_gesture_scroll(pos_within_output - ws_pos, 1. / zoom);
2780+ }
2781+ }
2782+ }
2783+
2784+ if !self.overview_open {
2785+ if let Some(OverviewProgress::Animation(anim)) = &mut self.overview_progress {
2786+ if anim.is_done() {
2787+ self.overview_progress = None;
2661 }2788 }
2662 }2789 }
2663 }2790 }
@@ -2665,6 +2792,7 @@ impl<W: LayoutElement> Layout<W> {
2665 match &mut self.monitor_set {2792 match &mut self.monitor_set {
2666 MonitorSet::Normal { monitors, .. } => {2793 MonitorSet::Normal { monitors, .. } => {
2667 for mon in monitors {2794 for mon in monitors {
2795+ mon.set_overview_progress(self.overview_progress.as_ref());
2668 mon.advance_animations();2796 mon.advance_animations();
2669 }2797 }
2670 }2798 }
@@ -2697,6 +2825,14 @@ impl<W: LayoutElement> Layout<W> {
2697 }2825 }
2698 }2826 }
2699 2827
2828+ if self
2829+ .overview_progress
2830+ .as_ref()
2831+ .is_some_and(|p| p.is_animation())
2832+ {
2833+ return true;
2834+ }
2835+
2700 let MonitorSet::Normal { monitors, .. } = &self.monitor_set else {2836 let MonitorSet::Normal { monitors, .. } = &self.monitor_set else {
2701 return false;2837 return false;
2702 };2838 };
@@ -2719,9 +2855,10 @@ impl<W: LayoutElement> Layout<W> {
2719 2855
2720 self.update_render_elements_time = self.clock.now();2856 self.update_render_elements_time = self.clock.now();
2721 2857
2858+ let zoom = self.overview_zoom();
2722 if let Some(InteractiveMoveState::Moving(move_)) = &mut self.interactive_move {2859 if let Some(InteractiveMoveState::Moving(move_)) = &mut self.interactive_move {
2723 if output.map_or(true, |output| move_.output == *output) {2860 if output.map_or(true, |output| move_.output == *output) {
2724- let pos_within_output = move_.tile_render_location();2861+ let pos_within_output = move_.tile_render_location(zoom);
2725 let view_rect =2862 let view_rect =
2726 Rectangle::new(pos_within_output.upscale(-1.), output_size(&move_.output));2863 Rectangle::new(pos_within_output.upscale(-1.), output_size(&move_.output));
2727 move_.tile.update_render_elements(true, view_rect);2864 move_.tile.update_render_elements(true, view_rect);
@@ -2745,6 +2882,7 @@ impl<W: LayoutElement> Layout<W> {
2745 let is_active = self.is_active2882 let is_active = self.is_active
2746 && idx == *active_monitor_idx2883 && idx == *active_monitor_idx
2747 && !matches!(self.interactive_move, Some(InteractiveMoveState::Moving(_)));2884 && !matches!(self.interactive_move, Some(InteractiveMoveState::Moving(_)));
2885+ mon.set_overview_progress(self.overview_progress.as_ref());
2748 mon.update_render_elements(is_active);2886 mon.update_render_elements(is_active);
2749 }2887 }
2750 }2888 }
@@ -2798,6 +2936,7 @@ impl<W: LayoutElement> Layout<W> {
2798 let _span = tracy_client::span!("Layout::update_insert_hint::update");2936 let _span = tracy_client::span!("Layout::update_insert_hint::update");
2799 2937
2800 if let Some(mon) = self.monitor_for_output_mut(&move_.output) {2938 if let Some(mon) = self.monitor_for_output_mut(&move_.output) {
2939+ let zoom = mon.overview_zoom();
2801 if let Some((ws, geo)) = mon.workspace_under(move_.pointer_pos_within_output) {2940 if let Some((ws, geo)) = mon.workspace_under(move_.pointer_pos_within_output) {
2802 let ws_id = ws.id();2941 let ws_id = ws.id();
2803 let ws = mon2942 let ws = mon
@@ -2805,8 +2944,8 @@ impl<W: LayoutElement> Layout<W> {
2805 .iter_mut()2944 .iter_mut()
2806 .find(|ws| ws.id() == ws_id)2945 .find(|ws| ws.id() == ws_id)
2807 .unwrap();2946 .unwrap();
2808-2947+ let pos_within_workspace =
2809- let pos_within_workspace = move_.pointer_pos_within_output - geo.loc;2948+ (move_.pointer_pos_within_output - geo.loc).downscale(zoom);
2810 let position = ws.scrolling_insert_position(pos_within_workspace);2949 let position = ws.scrolling_insert_position(pos_within_workspace);
2811 2950
2812 let rules = move_.tile.window().rules();2951 let rules = move_.tile.window().rules();
@@ -3645,6 +3784,9 @@ impl<W: LayoutElement> Layout<W> {
3645 timestamp: Duration,3784 timestamp: Duration,
3646 is_touchpad: bool,3785 is_touchpad: bool,
3647 ) -> Option<Option<Output>> {3786 ) -> Option<Option<Output>> {
3787+ let zoom = self.overview_zoom();
3788+ let delta_x = delta_x / zoom;
3789+
3648 let monitors = match &mut self.monitor_set {3790 let monitors = match &mut self.monitor_set {
3649 MonitorSet::Normal { monitors, .. } => monitors,3791 MonitorSet::Normal { monitors, .. } => monitors,
3650 MonitorSet::NoOutputs { .. } => return None,3792 MonitorSet::NoOutputs { .. } => return None,
@@ -3684,6 +3826,77 @@ impl<W: LayoutElement> Layout<W> {
3684 None3826 None
3685 }3827 }
3686 3828
3829+ pub fn overview_gesture_begin(&mut self) {
3830+ self.overview_open = true;
3831+
3832+ let value = self.overview_progress.take().map_or(0., |p| p.value());
3833+ let gesture = OverviewGesture {
3834+ tracker: SwipeTracker::new(),
3835+ start: value,
3836+ value,
3837+ };
3838+ self.overview_progress = Some(OverviewProgress::Gesture(gesture));
3839+
3840+ self.set_monitors_overview_state();
3841+ }
3842+
3843+ pub fn overview_gesture_update(&mut self, delta_y: f64, timestamp: Duration) -> Option<bool> {
3844+ let Some(OverviewProgress::Gesture(gesture)) = &mut self.overview_progress else {
3845+ return None;
3846+ };
3847+
3848+ gesture.tracker.push(delta_y, timestamp);
3849+
3850+ let total_height = OVERVIEW_GESTURE_MOVEMENT;
3851+ let pos = gesture.tracker.pos() / total_height;
3852+ let new_value = gesture.start + pos;
3853+ let new_value = OVERVIEW_GESTURE_RUBBER_BAND.clamp(0., 1., new_value);
3854+
3855+ if gesture.value == new_value {
3856+ return Some(false);
3857+ }
3858+
3859+ gesture.value = new_value;
3860+ self.set_monitors_overview_state();
3861+
3862+ Some(true)
3863+ }
3864+
3865+ pub fn overview_gesture_end(&mut self) -> bool {
3866+ let Some(OverviewProgress::Gesture(gesture)) = &mut self.overview_progress else {
3867+ return false;
3868+ };
3869+
3870+ // Take into account any idle time between the last event and now.
3871+ let now = self.clock.now_unadjusted();
3872+ gesture.tracker.push(0., now);
3873+
3874+ let total_height = OVERVIEW_GESTURE_MOVEMENT;
3875+
3876+ let mut velocity = gesture.tracker.velocity() / total_height;
3877+ let current_pos = gesture.tracker.pos() / total_height;
3878+ let pos = gesture.tracker.projected_end_pos() / total_height;
3879+
3880+ let new_value = gesture.start + pos;
3881+ let new_value = new_value.clamp(0., 1.).round();
3882+
3883+ velocity *=
3884+ OVERVIEW_GESTURE_RUBBER_BAND.clamp_derivative(0., 1., gesture.start + current_pos);
3885+
3886+ self.overview_open = new_value == 1.;
3887+ self.overview_progress = Some(OverviewProgress::Animation(Animation::new(
3888+ self.clock.clone(),
3889+ gesture.value,
3890+ new_value,
3891+ velocity,
3892+ self.options.animations.overview_open_close.0,
3893+ )));
3894+
3895+ self.set_monitors_overview_state();
3896+
3897+ true
3898+ }
3899+
3687 pub fn interactive_move_begin(3900 pub fn interactive_move_begin(
3688 &mut self,3901 &mut self,
3689 window_id: W::Id,3902 window_id: W::Id,
@@ -3710,6 +3923,8 @@ impl<W: LayoutElement> Layout<W> {
3710 return false;3923 return false;
3711 }3924 }
3712 3925
3926+ let zoom = mon.overview_zoom();
3927+
3713 let is_floating = ws.is_floating(&window_id);3928 let is_floating = ws.is_floating(&window_id);
3714 let (tile, tile_offset, _visible) = ws3929 let (tile, tile_offset, _visible) = ws
3715 .tiles_with_render_positions()3930 .tiles_with_render_positions()
@@ -3717,10 +3932,11 @@ impl<W: LayoutElement> Layout<W> {
3717 .unwrap();3932 .unwrap();
3718 let window_offset = tile.window_loc();3933 let window_offset = tile.window_loc();
3719 3934
3720- let tile_pos = ws_geo.loc + tile_offset;3935+ let tile_pos = ws_geo.loc + tile_offset.upscale(zoom);
3721 3936
3722- let pointer_offset_within_window = start_pos_within_output - tile_pos - window_offset;3937+ let pointer_offset_within_window =
3723- let window_size = tile.window_size();3938+ start_pos_within_output - tile_pos - window_offset.upscale(zoom);
3939+ let window_size = tile.window_size().upscale(zoom);
3724 let pointer_ratio_within_window = (3940 let pointer_ratio_within_window = (
3725 f64::clamp(pointer_offset_within_window.x / window_size.w, 0., 1.),3941 f64::clamp(pointer_offset_within_window.x / window_size.w, 0., 1.),
3726 f64::clamp(pointer_offset_within_window.y / window_size.h, 0., 1.),3942 f64::clamp(pointer_offset_within_window.y / window_size.h, 0., 1.),
@@ -3768,6 +3984,9 @@ impl<W: LayoutElement> Layout<W> {
3768 return false;3984 return false;
3769 }3985 }
3770 3986
3987+ let zoom = self.overview_zoom();
3988+ let delta = delta.downscale(zoom);
3989+
3771 pointer_delta += delta;3990 pointer_delta += delta;
3772 3991
3773 let (cx, cy) = (pointer_delta.x, pointer_delta.y);3992 let (cx, cy) = (pointer_delta.x, pointer_delta.y);
@@ -3824,7 +4043,8 @@ impl<W: LayoutElement> Layout<W> {
3824 .find(|(tile, _, _)| tile.window().id() == window)4043 .find(|(tile, _, _)| tile.window().id() == window)
3825 .unwrap();4044 .unwrap();
3826 4045
3827- tile_pos = Some(ws_geo.loc + tile_offset);4046+ let zoom = mon.overview_zoom();
4047+ tile_pos = Some((ws_geo.loc + tile_offset.upscale(zoom), zoom));
3828 }4048 }
3829 }4049 }
3830 }4050 }
@@ -3903,9 +4123,10 @@ impl<W: LayoutElement> Layout<W> {
3903 pointer_ratio_within_window,4123 pointer_ratio_within_window,
3904 };4124 };
3905 4125
3906- if let Some(tile_pos) = tile_pos {4126+ if let Some((tile_pos, zoom)) = tile_pos {
3907- let new_tile_pos = data.tile_render_location();4127+ let new_tile_pos = data.tile_render_location(zoom);
3908- data.tile.animate_move_from(tile_pos - new_tile_pos);4128+ data.tile
4129+ .animate_move_from((tile_pos - new_tile_pos).downscale(zoom));
3909 }4130 }
3910 4131
3911 self.interactive_move = Some(InteractiveMoveState::Moving(data));4132 self.interactive_move = Some(InteractiveMoveState::Moving(data));
@@ -3960,12 +4181,16 @@ impl<W: LayoutElement> Layout<W> {
3960 unreachable!()4181 unreachable!()
3961 };4182 };
3962 4183
4184+ let mut ws_id = None;
3963 for ws in self.workspaces_mut() {4185 for ws in self.workspaces_mut() {
4186+ let id = ws.id();
3964 if let Some(tile) = ws.tiles_mut().find(|tile| *tile.window().id() == window_id)4187 if let Some(tile) = ws.tiles_mut().find(|tile| *tile.window().id() == window_id)
3965 {4188 {
3966 let offset = tile.interactive_move_offset;4189 let offset = tile.interactive_move_offset;
3967 tile.interactive_move_offset = Point::from((0., 0.));4190 tile.interactive_move_offset = Point::from((0., 0.));
3968 tile.animate_move_from(offset);4191 tile.animate_move_from(offset);
4192+
4193+ ws_id = Some(id);
3969 }4194 }
3970 4195
3971 // Unlock the view on the workspaces, but if the moved window was active,4196 // Unlock the view on the workspaces, but if the moved window was active,
@@ -3980,6 +4205,32 @@ impl<W: LayoutElement> Layout<W> {
3980 }4205 }
3981 }4206 }
3982 4207
4208+ // In the overview, we want to click on a window to focus it, and also to
4209+ // click-and-drag to move the window. The way we handle this is by always starting
4210+ // the interactive move (to get frozen view), then, when in the overview, *not*
4211+ // calling interactive_move_update() until the cursor moves far enough. This means
4212+ // that if we "just click" then we end up in this branch with state == Starting.
4213+ // Close the overview in this case.
4214+ if self.overview_open {
4215+ let ws_id = ws_id.unwrap();
4216+ if let MonitorSet::Normal { monitors, .. } = &mut self.monitor_set {
4217+ for mon in monitors {
4218+ if let Some(ws_idx) =
4219+ mon.workspaces.iter().position(|ws| ws.id() == ws_id)
4220+ {
4221+ mon.activate_workspace_with_anim_config(
4222+ ws_idx,
4223+ Some(self.options.animations.overview_open_close.0),
4224+ );
4225+ break;
4226+ }
4227+ }
4228+ }
4229+
4230+ self.activate_window(&window_id);
4231+ self.close_overview();
4232+ }
4233+
3983 return;4234 return;
3984 }4235 }
3985 InteractiveMoveState::Moving(move_) => move_,4236 InteractiveMoveState::Moving(move_) => move_,
@@ -4007,20 +4258,28 @@ impl<W: LayoutElement> Layout<W> {
4007 );4258 );
4008 }4259 }
4009 4260
4261+ // Dragging in the overview shouldn't switch the workspace and so on.
4262+ let activate = if self.overview_open {
4263+ ActivateWindow::No
4264+ } else {
4265+ ActivateWindow::Yes
4266+ };
4267+
4010 match &mut self.monitor_set {4268 match &mut self.monitor_set {
4011 MonitorSet::Normal {4269 MonitorSet::Normal {
4012 monitors,4270 monitors,
4013 active_monitor_idx,4271 active_monitor_idx,
4014 ..4272 ..
4015 } => {4273 } => {
4016- let (mon, ws_idx, position, offset) = if let Some(mon) =4274+ let (mon, ws_idx, position, offset, zoom) = if let Some(mon) =
4017 monitors.iter_mut().find(|mon| mon.output == move_.output)4275 monitors.iter_mut().find(|mon| mon.output == move_.output)
4018 {4276 {
4277+ let zoom = mon.overview_zoom();
4278+
4019 let (ws, ws_geo) = mon4279 let (ws, ws_geo) = mon
4020 .workspace_under(move_.pointer_pos_within_output)4280 .workspace_under(move_.pointer_pos_within_output)
4021 // If the pointer is somehow outside the move output and a workspace switch4281 // If the pointer is somehow outside the move output and a workspace switch
4022- // is in progress, this won't necessarily do the expected thing, but also4282+ // is in progress, this won't necessarily do the expected thing.
4023- // that is not really supposed to happen so eh?
4024 .unwrap_or_else(|| mon.workspaces_with_render_geo().next().unwrap());4283 .unwrap_or_else(|| mon.workspaces_with_render_geo().next().unwrap());
4025 4284
4026 let ws_id = ws.id();4285 let ws_id = ws.id();
@@ -4033,14 +4292,16 @@ impl<W: LayoutElement> Layout<W> {
4033 let position = if move_.is_floating {4292 let position = if move_.is_floating {
4034 InsertPosition::Floating4293 InsertPosition::Floating
4035 } else {4294 } else {
4036- let pos_within_workspace = move_.pointer_pos_within_output - ws_geo.loc;4295+ let pos_within_workspace =
4296+ (move_.pointer_pos_within_output - ws_geo.loc).downscale(zoom);
4037 let ws = &mut mon.workspaces[ws_idx];4297 let ws = &mut mon.workspaces[ws_idx];
4038 ws.scrolling_insert_position(pos_within_workspace)4298 ws.scrolling_insert_position(pos_within_workspace)
4039 };4299 };
4040 4300
4041- (mon, ws_idx, position, ws_geo.loc)4301+ (mon, ws_idx, position, ws_geo.loc, zoom)
4042 } else {4302 } else {
4043 let mon = &mut monitors[*active_monitor_idx];4303 let mon = &mut monitors[*active_monitor_idx];
4304+ let zoom = mon.overview_zoom();
4044 // No point in trying to use the pointer position on the wrong output.4305 // No point in trying to use the pointer position on the wrong output.
4045 let (ws, ws_geo) = mon.workspaces_with_render_geo().next().unwrap();4306 let (ws, ws_geo) = mon.workspaces_with_render_geo().next().unwrap();
4046 4307
@@ -4056,11 +4317,12 @@ impl<W: LayoutElement> Layout<W> {
4056 .iter_mut()4317 .iter_mut()
4057 .position(|ws| ws.id() == ws_id)4318 .position(|ws| ws.id() == ws_id)
4058 .unwrap();4319 .unwrap();
4059- (mon, ws_idx, position, ws_geo.loc)4320+
4321+ (mon, ws_idx, position, ws_geo.loc, zoom)
4060 };4322 };
4061 4323
4062 let win_id = move_.tile.window().id().clone();4324 let win_id = move_.tile.window().id().clone();
4063- let window_render_loc = move_.tile_render_location() + move_.tile.window_loc();4325+ let window_render_loc = move_.tile_render_location(zoom) + move_.tile.window_loc();
4064 4326
4065 match position {4327 match position {
4066 InsertPosition::NewColumn(column_idx) => {4328 InsertPosition::NewColumn(column_idx) => {
@@ -4071,7 +4333,7 @@ impl<W: LayoutElement> Layout<W> {
4071 id: ws_id,4333 id: ws_id,
4072 column_idx: Some(column_idx),4334 column_idx: Some(column_idx),
4073 },4335 },
4074- ActivateWindow::Yes,4336+ activate,
4075 move_.width,4337 move_.width,
4076 move_.is_full_width,4338 move_.is_full_width,
4077 false,4339 false,
@@ -4083,13 +4345,15 @@ impl<W: LayoutElement> Layout<W> {
4083 column_idx,4345 column_idx,
4084 Some(tile_idx),4346 Some(tile_idx),
4085 move_.tile,4347 move_.tile,
4086- true,4348+ activate == ActivateWindow::Yes,
4087 );4349 );
4088 }4350 }
4089 InsertPosition::Floating => {4351 InsertPosition::Floating => {
4090- let pos = move_.tile_render_location() - offset;4352+ let tile_render_loc = move_.tile_render_location(zoom);
4091 4353
4092 let mut tile = move_.tile;4354 let mut tile = move_.tile;
4355+
4356+ let pos = (tile_render_loc - offset).downscale(zoom);
4093 let pos = mon.workspaces[ws_idx].floating_logical_to_size_frac(pos);4357 let pos = mon.workspaces[ws_idx].floating_logical_to_size_frac(pos);
4094 tile.floating_pos = Some(pos);4358 tile.floating_pos = Some(pos);
4095 4359
@@ -4106,7 +4370,7 @@ impl<W: LayoutElement> Layout<W> {
4106 id: ws_id,4370 id: ws_id,
4107 column_idx: None,4371 column_idx: None,
4108 },4372 },
4109- ActivateWindow::Yes,4373+ activate,
4110 move_.width,4374 move_.width,
4111 move_.is_full_width,4375 move_.is_full_width,
4112 true,4376 true,
@@ -4115,15 +4379,18 @@ impl<W: LayoutElement> Layout<W> {
4115 }4379 }
4116 4380
4117 // needed because empty_workspace_above_first could have modified the idx4381 // needed because empty_workspace_above_first could have modified the idx
4118- let ws_idx = mon.active_workspace_idx();4382+ let (tile, tile_render_loc, ws_geo) = mon
4119- let ws = &mut mon.workspaces[ws_idx];4383+ .workspaces_with_render_geo_mut()
4120- let (tile, tile_render_loc) = ws4384+ .find_map(|(ws, geo)| {
4121- .tiles_with_render_positions_mut(false)4385+ ws.tiles_with_render_positions_mut(false)
4122- .find(|(tile, _)| tile.window().id() == &win_id)4386+ .find(|(tile, _)| tile.window().id() == &win_id)
4387+ .map(|(tile, tile_render_loc)| (tile, tile_render_loc, geo))
4388+ })
4123 .unwrap();4389 .unwrap();
4124- let new_window_render_loc = offset + tile_render_loc + tile.window_loc();4390+ let new_window_render_loc =
4391+ ws_geo.loc + (tile_render_loc + tile.window_loc()).upscale(zoom);
4125 4392
4126- tile.animate_move_from(window_render_loc - new_window_render_loc);4393+ tile.animate_move_from((window_render_loc - new_window_render_loc).downscale(zoom));
4127 }4394 }
4128 MonitorSet::NoOutputs { workspaces, .. } => {4395 MonitorSet::NoOutputs { workspaces, .. } => {
4129 if workspaces.is_empty() {4396 if workspaces.is_empty() {
@@ -4138,7 +4405,7 @@ impl<W: LayoutElement> Layout<W> {
4138 ws.add_tile(4405 ws.add_tile(
4139 move_.tile,4406 move_.tile,
4140 WorkspaceAddWindowTarget::Auto,4407 WorkspaceAddWindowTarget::Auto,
4141- ActivateWindow::Yes,4408+ activate,
4142 move_.width,4409 move_.width,
4143 move_.is_full_width,4410 move_.is_full_width,
4144 move_.is_floating,4411 move_.is_floating,
@@ -4376,6 +4643,60 @@ impl<W: LayoutElement> Layout<W> {
4376 self.unname_workspace_by_id(id);4643 self.unname_workspace_by_id(id);
4377 }4644 }
4378 4645
4646+ pub fn set_monitors_overview_state(&mut self) {
4647+ let MonitorSet::Normal { monitors, .. } = &mut self.monitor_set else {
4648+ return;
4649+ };
4650+
4651+ for mon in monitors {
4652+ mon.overview_open = self.overview_open;
4653+ mon.set_overview_progress(self.overview_progress.as_ref());
4654+ }
4655+ }
4656+
4657+ pub fn toggle_overview(&mut self) {
4658+ self.overview_open = !self.overview_open;
4659+
4660+ let from = self.overview_progress.take().map_or(0., |p| p.value());
4661+ let to = if self.overview_open { 1. } else { 0. };
4662+
4663+ self.overview_progress = Some(OverviewProgress::Animation(Animation::new(
4664+ self.clock.clone(),
4665+ from,
4666+ to,
4667+ 0.,
4668+ self.options.animations.overview_open_close.0,
4669+ )));
4670+
4671+ self.set_monitors_overview_state();
4672+ }
4673+
4674+ pub fn open_overview(&mut self) -> bool {
4675+ if self.overview_open {
4676+ return false;
4677+ }
4678+
4679+ self.toggle_overview();
4680+ true
4681+ }
4682+
4683+ pub fn close_overview(&mut self) -> bool {
4684+ if !self.overview_open {
4685+ return false;
4686+ }
4687+
4688+ self.toggle_overview();
4689+ true
4690+ }
4691+
4692+ pub fn toggle_overview_to_workspace(&mut self, ws_idx: usize) {
4693+ let config = self.options.animations.overview_open_close.0;
4694+ if let Some(mon) = self.active_monitor() {
4695+ mon.activate_workspace_with_anim_config(ws_idx, Some(config));
4696+ }
4697+ self.toggle_overview();
4698+ }
4699+
4379 pub fn start_open_animation_for_window(&mut self, window: &W::Id) {4700 pub fn start_open_animation_for_window(&mut self, window: &W::Id) {
4380 if let Some(InteractiveMoveState::Moving(move_)) = &self.interactive_move {4701 if let Some(InteractiveMoveState::Moving(move_)) = &self.interactive_move {
4381 if move_.tile.window().id() == window {4702 if move_.tile.window().id() == window {
@@ -4460,12 +4781,14 @@ impl<W: LayoutElement> Layout<W> {
4460 ) {4781 ) {
4461 let _span = tracy_client::span!("Layout::start_close_animation_for_window");4782 let _span = tracy_client::span!("Layout::start_close_animation_for_window");
4462 4783
4784+ let zoom = self.overview_zoom();
4785+
4463 if let Some(InteractiveMoveState::Moving(move_)) = &mut self.interactive_move {4786 if let Some(InteractiveMoveState::Moving(move_)) = &mut self.interactive_move {
4464 if move_.tile.window().id() == window {4787 if move_.tile.window().id() == window {
4465 let Some(snapshot) = move_.tile.take_unmap_snapshot() else {4788 let Some(snapshot) = move_.tile.take_unmap_snapshot() else {
4466 return;4789 return;
4467 };4790 };
4468- let tile_pos = move_.tile_render_location();4791+ let tile_pos = move_.tile_render_location(zoom);
4469 let tile_size = move_.tile.tile_size();4792 let tile_size = move_.tile.tile_size();
4470 4793
4471 let output = move_.output.clone();4794 let output = move_.output.clone();
@@ -4516,7 +4839,7 @@ impl<W: LayoutElement> Layout<W> {
4516 renderer: &mut R,4839 renderer: &mut R,
4517 output: &Output,4840 output: &Output,
4518 target: RenderTarget,4841 target: RenderTarget,
4519- ) -> impl Iterator<Item = TileRenderElement<R>> + 'a {4842+ ) -> impl Iterator<Item = RescaleRenderElement<TileRenderElement<R>>> + 'a {
4520 if self.update_render_elements_time != self.clock.now() {4843 if self.update_render_elements_time != self.clock.now() {
4521 error!("clock moved between updating render elements and rendering");4844 error!("clock moved between updating render elements and rendering");
4522 }4845 }
@@ -4525,8 +4848,20 @@ impl<W: LayoutElement> Layout<W> {
4525 4848
4526 if let Some(InteractiveMoveState::Moving(move_)) = &self.interactive_move {4849 if let Some(InteractiveMoveState::Moving(move_)) = &self.interactive_move {
4527 if &move_.output == output {4850 if &move_.output == output {
4528- let location = move_.tile_render_location();4851+ let scale = Scale::from(move_.output.current_scale().fractional_scale());
4529- rv = Some(move_.tile.render(renderer, location, true, target));4852+ let zoom = self.overview_zoom();
4853+ let location = move_.tile_render_location(zoom);
4854+ let iter = move_
4855+ .tile
4856+ .render(renderer, location, true, target)
4857+ .map(move |elem| {
4858+ RescaleRenderElement::from_element(
4859+ elem,
4860+ location.to_physical_precise_round(scale),
4861+ zoom,
4862+ )
4863+ });
4864+ rv = Some(iter);
4530 }4865 }
4531 }4866 }
4532 4867
@@ -4589,7 +4924,7 @@ impl<W: LayoutElement> Layout<W> {
4589 }4924 }
4590 } else {4925 } else {
4591 // Cancel the view offset gesture after workspace switches, moves, etc.4926 // Cancel the view offset gesture after workspace switches, moves, etc.
4592- if ws_idx != mon.active_workspace_idx {4927+ if !self.overview_open && ws_idx != mon.active_workspace_idx {
4593 ws.view_offset_gesture_end(None);4928 ws.view_offset_gesture_end(None);
4594 }4929 }
4595 }4930 }
@@ -4684,6 +5019,10 @@ impl<W: LayoutElement> Layout<W> {
4684 self.windows().any(|(_, win)| win.id() == window)5019 self.windows().any(|(_, win)| win.id() == window)
4685 }5020 }
4686 5021
5022+ pub fn is_overview_open(&self) -> bool {
5023+ self.overview_open
5024+ }
5025+
4687 fn resolve_scrolling_width(&self, window: &W, width: Option<PresetSize>) -> ColumnWidth {5026 fn resolve_scrolling_width(&self, window: &W, width: Option<PresetSize>) -> ColumnWidth {
4688 let width = width.unwrap_or_else(|| PresetSize::Fixed(window.size().w));5027 let width = width.unwrap_or_else(|| PresetSize::Fixed(window.size().w));
4689 match width {5028 match width {
@@ -4709,3 +5048,14 @@ impl<W: LayoutElement> Default for MonitorSet<W> {
4709 Self::NoOutputs { workspaces: vec![] }5048 Self::NoOutputs { workspaces: vec![] }
4710 }5049 }
4711 }5050 }
5051+
5052+fn compute_overview_zoom(options: &Options, overview_progress: Option<f64>) -> f64 {
5053+ // Clamp to some sane values.
5054+ let zoom = options.overview.zoom.0.clamp(0.0001, 0.75);
5055+
5056+ if let Some(p) = overview_progress {
5057+ (1. - p * (1. - zoom)).max(0.0001)
5058+ } else {
5059+ 1.
5060+ }
5061+}
src/layout/monitor.rsmodified+216 -20
@@ -5,7 +5,7 @@ use std::time::Duration;
5 5
6 use niri_config::CornerRadius;6 use niri_config::CornerRadius;
7 use smithay::backend::renderer::element::utils::{7 use smithay::backend::renderer::element::utils::{
8- CropRenderElement, Relocate, RelocateRenderElement,8+ CropRenderElement, Relocate, RelocateRenderElement, RescaleRenderElement,
9 };9 };
10 use smithay::output::Output;10 use smithay::output::Output;
11 use smithay::utils::{Logical, Point, Rectangle, Size};11 use smithay::utils::{Logical, Point, Rectangle, Size};
@@ -17,11 +17,12 @@ use super::workspace::{
17 compute_working_area, OutputId, Workspace, WorkspaceAddWindowTarget, WorkspaceId,17 compute_working_area, OutputId, Workspace, WorkspaceAddWindowTarget, WorkspaceId,
18 WorkspaceRenderElement,18 WorkspaceRenderElement,
19 };19 };
20-use super::{ActivateWindow, HitType, LayoutElement, Options};20+use super::{compute_overview_zoom, ActivateWindow, HitType, LayoutElement, Options};
21 use crate::animation::{Animation, Clock};21 use crate::animation::{Animation, Clock};
22 use crate::input::swipe_tracker::SwipeTracker;22 use crate::input::swipe_tracker::SwipeTracker;
23 use crate::niri_render_elements;23 use crate::niri_render_elements;
24 use crate::render_helpers::renderer::NiriRenderer;24 use crate::render_helpers::renderer::NiriRenderer;
25+use crate::render_helpers::shadow::ShadowRenderElement;
25 use crate::render_helpers::RenderTarget;26 use crate::render_helpers::RenderTarget;
26 use crate::rubber_band::RubberBand;27 use crate::rubber_band::RubberBand;
27 use crate::utils::transaction::Transaction;28 use crate::utils::transaction::Transaction;
@@ -68,6 +69,10 @@ pub struct Monitor<W: LayoutElement> {
68 insert_hint_element: InsertHintElement,69 insert_hint_element: InsertHintElement,
69 /// Location to render the insert hint element.70 /// Location to render the insert hint element.
70 insert_hint_render_loc: Option<InsertHintRenderLoc>,71 insert_hint_render_loc: Option<InsertHintRenderLoc>,
72+ /// Whether the overview is open.
73+ pub(super) overview_open: bool,
74+ /// Progress of the overview zoom animation, 1 is fully in overview.
75+ overview_progress: Option<OverviewProgress>,
71 /// Clock for driving animations.76 /// Clock for driving animations.
72 pub(super) clock: Clock,77 pub(super) clock: Clock,
73 /// Configurable properties of the layout.78 /// Configurable properties of the layout.
@@ -94,6 +99,8 @@ pub struct WorkspaceSwitchGesture {
94 tracker: SwipeTracker,99 tracker: SwipeTracker,
95 /// Whether the gesture is controlled by the touchpad.100 /// Whether the gesture is controlled by the touchpad.
96 is_touchpad: bool,101 is_touchpad: bool,
102+ /// Whether the gesture is clamped to +-1 workspace around the center.
103+ is_clamped: bool,
97 }104 }
98 105
99 #[derive(Debug, Clone, Copy, PartialEq, Eq)]106 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -116,6 +123,12 @@ struct InsertHintRenderLoc {
116 location: Point<f64, Logical>,123 location: Point<f64, Logical>,
117 }124 }
118 125
126+#[derive(Debug)]
127+pub(super) enum OverviewProgress {
128+ Animation(Animation),
129+ Value(f64),
130+}
131+
119 /// Where to put a newly added window.132 /// Where to put a newly added window.
120 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]133 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
121 pub enum MonitorAddWindowTarget<'a, W: LayoutElement> {134 pub enum MonitorAddWindowTarget<'a, W: LayoutElement> {
@@ -137,10 +150,12 @@ niri_render_elements! {
137 MonitorInnerRenderElement<R> => {150 MonitorInnerRenderElement<R> => {
138 Workspace = CropRenderElement<WorkspaceRenderElement<R>>,151 Workspace = CropRenderElement<WorkspaceRenderElement<R>>,
139 InsertHint = CropRenderElement<InsertHintRenderElement>,152 InsertHint = CropRenderElement<InsertHintRenderElement>,
153+ Shadow = ShadowRenderElement,
140 }154 }
141 }155 }
142 156
143-pub type MonitorRenderElement<R> = RelocateRenderElement<MonitorInnerRenderElement<R>>;157+pub type MonitorRenderElement<R> =
158+ RelocateRenderElement<RescaleRenderElement<MonitorInnerRenderElement<R>>>;
144 159
145 impl WorkspaceSwitch {160 impl WorkspaceSwitch {
146 pub fn current_idx(&self) -> f64 {161 pub fn current_idx(&self) -> f64 {
@@ -183,9 +198,38 @@ impl WorkspaceSwitch {
183 198
184 impl WorkspaceSwitchGesture {199 impl WorkspaceSwitchGesture {
185 fn min_max(&self, workspace_count: usize) -> (f64, f64) {200 fn min_max(&self, workspace_count: usize) -> (f64, f64) {
186- let min = self.center_idx.saturating_sub(1) as f64;201+ if self.is_clamped {
187- let max = (self.center_idx + 1).min(workspace_count - 1) as f64;202+ let min = self.center_idx.saturating_sub(1) as f64;
188- (min, max)203+ let max = (self.center_idx + 1).min(workspace_count - 1) as f64;
204+ (min, max)
205+ } else {
206+ (0., (workspace_count - 1) as f64)
207+ }
208+ }
209+}
210+
211+impl OverviewProgress {
212+ pub fn value(&self) -> f64 {
213+ match self {
214+ OverviewProgress::Animation(anim) => anim.value(),
215+ OverviewProgress::Value(v) => *v,
216+ }
217+ }
218+
219+ pub fn clamped_value(&self) -> f64 {
220+ match self {
221+ OverviewProgress::Animation(anim) => anim.clamped_value(),
222+ OverviewProgress::Value(v) => *v,
223+ }
224+ }
225+}
226+
227+impl From<&super::OverviewProgress> for OverviewProgress {
228+ fn from(value: &super::OverviewProgress) -> Self {
229+ match value {
230+ super::OverviewProgress::Animation(anim) => Self::Animation(anim.clone()),
231+ super::OverviewProgress::Gesture(gesture) => Self::Value(gesture.value),
232+ }
189 }233 }
190 }234 }
191 235
@@ -212,6 +256,8 @@ impl<W: LayoutElement> Monitor<W> {
212 insert_hint: None,256 insert_hint: None,
213 insert_hint_element: InsertHintElement::new(options.insert_hint),257 insert_hint_element: InsertHintElement::new(options.insert_hint),
214 insert_hint_render_loc: None,258 insert_hint_render_loc: None,
259+ overview_open: false,
260+ overview_progress: None,
215 workspace_switch: None,261 workspace_switch: None,
216 clock,262 clock,
217 options,263 options,
@@ -769,7 +815,9 @@ impl<W: LayoutElement> Monitor<W> {
769 815
770 // Make sure the hint is at least partially visible.816 // Make sure the hint is at least partially visible.
771 if matches!(hint.position, InsertPosition::NewColumn(_)) {817 if matches!(hint.position, InsertPosition::NewColumn(_)) {
818+ let zoom = self.overview_zoom();
772 let geo = insert_hint_ws_geo.unwrap();819 let geo = insert_hint_ws_geo.unwrap();
820+ let geo = geo.downscale(zoom);
773 821
774 area.loc.x = area.loc.x.max(-geo.loc.x - area.size.w / 2.);822 area.loc.x = area.loc.x.max(-geo.loc.x - area.size.w / 2.);
775 area.loc.x = area.loc.x.min(geo.loc.x + geo.size.w - area.size.w / 2.);823 area.loc.x = area.loc.x.min(geo.loc.x + geo.size.w - area.size.w / 2.);
@@ -942,6 +990,10 @@ impl<W: LayoutElement> Monitor<W> {
942 ///990 ///
943 /// During animations, assumes the final view position.991 /// During animations, assumes the final view position.
944 pub fn active_tile_visual_rectangle(&self) -> Option<Rectangle<f64, Logical>> {992 pub fn active_tile_visual_rectangle(&self) -> Option<Rectangle<f64, Logical>> {
993+ if self.overview_open {
994+ return None;
995+ }
996+
945 self.active_workspace_ref().active_tile_visual_rectangle()997 self.active_workspace_ref().active_tile_visual_rectangle()
946 }998 }
947 999
@@ -962,7 +1014,100 @@ impl<W: LayoutElement> Monitor<W> {
962 self.workspace_size(zoom) + Size::from((0., gap))1014 self.workspace_size(zoom) + Size::from((0., gap))
963 }1015 }
964 1016
1017+ pub fn overview_zoom(&self) -> f64 {
1018+ let progress = self.overview_progress.as_ref().map(|p| p.value());
1019+ compute_overview_zoom(&self.options, progress)
1020+ }
1021+
1022+ pub(super) fn set_overview_progress(&mut self, progress: Option<&super::OverviewProgress>) {
1023+ let prev_render_idx = self.workspace_render_idx();
1024+ self.overview_progress = progress.map(OverviewProgress::from);
1025+ let new_render_idx = self.workspace_render_idx();
1026+
1027+ // If the view jumped (can happen when going from corrected to uncorrected render_idx, for
1028+ // example when toggling the overview in the middle of an overview animation), then restart
1029+ // the workspace switch to avoid jumps.
1030+ if prev_render_idx != new_render_idx {
1031+ if let Some(WorkspaceSwitch::Animation(anim)) = &mut self.workspace_switch {
1032+ // FIXME: maintain velocity.
1033+ *anim = anim.restarted(prev_render_idx, anim.to(), 0.);
1034+ }
1035+ }
1036+ }
1037+
1038+ #[cfg(test)]
1039+ pub(super) fn overview_progress_value(&self) -> Option<f64> {
1040+ self.overview_progress.as_ref().map(|p| p.value())
1041+ }
1042+
965 pub fn workspace_render_idx(&self) -> f64 {1043 pub fn workspace_render_idx(&self) -> f64 {
1044+ // If workspace switch and overview progress are matching animations, then compute a
1045+ // correction term to make the movement appear monotonic.
1046+ if let (
1047+ Some(WorkspaceSwitch::Animation(switch_anim)),
1048+ Some(OverviewProgress::Animation(progress_anim)),
1049+ ) = (&self.workspace_switch, &self.overview_progress)
1050+ {
1051+ if switch_anim.start_time() == progress_anim.start_time()
1052+ && (switch_anim.duration().as_secs_f64() - progress_anim.duration().as_secs_f64())
1053+ .abs()
1054+ <= 0.001
1055+ {
1056+ #[rustfmt::skip]
1057+ // How this was derived:
1058+ //
1059+ // - Assume we're animating a zoom + switch. Consider switch "from" and "to".
1060+ // These are render_idx values, so first workspace to second would have switch
1061+ // from = 0. and to = 1. regardless of the zoom level.
1062+ //
1063+ // - At the start, the point at "from" is at Y = 0. We're moving the point at "to"
1064+ // to Y = 0. We want this to be a monotonic motion in apparent coordinates (after
1065+ // zoom).
1066+ //
1067+ // - Height at the start:
1068+ // from_height = (size.h + gap) * from_zoom.
1069+ //
1070+ // - Current height:
1071+ // current_height = (size.h + gap) * zoom.
1072+ //
1073+ // - We're moving the "to" point to Y = 0:
1074+ // to_y = 0.
1075+ //
1076+ // - The initial position of the point we're moving:
1077+ // from_y = (to - from) * from_height.
1078+ //
1079+ // - We want this point to travel monotonically in apparent coordinates:
1080+ // current_y = from_y + (to_y - from_y) * progress,
1081+ // where progress is from 0 to 1, equals to the animation progress (switch and
1082+ // zoom are the same since they are synchronized).
1083+ //
1084+ // - Derive the Y of the first workspace from this:
1085+ // first_y = current_y - to * current_height.
1086+ //
1087+ // Now, let's substitute and rearrange the terms.
1088+ //
1089+ // - current_y = from_y + (0 - (to - from) * from_height) * progress
1090+ // - progress = (switch_anim.value() - from) / (to - from)
1091+ // - current_y = from_y - (to - from) * from_height * (switch_anim.value() - from) / (to - from)
1092+ // - current_y = from_y - from_height * (switch_anim.value() - from)
1093+ // - first_y = from_y - from_height * (switch_anim.value() - from) - to * current_height
1094+ // - first_y = (to - from) * from_height - from_height * (switch_anim.value() - from) - to * current_height
1095+ // - first_y = to * from_height - switch_anim.value() * from_height - to * current_height
1096+ // - first_y = -switch_anim.value() * from_height + to * (from_height - current_height)
1097+ let from = progress_anim.from();
1098+ let from_zoom = compute_overview_zoom(&self.options, Some(from));
1099+ let from_ws_height_with_gap = self.workspace_size_with_gap(from_zoom).h;
1100+
1101+ let zoom = self.overview_zoom();
1102+ let ws_height_with_gap = self.workspace_size_with_gap(zoom).h;
1103+
1104+ let first_ws_y = -switch_anim.value() * from_ws_height_with_gap
1105+ + switch_anim.to() * (from_ws_height_with_gap - ws_height_with_gap);
1106+
1107+ return -first_ws_y / ws_height_with_gap;
1108+ }
1109+ };
1110+
966 if let Some(switch) = &self.workspace_switch {1111 if let Some(switch) = &self.workspace_switch {
967 switch.current_idx()1112 switch.current_idx()
968 } else {1113 } else {
@@ -972,19 +1117,24 @@ impl<W: LayoutElement> Monitor<W> {
972 1117
973 pub fn workspaces_render_geo(&self) -> impl Iterator<Item = Rectangle<f64, Logical>> {1118 pub fn workspaces_render_geo(&self) -> impl Iterator<Item = Rectangle<f64, Logical>> {
974 let scale = self.scale.fractional_scale();1119 let scale = self.scale.fractional_scale();
975- let zoom = 1.;1120+ let zoom = self.overview_zoom();
976 1121
977 let ws_size = self.workspace_size(zoom);1122 let ws_size = self.workspace_size(zoom);
978 let gap = self.workspace_gap(zoom);1123 let gap = self.workspace_gap(zoom);
979 let ws_height_with_gap = ws_size.h + gap;1124 let ws_height_with_gap = ws_size.h + gap;
980 1125
1126+ let static_offset = (self.view_size.to_point() - ws_size.to_point()).downscale(2.);
1127+ let static_offset = static_offset
1128+ .to_physical_precise_round(scale)
1129+ .to_logical(scale);
1130+
981 let first_ws_y = -self.workspace_render_idx() * ws_height_with_gap;1131 let first_ws_y = -self.workspace_render_idx() * ws_height_with_gap;
982 let first_ws_y = round_logical_in_physical(scale, first_ws_y);1132 let first_ws_y = round_logical_in_physical(scale, first_ws_y);
983 1133
984 // Return position for one-past-last workspace too.1134 // Return position for one-past-last workspace too.
985 (0..=self.workspaces.len()).map(move |idx| {1135 (0..=self.workspaces.len()).map(move |idx| {
986 let y = first_ws_y + idx as f64 * ws_height_with_gap;1136 let y = first_ws_y + idx as f64 * ws_height_with_gap;
987- let loc = Point::from((0., y));1137+ let loc = Point::from((0., y)) + static_offset;
988 Rectangle::new(loc, ws_size)1138 Rectangle::new(loc, ws_size)
989 })1139 })
990 }1140 }
@@ -1026,20 +1176,42 @@ impl<W: LayoutElement> Monitor<W> {
1026 Some((ws, geo))1176 Some((ws, geo))
1027 }1177 }
1028 1178
1179+ pub fn workspace_under_narrow(
1180+ &self,
1181+ pos_within_output: Point<f64, Logical>,
1182+ ) -> Option<&Workspace<W>> {
1183+ self.workspaces_with_render_geo()
1184+ .find_map(|(ws, geo)| geo.contains(pos_within_output).then_some(ws))
1185+ }
1186+
1029 pub fn window_under(&self, pos_within_output: Point<f64, Logical>) -> Option<(&W, HitType)> {1187 pub fn window_under(&self, pos_within_output: Point<f64, Logical>) -> Option<(&W, HitType)> {
1030 let (ws, geo) = self.workspace_under(pos_within_output)?;1188 let (ws, geo) = self.workspace_under(pos_within_output)?;
1031- let (win, hit) = ws.window_under(pos_within_output - geo.loc)?;1189+
1032- Some((win, hit.offset_win_pos(geo.loc)))1190+ if self.overview_progress.is_some() {
1191+ let zoom = self.overview_zoom();
1192+ let pos_within_workspace = (pos_within_output - geo.loc).downscale(zoom);
1193+ let (win, hit) = ws.window_under(pos_within_workspace)?;
1194+ // During the overview animation, we cannot do input hits because we cannot really
1195+ // represent scaled windows properly.
1196+ Some((win, hit.to_activate()))
1197+ } else {
1198+ let (win, hit) = ws.window_under(pos_within_output - geo.loc)?;
1199+ Some((win, hit.offset_win_pos(geo.loc)))
1200+ }
1033 }1201 }
1034 1202
1035 pub fn resize_edges_under(&self, pos_within_output: Point<f64, Logical>) -> Option<ResizeEdge> {1203 pub fn resize_edges_under(&self, pos_within_output: Point<f64, Logical>) -> Option<ResizeEdge> {
1204+ if self.overview_progress.is_some() {
1205+ return None;
1206+ }
1207+
1036 let (ws, geo) = self.workspace_under(pos_within_output)?;1208 let (ws, geo) = self.workspace_under(pos_within_output)?;
1037 ws.resize_edges_under(pos_within_output - geo.loc)1209 ws.resize_edges_under(pos_within_output - geo.loc)
1038 }1210 }
1039 1211
1040 pub fn render_above_top_layer(&self) -> bool {1212 pub fn render_above_top_layer(&self) -> bool {
1041 // Render above the top layer only if the view is stationary.1213 // Render above the top layer only if the view is stationary.
1042- if self.workspace_switch.is_some() {1214+ if self.workspace_switch.is_some() || self.overview_progress.is_some() {
1043 return false;1215 return false;
1044 }1216 }
1045 1217
@@ -1074,7 +1246,7 @@ impl<W: LayoutElement> Monitor<W> {
1074 // rendering for maximized GTK windows.1246 // rendering for maximized GTK windows.
1075 //1247 //
1076 // FIXME: use proper bounds after fixing the Crop element.1248 // FIXME: use proper bounds after fixing the Crop element.
1077- let crop_bounds = if self.workspace_switch.is_some() {1249+ let crop_bounds = if self.workspace_switch.is_some() || self.overview_progress.is_some() {
1078 Rectangle::new(1250 Rectangle::new(
1079 Point::from((-i32::MAX / 2, 0)),1251 Point::from((-i32::MAX / 2, 0)),
1080 Size::from((i32::MAX, height)),1252 Size::from((i32::MAX, height)),
@@ -1086,6 +1258,9 @@ impl<W: LayoutElement> Monitor<W> {
1086 )1258 )
1087 };1259 };
1088 1260
1261+ let zoom = self.overview_zoom();
1262+ let overview_clamped_progress = self.overview_progress.as_ref().map(|p| p.clamped_value());
1263+
1089 // Draw the insert hint.1264 // Draw the insert hint.
1090 let mut insert_hint = None;1265 let mut insert_hint = None;
1091 if !self.options.insert_hint.off {1266 if !self.options.insert_hint.off {
@@ -1109,6 +1284,13 @@ impl<W: LayoutElement> Monitor<W> {
1109 let floating = floating.filter_map(map_ws_contents);1284 let floating = floating.filter_map(map_ws_contents);
1110 let scrolling = scrolling.filter_map(map_ws_contents);1285 let scrolling = scrolling.filter_map(map_ws_contents);
1111 1286
1287+ let shadow = overview_clamped_progress.map(|value| {
1288+ ws.render_shadow(renderer)
1289+ .map(move |elem| elem.with_alpha(value.clamp(0., 1.) as f32))
1290+ .map(MonitorInnerRenderElement::Shadow)
1291+ });
1292+ let shadow = shadow.into_iter().flatten();
1293+
1112 let hint = if matches!(insert_hint, Some((hint_ws_id, _)) if hint_ws_id == ws.id()) {1294 let hint = if matches!(insert_hint, Some((hint_ws_id, _)) if hint_ws_id == ws.id()) {
1113 let iter = insert_hint.take().unwrap().1;1295 let iter = insert_hint.take().unwrap().1;
1114 let iter = iter.filter_map(move |elem| {1296 let iter = iter.filter_map(move |elem| {
@@ -1122,9 +1304,10 @@ impl<W: LayoutElement> Monitor<W> {
1122 };1304 };
1123 let hint = hint.into_iter().flatten();1305 let hint = hint.into_iter().flatten();
1124 1306
1125- let iter = floating.chain(hint).chain(scrolling);1307+ let iter = floating.chain(hint).chain(scrolling).chain(shadow);
1126 1308
1127 let iter = iter.map(move |elem| {1309 let iter = iter.map(move |elem| {
1310+ let elem = RescaleRenderElement::from_element(elem, Point::from((0, 0)), zoom);
1128 RelocateRenderElement::from_element(1311 RelocateRenderElement::from_element(
1129 elem,1312 elem,
1130 // The offset we get from workspaces_with_render_positions() is already1313 // The offset we get from workspaces_with_render_positions() is already
@@ -1149,6 +1332,7 @@ impl<W: LayoutElement> Monitor<W> {
1149 current_idx,1332 current_idx,
1150 tracker: SwipeTracker::new(),1333 tracker: SwipeTracker::new(),
1151 is_touchpad,1334 is_touchpad,
1335+ is_clamped: !self.overview_open,
1152 };1336 };
1153 self.workspace_switch = Some(WorkspaceSwitch::Gesture(gesture));1337 self.workspace_switch = Some(WorkspaceSwitch::Gesture(gesture));
1154 }1338 }
@@ -1167,6 +1351,7 @@ impl<W: LayoutElement> Monitor<W> {
1167 return None;1351 return None;
1168 }1352 }
1169 1353
1354+ let zoom = self.overview_zoom();
1170 let total_height = if gesture.is_touchpad {1355 let total_height = if gesture.is_touchpad {
1171 WORKSPACE_GESTURE_MOVEMENT1356 WORKSPACE_GESTURE_MOVEMENT
1172 } else {1357 } else {
@@ -1177,13 +1362,24 @@ impl<W: LayoutElement> Monitor<W> {
1177 return None;1362 return None;
1178 };1363 };
1179 1364
1365+ // Reduce the effect of zoom on the touchpad somewhat.
1366+ let delta_scale = if gesture.is_touchpad {
1367+ (zoom - 1.) / 2.5 + 1.
1368+ } else {
1369+ zoom
1370+ };
1371+
1372+ let delta_y = delta_y / delta_scale;
1373+ let mut rubber_band = WORKSPACE_GESTURE_RUBBER_BAND;
1374+ rubber_band.limit /= zoom;
1375+
1180 gesture.tracker.push(delta_y, timestamp);1376 gesture.tracker.push(delta_y, timestamp);
1181 1377
1182 let pos = gesture.tracker.pos() / total_height;1378 let pos = gesture.tracker.pos() / total_height;
1183 1379
1184 let (min, max) = gesture.min_max(self.workspaces.len());1380 let (min, max) = gesture.min_max(self.workspaces.len());
1185 let new_idx = gesture.start_idx + pos;1381 let new_idx = gesture.start_idx + pos;
1186- let new_idx = WORKSPACE_GESTURE_RUBBER_BAND.clamp(min, max, new_idx);1382+ let new_idx = rubber_band.clamp(min, max, new_idx);
1187 1383
1188 if gesture.current_idx == new_idx {1384 if gesture.current_idx == new_idx {
1189 return Some(false);1385 return Some(false);
@@ -1202,6 +1398,7 @@ impl<W: LayoutElement> Monitor<W> {
1202 return false;1398 return false;
1203 }1399 }
1204 1400
1401+ let zoom = self.overview_zoom();
1205 let total_height = if gesture.is_touchpad {1402 let total_height = if gesture.is_touchpad {
1206 WORKSPACE_GESTURE_MOVEMENT1403 WORKSPACE_GESTURE_MOVEMENT
1207 } else {1404 } else {
@@ -1216,6 +1413,9 @@ impl<W: LayoutElement> Monitor<W> {
1216 let now = self.clock.now_unadjusted();1413 let now = self.clock.now_unadjusted();
1217 gesture.tracker.push(0., now);1414 gesture.tracker.push(0., now);
1218 1415
1416+ let mut rubber_band = WORKSPACE_GESTURE_RUBBER_BAND;
1417+ rubber_band.limit /= zoom;
1418+
1219 let mut velocity = gesture.tracker.velocity() / total_height;1419 let mut velocity = gesture.tracker.velocity() / total_height;
1220 let current_pos = gesture.tracker.pos() / total_height;1420 let current_pos = gesture.tracker.pos() / total_height;
1221 let pos = gesture.tracker.projected_end_pos() / total_height;1421 let pos = gesture.tracker.projected_end_pos() / total_height;
@@ -1223,14 +1423,10 @@ impl<W: LayoutElement> Monitor<W> {
1223 let (min, max) = gesture.min_max(self.workspaces.len());1423 let (min, max) = gesture.min_max(self.workspaces.len());
1224 let new_idx = gesture.start_idx + pos;1424 let new_idx = gesture.start_idx + pos;
1225 1425
1226- let new_idx = WORKSPACE_GESTURE_RUBBER_BAND.clamp(min, max, new_idx);1426+ let new_idx = new_idx.clamp(min, max);
1227 let new_idx = new_idx.round() as usize;1427 let new_idx = new_idx.round() as usize;
1228 1428
1229- velocity *= WORKSPACE_GESTURE_RUBBER_BAND.clamp_derivative(1429+ velocity *= rubber_band.clamp_derivative(min, max, gesture.start_idx + current_pos);
1230- min,
1231- max,
1232- gesture.start_idx + current_pos,
1233- );
1234 1430
1235 self.previous_workspace_id = Some(self.workspaces[self.active_workspace_idx].id());1431 self.previous_workspace_id = Some(self.workspaces[self.active_workspace_idx].id());
1236 1432
src/layout/tests.rsmodified+20 -0
@@ -603,6 +603,13 @@ enum Op {
603 WorkspaceSwitchGestureEnd {603 WorkspaceSwitchGestureEnd {
604 is_touchpad: Option<bool>,604 is_touchpad: Option<bool>,
605 },605 },
606+ OverviewGestureBegin,
607+ OverviewGestureUpdate {
608+ #[proptest(strategy = "-400f64..400f64")]
609+ delta: f64,
610+ timestamp: Duration,
611+ },
612+ OverviewGestureEnd,
606 InteractiveMoveBegin {613 InteractiveMoveBegin {
607 #[proptest(strategy = "1..=5usize")]614 #[proptest(strategy = "1..=5usize")]
608 window: usize,615 window: usize,
@@ -658,6 +665,7 @@ enum Op {
658 #[proptest(strategy = "1..=5usize")]665 #[proptest(strategy = "1..=5usize")]
659 window: usize,666 window: usize,
660 },667 },
668+ ToggleOverview,
661 }669 }
662 670
663 impl Op {671 impl Op {
@@ -1387,6 +1395,15 @@ impl Op {
1387 Op::WorkspaceSwitchGestureEnd { is_touchpad } => {1395 Op::WorkspaceSwitchGestureEnd { is_touchpad } => {
1388 layout.workspace_switch_gesture_end(is_touchpad);1396 layout.workspace_switch_gesture_end(is_touchpad);
1389 }1397 }
1398+ Op::OverviewGestureBegin => {
1399+ layout.overview_gesture_begin();
1400+ }
1401+ Op::OverviewGestureUpdate { delta, timestamp } => {
1402+ layout.overview_gesture_update(delta, timestamp);
1403+ }
1404+ Op::OverviewGestureEnd => {
1405+ layout.overview_gesture_end();
1406+ }
1390 Op::InteractiveMoveBegin {1407 Op::InteractiveMoveBegin {
1391 window,1408 window,
1392 output_idx,1409 output_idx,
@@ -1440,6 +1457,9 @@ impl Op {
1440 Op::InteractiveResizeEnd { window } => {1457 Op::InteractiveResizeEnd { window } => {
1441 layout.interactive_resize_end(&window);1458 layout.interactive_resize_end(&window);
1442 }1459 }
1460+ Op::ToggleOverview => {
1461+ layout.toggle_overview();
1462+ }
1443 }1463 }
1444 }1464 }
1445 }1465 }
src/layout/workspace.rsmodified+51 -2
@@ -2,7 +2,10 @@ use std::cmp::max;
2 use std::rc::Rc;2 use std::rc::Rc;
3 use std::time::Duration;3 use std::time::Duration;
4 4
5-use niri_config::{CenterFocusedColumn, OutputName, PresetSize, Workspace as WorkspaceConfig};5+use niri_config::{
6+ CenterFocusedColumn, CornerRadius, FloatOrInt, OutputName, PresetSize,
7+ Workspace as WorkspaceConfig,
8+};
6 use niri_ipc::{ColumnDisplay, PositionChange, SizeChange};9 use niri_ipc::{ColumnDisplay, PositionChange, SizeChange};
7 use smithay::backend::renderer::gles::GlesRenderer;10 use smithay::backend::renderer::gles::GlesRenderer;
8 use smithay::desktop::{layer_map_for_output, Window};11 use smithay::desktop::{layer_map_for_output, Window};
@@ -17,6 +20,7 @@ use super::floating::{FloatingSpace, FloatingSpaceRenderElement};
17 use super::scrolling::{20 use super::scrolling::{
18 Column, ColumnWidth, ScrollDirection, ScrollingSpace, ScrollingSpaceRenderElement,21 Column, ColumnWidth, ScrollDirection, ScrollingSpace, ScrollingSpaceRenderElement,
19 };22 };
23+use super::shadow::Shadow;
20 use super::tile::{Tile, TileRenderSnapshot};24 use super::tile::{Tile, TileRenderSnapshot};
21 use super::{25 use super::{
22 ActivateWindow, HitType, InsertPosition, InteractiveResizeData, LayoutElement, Options,26 ActivateWindow, HitType, InsertPosition, InteractiveResizeData, LayoutElement, Options,
@@ -25,6 +29,7 @@ use super::{
25 use crate::animation::Clock;29 use crate::animation::Clock;
26 use crate::niri_render_elements;30 use crate::niri_render_elements;
27 use crate::render_helpers::renderer::NiriRenderer;31 use crate::render_helpers::renderer::NiriRenderer;
32+use crate::render_helpers::shadow::ShadowRenderElement;
28 use crate::render_helpers::RenderTarget;33 use crate::render_helpers::RenderTarget;
29 use crate::utils::id::IdCounter;34 use crate::utils::id::IdCounter;
30 use crate::utils::transaction::{Transaction, TransactionBlocker};35 use crate::utils::transaction::{Transaction, TransactionBlocker};
@@ -80,6 +85,9 @@ pub struct Workspace<W: LayoutElement> {
80 /// zones.85 /// zones.
81 working_area: Rectangle<f64, Logical>,86 working_area: Rectangle<f64, Logical>,
82 87
88+ /// This workspace's shadow in the overview.
89+ shadow: Shadow,
90+
83 /// Clock for driving animations.91 /// Clock for driving animations.
84 pub(super) clock: Clock,92 pub(super) clock: Clock,
85 93
@@ -228,6 +236,17 @@ impl<W: LayoutElement> Workspace<W> {
228 options.clone(),236 options.clone(),
229 );237 );
230 238
239+ let shadow_config = niri_config::Shadow {
240+ on: true,
241+ offset: niri_config::ShadowOffset {
242+ x: FloatOrInt(0.),
243+ y: FloatOrInt(20.),
244+ },
245+ softness: FloatOrInt(120.),
246+ spread: FloatOrInt(20.),
247+ ..Default::default()
248+ };
249+
231 Self {250 Self {
232 scrolling,251 scrolling,
233 floating,252 floating,
@@ -237,6 +256,7 @@ impl<W: LayoutElement> Workspace<W> {
237 transform: output.current_transform(),256 transform: output.current_transform(),
238 view_size,257 view_size,
239 working_area,258 working_area,
259+ shadow: Shadow::new(shadow_config),
240 output: Some(output),260 output: Some(output),
241 clock,261 clock,
242 base_options,262 base_options,
@@ -281,6 +301,17 @@ impl<W: LayoutElement> Workspace<W> {
281 options.clone(),301 options.clone(),
282 );302 );
283 303
304+ let shadow_config = niri_config::Shadow {
305+ on: true,
306+ offset: niri_config::ShadowOffset {
307+ x: FloatOrInt(0.),
308+ y: FloatOrInt(20.),
309+ },
310+ softness: FloatOrInt(120.),
311+ spread: FloatOrInt(20.),
312+ ..Default::default()
313+ };
314+
284 Self {315 Self {
285 scrolling,316 scrolling,
286 floating,317 floating,
@@ -291,6 +322,7 @@ impl<W: LayoutElement> Workspace<W> {
291 original_output,322 original_output,
292 view_size,323 view_size,
293 working_area,324 working_area,
325+ shadow: Shadow::new(shadow_config),
294 clock,326 clock,
295 base_options,327 base_options,
296 options,328 options,
@@ -343,6 +375,14 @@ impl<W: LayoutElement> Workspace<W> {
343 let view_rect = Rectangle::from_size(self.view_size);375 let view_rect = Rectangle::from_size(self.view_size);
344 self.floating376 self.floating
345 .update_render_elements(is_active && self.floating_is_active.get(), view_rect);377 .update_render_elements(is_active && self.floating_is_active.get(), view_rect);
378+
379+ self.shadow.update_render_elements(
380+ self.view_size,
381+ true,
382+ CornerRadius::default(),
383+ self.scale.fractional_scale(),
384+ 1.,
385+ );
346 }386 }
347 387
348 pub fn update_config(&mut self, base_options: Rc<Options>) {388 pub fn update_config(&mut self, base_options: Rc<Options>) {
@@ -370,6 +410,7 @@ impl<W: LayoutElement> Workspace<W> {
370 pub fn update_shaders(&mut self) {410 pub fn update_shaders(&mut self) {
371 self.scrolling.update_shaders();411 self.scrolling.update_shaders();
372 self.floating.update_shaders();412 self.floating.update_shaders();
413+ self.shadow.update_shaders();
373 }414 }
374 415
375 pub fn windows(&self) -> impl Iterator<Item = &W> + '_ {416 pub fn windows(&self) -> impl Iterator<Item = &W> + '_ {
@@ -1432,6 +1473,13 @@ impl<W: LayoutElement> Workspace<W> {
1432 (floating, scrolling)1473 (floating, scrolling)
1433 }1474 }
1434 1475
1476+ pub fn render_shadow<R: NiriRenderer>(
1477+ &self,
1478+ renderer: &mut R,
1479+ ) -> impl Iterator<Item = ShadowRenderElement> + '_ {
1480+ self.shadow.render(renderer, Point::from((0., 0.)))
1481+ }
1482+
1435 pub fn render_above_top_layer(&self) -> bool {1483 pub fn render_above_top_layer(&self) -> bool {
1436 self.scrolling.render_above_top_layer()1484 self.scrolling.render_above_top_layer()
1437 }1485 }
@@ -1630,7 +1678,7 @@ impl<W: LayoutElement> Workspace<W> {
1630 self.scrolling.dnd_scroll_gesture_begin();1678 self.scrolling.dnd_scroll_gesture_begin();
1631 }1679 }
1632 1680
1633- pub fn dnd_scroll_gesture_scroll(&mut self, pos: Point<f64, Logical>) {1681+ pub fn dnd_scroll_gesture_scroll(&mut self, pos: Point<f64, Logical>, speed: f64) {
1634 let config = &self.options.gestures.dnd_edge_view_scroll;1682 let config = &self.options.gestures.dnd_edge_view_scroll;
1635 let trigger_width = config.trigger_width.0;1683 let trigger_width = config.trigger_width.0;
1636 1684
@@ -1656,6 +1704,7 @@ impl<W: LayoutElement> Workspace<W> {
1656 // Normalize to [0, 1].1704 // Normalize to [0, 1].
1657 delta / trigger_width1705 delta / trigger_width
1658 };1706 };
1707+ let delta = delta * speed;
1659 1708
1660 self.scrolling.dnd_scroll_gesture_scroll(delta);1709 self.scrolling.dnd_scroll_gesture_scroll(delta);
1661 }1710 }
src/niri.rsmodified+88 -14
@@ -133,7 +133,7 @@ use crate::ipc::server::IpcServer;
133 use crate::layer::mapped::LayerSurfaceRenderElement;133 use crate::layer::mapped::LayerSurfaceRenderElement;
134 use crate::layer::MappedLayer;134 use crate::layer::MappedLayer;
135 use crate::layout::tile::TileRenderElement;135 use crate::layout::tile::TileRenderElement;
136-use crate::layout::workspace::WorkspaceId;136+use crate::layout::workspace::{Workspace, WorkspaceId};
137 use crate::layout::{HitType, Layout, LayoutElement as _, MonitorRenderElement};137 use crate::layout::{HitType, Layout, LayoutElement as _, MonitorRenderElement};
138 use crate::niri_render_elements;138 use crate::niri_render_elements;
139 use crate::protocols::foreign_toplevel::{self, ForeignToplevelManagerState};139 use crate::protocols::foreign_toplevel::{self, ForeignToplevelManagerState};
@@ -470,6 +470,7 @@ pub enum KeyboardFocus {
470 LayerShell { surface: WlSurface },470 LayerShell { surface: WlSurface },
471 LockScreen { surface: Option<WlSurface> },471 LockScreen { surface: Option<WlSurface> },
472 ScreenshotUi,472 ScreenshotUi,
473+ Overview,
473 }474 }
474 475
475 #[derive(Default, Clone, PartialEq)]476 #[derive(Default, Clone, PartialEq)]
@@ -566,6 +567,7 @@ impl KeyboardFocus {
566 KeyboardFocus::LayerShell { surface } => Some(surface),567 KeyboardFocus::LayerShell { surface } => Some(surface),
567 KeyboardFocus::LockScreen { surface } => surface.as_ref(),568 KeyboardFocus::LockScreen { surface } => surface.as_ref(),
568 KeyboardFocus::ScreenshotUi => None,569 KeyboardFocus::ScreenshotUi => None,
570+ KeyboardFocus::Overview => None,
569 }571 }
570 }572 }
571 573
@@ -575,12 +577,17 @@ impl KeyboardFocus {
575 KeyboardFocus::LayerShell { surface } => Some(surface),577 KeyboardFocus::LayerShell { surface } => Some(surface),
576 KeyboardFocus::LockScreen { surface } => surface,578 KeyboardFocus::LockScreen { surface } => surface,
577 KeyboardFocus::ScreenshotUi => None,579 KeyboardFocus::ScreenshotUi => None,
580+ KeyboardFocus::Overview => None,
578 }581 }
579 }582 }
580 583
581 pub fn is_layout(&self) -> bool {584 pub fn is_layout(&self) -> bool {
582 matches!(self, KeyboardFocus::Layout { .. })585 matches!(self, KeyboardFocus::Layout { .. })
583 }586 }
587+
588+ pub fn is_overview(&self) -> bool {
589+ matches!(self, KeyboardFocus::Overview)
590+ }
584 }591 }
585 592
586 pub struct State {593 pub struct State {
@@ -1026,13 +1033,18 @@ impl State {
1026 let focus_on_layer =1033 let focus_on_layer =
1027 |layer| excl_focus_on_layer(layer).or_else(|| on_d_focus_on_layer(layer));1034 |layer| excl_focus_on_layer(layer).or_else(|| on_d_focus_on_layer(layer));
1028 1035
1036+ let is_overview_open = self.niri.layout.is_overview_open();
1037+
1029 let mut surface = grab_on_layer(Layer::Overlay);1038 let mut surface = grab_on_layer(Layer::Overlay);
1030 // FIXME: we shouldn't prioritize the top layer grabs over regular overlay input or a1039 // FIXME: we shouldn't prioritize the top layer grabs over regular overlay input or a
1031 // fullscreen layout window. This will need tracking in grab() to avoid handing it out1040 // fullscreen layout window. This will need tracking in grab() to avoid handing it out
1032 // in the first place. Or a better way to structure this code.1041 // in the first place. Or a better way to structure this code.
1033 surface = surface.or_else(|| grab_on_layer(Layer::Top));1042 surface = surface.or_else(|| grab_on_layer(Layer::Top));
1034- surface = surface.or_else(|| grab_on_layer(Layer::Bottom));1043+
1035- surface = surface.or_else(|| grab_on_layer(Layer::Background));1044+ if !is_overview_open {
1045+ surface = surface.or_else(|| grab_on_layer(Layer::Bottom));
1046+ surface = surface.or_else(|| grab_on_layer(Layer::Background));
1047+ }
1036 1048
1037 surface = surface.or_else(|| focus_on_layer(Layer::Overlay));1049 surface = surface.or_else(|| focus_on_layer(Layer::Overlay));
1038 1050
@@ -1043,6 +1055,11 @@ impl State {
1043 surface = surface.or_else(|| focus_on_layer(Layer::Background));1055 surface = surface.or_else(|| focus_on_layer(Layer::Background));
1044 } else {1056 } else {
1045 surface = surface.or_else(|| focus_on_layer(Layer::Top));1057 surface = surface.or_else(|| focus_on_layer(Layer::Top));
1058+
1059+ if is_overview_open {
1060+ surface = Some(surface.unwrap_or(KeyboardFocus::Overview));
1061+ }
1062+
1046 surface = surface.or_else(|| on_d_focus_on_layer(Layer::Bottom));1063 surface = surface.or_else(|| on_d_focus_on_layer(Layer::Bottom));
1047 surface = surface.or_else(|| on_d_focus_on_layer(Layer::Background));1064 surface = surface.or_else(|| on_d_focus_on_layer(Layer::Background));
1048 surface = surface.or_else(layout_focus);1065 surface = surface.or_else(layout_focus);
@@ -1102,7 +1119,9 @@ impl State {
1102 // focused window.1119 // focused window.
1103 //1120 //
1104 // FIXME: Ideally this should happen inside Layout itself, then there wouldn't be any1121 // FIXME: Ideally this should happen inside Layout itself, then there wouldn't be any
1105- // problems with layer-shell, etc.1122+ // problems with layer-shell, etc. Or a similar problem now with the Overview where we
1123+ // don't update the previously focused window because the keyboard focus is on the
1124+ // Overview rather than on the Layout.
1106 if matches!(self.niri.keyboard_focus, KeyboardFocus::Layout { .. })1125 if matches!(self.niri.keyboard_focus, KeyboardFocus::Layout { .. })
1107 && matches!(focus, KeyboardFocus::Layout { .. })1126 && matches!(focus, KeyboardFocus::Layout { .. })
1108 {1127 {
@@ -2910,6 +2929,10 @@ impl Niri {
2910 output: &Output,2929 output: &Output,
2911 pos_within_output: Point<f64, Logical>,2930 pos_within_output: Point<f64, Logical>,
2912 ) -> bool {2931 ) -> bool {
2932+ if self.layout.is_overview_open() {
2933+ return false;
2934+ }
2935+
2913 // Check if some layer-shell surface is on top.2936 // Check if some layer-shell surface is on top.
2914 let layers = layer_map_for_output(output);2937 let layers = layer_map_for_output(output);
2915 let layer_popup_under = |layer| {2938 let layer_popup_under = |layer| {
@@ -2939,6 +2962,42 @@ impl Niri {
2939 false2962 false
2940 }2963 }
2941 2964
2965+ /// Returns the workspace under the position to be activated.
2966+ ///
2967+ /// The return value is an output and a workspace index on it.
2968+ pub fn workspace_under(
2969+ &self,
2970+ extended_bounds: bool,
2971+ pos: Point<f64, Logical>,
2972+ ) -> Option<(Output, &Workspace<Mapped>)> {
2973+ if self.is_locked() || self.screenshot_ui.is_open() {
2974+ return None;
2975+ }
2976+
2977+ let (output, pos_within_output) = self.output_under(pos)?;
2978+
2979+ if self.is_sticky_obscured_under(output, pos_within_output) {
2980+ return None;
2981+ }
2982+
2983+ if self.is_layout_obscured_under(output, pos_within_output) {
2984+ return None;
2985+ }
2986+
2987+ let ws = self
2988+ .layout
2989+ .workspace_under(extended_bounds, output, pos_within_output)?;
2990+ Some((output.clone(), ws))
2991+ }
2992+
2993+ pub fn workspace_under_cursor(
2994+ &self,
2995+ extended_bounds: bool,
2996+ ) -> Option<(Output, &Workspace<Mapped>)> {
2997+ let pos = self.seat.get_pointer().unwrap().current_location();
2998+ self.workspace_under(extended_bounds, pos)
2999+ }
3000+
2942 /// Returns the window under the position to be activated.3001 /// Returns the window under the position to be activated.
2943 ///3002 ///
2944 /// The cursor may be inside the window's activation region, but not within the window's input3003 /// The cursor may be inside the window's activation region, but not within the window's input
@@ -3039,6 +3098,8 @@ impl Niri {
3039 let mon = self.layout.monitor_for_output(output)?;3098 let mon = self.layout.monitor_for_output(output)?;
3040 let (_, geo) = mon.workspace_under(pos_within_output)?;3099 let (_, geo) = mon.workspace_under(pos_within_output)?;
3041 layer_pos_within_output += geo.loc;3100 layer_pos_within_output += geo.loc;
3101+ // Don't need to deal with zoom here because in the overview background and
3102+ // bottom layers don't receive input.
3042 }3103 }
3043 3104
3044 let surface_type = if popup {3105 let surface_type = if popup {
@@ -3096,6 +3157,8 @@ impl Niri {
3096 let mut under =3157 let mut under =
3097 layer_popup_under(Layer::Overlay).or_else(|| layer_toplevel_under(Layer::Overlay));3158 layer_popup_under(Layer::Overlay).or_else(|| layer_toplevel_under(Layer::Overlay));
3098 3159
3160+ let is_overview_open = self.layout.is_overview_open();
3161+
3099 // When rendering above the top layer, we put the regular monitor elements first.3162 // When rendering above the top layer, we put the regular monitor elements first.
3100 // Otherwise, we will render all layer-shell pop-ups and the top layer on top.3163 // Otherwise, we will render all layer-shell pop-ups and the top layer on top.
3101 if mon.render_above_top_layer() {3164 if mon.render_above_top_layer() {
@@ -3111,13 +3174,23 @@ impl Niri {
3111 } else {3174 } else {
3112 under = under3175 under = under
3113 .or_else(|| layer_popup_under(Layer::Top))3176 .or_else(|| layer_popup_under(Layer::Top))
3114- .or_else(|| layer_toplevel_under(Layer::Top))3177+ .or_else(|| layer_toplevel_under(Layer::Top));
3115- .or_else(interactive_moved_window_under)3178+
3116- .or_else(|| layer_popup_under(Layer::Bottom))3179+ under = under.or_else(interactive_moved_window_under);
3117- .or_else(|| layer_popup_under(Layer::Background))3180+
3118- .or_else(window_under)3181+ if !is_overview_open {
3119- .or_else(|| layer_toplevel_under(Layer::Bottom))3182+ under = under
3120- .or_else(|| layer_toplevel_under(Layer::Background));3183+ .or_else(|| layer_popup_under(Layer::Bottom))
3184+ .or_else(|| layer_popup_under(Layer::Background));
3185+ }
3186+
3187+ under = under.or_else(window_under);
3188+
3189+ if !is_overview_open {
3190+ under = under
3191+ .or_else(|| layer_toplevel_under(Layer::Bottom))
3192+ .or_else(|| layer_toplevel_under(Layer::Background));
3193+ }
3121 }3194 }
3122 3195
3123 let Some((mut surface_and_pos, (window, layer))) = under else {3196 let Some((mut surface_and_pos, (window, layer))) = under else {
@@ -3576,6 +3649,7 @@ impl Niri {
3576 // layer-shell, the layout will briefly draw as active, despite never having focus.3649 // layer-shell, the layout will briefly draw as active, despite never having focus.
3577 KeyboardFocus::LockScreen { .. } => true,3650 KeyboardFocus::LockScreen { .. } => true,
3578 KeyboardFocus::ScreenshotUi => true,3651 KeyboardFocus::ScreenshotUi => true,
3652+ KeyboardFocus::Overview => true,
3579 };3653 };
3580 3654
3581 self.layout.refresh(layout_is_active);3655 self.layout.refresh(layout_is_active);
@@ -3877,7 +3951,7 @@ impl Niri {
3877 3951
3878 // Get monitor elements.3952 // Get monitor elements.
3879 let mon = self.layout.monitor_for_output(output).unwrap();3953 let mon = self.layout.monitor_for_output(output).unwrap();
3880- let zoom = 1.;3954+ let zoom = mon.overview_zoom();
3881 let monitor_elements = Vec::from_iter(3955 let monitor_elements = Vec::from_iter(
3882 mon.render_elements(renderer, target, focus_ring)3956 mon.render_elements(renderer, target, focus_ring)
3883 .map(|(geo, iter)| (geo, Vec::from_iter(iter))),3957 .map(|(geo, iter)| (geo, Vec::from_iter(iter))),
@@ -5560,7 +5634,7 @@ impl Niri {
5560 }5634 }
5561 5635
5562 if let Some(window) = &new_focus.window {5636 if let Some(window) = &new_focus.window {
5563- if current_focus.window.as_ref() != Some(window) {5637+ if !self.layout.is_overview_open() && current_focus.window.as_ref() != Some(window) {
5564 let (window, hit) = window;5638 let (window, hit) = window;
5565 5639
5566 // Don't trigger focus-follows-mouse over the tab indicator.5640 // Don't trigger focus-follows-mouse over the tab indicator.
@@ -5809,7 +5883,7 @@ fn scale_relocate_crop<E: Element>(
5809 niri_render_elements! {5883 niri_render_elements! {
5810 OutputRenderElements<R> => {5884 OutputRenderElements<R> => {
5811 Monitor = MonitorRenderElement<R>,5885 Monitor = MonitorRenderElement<R>,
5812- Tile = TileRenderElement<R>,5886+ RescaledTile = RescaleRenderElement<TileRenderElement<R>>,
5813 LayerSurface = LayerSurfaceRenderElement<R>,5887 LayerSurface = LayerSurfaceRenderElement<R>,
5814 RelocatedLayerSurface = CropRenderElement<RelocateRenderElement<RescaleRenderElement<5888 RelocatedLayerSurface = CropRenderElement<RelocateRenderElement<RescaleRenderElement<
5815 LayerSurfaceRenderElement<R>5889 LayerSurfaceRenderElement<R>