A lightweight, macOS-style dock for Windows 11, with glass visuals, smooth magnification, and Genie effect.
feat: update version to 0.1.15 and enhance drag-and-drop functionality
CristianOlivera172ac40bb0fa6
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 9283ebf..90a2486 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,6 +10,29 @@ copia la sección de la versión que se publica a la release de GitHub.### English+- Fixed icons remaining over the desktop after dragging an app out of a dock+ group. Drag tracking now recovers missed pointer messages without taking+ focus, stops on release or Escape, and rejects late clicks after cancellation.+- Grouping now requires dropping over the target icon vertically as well as+ horizontally. Recovered or collapsed groups no longer duplicate pinned apps+ in recent apps.++### Español++- Corregido el icono que quedaba flotando sobre el escritorio al sacar una app+ de un grupo del dock. El arrastre recupera mensajes del puntero perdidos sin+ tomar el foco, termina al soltar o pulsar Escape y descarta clics tardíos tras+ una cancelación.+- Agrupar requiere soltar sobre el icono también en vertical. Recuperar o+ reducir un grupo ya no duplica apps fijadas en las apps recientes.++## [0.1.15]++### English++- Dragging apps out of the dock or a group now completes or cancels reliably+ even when a non-activating window misses mouse input outside its bounds.+ Press Escape to cancel a drag.- Dock groups: drag a pinned app onto the middle of another one (a blue frameshows it) to put both in a group that takes a single place in the dock;drop more apps on the group to add them. A group shows its first apps'@@ -26,6 +49,10 @@ copia la sección de la versión que se publica a la release de GitHub.it in Settings → System, or leave Automatic to follow Windows. A languageMuelle does not know in the settings file now reads as Automatic instead ofmaking the file invalid.+- Mascot showcase: the website now previews the crab's reactions to AI limits,+ charging and energy saver, and the hero crab moves between the Notes window+ and dock. Choose a moment to play its scene or let the preview run; reduced+ motion is respected.- Apps that showed a blank page instead of their icon now show it, as on thetaskbar: LibreOffice (its windows belong to `soffice.bin`; the dock nowshows LibreOffice Calc, Writer… with their names and icons), and programs@@ -35,6 +62,9 @@ copia la sección de la versión que se publica a la release de GitHub.### Español+- Arrastrar apps fuera del dock o de un grupo ahora termina o se cancela de+ forma fiable aunque una ventana que no toma el foco pierda los eventos del+ mouse fuera de sus límites. Pulsa Esc para cancelar el arrastre.- Grupos en el dock: arrastra una app fijada al centro de otra (un marco azullo indica) para reunirlas en un grupo que ocupa un solo lugar en el dock;suelta más apps sobre el grupo para añadirlas. Un grupo muestra los iconos@@ -52,6 +82,10 @@ copia la sección de la versión que se publica a la release de GitHub.Elígelo en Ajustes → Sistema, o deja Automático para seguir a Windows. Unidioma que Muelle no conoce en el archivo de ajustes ahora se lee comoAutomático en lugar de invalidar el archivo.+- Vista previa de la mascota: la web muestra las reacciones del cangrejo ante+ los límites de IA, la carga y el ahorro de energía; además, en la portada se+ mueve entre la ventana de Notas y el dock. Elige un momento para ver su escena+ o deja que la vista previa avance; se respeta la opción de reducir movimiento.- Las apps que mostraban una página en blanco en lugar de su icono ahora lomuestran, como en la barra de tareas: LibreOffice (sus ventanas pertenecena `soffice.bin`; el dock ahora muestra LibreOffice Calc, Writer… con susdiff --git a/Cargo.lock b/Cargo.lockindex c81b31b..29fcef0 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -2259,7 +2259,7 @@ dependencies = [[[package]]name = "muelle"-version = "0.1.14"+version = "0.1.15"dependencies = ["anyhow","base64 0.22.1",@@ -2280,7 +2280,7 @@ dependencies = [[[package]]name = "muelle-config"-version = "0.1.14"+version = "0.1.15"dependencies = ["serde","serde_json",@@ -2289,11 +2289,11 @@ dependencies = [[[package]]name = "muelle-core"-version = "0.1.14"+version = "0.1.15"[[package]]name = "muelle-settings"-version = "0.1.14"+version = "0.1.15"dependencies = ["muelle-config","muelle-shell",@@ -2307,7 +2307,7 @@ dependencies = [[[package]]name = "muelle-shell"-version = "0.1.14"+version = "0.1.15"dependencies = ["thiserror 2.0.21","windows",diff --git a/Cargo.toml b/Cargo.tomlindex 9403157..5fe9089 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -3,7 +3,7 @@ resolver = "3"members = ["crates/*", "apps/dock", "apps/settings/src-tauri", "spikes"][workspace.package]-version = "0.1.14"+version = "0.1.15"edition = "2024"license = "MIT"diff --git a/apps/dock/src/app.rs b/apps/dock/src/app.rsindex 081e881..cffbcba 100644--- a/apps/dock/src/app.rs+++ b/apps/dock/src/app.rs@@ -25,7 +25,7 @@ use anyhow::{Context, Result};use muelle_config::{Config, DockGroup};use muelle_core::{bounce,- layout::{ItemKind, Layout, Metrics, layout},+ layout::{ItemKind, Layout, Metrics, Rect, layout},magnify::{Magnifier, magnify},roster::{Group, Roster},spring::Spring,@@ -64,10 +64,10 @@ use windows::{UI::{Accessibility::{HWINEVENTHOOK, SetWinEventHook, UnhookWinEvent},Input::KeyboardAndMouse::{- GetAsyncKeyState, GetKeyState, ReleaseCapture, SetCapture, TME_LEAVE,+ GetAsyncKeyState, GetCapture, GetKeyState, ReleaseCapture, SetCapture, TME_LEAVE,TRACKMOUSEEVENT, TrackMouseEvent, VIRTUAL_KEY, VK_CONTROL, VK_DOWN, VK_END,- VK_HOME, VK_LBUTTON, VK_LEFT, VK_LWIN, VK_MBUTTON, VK_MENU, VK_RBUTTON, VK_RIGHT,- VK_RWIN, VK_SHIFT, VK_TAB, VK_UP,+ VK_ESCAPE, VK_HOME, VK_LBUTTON, VK_LEFT, VK_LWIN, VK_MBUTTON, VK_MENU, VK_RBUTTON,+ VK_RIGHT, VK_RWIN, VK_SHIFT, VK_TAB, VK_UP,},WindowsAndMessaging::{CreateWindowExW, DefWindowProcW, DispatchMessageW, EVENT_OBJECT_CLOAKED,@@ -76,8 +76,8 @@ use windows::{GetSystemMetrics, HMENU, HWND_TOPMOST, IDC_ARROW, KillTimer, LoadCursorW,MA_ACTIVATE, MA_NOACTIVATE, MSG, OBJID_WINDOW, PM_REMOVE, PeekMessageW,PostMessageW, PostQuitMessage, RegisterClassW, RegisterShellHookWindow,- RegisterWindowMessageW, SM_CXDRAG, SWP_HIDEWINDOW, SWP_NOACTIVATE, SWP_SHOWWINDOW,- SetTimer, SetWindowPos, WINDOW_EX_STYLE, WINEVENT_OUTOFCONTEXT,+ RegisterWindowMessageW, SM_CXDRAG, SM_SWAPBUTTON, SWP_HIDEWINDOW, SWP_NOACTIVATE,+ SWP_SHOWWINDOW, SetTimer, SetWindowPos, WINDOW_EX_STYLE, WINEVENT_OUTOFCONTEXT,WINEVENT_SKIPOWNPROCESS, WM_APP, WM_CAPTURECHANGED, WM_CLOSE, WM_DESTROY,WM_DISPLAYCHANGE, WM_DPICHANGED, WM_INITMENUPOPUP, WM_LBUTTONDOWN, WM_LBUTTONUP,WM_MBUTTONDOWN, WM_MBUTTONUP, WM_MOUSEACTIVATE, WM_MOUSEMOVE, WM_QUIT,@@ -227,6 +227,10 @@ const FULLSCREEN_RECHECK_MS: u32 = 3_000;/// Shell results arriving together cause one scene rebuild.const ASSETS_TIMER: usize = 11;const ASSETS_DELAY_MS: u32 = 16;+/// Non-activating windows cannot rely on capture outside their bounds.+/// Armed only while dragging or holding a draggable icon.+const DRAG_TIMER: usize = 16;+const DRAG_POLL_MS: u32 = 16;/// Auto-hide slide speed (about 250 ms).const SLIDE_OMEGA: f32 = 24.0;@@ -238,6 +242,7 @@ const REMOVE_DISTANCE: f32 = 0.8;/// its middle, past this fraction of its width from either side; over its/// sides, it moves between icons as usual.const MERGE_SIDE: f32 = 0.25;+/// Longest hover label of a group, which lists its apps.const GROUP_LABEL_CHARS: usize = 48;@@ -447,6 +452,7 @@ struct Asset {struct Press {id: String,at: POINT,+ draggable: bool,}struct Dragging {@@ -523,6 +529,25 @@ fn selection_after_closing(index: usize, alive: &[bool]) -> Option<usize> {Some((index - closed_before).min(left - 1))}+fn group_drop_contains(rect: &Rect, x: f32, y: f32) -> bool {+ let side = rect.width * MERGE_SIDE;+ x >= rect.x + side && x <= rect.x + rect.width - side && y >= rect.y && y < rect.y + rect.height+}++pub(crate) fn primary_button_down() -> bool {+ // GetAsyncKeyState reports physical buttons; WM_LBUTTON* is logical.+ // Respect Windows' left-handed mouse configuration.+ // SAFETY: Read-only system metrics and button state.+ unsafe {+ let key = if GetSystemMetrics(SM_SWAPBUTTON) != 0 {+ VK_RBUTTON+ } else {+ VK_LBUTTON+ };+ GetAsyncKeyState(i32::from(key.0)) < 0+ }+}+fn group_is_foreground(windows: &[isize], foreground: isize) -> bool {if !windows.contains(&foreground) {return false;@@ -2256,14 +2281,17 @@ impl App {let Some(entry) = self.hovered.and_then(|index| self.entries.get(index)) else {return Ok(());};- if !self.is_draggable(entry) {- return Ok(());- }- // SAFETY: Capture keeps mouse input while dragging outside the dock.- unsafe {- SetCapture(self.input);+ let draggable = self.is_draggable(entry);+ self.press = entry.id.clone().map(|id| Press { id, at, draggable });+ if draggable {+ // Capture is best effort: this non-activating window also polls+ // until release, including when the pointer leaves the dock.+ // SAFETY: Both calls target our window on its owning thread.+ unsafe {+ SetCapture(self.input);+ SetTimer(Some(self.input), DRAG_TIMER, DRAG_POLL_MS, None);+ }}- self.press = entry.id.clone().map(|id| Press { id, at });Ok(())}@@ -2299,7 +2327,8 @@ impl App {/// Returns `true` while a drag is in progress.fn update_drag(&mut self, point: POINT) -> bool {if self.drag.is_none()- && let Some(press) = &self.press+ && let Some(press) = self.press.as_ref().filter(|press| press.draggable)+ && primary_button_down(){// SAFETY: Read-only query.let threshold = unsafe { GetSystemMetrics(SM_CXDRAG) }.max(1);@@ -2358,13 +2387,15 @@ impl App {.iter().zip(&state.rects).find(|(entry, rect)| {- let side = rect.width * MERGE_SIDE;matches!(entry.role, Role::App | Role::Group)&& entry.id.as_ref().is_some_and(|other| {*other != id && *other != explorer && self.roster.is_pinned(other)})- && self.cursor >= rect.x + side- && self.cursor <= rect.x + rect.width - side+ && group_drop_contains(+ rect,+ self.cursor,+ (point.y - stage.dock_origin.y) as f32,+ )}).and_then(|(entry, _)| entry.id.clone());if drag.merge.is_some() {@@ -2621,19 +2652,26 @@ impl App {}fn on_release(&mut self) -> Result<Option<Outside>> {- self.press = None;- let Some(drag) = self.drag.take() else {- // SAFETY: Releasing capture we may not hold is harmless.- unsafe {- let _ = ReleaseCapture();- }- return self.on_click();+ let press = self.press.take();+ // Sample the release position too: the final WM_MOUSEMOVE can be+ // coalesced or delivered to another window outside this dock.+ let positioned = if self.drag.is_some() {+ self.on_mouse_move()+ } else {+ Ok(())};- // SAFETY: Same as above.- unsafe {- let _ = ReleaseCapture();- }+ let drag = self.drag.take();self.ghost = None;+ self.stop_drag_input();+ positioned?;+ let Some(drag) = drag else {+ // A late button-up after polling/cancellation must never launch+ // an app, nor should releasing over a different icon.+ if let Some(press) = press {+ return self.on_click(&press.id);+ }+ return Ok(None);+ };if let Some(target) = &drag.merge {self.roster.group_with(&drag.id, target);} else if drag.removing {@@ -2650,16 +2688,61 @@ impl App {/// reached so far.fn cancel_drag(&mut self) -> Result<()> {self.press = None;+ self.group_was_open = None;+ self.ghost = None;+ self.stop_drag_input();let Some(drag) = self.drag.take() else {return Ok(());};- self.ghost = None;save_settings(&self.roster, &self.config);self.leave_if_outside(drag.point)?;self.after_group_drag(&drag)?;self.render()}+ fn stop_drag_input(&self) {+ // Never release capture now held by a menu or a different popup.+ // SAFETY: Our timer and the current thread's capture window.+ unsafe {+ let _ = KillTimer(Some(self.input), DRAG_TIMER);+ if GetCapture() == self.input {+ let _ = ReleaseCapture();+ }+ }+ }++ fn poll_drag(&mut self) -> Result<Option<Outside>> {+ if self.press.is_none() && self.drag.is_none() {+ self.stop_drag_input();+ return Ok(None);+ }+ // SAFETY: Read-only physical button state, independent of capture.+ let (down, escape) = unsafe {+ (+ primary_button_down(),+ GetAsyncKeyState(i32::from(VK_ESCAPE.0)) < 0,+ )+ };+ if escape || (!down && self.drag.is_none()) {+ self.cancel_drag()?;+ } else if !down {+ return self.on_release();+ } else {+ let mut point = POINT::default();+ // SAFETY: Valid output for this query.+ unsafe { GetCursorPos(&mut point)? };+ let previous = self+ .drag+ .as_ref()+ .map(|drag| drag.point)+ .or_else(|| self.press.as_ref().map(|press| press.at));+ if previous != Some(point) {+ self.on_mouse_move()?;+ }+ }+ Ok(None)+ }+/// A drag out of a group starts away from the dock, so no hover ends/// with it: the input area shrinks back now, and an auto-hidden dock/// goes down.@@ -2701,7 +2784,7 @@ impl App {/// On icon click, launches a closed app or brings its windows to the/// foreground. Clicking the app that is already in front minimizes it, as/// the Windows taskbar does; the next click brings it back.- fn on_click(&mut self) -> Result<Option<Outside>> {+ fn on_click(&mut self, pressed_id: &str) -> Result<Option<Outside>> {let group_was_open = self.group_was_open.take();if self.pointer_at_click()?.is_none() {return Ok(None);@@ -2712,6 +2795,9 @@ impl App {let (Some(id), role) = (entry.id.clone(), entry.role) else {return Ok(None);};+ if id != pressed_id {+ return Ok(None);+ }Ok(match role {Role::App => self.click_app(id),@@ -2941,6 +3027,7 @@ impl App {// SAFETY: Capture keeps mouse input while dragging outside the dock.unsafe {SetCapture(self.input);+ SetTimer(Some(self.input), DRAG_TIMER, DRAG_POLL_MS, None);}self.drag_to(point)}@@ -3829,6 +3916,7 @@ impl App {self.press = None;self.drag = None;self.ghost = None;+ self.stop_drag_input();}if let Err(error) = self.place_windows() {self.fullscreen = previous;@@ -4046,6 +4134,13 @@ pub fn group_view_tick() {{app.close_group_view();}+ // Capture from a background popup does not guarantee mouse-move+ // delivery once the pointer leaves it. Poll only its active press.+ if let Some(view) = &app.group_view+ && let Some((id, point)) = view.drag_started()?+ {+ app.start_group_drag(id, point)?;+ }Ok(())});}@@ -4360,7 +4455,14 @@ unsafe extern "system" fn wndproc(hwnd: HWND, msg: u32, w: WPARAM, l: LPARAM) ->let _ = PostMessageW(Some(hwnd), DRAG_CANCELLED, WPARAM(0), LPARAM(0));}}- DRAG_CANCELLED => with_app("arrastre", App::cancel_drag),+ DRAG_CANCELLED => {+ // ReleaseCapture posts this too. A newer press may already+ // own capture by the time the deferred cancellation runs.+ if unsafe { GetCapture() } != hwnd {+ with_app("arrastre", App::cancel_drag);+ }+ }+ WM_TIMER if w.0 == DRAG_TIMER => with_app_then("arrastre", App::poll_drag),DROP_RUN => with_app_then("soltar archivos", |app| Ok(app.pending_drop.take())),WM_RBUTTONUP => with_app_then("menú", App::on_right_click),BIN_STATE => with_app("papelera", |app| app.set_bin_full(w.0 != 0)),@@ -5050,6 +5152,41 @@ mod activation_tests {}}+#[cfg(test)]+mod group_drop_tests {+ use super::{Rect, group_drop_contains};++ #[test]+ fn grouping_requires_the_pointer_over_the_icon_not_another_monitor_below_it() {+ let icon = Rect {+ x: 80.0,+ y: -24.0,+ width: 72.0,+ height: 72.0,+ };+ assert!(group_drop_contains(&icon, 116.0, 12.0));+ for y in [-25.0, 48.0, 200.0] {+ assert!(+ !group_drop_contains(&icon, 116.0, y),+ "outside the icon at y={y}"+ );+ }+ }++ #[test]+ fn the_sides_of_an_icon_remain_available_for_reordering() {+ let icon = Rect {+ x: 80.0,+ y: -24.0,+ width: 72.0,+ height: 72.0,+ };+ for x in [79.0, 81.0, 151.0, 153.0] {+ assert!(!group_drop_contains(&icon, x, 12.0));+ }+ }+}+#[cfg(test)]mod preview_order_tests {use super::{PreviewOrder, TrackedWindow};diff --git a/apps/dock/src/group_view.rs b/apps/dock/src/group_view.rsindex 1ace1f8..adcc025 100644--- a/apps/dock/src/group_view.rs+++ b/apps/dock/src/group_view.rs@@ -21,8 +21,8 @@ use windows::{System::{LibraryLoader::GetModuleHandleW, WinRT::Composition::ICompositorDesktopInterop},UI::{Input::KeyboardAndMouse::{- GetAsyncKeyState, ReleaseCapture, SetCapture, VK_ESCAPE, VK_LBUTTON, VK_MBUTTON,- VK_RBUTTON,+ GetAsyncKeyState, GetCapture, ReleaseCapture, SetCapture, VK_ESCAPE, VK_LBUTTON,+ VK_MBUTTON, VK_RBUTTON,},WindowsAndMessaging::{CreateWindowExW, DefWindowProcW, DestroyWindow, GetCursorPos, GetSystemMetrics,@@ -545,7 +545,18 @@ impl GroupView {}// Quick while unfolding; then just often enough to follow the pointer.// SAFETY: Our own timer; setting it again replaces it.- unsafe { SetTimer(Some(self.hwnd), TIMER, if moving { 16 } else { 50 }, None) };+ unsafe {+ SetTimer(+ Some(self.hwnd),+ TIMER,+ if moving || self.pressed.is_some() {+ 16+ } else {+ 50+ },+ None,+ )+ };Ok(())}@@ -577,6 +588,11 @@ impl GroupView {return Ok(false);}self.mouse_was_down = mouse_down;+ // A non-activating popup can miss button-up outside its bounds.+ // Do not leave a stale press that could detach an app on re-entry.+ if self.pressed.is_some() && !app::primary_button_down() {+ self.cancel_press();+ }self.update()?;Ok(true)}@@ -603,6 +619,9 @@ impl GroupView {let Some((index, at)) = self.pressed else {return Ok(None);};+ if !app::primary_button_down() {+ return Ok(None);+ }let mut point = POINT::default();// SAFETY: Read-only queries.let threshold = unsafe {@@ -641,6 +660,12 @@ impl GroupView {/// The mouse was taken away mid-press (Alt+Tab, a system dialog).pub fn cancel_press(&mut self) {self.pressed = None;+ // SAFETY: Release only this popup's capture, never a newer owner's.+ unsafe {+ if GetCapture() == self.hwnd {+ let _ = ReleaseCapture();+ }+ }}/// The app under the pointer, and its icon on screen.@@ -705,7 +730,7 @@ unsafe extern "system" fn group_view_proc(hwnd: HWND, msg: u32, w: WPARAM, l: LPWM_CAPTURECHANGED => unsafe {let _ = PostMessageW(Some(hwnd), PRESS_LOST, WPARAM(0), LPARAM(0));},- PRESS_LOST => app::group_view_press_lost(),+ PRESS_LOST if unsafe { GetCapture() } != hwnd => app::group_view_press_lost(),_ => return unsafe { DefWindowProcW(hwnd, msg, w, l) },}LRESULT(0)diff --git a/crates/muelle-core/src/roster.rs b/crates/muelle-core/src/roster.rsindex 2f4dc91..68ba8d3 100644--- a/crates/muelle-core/src/roster.rs+++ b/crates/muelle-core/src/roster.rs@@ -86,12 +86,10 @@ impl Roster {keep});self.tidy_groups();- let grouped: Vec<String> = self- .groups- .iter()- .flat_map(|group| group.apps.iter().cloned())- .collect();- self.recent.retain(|id| !grouped.contains(id));+ // Recovery can move members back to the top level. They remain+ // pinned even though their old group no longer exists.+ let pinned = self.pinned_apps();+ self.recent.retain(|id| !pinned.contains(id));self}@@ -705,4 +703,29 @@ mod tests {assert_eq!(members(&roster, "muelle:group:1"), ["x", "y"]);assert!(roster.recent().is_empty());}++ #[test]+ fn loading_a_collapsed_group_must_not_also_show_its_app_in_recent() {+ let roster = Roster::new(+ vec!["muelle:group:1".into()],+ vec!["a".into(), "other".into()],+ )+ .with_groups(vec![Group {+ id: "muelle:group:1".into(),+ apps: vec!["a".into()],+ }]);+ assert_eq!(roster.pinned(), ["a"]);+ assert_eq!(roster.recent(), ["other"]);+ }++ #[test]+ fn recovering_an_orphaned_group_must_not_duplicate_its_apps_in_recent() {+ let roster =+ Roster::new(Vec::new(), vec!["a".into(), "b".into()]).with_groups(vec![Group {+ id: "muelle:group:1".into(),+ apps: vec!["a".into(), "b".into()],+ }]);+ assert_eq!(roster.pinned(), ["a", "b"]);+ assert!(roster.recent().is_empty());+ }}