From 87685b65786cc03049d6d46d618ce28703fc8443 Mon Sep 17 00:00:00 2001 From: Alfredo Pinto Date: Thu, 26 Nov 2026 23:43:26 -0800 Subject: [PATCH] El deck muestra las apps que corren como administrador MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - SADP y HiToolsDelivery corren elevadas y Windows no deja moverlas: salen en Libres, atenuadas y con 🛡; tocarlas las trae al frente. Ningún modo las toca. - El filtro ya no descarta las ventanas sin marco que tienen botón de minimizar (Qt, como SADP). - Limitaciones y CHANGELOG. --- CHANGELOG.md | 1 + site/es/limitaciones.md | 2 +- site/limitations.md | 2 +- src/FocusWShell.App/DeckWindow.cs | 38 +++++++++++++++++-- src/FocusWShell.App/ListPanels.cs | 6 +++ src/FocusWShell.App/ShellController.cs | 22 +++++++++++ src/FocusWShell.App/Strings.Designer.cs | 3 ++ src/FocusWShell.App/Strings.en.resx | 1 + src/FocusWShell.App/Strings.resx | 1 + .../Windows/EligibilityFilter.cs | 5 ++- .../Windows/WindowSnapshot.cs | 3 ++ src/FocusWShell.Win32/WindowEnumerator.cs | 1 + .../Windows/EligibilityFilterTests.cs | 9 +++++ 13 files changed, 86 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c035ea..fd41ddf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Todos los cambios importantes de FocusWShell. Cada versión tiene sus notas en [ ## Unreleased / Sin publicar - Fixed: Store apps whose window does not give its app ID (WhatsApp) showed an internal name ("WhatsApp.Root") and a generic icon. They now take the name and icon of the Start menu. / Corregido: las apps de la Store cuya ventana no da su id de app (WhatsApp) salían con un nombre interno («WhatsApp.Root») y un icono genérico. Ahora toman el nombre y el icono del menú Inicio. +- The deck now shows the apps that run as administrator (SADP, for example), in Free, dimmed and with 🛡: FocusWShell can't move them, but tapping one brings it to the front. Borderless apps with a minimize button (Qt) are no longer ignored. / El deck ahora muestra las apps que corren como administrador (SADP, por ejemplo), en Libres, atenuadas y con 🛡: FocusWShell no puede moverlas, pero tocarlas las trae al frente. Las apps sin marco con botón de minimizar (Qt) ya no se ignoran. ## 0.5.0-alpha diff --git a/site/es/limitaciones.md b/site/es/limitaciones.md index 9a7c4ad..8737297 100644 --- a/site/es/limitaciones.md +++ b/site/es/limitaciones.md @@ -22,7 +22,7 @@ El soporte completo (un foco y unas apps por escritorio, y pestañas de escritor ## Apps que no se pueden organizar -- **Las apps que se ejecutan como administrador** no las puede mover FocusWShell, que corre sin elevación. Aparecen con el motivo y se quedan donde están. +- **Las apps que se ejecutan como administrador** no las puede mover FocusWShell, que corre sin elevación: Windows no lo deja. Salen en Libres del deck, atenuadas y con 🛡, y tocarlas las trae al frente; en la ventana principal aparecen con el motivo. Si una app no necesita ser administrador (en sus propiedades, Compatibilidad → «Ejecutar este programa como administrador»), quítalo y FocusWShell la organiza como a las demás. - **Juegos y presentaciones en pantalla completa:** cuando una app se pone en pantalla completa por sí misma (F11, un juego), FocusWShell deja ese monitor en paz hasta que sale. Se ha probado con navegadores; con juegos y presentaciones, todavía poco. - Algunas apps tienen **tamaño fijo** o un tamaño mínimo grande. FocusWShell lo aprende y les hace sitio, o las deja fuera del layout con una nota. diff --git a/site/limitations.md b/site/limitations.md index c8f459a..bd559e4 100644 --- a/site/limitations.md +++ b/site/limitations.md @@ -22,7 +22,7 @@ Full support (a focus and apps per desktop, and desktop tabs in the deck) is pla ## Apps that cannot be organized -- **Apps running as administrator** cannot be moved by FocusWShell, which runs without elevation. They are listed with the reason, and stay where they are. +- **Apps running as administrator** cannot be moved by FocusWShell, which runs without elevation: Windows doesn't allow it. They show in Free in the deck, dimmed and with 🛡, and tapping one brings it to the front; the main window lists them with the reason. If an app doesn't need to be administrator (in its properties, Compatibility → "Run this program as an administrator"), turn that off and FocusWShell organizes it like the rest. - **Fullscreen games and presentations:** when an app goes fullscreen by itself (F11, a game), FocusWShell leaves that monitor alone until it exits. This has been tested with browsers; games and presentations have not been tested much yet. - Some apps have a **fixed size** or a large minimum size. FocusWShell learns it and makes room, or leaves them out of the layout with a note. diff --git a/src/FocusWShell.App/DeckWindow.cs b/src/FocusWShell.App/DeckWindow.cs index 23f5e2d..ccb01ef 100644 --- a/src/FocusWShell.App/DeckWindow.cs +++ b/src/FocusWShell.App/DeckWindow.cs @@ -1519,7 +1519,7 @@ private List Visible(IEnumerable apps) => /// No está aquí: cerrada, en la bandeja o en otro escritorio (ADR 0016). Se ve apagada, no se mueve ni se /// cierra, y tocarla la abre (la de la bandeja se muestra ella misma) o lleva a su escritorio. /// - private static bool Away(DeckApp app) => app.State is ListItemState.Closed or ListItemState.InTray or ListItemState.OtherDesktop; + private static bool Away(DeckApp app) => app.State is ListItemState.Closed or ListItemState.InTray or ListItemState.OtherDesktop or ListItemState.Unmovable; /// /// Modo cerrar: la app que se toque se cierra como con su X (si tiene algo sin guardar, ella pregunta) y @@ -2029,6 +2029,7 @@ private Button AppTile(DeckApp app) ListItemState.Detached => " ↗", ListItemState.OtherDesktop => " ⧉", ListItemState.InTray => " ▴", + ListItemState.Unmovable => " 🛡", _ => "", }, Foreground = Away(app) ? DimBrush : TextBrush, @@ -2067,12 +2068,21 @@ private Button AppTile(DeckApp app) Cursor = Cursors.Hand, ToolTip = app.State == ListItemState.OtherDesktop ? Core.Text.F(Strings.Deck_OtherDesktopTip, app.Name) : app.State == ListItemState.InTray ? Core.Text.F(Strings.Deck_InTrayTip, app.Name) + : app.State == ListItemState.Unmovable ? Core.Text.F(Strings.Deck_UnmovableTip, app.Name) : string.IsNullOrEmpty(app.Title) ? app.Name : $"{app.Name} · {app.Title}", }; System.Windows.Automation.AutomationProperties.SetName(tile, $"Deck: {app.Name} ({app.State})"); // Modo mover (borde = se puede tocar; amarillo = mover): primero todas las que se pueden mover; ya // elegida, sólo ella conserva el borde hasta que se mueve o se cancela. - if (_pinning) + if (app.State == ListItemState.Unmovable) + { + // Como administrador: ningún modo la toca (no se mueve, ni se ancla, ni se cierra desde aquí). + if (InMode) + { + tile.Opacity = 0.4; + } + } + else if (_pinning) { // Borde = se puede tocar; índigo = anclar. Sólido: anclada; tenue: se puede anclar. if (CanPin(app)) @@ -2151,8 +2161,12 @@ private Button AppTile(DeckApp app) await TapApp(app); }; - StartDragFrom(tile, app); - tile.ContextMenu = MenuFor(app); + if (app.State != ListItemState.Unmovable) + { + StartDragFrom(tile, app); + tile.ContextMenu = MenuFor(app); + } + return tile; } @@ -2352,6 +2366,22 @@ private static Button NavButton(string text, string name, Func click) /// Tocar una app: en modo mover, elegirla; si no, llevarla al foco (o abrirla). private async Task TapApp(DeckApp app) { + // Como administrador: sólo se puede traer al frente (eso Windows sí lo deja); en un modo, nada. + if (app.State == ListItemState.Unmovable) + { + if (!InMode && app.Handle is { } elevated) + { + if (!Docked) + { + _actions.Hide(); + } + + await _actions.BringToFront(elevated); + } + + return; + } + if (_closing) { if (app.Handle is { } h) diff --git a/src/FocusWShell.App/ListPanels.cs b/src/FocusWShell.App/ListPanels.cs index b1acd13..00ad32e 100644 --- a/src/FocusWShell.App/ListPanels.cs +++ b/src/FocusWShell.App/ListPanels.cs @@ -22,6 +22,12 @@ public enum ListItemState /// En otro escritorio virtual (ADR 0016): no está aquí; tocarla lleva a su escritorio. OtherDesktop, + /// + /// Abierta pero no se puede mover: corre como administrador (o del sistema) y Windows no deja que FocusWShell + /// la mueva. Sale en LIBRES, atenuada; tocarla sólo la trae al frente. + /// + Unmovable, + /// Cerrada: está en el catálogo y su último panel es éste. Tocarla la abre. Closed, diff --git a/src/FocusWShell.App/ShellController.cs b/src/FocusWShell.App/ShellController.cs index ea66e82..d27301b 100644 --- a/src/FocusWShell.App/ShellController.cs +++ b/src/FocusWShell.App/ShellController.cs @@ -304,6 +304,25 @@ string Where(Panel p) => p.Display is null .OrderBy(a => a.Name, StringComparer.CurrentCultureIgnoreCase) .ToList(); + // Las que corren como administrador: se ven y se traen al frente, pero no se mueven. Al final de LIBRES. + // No están en el catálogo (no se organizan): su nombre y su icono salen de su ejecutable. + DeckApp Unmovable(WindowSnapshot s) + { + var key = MinSizeCatalog.KeyFor(s); + if (!_unmovableNames.TryGetValue(key, out var name)) + { + name = AppLauncher.FriendlyName(s.ProcessPath, s.AppUserModelId) ?? Path.GetFileNameWithoutExtension(s.ProcessName); + _unmovableNames[key] = name; + } + + var app = _catalog.Find(key) ?? new CatalogApp(key, name, s.ProcessPath, s.AppUserModelId, null, false, DateTimeOffset.Now, DateTimeOffset.Now); + return new DeckApp(_catalog.Find(key)?.Name ?? name, key, s.Handle, ListItemState.Unmovable, s.Title, null, app); + } + + free.AddRange(_unmanageable + .Select(u => Unmovable(u.Window)) + .OrderBy(a => a.Name, StringComparer.CurrentCultureIgnoreCase)); + // La del foco en otro escritorio no está aquí: el foco de este escritorio se ve vacío (ADR 0016). var focused = _workspace.Focused is { } f && !_elsewhere.ContainsKey(f.Handle) && _snapshots.TryGetValue(f.Handle, out var fs) ? Managed(f, fs) : null; var current = focused?.Handle; @@ -696,6 +715,9 @@ private sealed record TrayWindow(string AppKey, string Label, string PanelId, st /// private readonly Dictionary _inTray = []; + /// Nombre de las apps que corren como administrador (no están en el catálogo), por clave: leerlo cuesta. + private readonly Dictionary _unmovableNames = new(StringComparer.OrdinalIgnoreCase); + /// Apps con alguna ventana en la bandeja y ninguna a la vista. private HashSet TrayKeysLocked() { diff --git a/src/FocusWShell.App/Strings.Designer.cs b/src/FocusWShell.App/Strings.Designer.cs index fd8b7c9..a89ff8e 100644 --- a/src/FocusWShell.App/Strings.Designer.cs +++ b/src/FocusWShell.App/Strings.Designer.cs @@ -507,6 +507,9 @@ public static class Strings /// Al panel public static string Deck_ToPanelShort => ResourceManager.GetString("Deck_ToPanelShort", Culture)!; + /// {0} corre como administrador: FocusWShell no puede moverla. Tócala para traerla + public static string Deck_UnmovableTip => ResourceManager.GetString("Deck_UnmovableTip", Culture)!; + /// {0} es la pestaña que se ve en su panel: tócala para llevarla al foco public static string Deck_VisibleTabTip => ResourceManager.GetString("Deck_VisibleTabTip", Culture)!; diff --git a/src/FocusWShell.App/Strings.en.resx b/src/FocusWShell.App/Strings.en.resx index e04bb4c..0e8d90b 100644 --- a/src/FocusWShell.App/Strings.en.resx +++ b/src/FocusWShell.App/Strings.en.resx @@ -374,6 +374,7 @@ Restore them now? {0} is already open on another desktop. Switch to that desktop to use it. {0} · on another desktop. Tap to go there. {0} · in the tray. Tap to show it. + {0} runs as administrator: FocusWShell can't move it. Tap it to bring it to the front. on another desktop {0} · on another desktop. Click: go there. Go to its desktop diff --git a/src/FocusWShell.App/Strings.resx b/src/FocusWShell.App/Strings.resx index aa9cb89..ca8d65f 100644 --- a/src/FocusWShell.App/Strings.resx +++ b/src/FocusWShell.App/Strings.resx @@ -374,6 +374,7 @@ {0} ya está abierta en otro escritorio. Cambia a ese escritorio para usarla. {0} · en otro escritorio. Tócala para ir allí. {0} · en la bandeja. Tócala para mostrarla. + {0} corre como administrador: FocusWShell no puede moverla. Tócala para traerla al frente. en otro escritorio {0} · en otro escritorio. Clic: ir allí. Ir a su escritorio diff --git a/src/FocusWShell.Core/Windows/EligibilityFilter.cs b/src/FocusWShell.Core/Windows/EligibilityFilter.cs index e4a6ff1..17c564e 100644 --- a/src/FocusWShell.Core/Windows/EligibilityFilter.cs +++ b/src/FocusWShell.Core/Windows/EligibilityFilter.cs @@ -123,8 +123,9 @@ private ExclusionReason FindExclusion(WindowSnapshot w) // Ventanas sin barra de título ni marco redimensionable suelen ser popups, splash screens u overlays. // Excepción: apps con barra de título dibujada por ellas mismas (Chromium, Electron, Terminal) - // conservan WS_THICKFRAME aunque quiten WS_CAPTION. - if (!w.HasCaption && !w.IsResizable && !w.IsAppWindow) + // conservan WS_THICKFRAME aunque quiten WS_CAPTION; y las apps sin marco (Qt, como SADP) conservan + // WS_MINIMIZEBOX para minimizarse a la barra de tareas, cosa que una pantalla de inicio no hace. + if (!w.HasCaption && !w.IsResizable && !w.HasMinimizeBox && !w.IsAppWindow) { return ExclusionReason.NoCaption; } diff --git a/src/FocusWShell.Core/Windows/WindowSnapshot.cs b/src/FocusWShell.Core/Windows/WindowSnapshot.cs index 997ddec..e650b14 100644 --- a/src/FocusWShell.Core/Windows/WindowSnapshot.cs +++ b/src/FocusWShell.Core/Windows/WindowSnapshot.cs @@ -63,6 +63,9 @@ public sealed record WindowSnapshot /// Se puede redimensionar (WS_THICKFRAME). public bool IsResizable { get; init; } + /// Tiene botón de minimizar (WS_MINIMIZEBOX): se minimiza a la barra de tareas como una app. + public bool HasMinimizeBox { get; init; } + public bool IsTopmost { get; init; } /// Rectángulo completo, incluye bordes invisibles de redimensionado (GetWindowRect). diff --git a/src/FocusWShell.Win32/WindowEnumerator.cs b/src/FocusWShell.Win32/WindowEnumerator.cs index cae3224..4102a05 100644 --- a/src/FocusWShell.Win32/WindowEnumerator.cs +++ b/src/FocusWShell.Win32/WindowEnumerator.cs @@ -100,6 +100,7 @@ public static unsafe TimeSpan IdleTime() IsTopmost = exStyle.HasFlag(WINDOW_EX_STYLE.WS_EX_TOPMOST), HasCaption = (style & WINDOW_STYLE.WS_CAPTION) == WINDOW_STYLE.WS_CAPTION, IsResizable = style.HasFlag(WINDOW_STYLE.WS_THICKFRAME), + HasMinimizeBox = style.HasFlag(WINDOW_STYLE.WS_MINIMIZEBOX), Bounds = bounds, VisibleBounds = GetVisibleBounds(hwnd) ?? bounds, MonitorBounds = GetMonitorBounds(hwnd), diff --git a/tests/FocusWShell.Core.Tests/Windows/EligibilityFilterTests.cs b/tests/FocusWShell.Core.Tests/Windows/EligibilityFilterTests.cs index 87de424..217091e 100644 --- a/tests/FocusWShell.Core.Tests/Windows/EligibilityFilterTests.cs +++ b/tests/FocusWShell.Core.Tests/Windows/EligibilityFilterTests.cs @@ -149,6 +149,15 @@ public void FixedBorderlessPopupIsExcluded() Assert.Equal(ExclusionReason.NoCaption, result.Reason); } + [Fact] + public void BorderlessWindowWithAMinimizeButtonIsAnApp() + { + // Qt sin marco (SADP): ni barra de título ni marco redimensionable, pero se minimiza a la barra de tareas. + var result = Evaluate(NormalWindow() with { HasCaption = false, IsResizable = false, HasMinimizeBox = true }); + + Assert.True(result.IsCandidate); + } + [Fact] public void UserExclusionIsApplied() {