Skip to content

A lightweight, macOS-style dock for Windows 11, with glass visuals, smooth magnification, and Genie effect.

feat(dock): enhance full-screen detection and improve dock behavior

CristianOlivera1aaf1ce98518d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 20b6ee1..b01e512 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,9 @@ copia la sección de la versión que se publica a la release de GitHub.
### English
+- Fixed the dock appearing over full-screen playback controls (#33). Full-screen
+ detection now follows owned controls, distinguishes custom-frame maximized
+ windows, and reacts to in-place size changes without permanent polling.
- Added Z.ai GLM Coding Plan usage limits to the menu bar island. The 5-hour rolling quota and weekly plan limits appear alongside their reset times whenever OpenCode CLI is active with a configured Z.ai Coding Plan key.
- Fixed notification controls and stray conditional text appearing in Menu Bar
settings. Each page now starts at the top when selected. Failed preference
@@ -37,6 +40,10 @@ copia la sección de la versión que se publica a la release de GitHub.
### Español
+- Corregido el dock que aparecía sobre los controles de reproducción en pantalla
+ completa (#33). La detección contempla controles flotantes vinculados a su
+ ventana, distingue ventanas maximizadas con marco propio y atiende cambios de
+ tamaño sin sondeo permanente.
- Incorporado el uso del plan Z.ai GLM Coding Plan a la isla de la barra superior. El cupo móvil de 5 horas y el límite semanal aparecen junto con sus horas de reinicio cuando OpenCode CLI está en ejecución con una clave de Z.ai Coding Plan configurada.
- Corregidas las opciones de Notificaciones y el texto de una condición que
aparecían en Barra superior. Cada sección comienza arriba al seleccionarla.
diff --git a/README.es.md b/README.es.md
index 197549b..c57f8dc 100644
--- a/README.es.md
+++ b/README.es.md
@@ -18,6 +18,8 @@ en desarrollo activo.
## Funciones
- Dock de cristal con ampliación suave de los iconos bajo el cursor.
+- Elige en Ajustes → Dock → *Posición en pantalla* si el dock va a la izquierda,
+ abajo o a la derecha. Abajo es la posición predeterminada.
- Abrir, fijar, reordenar y gestionar apps, incluidas las recientes y las ventanas abiertas.
- Agrupar apps fijadas en un solo icono del dock: suelta una app sobre otra, haz
clic en el grupo para desplegar sus apps en abanico y arrastra una fuera del
@@ -31,13 +33,16 @@ en desarrollo activo.
como un menú, con un submenú para cada carpeta, como una barra de
herramientas de la barra de tareas de Windows 10.
- Ocultación automática opcional.
+- Porcentaje de batería de ratones y auriculares compatibles. Se activa en
+ Ajustes → Barra superior → *Mostrar batería de accesorios*; viene desactivado.
- Barra superior con la app en primer plano, hora, red, volumen y batería, el idioma
del teclado, el micrófono/cámara en uso y los iconos ocultos de la bandeja,
además de los botones de búsqueda, Vista de tareas y Widgets si los tienes en la barra
de Windows.
- Una isla curva en la barra superior con los límites de Claude Code, Codex,
- OpenCode Go, Z.ai GLM Coding Plan, Gemini CLI y Antigravity. Las cuotas de
- Gemini Pro y Flash aparecen por separado cuando están disponibles.
+ OpenCode Go, Z.ai GLM Coding Plan, Gemini CLI y Antigravity. Z.ai muestra
+ sus límites de 5 horas y de la semana; las cuotas de Gemini Pro y Flash
+ aparecen por separado cuando están disponibles.
- App de Ajustes aparte, con cambios en vivo, en español, inglés y francés, y efecto genio configurable.
- Un proceso guardián devuelve la barra de tareas de Windows si el dock se cierra de forma inesperada.
@@ -149,8 +154,10 @@ dos tipos de conexión de red, ambas opcionales:
su proveedor cada cinco minutos mientras está visible, o al pulsar Actualizar.
Gemini CLI y Antigravity pueden mostrar por separado las cuotas de Gemini Pro
y Flash; Antigravity se consulta mediante su servicio local. Las credenciales
- permanecen en memoria; Muelle no las guarda. Se desactiva en Ajustes → Barra
- superior → *Mostrar uso de proveedores de IA*.
+ permanecen en memoria; Muelle no las guarda. Para Z.ai Coding Plan, Muelle
+ lee la clave del `auth.json` local de OpenCode o de `ZAI_API_KEY` /
+ `ZHIPU_API_KEY` y la envía al servicio de cuotas de Z.ai. Desactiva las
+ consultas en Ajustes → Barra superior → *Mostrar uso de proveedores de IA*.
- **Notificaciones:** el contenido y los avisos de las notificaciones se procesan exclusivamente en la memoria local de tu equipo; nunca se escriben en disco, ni se guardan en registros ni se transmiten por la red.
Detalles: [muelle.crafter.run/privacy](https://muelle.crafter.run/privacy).
diff --git a/README.fr.md b/README.fr.md
index bc1c28a..f8c51de 100644
--- a/README.fr.md
+++ b/README.fr.md
@@ -26,6 +26,8 @@ Agrandissement fluide, aperçus des fenêtres en direct et effet génie facultat
## Fonctionnalités
- Dock effet verre, avec un agrandissement fluide des icônes sous le pointeur.
+- Choisissez le bord de l'écran dans Réglages → Dock → *Position à l'écran* :
+ gauche, bas ou droite. Le bas est la position par défaut.
- Lancer, épingler, réorganiser et gérer les apps, y compris les apps récentes
et les fenêtres ouvertes.
- Regrouper des apps épinglées dans une seule icône du dock : déposez une app
@@ -46,14 +48,18 @@ Agrandissement fluide, aperçus des fenêtres en direct et effet génie facultat
un sous-menu pour chaque dossier qu'il contient, comme une barre d'outils de
la barre des tâches de Windows 10.
- Masquage automatique facultatif.
+- Niveau de batterie facultatif pour les souris et casques compatibles
+ connectés. Activez Réglages → Barre de menus → *Afficher la batterie des
+ accessoires* ; l'option est désactivée par défaut.
- Une barre de menus en haut de l'écran avec l'app au premier plan, l'heure, le
réseau, le volume et la batterie, la langue de saisie, le micro et la caméra
en cours d'utilisation, les icônes masquées de la zone de notification, ainsi
que les boutons Rechercher, Affichage des tâches et Widgets s'ils figurent
dans votre barre des tâches Windows.
- Un îlot arrondi dans la barre de menus pour les limites d'utilisation de
- Claude Code, Codex, OpenCode Go, Gemini CLI et Antigravity. Les quotas Gemini
- Pro et Flash s'affichent séparément quand ils sont disponibles.
+ Claude Code, Codex, OpenCode Go, Z.ai GLM Coding Plan, Gemini CLI et
+ Antigravity. Z.ai affiche ses quotas sur 5 heures et sur une semaine ; les
+ quotas Gemini Pro et Flash s'affichent séparément quand ils sont disponibles.
- Une app Réglages séparée, aux changements appliqués en direct, en espagnol,
anglais et français, avec une animation de réduction façon génie
configurable.
@@ -168,7 +174,9 @@ au projet. Il fait deux sortes de requêtes réseau, toutes deux facultatives :
Antigravity, les quotas Gemini Pro et Flash s'affichent séparément quand ils
sont disponibles ; Antigravity est interrogé via son service local. Les
identifiants restent en mémoire et ne sont jamais enregistrés par Muelle.
- Désactivez-la dans Réglages → Barre de menus → *Afficher l'utilisation des
- fournisseurs d'IA*.
+ Pour Z.ai Coding Plan, Muelle lit la clé dans le fichier local `auth.json`
+ d'OpenCode ou dans `ZAI_API_KEY` / `ZHIPU_API_KEY`, puis l'envoie au service
+ de quotas de Z.ai. Désactivez les requêtes dans Réglages → Barre de menus →
+ *Afficher l'utilisation des fournisseurs d'IA*.
Détails : [muelle.crafter.run/privacy](https://muelle.crafter.run/privacy).
diff --git a/README.md b/README.md
index f3321dc..4252caf 100644
--- a/README.md
+++ b/README.md
@@ -25,6 +25,8 @@ Smooth magnification, live window previews, and an optional Genie-style minimize
## Features
- Glass-style dock with smooth, cursor-based icon magnification.
+- Choose the dock's screen edge in Settings → Dock → *Position on screen*:
+ left, bottom, or right. Bottom is the default.
- Launch, pin, reorder, and manage apps, including recent apps and open windows.
- Group pinned apps into a single dock icon: drop one app onto another, click
the group to fan its apps out, and drag one out of the fan to take it back.
@@ -39,12 +41,15 @@ Smooth magnification, live window previews, and an optional Genie-style minimize
- A shortcuts folder at the right of the dock: its contents open as a menu,
with a submenu for each folder inside, like a Windows 10 taskbar toolbar.
- Optional auto-hide.
+- Optional battery levels for compatible connected mice and headsets. Enable
+ Settings → Menu bar → *Show accessory battery*; it is off by default.
- A top menu bar with the app in front, clock, network, volume and battery, the
input language, microphone/camera in use, the hidden tray icons, plus
the Search, Task View and Widgets buttons if you have them on the Windows taskbar.
- A curved island in the menu bar for usage limits from Claude Code, Codex,
- OpenCode Go, Z.ai GLM Coding Plan, Gemini CLI, and Antigravity. Gemini Pro
- and Flash quotas appear separately when available.
+ OpenCode Go, Z.ai GLM Coding Plan, Gemini CLI, and Antigravity. Z.ai shows
+ its 5-hour and weekly limits; Gemini Pro and Flash quotas appear separately
+ when available.
- Separate Settings app with live changes, Spanish, English and French, and a
configurable Genie-style minimize animation.
- A watchdog restores the Windows taskbar if the dock exits unexpectedly.
@@ -151,8 +156,10 @@ project. It makes two kinds of network requests, both optional:
every five minutes while visible, or when you press Refresh. For Gemini CLI
and Antigravity, Gemini Pro and Flash quotas are shown separately when
available; Antigravity is queried through its local service. Credentials stay
- in memory and are never stored by Muelle. Turn it off in Settings → Menu bar
- → *Show AI provider usage*.
+ in memory and are never stored by Muelle. For Z.ai Coding Plan, Muelle reads
+ the key from OpenCode's local `auth.json` or `ZAI_API_KEY` /
+ `ZHIPU_API_KEY`, then sends it to Z.ai's quota service. Turn usage queries
+ off in Settings → Menu bar → *Show AI provider usage*.
- **Notifications:** notification content and banners are processed strictly in memory on your local machine and are never written to disk, saved in log files, or transmitted over the network.
Details: [muelle.crafter.run/privacy](https://muelle.crafter.run/privacy).
diff --git a/apps/dock/src/app.rs b/apps/dock/src/app.rs
index 1cbccd4..6b5957b 100644
--- a/apps/dock/src/app.rs
+++ b/apps/dock/src/app.rs
@@ -74,19 +74,20 @@ use windows::{
},
WindowsAndMessaging::{
CreateWindowExW, DefWindowProcW, DispatchMessageW, EVENT_OBJECT_CLOAKED,
- EVENT_OBJECT_UNCLOAKED, EVENT_SYSTEM_FOREGROUND, EVENT_SYSTEM_MINIMIZEEND,
- EVENT_SYSTEM_MINIMIZESTART, FindWindowW, GetCursorPos, GetMessageW,
- 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, SM_SWAPBUTTON, SWP_HIDEWINDOW, SWP_NOACTIVATE,
- SWP_SHOWWINDOW, SetTimer, SetWindowPos, WINDOW_EX_STYLE, WINEVENT_OUTOFCONTEXT,
- WINEVENT_SKIPOWNPROCESS, WM_APP, WM_CAPTURECHANGED, WM_CLOSE, WM_COPYDATA,
- WM_DESTROY, WM_DISPLAYCHANGE, WM_DPICHANGED, WM_INITMENUPOPUP, WM_LBUTTONDOWN,
- WM_LBUTTONUP, WM_MBUTTONDOWN, WM_MBUTTONUP, WM_MOUSEACTIVATE, WM_MOUSEMOVE,
- WM_QUIT, WM_RBUTTONUP, WM_SETTINGCHANGE, WM_TIMER, WNDCLASSW, WS_EX_LAYERED,
- WS_EX_NOACTIVATE, WS_EX_NOREDIRECTIONBITMAP, WS_EX_TOOLWINDOW, WS_EX_TOPMOST,
- WS_EX_TRANSPARENT, WS_POPUP,
+ EVENT_OBJECT_LOCATIONCHANGE, EVENT_OBJECT_UNCLOAKED, EVENT_SYSTEM_FOREGROUND,
+ EVENT_SYSTEM_MINIMIZEEND, EVENT_SYSTEM_MINIMIZESTART, FindWindowW, GetCursorPos,
+ GetMessageW, 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, SM_SWAPBUTTON,
+ SWP_HIDEWINDOW, SWP_NOACTIVATE, SWP_SHOWWINDOW, SetTimer, SetWindowPos,
+ WINDOW_EX_STYLE, WINEVENT_OUTOFCONTEXT, WINEVENT_SKIPOWNPROCESS, WM_APP,
+ WM_CAPTURECHANGED, WM_CLOSE, WM_COPYDATA, WM_DESTROY, WM_DISPLAYCHANGE,
+ WM_DPICHANGED, WM_INITMENUPOPUP, WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MBUTTONDOWN,
+ WM_MBUTTONUP, WM_MOUSEACTIVATE, WM_MOUSEMOVE, WM_QUIT, WM_RBUTTONUP,
+ WM_SETTINGCHANGE, WM_TIMER, WNDCLASSW, WS_EX_LAYERED, WS_EX_NOACTIVATE,
+ WS_EX_NOREDIRECTIONBITMAP, WS_EX_TOOLWINDOW, WS_EX_TOPMOST, WS_EX_TRANSPARENT,
+ WS_POPUP,
},
},
},
@@ -296,6 +297,7 @@ static DROP_WINDOW: AtomicIsize = AtomicIsize::new(0);
static MINIMIZE_HOOK: AtomicIsize = AtomicIsize::new(0);
static CLOAK_HOOK: AtomicIsize = AtomicIsize::new(0);
static FOREGROUND_HOOK: AtomicIsize = AtomicIsize::new(0);
+static LOCATION_HOOK: AtomicIsize = AtomicIsize::new(0);
/// The window in front before the Alt+Tab switcher opened.
static LAST_FRONT: AtomicIsize = AtomicIsize::new(0);
@@ -1974,6 +1976,14 @@ impl App {
}
fn on_mouse_move(&mut self) -> Result<()> {
+ // A player or browser can enter full screen without changing focus.
+ // Do not let a stale reveal-strip message raise the dock above it.
+ if !self.hovering {
+ self.update_fullscreen()?;
+ }
+ if self.fullscreen {
+ return Ok(());
+ }
let Some(stage) = &self.stage else {
return Ok(());
};
@@ -4757,7 +4767,7 @@ unsafe extern "system" fn on_win_event(
event: u32,
hwnd: HWND,
object: i32,
- _child: i32,
+ child: i32,
_thread: u32,
_time: u32,
) {
@@ -4778,6 +4788,13 @@ unsafe extern "system" fn on_win_event(
LAST_FRONT.store(hwnd.0 as isize, Ordering::Relaxed);
with_app("ventana activa", App::on_foreground_changed);
}
+ } else if event == EVENT_OBJECT_LOCATIONCHANGE {
+ // Only the foreground top-level window matters. Ignore child controls,
+ // carets and background animations, and coalesce resize bursts using
+ // the existing full-screen timer, without enumerating apps or polling.
+ if child == 0 && hwnd.0 as isize == tracker::foreground_window() {
+ unsafe { SetTimer(Some(main_window()), FULLSCREEN_TIMER, SYNC_DELAY_MS, None) };
+ }
} else if event == EVENT_OBJECT_CLOAKED || event == EVENT_OBJECT_UNCLOAKED {
// Shows the windows of the virtual desktop in front, as the Windows
// taskbar does. A desktop switch cloaks many windows at once; the
@@ -5781,6 +5798,16 @@ pub fn run() -> Result<()> {
WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS,
);
FOREGROUND_HOOK.store(foreground_hook.0 as isize, Ordering::Relaxed);
+ let location_hook = SetWinEventHook(
+ EVENT_OBJECT_LOCATIONCHANGE,
+ EVENT_OBJECT_LOCATIONCHANGE,
+ None,
+ Some(on_win_event),
+ 0,
+ 0,
+ WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS,
+ );
+ LOCATION_HOOK.store(location_hook.0 as isize, Ordering::Relaxed);
LAST_FRONT.store(tracker::foreground_window(), Ordering::Relaxed);
let target: IDropTarget = DropTarget.into();
RegisterDragDrop(input, &target)?;
@@ -5805,7 +5832,12 @@ pub fn run() -> Result<()> {
// SAFETY: The drop target was registered on this window in this thread.
unsafe {
let _ = RevokeDragDrop(HWND(DROP_WINDOW.load(Ordering::Relaxed) as *mut _));
- for hook in [&MINIMIZE_HOOK, &CLOAK_HOOK, &FOREGROUND_HOOK] {
+ for hook in [
+ &MINIMIZE_HOOK,
+ &CLOAK_HOOK,
+ &FOREGROUND_HOOK,
+ &LOCATION_HOOK,
+ ] {
let _ = UnhookWinEvent(HWINEVENTHOOK(hook.load(Ordering::Relaxed) as *mut _));
}
}
diff --git a/apps/dock/src/multi_window_view.rs b/apps/dock/src/multi_window_view.rs
index 533e8d4..7563821 100644
--- a/apps/dock/src/multi_window_view.rs
+++ b/apps/dock/src/multi_window_view.rs
@@ -48,6 +48,8 @@ const CARD_WIDTH: f32 = 216.0;
const CARD_HEIGHT: f32 = 164.0;
const HEADER: f32 = 24.0;
const ARC: f32 = 16.0;
+const PREVIEW_INSET: f32 = 4.0;
+const CLOSE_BUTTON_GAP: f32 = 4.0;
const OPEN_SECONDS: f32 = 0.2;
const LEAVE_DELAY: Duration = Duration::from_millis(220);
@@ -175,6 +177,23 @@ fn contains(rect: RECT, point: POINT) -> bool {
point.x >= rect.left && point.x < rect.right && point.y >= rect.top && point.y < rect.bottom
}
+fn thumbnail_top_inset(scale: f32, show_close: bool) -> f32 {
+ if show_close {
+ let close = muelle_core::preview::close_button_bounds(
+ muelle_core::layout::Rect {
+ x: 0.0,
+ y: 0.0,
+ width: CARD_WIDTH,
+ height: CARD_HEIGHT,
+ },
+ scale,
+ );
+ close.visual.y + close.visual.height + CLOSE_BUTTON_GAP * scale.max(0.5)
+ } else {
+ PREVIEW_INSET * scale
+ }
+}
+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum MultiWindowAction {
Activate(isize),
@@ -187,7 +206,6 @@ struct Card {
close_btn: Option<SpriteVisual>,
close_normal_brush: Option<CompositionSurfaceBrush>,
close_hover_brush: Option<CompositionSurfaceBrush>,
- close_tooltip: Option<SpriteVisual>,
}
pub struct MultiWindowView {
@@ -394,8 +412,8 @@ impl MultiWindowView {
let shape = c.CreateRoundedRectangleGeometry()?;
shape.SetSize(size)?;
shape.SetCornerRadius(Vector2 {
- X: 12.0 * self.scale,
- Y: 12.0 * self.scale,
+ X: muelle_core::preview::PREVIEW_CARD_CORNER_RADIUS * self.scale,
+ Y: muelle_core::preview::PREVIEW_CARD_CORNER_RADIUS * self.scale,
})?;
card.SetClip(&c.CreateGeometricClipWithGeometry(&shape)?)?;
let background = c.CreateSpriteVisual()?;
@@ -449,9 +467,7 @@ impl MultiWindowView {
})?;
card.Children()?.InsertAtTop(&caption)?;
- let (close_btn, close_normal_brush, close_hover_brush, close_tooltip) = if self
- .show_close
- {
+ let (close_btn, close_normal_brush, close_hover_brush) = if self.show_close {
let card_rect = muelle_core::layout::Rect {
x: 0.0,
y: 0.0,
@@ -477,31 +493,9 @@ impl MultiWindowView {
btn_visual.SetOpacity(0.0)?;
card.Children()?.InsertAtTop(&btn_visual)?;
- let tip_text = text().close_window.replace('&', "");
- let tip_label =
- gfx.label_brush(&tip_text, self.scale, self.theme.light, self.layout.edge)?;
- let tip_visual = c.CreateSpriteVisual()?;
- tip_visual.SetBrush(&tip_label.brush)?;
- tip_visual.SetSize(Vector2 {
- X: tip_label.width,
- Y: tip_label.height,
- })?;
- tip_visual.SetOffset(Vector3 {
- X: btn_bounds.visual.x + btn_bounds.visual.width + 4.0 * self.scale,
- Y: btn_bounds.visual.y,
- Z: 0.0,
- })?;
- tip_visual.SetOpacity(0.0)?;
- card.Children()?.InsertAtTop(&tip_visual)?;
-
- (
- Some(btn_visual),
- Some(normal_brush),
- Some(hover_brush),
- Some(tip_visual),
- )
+ (Some(btn_visual), Some(normal_brush), Some(hover_brush))
} else {
- (None, None, None, None)
+ (None, None, None)
};
layers.InsertAtTop(&card)?;
@@ -511,7 +505,6 @@ impl MultiWindowView {
close_btn,
close_normal_brush,
close_hover_brush,
- close_tooltip,
});
}
if let Some(target) = &self.target {
@@ -576,17 +569,14 @@ impl MultiWindowView {
})?;
}
btn.SetOpacity(if is_card_hovered { 1.0 } else { 0.0 })?;
- if let Some(tip) = &card.close_tooltip {
- tip.SetOpacity(if is_close_hovered { 1.0 } else { 0.0 })?;
- }
}
if let Some(&hwnd) = self.windows.get(self.page + index) {
self.thumbnails.place_preview(
hwnd,
RECT {
- left: (x + 4.0 * self.scale).round() as i32,
- top: (y + 4.0 * self.scale).round() as i32,
- right: (x + width - 4.0 * self.scale).round() as i32,
+ left: (x + PREVIEW_INSET * self.scale).round() as i32,
+ top: (y + thumbnail_top_inset(self.scale, self.show_close)).round() as i32,
+ right: (x + width - PREVIEW_INSET * self.scale).round() as i32,
bottom: (y + (CARD_HEIGHT - 31.0) * self.scale).round() as i32,
},
(255.0 * eased) as u8,
@@ -783,6 +773,30 @@ unsafe extern "system" fn multi_window_view_proc(
mod tests {
use super::*;
+ #[test]
+ fn thumbnail_starts_below_close_button_when_enabled() {
+ for scale in [0.75, 1.0, 1.1, 1.25, 1.5, 2.0] {
+ let close = muelle_core::preview::close_button_bounds(
+ muelle_core::layout::Rect {
+ x: 0.0,
+ y: 0.0,
+ width: CARD_WIDTH,
+ height: CARD_HEIGHT,
+ },
+ scale,
+ );
+ assert!(
+ thumbnail_top_inset(scale, true)
+ >= close.visual.y + close.visual.height + CLOSE_BUTTON_GAP * scale
+ );
+ }
+ }
+
+ #[test]
+ fn thumbnail_keeps_original_top_inset_when_close_button_is_disabled() {
+ assert_eq!(thumbnail_top_inset(1.0, false), PREVIEW_INSET);
+ }
+
#[test]
#[ignore = "requires an interactive Windows desktop and DWM"]
fn native_multi_window_view_should_page_select_without_focus_and_release_its_window()
@@ -882,6 +896,12 @@ mod tests {
(rect.top as f32 + (CARD_HEIGHT - 31.0) * view.scale).round() as i32,
"each preview must align with its card's caption baseline"
);
+ assert!(
+ image.top
+ >= (rect.top as f32 + thumbnail_top_inset(view.scale, view.show_close))
+ .round() as i32,
+ "the DWM thumbnail must leave room for the close button"
+ );
}
let hwnd = view.hwnd;
assert!(unsafe { IsWindowVisible(hwnd) }.as_bool());
diff --git a/apps/dock/src/usage.rs b/apps/dock/src/usage.rs
index 11f319c..3c5492a 100644
--- a/apps/dock/src/usage.rs
+++ b/apps/dock/src/usage.rs
@@ -778,10 +778,10 @@ fn zai_token(
return Some(key.to_owned());
}
for path in zai_auth_paths(data_home, home) {
- if let Some(auth) = read_opencode_auth(&path) {
- if let Some(key) = zai_key(None, Some(&auth)) {
- return Some(key.to_owned());
- }
+ if let Some(auth) = read_opencode_auth(&path)
+ && let Some(key) = zai_key(None, Some(&auth))
+ {
+ return Some(key.to_owned());
}
}
None
diff --git a/assets/usage/zai.png b/assets/usage/zai.png
index a7c6d5a..9eed05e 100644
Binary files a/assets/usage/zai.png and b/assets/usage/zai.png differ
diff --git a/assets/usage/zai.svg b/assets/usage/zai.svg
index 80a6935..25ecadd 100644
--- a/assets/usage/zai.svg
+++ b/assets/usage/zai.svg
@@ -1,3 +1,4 @@
-<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128">
- <path fill="#f5f7fa" fill-rule="evenodd" d="M26 26h76v16L54 86h48v16H26V86l48-44H26Z"/>
+<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 24 24">
+ <title>Z.ai</title>
+ <path fill="currentColor" fill-rule="evenodd" d="M12.105 2 9.927 4.953H.653L2.83 2h9.276zM23.254 19.048 21.078 22h-9.242l2.174-2.952h9.244zM24 2 9.264 22H0L14.736 2H24z"/>
</svg>
diff --git a/crates/muelle-core/src/preview.rs b/crates/muelle-core/src/preview.rs
index 14f2fb0..ae09795 100644
--- a/crates/muelle-core/src/preview.rs
+++ b/crates/muelle-core/src/preview.rs
@@ -6,8 +6,10 @@ use crate::layout::Rect;
pub const MIN_CLOSE_HIT_TARGET: f32 = 20.0;
/// Nominal diameter of the visible close circle at scale 1.0.
pub const CLOSE_BUTTON_DIAMETER: f32 = 18.0;
-/// Padding from the top and left edges of the card.
-pub const CLOSE_BUTTON_INSET: f32 = 6.0;
+/// Corner radius used by the preview card's rounded clip.
+pub const PREVIEW_CARD_CORNER_RADIUS: f32 = 12.0;
+/// Keeps the close button inside the preview card's rounded-corner clip.
+pub const CLOSE_BUTTON_INSET: f32 = PREVIEW_CARD_CORNER_RADIUS;
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Point {
@@ -36,7 +38,7 @@ pub struct CloseButtonBounds {
pub fn close_button_bounds(card: Rect, scale: f32) -> CloseButtonBounds {
let scale = scale.max(0.5);
let visual_size = (CLOSE_BUTTON_DIAMETER * scale).round();
- let inset = (CLOSE_BUTTON_INSET * scale).round();
+ let inset = (CLOSE_BUTTON_INSET * scale).ceil();
let visual = Rect {
x: card.x + inset,
@@ -148,6 +150,22 @@ mod tests {
}
}
+ #[test]
+ fn close_button_visual_stays_inside_rounded_corner_clip_at_all_scales() {
+ let card = Rect {
+ x: 100.0,
+ y: 200.0,
+ width: 216.0,
+ height: 164.0,
+ };
+ for scale in [0.75, 1.0, 1.1, 1.25, 1.5, 2.0] {
+ let bounds = close_button_bounds(card, scale);
+ let safe_inset = PREVIEW_CARD_CORNER_RADIUS * scale;
+ assert!(bounds.visual.x - card.x >= safe_inset);
+ assert!(bounds.visual.y - card.y >= safe_inset);
+ }
+ }
+
#[test]
fn hit_test_prioritizes_close_button_over_card_body() {
let card = Rect {
diff --git a/crates/muelle-shell/Cargo.toml b/crates/muelle-shell/Cargo.toml
index 50dfcd7..8f14d93 100644
--- a/crates/muelle-shell/Cargo.toml
+++ b/crates/muelle-shell/Cargo.toml
@@ -47,3 +47,6 @@ windows = { workspace = true, features = [
"Win32_UI_Shell_PropertiesSystem",
"Win32_UI_WindowsAndMessaging",
] }
+
+[dev-dependencies]
+windows = { workspace = true, features = ["Win32_System_LibraryLoader"] }
diff --git a/crates/muelle-shell/src/tracker.rs b/crates/muelle-shell/src/tracker.rs
index e3c65a1..593b36d 100644
--- a/crates/muelle-shell/src/tracker.rs
+++ b/crates/muelle-shell/src/tracker.rs
@@ -9,7 +9,10 @@ use std::collections::HashMap;
use windows::{
Win32::{
Foundation::{CloseHandle, HWND, LPARAM, POINT, RECT, WPARAM},
- Graphics::Dwm::{DWMWA_CLOAKED, DwmGetWindowAttribute},
+ Graphics::{
+ Dwm::{DWMWA_CLOAKED, DwmGetWindowAttribute},
+ Gdi::ClientToScreen,
+ },
Storage::{
EnhancedStorage::PKEY_AppUserModel_ID, Packaging::Appx::GetApplicationUserModelId,
},
@@ -20,12 +23,12 @@ use windows::{
UI::{
Shell::PropertiesSystem::{IPropertyStore, SHGetPropertyStoreForWindow},
WindowsAndMessaging::{
- EnumWindows, GW_OWNER, GWL_EXSTYLE, GWL_STYLE, GetClassNameW, GetForegroundWindow,
- GetWindow, GetWindowLongW, GetWindowPlacement, GetWindowRect, GetWindowTextLengthW,
- GetWindowTextW, GetWindowThreadProcessId, IsIconic, IsWindow, IsWindowVisible,
- IsZoomed, PostMessageW, SM_CXPADDEDBORDER, SM_CXSIZEFRAME, SWP_ASYNCWINDOWPOS,
- SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOOWNERZORDER, SWP_NOSIZE, SetWindowPos,
- WINDOWPLACEMENT, WM_CLOSE, WPF_RESTORETOMAXIMIZED, WS_EX_APPWINDOW,
+ EnumWindows, GW_OWNER, GWL_EXSTYLE, GWL_STYLE, GetClassNameW, GetClientRect,
+ GetForegroundWindow, GetWindow, GetWindowLongW, GetWindowPlacement, GetWindowRect,
+ GetWindowTextLengthW, GetWindowTextW, GetWindowThreadProcessId, IsIconic, IsWindow,
+ IsWindowVisible, IsZoomed, PostMessageW, SM_CXPADDEDBORDER, SM_CXSIZEFRAME,
+ SWP_ASYNCWINDOWPOS, SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOOWNERZORDER, SWP_NOSIZE,
+ SetWindowPos, WINDOWPLACEMENT, WM_CLOSE, WPF_RESTORETOMAXIMIZED, WS_EX_APPWINDOW,
WS_EX_NOACTIVATE, WS_EX_TOOLWINDOW, WS_EX_TOPMOST, WS_MAXIMIZE, WS_THICKFRAME,
},
},
@@ -304,9 +307,9 @@ fn recover_browser_z_order_with(
/// Returns `true` if the foreground window covers the entire `screen`
/// (for example, video, presentation, or game). The desktop does not count,
-/// and neither does a maximized window: when nothing reserves screen space
-/// (auto-hide), it covers the screen too, but it still has its sizing frame,
-/// which apps drop when they go full screen.
+/// and neither does a normally maximized window: its content still starts
+/// below the title bar. Custom-frame apps may retain maximize/resize style
+/// bits in full screen, so measure their content instead of those styles.
#[must_use]
pub fn foreground_is_fullscreen(screen: RECT) -> bool {
// SAFETY: Read-only queries on the foreground window.
@@ -327,13 +330,71 @@ pub fn foreground_is_fullscreen(screen: RECT) -> bool {
if pid == GetCurrentProcessId() {
return false;
}
- let style = GetWindowLongW(hwnd, GWL_STYLE) as u32;
- let maximized = WS_MAXIMIZE.0 | WS_THICKFRAME.0;
- if style & maximized == maximized {
- return false;
+ fullscreen_owner_chain(hwnd, screen)
+ }
+}
+
+fn fullscreen_owner_chain(mut hwnd: HWND, screen: RECT) -> bool {
+ // A player's floating playback controls can take focus while their owner
+ // stays full screen. Follow only that owner chain, never unrelated windows.
+ // SAFETY: Read-only queries; bound traversal even if a window changes owners.
+ unsafe {
+ for _ in 0..16 {
+ if IsWindowVisible(hwnd).as_bool()
+ && !IsIconic(hwnd).as_bool()
+ && !is_cloaked(hwnd)
+ && fills_screen(hwnd, screen)
+ {
+ return true;
+ }
+ let Ok(owner) = GetWindow(hwnd, GW_OWNER) else {
+ break;
+ };
+ if owner.is_invalid() {
+ break;
+ }
+ hwnd = owner;
}
+ }
+ false
+}
+
+fn fills_screen(hwnd: HWND, screen: RECT) -> bool {
+ // SAFETY: Read-only queries with stack outputs; none sends a synchronous
+ // message to the app, so a hung player cannot block the dock here.
+ unsafe {
let mut rect = RECT::default();
- GetWindowRect(hwnd, &mut rect).is_ok() && covers(rect, screen)
+ if GetWindowRect(hwnd, &mut rect).is_err() || !covers(rect, screen) {
+ return false;
+ }
+ // Browsers can draw their title bar inside the client area. When
+ // normally maximized they still overflow the screen by the invisible
+ // resize border; full-screen content fits the monitor itself.
+ if GetWindowLongW(hwnd, GWL_STYLE) as u32 & WS_MAXIMIZE.0 != 0 && rect != screen {
+ return false;
+ }
+ if GetClientRect(hwnd, &mut rect).is_err() {
+ return false;
+ }
+ let mut top_left = POINT {
+ x: rect.left,
+ y: rect.top,
+ };
+ let mut bottom_right = POINT {
+ x: rect.right,
+ y: rect.bottom,
+ };
+ ClientToScreen(hwnd, &mut top_left).as_bool()
+ && ClientToScreen(hwnd, &mut bottom_right).as_bool()
+ && covers(
+ RECT {
+ left: top_left.x,
+ top: top_left.y,
+ right: bottom_right.x,
+ bottom: bottom_right.y,
+ },
+ screen,
+ )
}
}
@@ -601,6 +662,230 @@ pub fn request_close_window(hwnd: isize) -> bool {
mod tests {
use super::*;
+ #[test]
+ fn fullscreen_geometry_should_follow_content_instead_of_maximized_style()
+ -> windows::core::Result<()> {
+ use windows::{
+ Win32::{
+ Foundation::LRESULT,
+ System::LibraryLoader::GetModuleHandleW,
+ UI::WindowsAndMessaging::{
+ CreateWindowExW, DefWindowProcW, DestroyWindow, RegisterClassW,
+ SW_SHOWNOACTIVATE, SWP_FRAMECHANGED, SetWindowLongW, ShowWindow,
+ UnregisterClassW, WM_NCCALCSIZE, WNDCLASSW, WS_OVERLAPPEDWINDOW, WS_POPUP,
+ },
+ },
+ core::w,
+ };
+
+ // Qt and other custom-frame apps can retain resize/maximize styles
+ // while returning the whole window as client area in full-screen mode.
+ unsafe extern "system" fn frameless(hwnd: HWND, msg: u32, w: WPARAM, l: LPARAM) -> LRESULT {
+ if msg == WM_NCCALCSIZE {
+ LRESULT(0)
+ } else {
+ unsafe { DefWindowProcW(hwnd, msg, w, l) }
+ }
+ }
+ struct Fixture(HWND);
+ impl Drop for Fixture {
+ fn drop(&mut self) {
+ unsafe {
+ let _ = DestroyWindow(self.0);
+ }
+ }
+ }
+ let class = w!("MuelleFullscreenGeometryTest");
+ // Small virtual displays avoid Windows' maximum tracking-size limit
+ // on test machines with smaller monitors or different DPI settings.
+ const SCREEN: RECT = RECT {
+ left: 0,
+ top: 0,
+ right: 800,
+ bottom: 600,
+ };
+ // The test's windows stay hidden, never taking focus from the user.
+ unsafe {
+ let instance = GetModuleHandleW(None)?;
+ let registered = RegisterClassW(&WNDCLASSW {
+ hInstance: instance.into(),
+ lpszClassName: class,
+ lpfnWndProc: Some(frameless),
+ ..Default::default()
+ });
+ assert_ne!(registered, 0);
+ let run = || -> windows::core::Result<()> {
+ for screen in [
+ SCREEN,
+ RECT {
+ left: -800,
+ right: 0,
+ ..SCREEN
+ },
+ ] {
+ for style in [WS_POPUP, WS_POPUP | WS_THICKFRAME | WS_MAXIMIZE] {
+ let window = Fixture(CreateWindowExW(
+ Default::default(),
+ class,
+ w!("Fullscreen fixture"),
+ style & !WS_MAXIMIZE,
+ screen.left,
+ screen.top,
+ 800,
+ 600,
+ None,
+ None,
+ Some(instance.into()),
+ None,
+ )?);
+ SetWindowPos(
+ window.0,
+ None,
+ screen.left,
+ screen.top,
+ 800,
+ 600,
+ SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_FRAMECHANGED,
+ )?;
+ // Preserve the requested full-screen geometry rather than
+ // letting Windows maximize it to this machine's work area.
+ SetWindowLongW(window.0, GWL_STYLE, style.0 as i32);
+ let mut actual = RECT::default();
+ let mut content = RECT::default();
+ let mut origin = POINT::default();
+ GetWindowRect(window.0, &mut actual)?;
+ GetClientRect(window.0, &mut content)?;
+ let _ = ClientToScreen(window.0, &mut origin);
+ assert!(
+ fills_screen(window.0, screen),
+ "full-screen content, style {style:?}, window {actual:?}, client {content:?}, origin {origin:?}, screen {screen:?}"
+ );
+ assert!(
+ !fills_screen(
+ window.0,
+ RECT {
+ left: screen.right,
+ right: screen.right + 800,
+ ..screen
+ }
+ ),
+ "a different display must stay usable"
+ );
+ SetWindowLongW(window.0, GWL_STYLE, (style & !WS_MAXIMIZE).0 as i32);
+ SetWindowPos(
+ window.0,
+ None,
+ screen.left,
+ screen.top,
+ 400,
+ 300,
+ SWP_NOACTIVATE | SWP_NOOWNERZORDER,
+ )?;
+ SetWindowLongW(window.0, GWL_STYLE, style.0 as i32);
+ assert!(
+ !fills_screen(window.0, screen),
+ "leaving full screen must restore the dock"
+ );
+ if style.0 & WS_MAXIMIZE.0 != 0 {
+ SetWindowLongW(window.0, GWL_STYLE, (style & !WS_MAXIMIZE).0 as i32);
+ SetWindowPos(
+ window.0,
+ None,
+ screen.left - 8,
+ screen.top - 8,
+ 816,
+ 616,
+ SWP_NOACTIVATE | SWP_NOOWNERZORDER,
+ )?;
+ SetWindowLongW(window.0, GWL_STYLE, style.0 as i32);
+ assert!(
+ !fills_screen(window.0, screen),
+ "a normally maximized custom-frame browser must keep the dock available"
+ );
+ }
+ }
+ let captioned = Fixture(CreateWindowExW(
+ Default::default(),
+ w!("STATIC"),
+ w!("Captioned fixture"),
+ WS_OVERLAPPEDWINDOW,
+ screen.left,
+ screen.top,
+ 800,
+ 600,
+ None,
+ None,
+ Some(instance.into()),
+ None,
+ )?);
+ assert!(
+ !fills_screen(captioned.0, screen),
+ "a captioned screen-sized window is not full screen"
+ );
+ }
+ // Off-screen, non-activating fixtures exercise actual Win32
+ // ownership and visibility without covering the user's apps.
+ let screen = RECT {
+ left: -16000,
+ top: -16000,
+ right: -15200,
+ bottom: -15400,
+ };
+ let owner = Fixture(CreateWindowExW(
+ WS_EX_NOACTIVATE,
+ class,
+ w!("Fullscreen owner"),
+ WS_POPUP,
+ screen.left,
+ screen.top,
+ 800,
+ 600,
+ None,
+ None,
+ Some(instance.into()),
+ None,
+ )?);
+ let controls = Fixture(CreateWindowExW(
+ WS_EX_NOACTIVATE | WS_EX_TOOLWINDOW,
+ class,
+ w!("Playback controls"),
+ WS_POPUP,
+ screen.left,
+ screen.bottom - 50,
+ 300,
+ 50,
+ Some(owner.0),
+ None,
+ Some(instance.into()),
+ None,
+ )?);
+ let _ = ShowWindow(owner.0, SW_SHOWNOACTIVATE);
+ let _ = ShowWindow(controls.0, SW_SHOWNOACTIVATE);
+ assert!(
+ fullscreen_owner_chain(controls.0, screen),
+ "playback controls must preserve their owner's fullscreen state"
+ );
+ SetWindowPos(
+ owner.0,
+ None,
+ screen.left,
+ screen.top,
+ 400,
+ 300,
+ SWP_NOACTIVATE | SWP_NOOWNERZORDER,
+ )?;
+ assert!(
+ !fullscreen_owner_chain(controls.0, screen),
+ "leaving fullscreen must clear the owned controls too"
+ );
+ Ok(())
+ };
+ let result = run();
+ let _ = UnregisterClassW(class, Some(instance.into()));
+ result
+ }
+ }
+
#[test]
#[ignore = "requires an interactive Windows desktop; only moves test windows"]
fn blocking_browser_should_move_behind_both_windows_of_the_selected_app()