Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Type `wifi` or `bluetooth` to go straight to a list.

### Dock

The dock appears when the pointer touches the bottom edge of a screen, and hides when you move away. To keep it on screen, turn on **Keep the dock visible** in Settings; maximized windows then stop above it. Full-screen apps hide it; touch the bottom edge to reveal it until you move away, in either mode. This works with borderless fullscreen apps; exclusive fullscreen games may block overlays. With autohide on, turn on **Hide only when windows overlap** to keep the dock shown on an empty desktop.
The dock appears when the pointer touches its screen edge: the bottom by default, or the left or right edge when `dock_edge` says so. It hides when you move away. Down a side the dock becomes a vertical column as thick as the bottom bar, showing just the time; clicking it opens Notifications just like the bottom dock, the launcher grows out of that edge, and windows animate to and from it. To keep it on screen, turn on **Keep the dock visible** in Settings; maximized windows then stop clear of it. Full-screen apps hide it; touch its edge to reveal it until you move away, in either mode. This works with borderless fullscreen apps; exclusive fullscreen games may block overlays. With autohide on, turn on **Hide only when windows overlap** to keep the dock shown on an empty desktop.

| Do this | To |
| --- | --- |
Expand Down Expand Up @@ -166,10 +166,11 @@ Open **Settings** by typing `settings` in the launcher or from Wisp's tray icon,
| `check_for_updates` | `true` | Checks daily for new stable releases, except on metered connections |
| `hide_taskbar` | `true` | Hides the Windows taskbar while Wisp runs |
| `dock` | `true` | Shows the dock |
| `dock_autohide` | `true` | Hides the dock until the pointer touches the bottom edge. `false` keeps it visible. |
| `dock_autohide` | `true` | Hides the dock until the pointer touches its edge. `false` keeps it visible. |
| `dock_dodge_windows` | `false` | With autohide on, stays visible until a window overlaps the dock. |
| `dock_margin` | `9` | The gap below the dock, in DIPs, from 0 to 24. `0` puts the dock on the screen edge. |
| `dock_margin` | `9` | The gap between the dock and its edge, in DIPs, from 0 to 24. `0` puts the dock on the screen edge. |
| `dock_screen` | `"pointer"` | `"pointer"` shows the dock on the screen the pointer touches, or the main screen while it stays visible; `"main"`; or a screen chosen in Settings |
| `dock_edge` | `"bottom"` | `"bottom"`, `"left"` or `"right"`. Down a side the dock's row becomes a column as thick as the bottom bar, with a time-only clock that opens Notifications when clicked; the launcher grows out of it, and windows minimize to and restore from that edge. |
| `dock_search_button` | `true` | Shows the search button at the start of the dock |
| `window_list` | `"multiple"` | `"multiple"` lists an app's windows on hover when it has more than one; `"always"` or `"off"` |
| `dock_icon_size` | `32` | App icon size in the dock, 24–40 DIP |
Expand Down
2 changes: 2 additions & 0 deletions examples/launcher_demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ mod launch;
mod messages;
#[path = "../src/migration.rs"]
mod migration;
#[path = "../src/minimize.rs"]
mod minimize;
#[path = "../src/morph.rs"]
mod morph;
#[path = "../src/render.rs"]
Expand Down
186 changes: 162 additions & 24 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use windows::core::{HSTRING, PCWSTR, Result, w};

use crate::commands::{self, Command, Commands};
use crate::config::{Config, Position, Theme};
use crate::dock::logic::Edge;
use crate::dock::space::DockSpace;
use crate::dock::{self, Dock};
use crate::drag::{self, Payload};
Expand Down Expand Up @@ -67,6 +68,29 @@ const MIXED_FILE_RESULTS: usize = 5;
const ONLY_FILE_RESULTS: usize = 30;
const RESCAN_AFTER: Duration = Duration::from_secs(120);
const PLACEHOLDER: &str = "Search apps and files, or try wifi, vol, time";

/// Rows that fit in `available` DIPs below the query box, always at least one.
fn fit_rows(available: f32) -> usize {
(((available - layout::height(1)) / layout::ROW_H).max(0.0) as usize + 1).max(1)
}

/// A side launcher's window: pinned to the dock's edge, top aligned with its
/// column, and tall enough to keep every dock band.
fn side_launcher_rect(edge: Edge, work: RECT, dock: RECT, margin: i32, width: i32, height: i32) -> RECT {
let height = height.max(dock.bottom - dock.top);
let left = match edge {
Edge::Left => work.left + margin,
Edge::Right => work.right - margin - width,
Edge::Bottom => work.left + (work.right - work.left - width) / 2,
};
RECT {
left,
top: dock.top,
right: left + width,
bottom: dock.top + height,
}
}

/// Space below the launcher at the bottom of the screen, in DIPs. Matches the
/// dock's margin so the query box covers the dock.
const BOTTOM_MARGIN: f32 = 4.0;
Expand Down Expand Up @@ -322,6 +346,13 @@ pub fn run() -> Result<()> {
taskbar: None,
taskbar_failures: 0,
dock_space: None,
minimize_hook: match crate::minimize::Hook::start() {
Ok(hook) => Some(hook),
Err(error) => {
eprintln!("could not start the minimize animation hook: {error}");
None
}
},
dock: None,
morph: None,
morphed: false,
Expand Down Expand Up @@ -490,6 +521,8 @@ struct Launcher {
taskbar_failures: u32,
/// Room kept for a dock that stays visible.
dock_space: Option<DockSpace>,
/// Points native window animations at the dock's edge.
minimize_hook: Option<crate::minimize::Hook>,
dock: Option<Dock>,
morph: Option<Morph>,
morphed: bool,
Expand Down Expand Up @@ -686,16 +719,21 @@ impl Launcher {
/// to match the config.
fn sync_shell(&mut self) {
self.sync_taskbar();
if self.dock.as_ref().is_some_and(|d| d.shared() != self.bottom()) {
// A bottom launcher draws the dock inside itself. Down a side it does
// too, wherever `position` puts the results, so it can grow from there.
let shared = self.config.position == Position::Bottom || Edge::parse(&self.config.dock_edge).vertical();
if self.dock.as_ref().is_some_and(|d| d.shared() != shared) {
self.drop_dock();
crate::minimize::set(Edge::Bottom, None);
}
if !self.config.dock {
self.drop_dock();
crate::minimize::set(Edge::Bottom, None);
self.sync_reserve();
return;
}
if self.dock.is_none() {
match if self.bottom() {
match if shared {
Dock::on_surface(self.hwnd)
} else {
Dock::new(self.hwnd)
Expand Down Expand Up @@ -732,29 +770,30 @@ impl Launcher {
fn sync_reserve(&mut self) {
let hidden = self.taskbar.as_ref().is_some_and(TaskbarWorker::is_active);
let wanted = hidden && self.dock.as_ref().is_some_and(Dock::stays_visible);
let reserved_height = self
let edge = self.dock.as_ref().map_or(Edge::Bottom, Dock::edge);
let reserved_extent = self
.dock
.as_ref()
.map_or(dock::DEFAULT_RESERVED_HEIGHT, Dock::reserved_height);
.map_or(dock::DEFAULT_RESERVED_EXTENT, Dock::reserved_extent);
// Before the space exists, so a re-hide while Windows places it
// cannot take the bottom back.
// cannot take the dock's strip back.
if wanted && let Some(hider) = &self.taskbar {
hider.keep_bottom(true);
hider.keep_edge(edge, true);
}
if !wanted {
if !wanted || self.dock_space.as_ref().is_some_and(|space| space.edge() != edge) {
self.dock_space = None;
} else if let Some(space) = &self.dock_space {
// The taskbar hider may have just changed the work area.
space.set_height(reserved_height);
space.set_extent(reserved_extent);
space.check();
} else {
match DockSpace::new(reserved_height) {
match DockSpace::new(edge, reserved_extent) {
Ok(space) => self.dock_space = Some(space),
Err(e) => eprintln!("could not keep space for the dock: {e}"),
}
}
if let Some(hider) = &self.taskbar {
hider.keep_bottom(self.dock_space.is_some());
hider.keep_edge(edge, self.dock_space.is_some());
}
}

Expand Down Expand Up @@ -1045,8 +1084,8 @@ impl Launcher {
}

/// Uses the monitor under the cursor, or the dock's chosen screen when the
/// launcher grows out of the dock. Reduces the result count and moves the
/// launcher up if needed to keep it within the work area.
/// launcher grows out of the dock. Reduces the result count and keeps the
/// launcher inside the work area. A side dock anchors it to that edge.
fn place_on_active_monitor(&mut self) {
let work = unsafe {
let monitor = match dock::chosen_screen().filter(|_| self.unified()) {
Expand Down Expand Up @@ -1076,7 +1115,27 @@ impl Launcher {
let margin = self.px(16.0);
let width = self.px(layout::WIDTH);
let left = work.left + (work.right - work.left - width) / 2;
if self.bottom() {
let edge = self.dock_edge();
let side = self.unified() && edge.vertical();
if side {
// The dock's column is the launcher's near edge; grow outward from
// it, keeping the column's height so every band still fits.
let dock = self.dock.as_ref().unwrap().resting_rect();
let scale = self.dpi as f32 / 96.0;
let available = (dock.bottom - dock.top) as f32 / scale;
self.rows_that_fit = fit_rows(available);
let rect = side_launcher_rect(
edge,
work,
dock,
self.px(dock::margin(&self.config)),
width,
self.px(self.window_h()),
);
// `bottom()` is true for a side dock, so the launcher's position is
// its bottom-right corner, as it is across the bottom.
self.position = (rect.left, rect.bottom);
} else if self.bottom() {
// The query box covers the dock's spot, and results grow upward.
let bottom = work.bottom
- self.px(if self.unified() {
Expand All @@ -1085,15 +1144,15 @@ impl Launcher {
BOTTOM_MARGIN
});
let available = (bottom - margin - work.top) as f32 * 96.0 / self.dpi as f32;
self.rows_that_fit = (((available - layout::height(1)) / layout::ROW_H).max(0.0) as usize + 1).max(1);
self.rows_that_fit = fit_rows(available);
self.position = (left, bottom);
} else {
let full_height = self.px(layout::height(self.config.max_results));
let top = (work.top + (work.bottom - work.top) / 4)
.min(work.bottom - margin - full_height)
.max(work.top + margin);
let available = (work.bottom - margin - top) as f32 * 96.0 / self.dpi as f32;
self.rows_that_fit = (((available - layout::height(1)) / layout::ROW_H).max(0.0) as usize + 1).max(1);
self.rows_that_fit = fit_rows(available);
self.position = (left, top);
}
self.apply_size();
Expand Down Expand Up @@ -1121,13 +1180,33 @@ impl Launcher {
}

/// The query box sits at the bottom of the screen and results stack upward.
/// A launcher grown from a side dock keeps that same orientation.
fn bottom(&self) -> bool {
self.config.position == Position::Bottom
self.config.position == Position::Bottom || self.side_dock()
}

/// The launcher's height in DIPs.
/// Whether this launcher grows out of a dock down a screen side.
fn side_dock(&self) -> bool {
self.dock
.as_ref()
.is_some_and(|dock| dock.shared() && dock.edge().vertical())
}

/// The edge the dock this launcher grows from sits on.
fn dock_edge(&self) -> Edge {
self.dock.as_ref().map_or(Edge::Bottom, Dock::edge)
}

/// The launcher's height in DIPs. A side dock's column sets a minimum, so
/// the dock drawn inside the launcher keeps every band.
fn window_h(&self) -> f32 {
layout::height(self.window_rows())
let rows_h = layout::height(self.window_rows());
if self.unified() && self.dock_edge().vertical() {
let dock = self.dock.as_ref().unwrap().resting_rect();
rows_h.max((dock.bottom - dock.top) as f32 * 96.0 / self.dpi as f32)
} else {
rows_h
}
}

fn px(&self, dips: f32) -> i32 {
Expand Down Expand Up @@ -1172,7 +1251,7 @@ impl Launcher {
}

fn unified(&self) -> bool {
self.bottom() && self.dock.as_ref().is_some_and(Dock::shared)
self.dock.as_ref().is_some_and(Dock::shared)
}

fn launcher_rect(&self) -> RECT {
Expand Down Expand Up @@ -2050,7 +2129,8 @@ impl Launcher {
}
let r = self.current_rect();
let scale = self.dpi as f32 / 96.0;
let (ox, oy) = crate::morph::content_offset(
let (ox, oy) = crate::morph::content_offset_on(
self.dock_edge(),
(r.right - r.left) as f32,
(r.bottom - r.top) as f32,
layout::WIDTH * scale,
Expand Down Expand Up @@ -2110,6 +2190,7 @@ impl Launcher {
fn paint(&mut self) {
let _span = util::perf::Span::new("paint");
let opacity = self.morph_opacity();
let edge = self.dock_edge();
let content_size = self.morph.as_ref().map(|_| (layout::WIDTH, self.window_h()));
let text = self.editor.text();
let frame = Frame {
Expand Down Expand Up @@ -2142,6 +2223,7 @@ impl Launcher {
rows: self.list_rows(),
}),
bottom: self.bottom(),
edge,
opacity: crate::morph::fades(opacity).1,
dock_opacity: crate::morph::fades(opacity).0,
content_size,
Expand All @@ -2155,7 +2237,8 @@ impl Launcher {
let rect = dock.resting_rect();
let scale = self.dpi as f32 / 96.0;
let dock_height = (rect.bottom - rect.top) as f32 / scale;
let (x, y) = crate::morph::content_offset(
let (x, y) = crate::morph::content_offset_on(
edge,
size.width,
size.height,
(rect.right - rect.left) as f32 / scale,
Expand Down Expand Up @@ -2598,7 +2681,7 @@ impl Launcher {
fn surface_point(&self, x: i32, y: i32) -> Option<(f32, f32)> {
let open = self.surface.as_ref()?;
let scale = 96.0 / self.dpi as f32;
let (ox, oy) = crate::render::surface_origin(self.bottom());
let (ox, oy) = crate::render::surface_origin(self.bottom(), self.window_h(), self.list_rows());
let (x, y) = (x as f32 * scale, y as f32 * scale);
if y < oy || y > oy + self.view_height() {
return None;
Expand Down Expand Up @@ -2684,7 +2767,7 @@ impl Launcher {
let Input::Slider { value, muted, target } = &open.widgets[index].input else {
return;
};
let (ox, _) = crate::render::surface_origin(self.bottom());
let (ox, _) = crate::render::surface_origin(self.bottom(), self.window_h(), self.list_rows());
let sx = x as f32 * 96.0 / self.dpi as f32 - ox;
let new = nav::slider_value(&open.rects[index], sx, open.widgets[index].quick.is_some());
// Compare with the value last sent, not the shown one, which a device
Expand Down Expand Up @@ -2736,6 +2819,12 @@ impl Launcher {
let _span = util::perf::Span::new("quit_dock");
self.dock = None;
}
{
let _span = util::perf::Span::new("quit_minimize_hook");
if let Some(hook) = self.minimize_hook.take() {
hook.close();
}
}
{
let _span = util::perf::Span::new("quit_taskbar");
if let Some(Err(e)) = self.taskbar.take().map(TaskbarWorker::shutdown) {
Expand Down Expand Up @@ -3319,7 +3408,10 @@ unsafe fn wndproc_inner(hwnd: HWND, msg: u32, wparam: WPARAM, lparam: LPARAM) ->

#[cfg(test)]
mod tests {
use super::mouse_moved;
use windows::Win32::Foundation::RECT;

use super::{fit_rows, mouse_moved, side_launcher_rect};
use crate::dock::logic::Edge;

#[test]
fn stationary_cursor_keeps_selection_across_layout_changes() {
Expand All @@ -3346,4 +3438,50 @@ mod tests {
assert_eq!(last, Some((800, 600)));
assert!(mouse_moved(&mut last, (801, 600)));
}

#[test]
fn side_launcher_grows_out_of_the_dock_column() {
let work = RECT {
left: 0,
top: 0,
right: 1920,
bottom: 1080,
};
let left_dock = RECT {
left: 0,
top: 200,
right: 56,
bottom: 700,
};
assert_eq!(
side_launcher_rect(Edge::Left, work, left_dock, 12, 680, 400),
RECT {
left: 12,
top: 200,
right: 692,
bottom: 700
}
);
let right_dock = RECT {
left: 1900,
top: 200,
right: 1956,
bottom: 700,
};
assert_eq!(
side_launcher_rect(Edge::Right, work, right_dock, 12, 680, 400),
RECT {
left: 1228,
top: 200,
right: 1908,
bottom: 700
}
);
}

#[test]
fn fit_rows_always_keeps_one_row() {
assert_eq!(fit_rows(0.0), 1);
assert!(fit_rows(1000.0) > fit_rows(500.0));
}
}
2 changes: 2 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ pub struct Config {
pub dock_color: String,
/// `"pointer"`, `"main"`, or a screen's ID from Settings.
pub dock_screen: String,
/// `"bottom"`, `"left"`, or `"right"`: the screen edge the dock sits on.
pub dock_edge: String,
pub hotkey: String,
pub win_key: bool,
pub max_results: usize,
Expand Down
Loading
Loading