diff --git a/CHANGELOG.md b/CHANGELOG.md index 406bef4..30fd557 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ Todos los cambios importantes de FocusWShell. Cada versión tiene sus notas en [ - Manual: a picture of how it works, a step-by-step getting started from the main window, step-by-step guides, and screenshots of every section of the main window. / Manual: un dibujo de cómo funciona, primeros pasos paso a paso desde la ventana principal, guías paso a paso y capturas de cada sección de la ventana principal. - Fixed: in the dark theme, the list in Windows was white with white text. / Corregido: en el tema oscuro, la lista de Ventanas salía blanca con el texto blanco. +- Apps that close to the tray (Codex, Discord, Teams…) show dimmed with ▴ in their panel, and tapping them opens the app again, which shows its window. Before, FocusWShell showed the hidden window itself, and some apps stayed frozen. When the app shows its window again, it goes back to its panel and to the focus. / Las apps que se cierran a la bandeja (Codex, Discord, Teams…) salen atenuadas con ▴ en su panel, y tocarlas abre la app otra vez, que muestra su ventana. Antes FocusWShell mostraba la ventana oculta por su cuenta, y algunas apps quedaban congeladas. Cuando la app vuelve a mostrar su ventana, regresa a su panel y al foco. +- The deck gives the focus app its own place: on a whole tablet, a big tile at the top, above the buttons; in its panel, a blue border. / El deck le da a la app del foco su lugar propio: en la tablet entera, un tile grande arriba, encima de los botones; en su panel, un borde azul. +- New Minimize… mode in the deck (teal), and the four modes in a 2×2 grid. Free all moves up with Previous and To panel; Mouse to focus moves to System. / Nuevo modo Minimizar… en el deck (verde azulado), y los cuatro modos en una cuadrícula de 2×2. Liberar todas sube junto a Anterior y Al panel; Ratón al foco pasa a Sistema. +- "Park" is now called "Minimize" everywhere. / «Estacionar» ahora se llama «Minimizar» en todos lados. - The main monitor is called "main" in English, and the Spanish buttons say "foco" instead of "Centro". / El monitor principal se llama «main» en inglés, y los botones en español dicen «foco» en lugar de «Centro». ## 0.2.0-alpha diff --git a/docs/README.md b/docs/README.md index 78ee81a..f66a2c2 100644 --- a/docs/README.md +++ b/docs/README.md @@ -39,6 +39,7 @@ Esta carpeta es la documentación de ingeniería del proyecto. Parte de las nota | [0015](adr/0015-tiles-adaptables-y-lista.md) | Presentaciones: tiles adaptables y lista tipo Explorador | Aceptada | | [0016](adr/0016-escritorios-virtuales.md) | Seguir los escritorios virtuales de Windows: un foco y unas apps por escritorio | Propuesta (fase 1 hecha) | | [0017](adr/0017-ventana-principal-wpf-ui.md) | La ventana principal con WPF-UI: configurar y ver el estado | Aceptada | +| [0018](adr/0018-apps-en-la-bandeja.md) | Apps que se cierran a la bandeja: no mostrarlas nosotros | Aceptada | ## Fuentes diff --git a/docs/adr/0013-deck-superficie-de-control.md b/docs/adr/0013-deck-superficie-de-control.md index 2ca3bd7..3fe09a2 100644 --- a/docs/adr/0013-deck-superficie-de-control.md +++ b/docs/adr/0013-deck-superficie-de-control.md @@ -67,3 +67,10 @@ Puede vivir en un monitor táctil, sea una tablet que extiende el escritorio ([A - **Pendiente:** - comprobar la desconexión con la tablet de verdad; - **Pantalla completa junto al deck:** en el monitor donde está fijado el deck, un panel en «Pantalla completa» no se maximiza. Ocupa el área que deja el deck, bajo su tira de pestañas (`AuxInput.NoMaximize`). Es la idea de Spotify en la tablet. + +## Enmienda: el lugar del foco y el modo Minimizar (2026-11-13) + +- **El foco tiene su lugar propio.** En el deck ancho, la cabecera pasa a ser FocusWShell (logo, el monitor que se ve y cuántas apps tiene), y debajo, la app del foco en un tile grande que ocupa el espacio que sobra, encima de los botones (lo primero que se mira; los botones quedan abajo, más cerca de la mano): icono, nombre, de qué panel viene y el título de su ventana. En el deck angosto sigue arriba, en la cabecera. En los dos, se toca como una app: en un modo, el modo; si no, su menú. En «Mover», con otra app elegida, es destino: la lleva al foco. En su panel, la del foco ya no va pintada de azul: lleva un borde azul y la ↑, para que no haya dos cosas iguales. +- **Botones.** Arriba las de acción inmediata: Anterior, Al panel y Liberar todas (que pide un segundo toque). Debajo los cuatro modos en 2×2: Mover y Anclar, que acomodan, a la izquierda; Minimizar y Cerrar, que quitan de la vista, a la derecha. En el deck angosto, dos filas: tres acciones y cuatro modos. Ratón al foco pasa a *Sistema*, junto a Pantalla encendida, Energía y Reordenar todas. +- **Modo Minimizar…** (verde azulado): como Cerrar, se apaga después de un toque (encendido como Anclar se sentía pegado: cada clic minimizaba otra app). Alterna: minimiza una app en su panel (`Park`) o la trae de vuelta (`Restore`). Sólo para apps en un panel; las libres no tienen dónde quedarse. +- **«Estacionar» se llama «Minimizar»** en la interfaz y en el sitio. En el código y en el dominio sigue siendo `Park` ([ADR 0006](0006-ocultar-con-minimizar.md)). diff --git a/docs/adr/0018-apps-en-la-bandeja.md b/docs/adr/0018-apps-en-la-bandeja.md new file mode 100644 index 0000000..7e69efe --- /dev/null +++ b/docs/adr/0018-apps-en-la-bandeja.md @@ -0,0 +1,33 @@ +# ADR 0018 — Apps que se cierran a la bandeja: no mostrar nosotros sus ventanas + +- **Estado:** Aceptada +- **Fecha:** 2026-11-12 + +## Contexto + +Muchas apps no se cierran con su X ni con «Cerrar» del deck: ocultan su ventana y siguen en la bandeja (Codex, Discord, Teams y otras de Electron). La ventana sigue existiendo, sólo sin `WS_VISIBLE`. + +FocusWShell sólo daba por cerrada una ventana que ya no existía. Una gestionada que dejaba de ser elegible seguía en su panel con su última foto, una regla pensada para las que cambian de estilo un momento (pantalla completa propia). Con Codex eso causó dos problemas: + +- Seguía en el deck como si estuviera abierta. +- Al tocarla, colocarla en el foco la mostraba con `ShowWindow`. La ventana aparecía, pero **congelada**: Electron detiene el dibujo y la entrada al ocultarse, y sólo los reanuda cuando la app misma se muestra. Al mostrarla desde su icono de la bandeja, volvía a responder. + +Cualquier acomodo (Reordenar todas, una escena, cambiar la disposición) la habría mostrado igual, sin que el usuario lo pidiera. + +## Decisión + +**Una ventana que su app ocultó está "en la bandeja", y FocusWShell nunca la muestra.** + +- Al ocultarse (el evento `EVENT_OBJECT_HIDE` o, si se perdió, el siguiente refresco), sale del modelo como si se cerrara (`WindowClosed`): ningún acomodo, ni salir, ni la emergencia la tocan. El controlador la recuerda aparte, con su app y su panel. +- El deck y la presentación de lista la muestran **atenuada con ▴** en su panel, aunque no esté anclada. +- **Tocarla lanza la app otra vez** (como una cerrada, `OpenApp`). Las apps de bandeja son de una sola instancia: la que corre recibe el aviso y muestra su ventana ella misma, viva. `OpenApp` la adopta en el panel y la lleva al foco: se tocó para usarla. Sólo adoptarla no basta: en un panel apagado o en pestañas quedaba minimizada al aparecer, y había que tocarla otra vez. +- Si la app vuelve a mostrar su ventana por su cuenta (su icono de la bandeja), el refresco la adopta en su panel de antes y la lleva al foco. +- Si la ventana deja de existir, se olvida. + +## Consecuencias + +- Al volver va al foco aunque antes estuviera en su panel; su panel se conserva. +- Si una app oculta su ventana sólo un momento, sale del modelo y regresa a su panel, en el foco, en el siguiente refresco. +- Si la app no se puede lanzar (sin ejecutable ni AUMID), tocarla dice por qué; se puede abrir desde su icono de la bandeja. +- Una ventana oculta no sale en **Ventanas** de la ventana principal. +- «Ocultar» como acción del usuario es minimizar: ya existe como **Estacionar** ([ADR 0006](0006-ocultar-con-minimizar.md)). diff --git a/site/assets/img/en/deck-layout.png b/site/assets/img/en/deck-layout.png index 967f1e2..bb040f7 100644 Binary files a/site/assets/img/en/deck-layout.png and b/site/assets/img/en/deck-layout.png differ diff --git a/site/assets/img/en/deck.png b/site/assets/img/en/deck.png index 98b5976..be850b7 100644 Binary files a/site/assets/img/en/deck.png and b/site/assets/img/en/deck.png differ diff --git a/site/assets/img/es/deck-layout.png b/site/assets/img/es/deck-layout.png index 524bb30..a15b882 100644 Binary files a/site/assets/img/es/deck-layout.png and b/site/assets/img/es/deck-layout.png differ diff --git a/site/assets/img/es/deck.png b/site/assets/img/es/deck.png index 62f42ba..42274b8 100644 Binary files a/site/assets/img/es/deck.png and b/site/assets/img/es/deck.png differ diff --git a/site/concepts.md b/site/concepts.md index 63d9c53..b90b9c1 100644 --- a/site/concepts.md +++ b/site/concepts.md @@ -45,7 +45,7 @@ When you bring an app to the focus, the one that was there **goes back to its pa Apps in a panel can also be: -- **Parked:** open but set aside (minimized). They come back from their panel. +- **Minimized:** open but set aside. They keep their panel and come back from it. - **Out of layout:** you moved or resized one by hand; FocusWShell leaves it where you put it until you bring it back. ## The main screen layout @@ -78,7 +78,7 @@ Each panel shows its apps in one of these ways. Change it in the panel header in Above each panel there is a thin **strip** with one tab per app: -- **Click:** shows it in the panel (or brings it back if it was parked). +- **Click:** shows it in the panel (or restores it if it was minimized). - **Double-click:** brings it to the focus. - **Right-click:** everything else. @@ -96,7 +96,7 @@ Before moving any window, FocusWShell writes down where it was. **Exit**, the em **"I dragged a window and it went back."** Windows in a panel keep their place. Drop it on the focus or on another panel to move it there; to place it yourself, free it first. -**"An app disappeared."** Its column may be off (its apps wait minimized in their panel), it may be parked, or it may be behind another app in a panel with tabs. Look for it in the deck or in **Windows**: tapping it brings it to the focus. +**"An app disappeared."** Its column may be off (its apps wait minimized in their panel), it may be minimized, or it may be behind another app in a panel with tabs. Look for it in the deck or in **Windows**: tapping it brings it to the focus. **"A window is not in the list."** Apps running as administrator cannot be moved and are listed at the end with the reason. Excluded apps are not listed at all: see **Excluded** in the main window. diff --git a/site/deck.md b/site/deck.md index bf1551d..584a3bd 100644 --- a/site/deck.md +++ b/site/deck.md @@ -18,18 +18,23 @@ Open or hide it with Ctrl+Alt+Shift+DCtrl+Alt+Mayús+Retroceso, en cualquier momento. diff --git a/site/es/primeros-pasos.md b/site/es/primeros-pasos.md index 0a58533..926de01 100644 --- a/site/es/primeros-pasos.md +++ b/site/es/primeros-pasos.md @@ -51,7 +51,7 @@ Puedes renombrar los paneles o crear más después. Está bien empezar sólo con La columna **Estado** dice qué hace FocusWShell con cada ventana. Para soltar una ventana, elige **— libre**: vuelve a donde estaba. -El botón **…** al final de cada fila (o el clic derecho) tiene lo demás: llevarla al foco o a pantalla completa, estacionarla, liberarla, o excluir su app para que FocusWShell no la vuelva a tocar. +El botón **…** al final de cada fila (o el clic derecho) tiene lo demás: llevarla al foco o a pantalla completa, minimizarla, liberarla, o excluir su app para que FocusWShell no la vuelva a tocar. ## Paso 4. Lleva una app al foco diff --git a/site/es/ventana-principal.md b/site/es/ventana-principal.md index a2b7554..553b9b0 100644 --- a/site/es/ventana-principal.md +++ b/site/es/ventana-principal.md @@ -26,7 +26,7 @@ Tiene el aspecto de Windows 11, en tema oscuro o claro, con sus secciones a la i Todas las ventanas que FocusWShell puede organizar, con el icono de su app, su título y su estado. **Elige un panel y se aplica al momento**: *libre*, *al foco* o cualquier panel. Las demás acciones están en **…**, al final de la fila, o en el clic derecho: - al foco, o pantalla completa en un monitor; -- estacionar o recuperar, reacomodar, liberarla; +- minimizar o restaurar, reacomodar, liberarla; - cómo se trata su tamaño (hay apps de tamaño fijo); - excluir su app o su tipo de ventana. diff --git a/site/first-steps.md b/site/first-steps.md index 6f9040b..4edf9f0 100644 --- a/site/first-steps.md +++ b/site/first-steps.md @@ -51,7 +51,7 @@ You can rename the panels or create more later. It is fine to start with only tw The **State** column tells you what FocusWShell is doing with each window. To let a window go, choose **— free**: it goes back to where it was. -The **…** button at the end of each row (or a right-click) has the rest: send it to the focus or fullscreen, park it, free it, or exclude its app so FocusWShell never touches it again. +The **…** button at the end of each row (or a right-click) has the rest: send it to the focus or fullscreen, minimize it, free it, or exclude its app so FocusWShell never touches it again. ## Step 4. Bring an app to the focus diff --git a/site/guides.md b/site/guides.md index b389a68..030f773 100644 --- a/site/guides.md +++ b/site/guides.md @@ -129,7 +129,7 @@ To change it, open **Shortcuts and gestures** and turn each one on or off under ## Take a break from FocusWShell {#break} -- **For a moment:** **Free all** (in **Home** or under *System* in the deck) lets every window go back to where it was. **Rearrange all** puts them back in their panels. +- **For a moment:** **Free all** (in **Home** or at the top of the deck) lets every window go back to where it was. **Rearrange all** puts them back in their panels. - **For good, this session:** **Exit** in the tray menu puts every window back and closes FocusWShell. - **Something is wrong:** Ctrl+Alt+Shift+Backspace, at any time. diff --git a/site/main-window.md b/site/main-window.md index 644c3aa..fe8f077 100644 --- a/site/main-window.md +++ b/site/main-window.md @@ -26,7 +26,7 @@ It follows the look of Windows 11, in a dark or light theme, with its sections o Every window FocusWShell can organize, with its app's icon, its title and its state. **Choose a panel and it applies right away**: *free*, *to the focus* or any panel. The other actions are in **…** at the end of the row, or on right-click: - to the focus, or fullscreen on a monitor; -- park or bring back, re-fit, free it; +- minimize or restore, re-fit, free it; - how its size is handled (some apps have a fixed size); - exclude its app or its kind of window. diff --git a/src/FocusWShell.App/DeckPreview.cs b/src/FocusWShell.App/DeckPreview.cs index a82d549..0f5456f 100644 --- a/src/FocusWShell.App/DeckPreview.cs +++ b/src/FocusWShell.App/DeckPreview.cs @@ -35,6 +35,7 @@ public static void Run(string folder, string? language = null) Save(Sample(manyApps: false), width, height, Path.Combine(folder, $"deck-{name}-cerrar.png"), mode: "cerrar"); Save(Sample(manyApps: false), width, height, Path.Combine(folder, $"deck-{name}-energia.png"), mode: "energia"); Save(Sample(manyApps: false), width, height, Path.Combine(folder, $"deck-{name}-anclar.png"), mode: "anclar"); + Save(Sample(manyApps: false), width, height, Path.Combine(folder, $"deck-{name}-minimizar.png"), mode: "minimizar"); // Disposición del principal (ADR 0012, enmienda): Trabajo apagado en un ultrawide (sale «⇠ Trabajo»), // un monitor normal con sólo Trabajo y Solo foco. Save(Arranged(FocusPosition.ContextOnly, ultrawide: true), width, height, Path.Combine(folder, $"deck-{name}-solo-contexto.png")); diff --git a/src/FocusWShell.App/DeckWindow.cs b/src/FocusWShell.App/DeckWindow.cs index 70f572e..6f5a39e 100644 --- a/src/FocusWShell.App/DeckWindow.cs +++ b/src/FocusWShell.App/DeckWindow.cs @@ -1,9 +1,11 @@ +using System.IO; using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Input; using System.Windows.Interop; using System.Windows.Media; +using System.Windows.Media.Imaging; using FocusWShell.Core.Browsers; using FocusWShell.Core.Domain; using FocusWShell.Core.Geometry; @@ -152,7 +154,7 @@ public void UpdateForeground(nint hwnd) : null; /// Si hay un modo encendido: entonces mandan sus bordes, no el de «al frente». - private bool InMode => _moving is not null || _closing || _pinning; + private bool InMode => _moving is not null || _closing || _pinning || _minimizing; /// Actualiza el contenido si está visible. public void Update(DeckState state) @@ -210,8 +212,8 @@ private void RenderWide(DeckState state) _root.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(12) }); _root.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); - // Izquierda, en tres tarjetas separadas por más aire que sus botones entre sí: - // Foco (la app y qué hacer con ella), Disposición (las columnas del principal) y, abajo, Sistema. + // Izquierda, en tarjetas separadas por más aire que sus botones entre sí: arriba FocusWShell y la app + // del foco (lo primero que se mira), debajo qué hacer con ella, la disposición y, abajo, Sistema. var left = new Grid(); void Card(Border card, GridLength height) { @@ -220,12 +222,17 @@ void Card(Border card, GridLength height) left.Children.Add(card); } - // Mover, anclar y cerrar en una fila de tres: con sus textos cortos, para que quepan. + // El foco, con su lugar propio bajo la cabecera: ocupa el aire que sobra, y los botones quedan abajo, + // más cerca de la mano en la tablet. + Card(Group(null, [(DeckHeader(state), GridLength.Auto), (Label(Strings.Deck_SecFocus), GridLength.Auto), (FocusTile(state), new GridLength(1, GridUnitType.Star))]), new GridLength(1, GridUnitType.Star)); + + // Las de acción inmediata (Anterior, Al panel, Liberar todas) y, con un hueco que separa los dos tipos, + // los cuatro modos en 2×2: los que acomodan a la izquierda (Mover, Anclar) y los que quitan de la vista + // a la derecha (Minimizar, Cerrar). var actions = FocusActions(state, shortText: true); - // Arriba las de acción inmediata, abajo las de modo, con un hueco que separa los dos tipos. - var modes = Buttons(3, actions.Skip(3)); + var modes = Buttons(2, [actions[3], actions[5], actions[4], actions[6]]); modes.Margin = new Thickness(0, 8, 0, 2); - Card(Group(null, [(FocusHeader(state), GridLength.Auto), (Buttons(3, actions.Take(3)), GridLength.Auto), (modes, GridLength.Auto)]), GridLength.Auto); + Card(Group(null, [(Buttons(3, actions.Take(3)), GridLength.Auto), (modes, GridLength.Auto)]), GridLength.Auto); // La disposición del principal: las columnas de paneles que se prenden y apagan, como un mapa del // monitor (ADR 0012, enmienda). El foco ocupa lo que dejan. @@ -237,7 +244,6 @@ void Card(Border card, GridLength height) }; Card(Group(null, layout), GridLength.Auto); - left.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); // aire hasta Sistema var system = Group(_powerOpen ? Strings.Deck_SecPower : Strings.Deck_SecSystem, [(Buttons(2, SystemButtons()), GridLength.Auto)]); system.Margin = new Thickness(0, 0, 0, 8); // abajo, alineada con LIBRES Card(system, GridLength.Auto); @@ -309,11 +315,12 @@ void Row(UIElement e, GridLength height, double min = 0) } Row(FocusHeader(state, arrangement: true), GridLength.Auto); - // Las seis en una fila: un hueco tras «Ratón» separa las de acción inmediata de las de modo. + // Dos filas: arriba las de acción inmediata, abajo los cuatro modos. var focusActions = FocusActions(state, shortText: true); - var focusRow = Buttons(6, focusActions); - focusActions[2].Margin = new Thickness(0, 0, 20, 8); - Row(focusRow, GridLength.Auto); + Row(Buttons(3, focusActions.Take(3)), GridLength.Auto); + var modeRow = Buttons(4, focusActions.Skip(3)); + modeRow.Margin = new Thickness(0, 0, 0, 8); + Row(modeRow, GridLength.Auto); // Pestañas por monitor y, debajo, sus paneles uno debajo de otro, con alto según cuántas apps tienen. if (TabRow(state, wide: false) is { } tabRow) @@ -348,7 +355,7 @@ void Row(UIElement e, GridLength height, double min = 0) // Abajo, lo del sistema. var system = SystemButtons(); - Row(Buttons(system.Count > 4 ? 3 : system.Count, system), GridLength.Auto); + Row(Buttons(_powerOpen ? 3 : system.Count, system), GridLength.Auto); } // --- Pestañas por monitor ------------------------------------------------------------------------- @@ -379,6 +386,7 @@ internal void ShowMode(string? mode, DeckState state) _closing = mode == "cerrar"; _pinning = mode == "anclar"; + _minimizing = mode == "minimizar"; _powerOpen = mode is "energia" or "energia-seguro"; if (mode == "energia-seguro") { @@ -1108,10 +1116,196 @@ private DockPanel FocusHeader(DeckState state, bool arrangement = false) line.Children.Add(names); focus.Children.Add(line); - header.Children.Add(focus); + // La del foco también se toca: en un modo, como cualquier otra app; si no, su menú. Mover otra app + // aquí la lleva al foco. + var tap = new Button + { + Content = focus, + Background = Brushes.Transparent, + BorderThickness = new Thickness(0), + Padding = new Thickness(0), + HorizontalContentAlignment = HorizontalAlignment.Stretch, + Focusable = false, + Cursor = Cursors.Hand, + }; + MarkFocusTarget(tap, state); + tap.Click += async (_, _) => await TapFocus(state, tap); + System.Windows.Automation.AutomationProperties.SetName(tap, "Deck: " + Strings.Deck_SecFocus); + header.Children.Add(tap); + return header; + } + + /// La cabecera del deck ancho: FocusWShell, el monitor que se ve y cuántas apps tiene. + private DockPanel DeckHeader(DeckState state) + { + var header = new DockPanel { Margin = new Thickness(0, 0, 8, 8) }; + var close = SmallButton("✕", Strings.Deck_Hide, () => _actions.Hide()); + DockPanel.SetDock(close, Dock.Right); + header.Children.Add(close); + var send = SmallButton("⇢", Strings.Deck_SendTo, () => { }); + send.Margin = new Thickness(0, 0, 6, 0); + send.ContextMenu = SendMenu(state); + send.Click += (_, _) => + { + send.ContextMenu.PlacementTarget = send; + send.ContextMenu.IsOpen = true; + }; + DockPanel.SetDock(send, Dock.Right); + header.Children.Add(send); + + var logo = new Image + { + Source = Logo, + Width = 32, + Height = 32, + Margin = new Thickness(0, 0, 10, 0), + VerticalAlignment = VerticalAlignment.Center, + }; + DockPanel.SetDock(logo, Dock.Left); + header.Children.Add(logo); + + var names = new StackPanel { VerticalAlignment = VerticalAlignment.Center }; + names.Children.Add(new TextBlock { Text = "FocusWShell", Foreground = TextBrush, FontSize = 18, FontWeight = FontWeights.SemiBold }); + if (MonitorTabs(state).FirstOrDefault(t => OnTab(t.Display)) is { } tab) + { + names.Children.Add(new TextBlock { Text = Core.Text.F(Strings.Deck_HeaderTab, tab.Name, tab.Apps), Foreground = DimBrush, FontSize = 11, TextTrimming = TextTrimming.CharacterEllipsis }); + } + + header.Children.Add(names); return header; } + private static readonly ImageSource? Logo = LoadLogo(); + + private static BitmapFrame? LoadLogo() + { + try + { + var decoder = BitmapDecoder.Create(new Uri("pack://application:,,,/Assets/FocusWShell.ico"), BitmapCreateOptions.None, BitmapCacheOption.OnLoad); + return decoder.Frames.OrderByDescending(f => f.PixelWidth).First(); + } + catch (Exception ex) when (ex is IOException or NotSupportedException or UriFormatException) + { + return null; + } + } + + /// + /// El lugar del foco en el deck ancho: un tile grande con la app del foco (icono, nombre, título y de qué + /// panel viene) o vacío. Se toca como cualquier app: en un modo, el modo; si no, su menú. En «Mover», con + /// otra app elegida, tocarlo la lleva al foco. + /// + private Button FocusTile(DeckState state) + { + var content = new StackPanel { VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center }; + if (state.Focus is { } focus) + { + if (focus.App is { } app && AppIcons.Get(app) is { } icon) + { + content.Children.Add(new Image { Source = icon, Width = 40, Height = 40, Margin = new Thickness(0, 0, 0, 4) }); + } + + content.Children.Add(new TextBlock + { + Text = focus.Name, + Foreground = TextBrush, + FontSize = 18, + FontWeight = FontWeights.SemiBold, + TextAlignment = TextAlignment.Center, + TextTrimming = TextTrimming.CharacterEllipsis, + }); + // En una línea, para que quepa en la tablet: de qué panel viene y el título de su ventana. + var from = state.Panels.FirstOrDefault(p => p.Id == focus.PanelId) is { } home ? Core.Text.F(Strings.Deck_FocusFrom, home.Name) : null; + var detail = string.Join(" · ", new[] { from, focus.Title }.Where(t => !string.IsNullOrEmpty(t))); + if (detail.Length > 0) + { + content.Children.Add(new TextBlock { Text = detail, Foreground = TextBrush, FontSize = 11, TextAlignment = TextAlignment.Center, TextTrimming = TextTrimming.CharacterEllipsis, Margin = new Thickness(0, 2, 0, 0) }); + } + } + else + { + content.Children.Add(new TextBlock { Text = Strings.Deck_FocusEmptyTile, Foreground = DimBrush, FontSize = 14, TextAlignment = TextAlignment.Center }); + } + + var tile = new Button + { + Content = content, + HorizontalContentAlignment = HorizontalAlignment.Stretch, + VerticalContentAlignment = VerticalAlignment.Stretch, + Padding = new Thickness(8), + Margin = new Thickness(0, 0, 8, 8), + Focusable = false, + BorderThickness = new Thickness(0), + Background = state.Focus is null ? CardBrush : ActiveBrush, + Cursor = Cursors.Hand, + ToolTip = state.Focus is { } f ? Core.Text.F(Strings.Deck_FocusTip, f.Name) : null, + }; + MarkFocusTarget(tile, state); + tile.Click += async (_, _) => await TapFocus(state, tile); + System.Windows.Automation.AutomationProperties.SetName(tile, "Deck: " + Strings.Deck_SecFocus + (state.Focus is { } g ? " " + g.Name : "")); + return tile; + } + + /// El borde del lugar del foco en un modo: el mismo que llevaría su app, o el de destino al mover. + private void MarkFocusTarget(Button target, DeckState state) + { + if (_moving == MoveStep.PickPanel && _moveApp is not null && _moveApp.State != ListItemState.InFocus) + { + target.BorderBrush = TargetBrush; + target.BorderThickness = new Thickness(3); + } + else if (state.Focus is { Handle: not null } focus) + { + if (_moving == MoveStep.PickApp || _moveApp?.Handle == focus.Handle) + { + target.BorderBrush = TargetBrush; + target.BorderThickness = new Thickness(_moveApp is null ? 2 : 3); + } + else if (_pinning && CanPin(focus)) + { + target.BorderBrush = IsPinned(focus) ? PinBrush : PinFaintBrush; + target.BorderThickness = new Thickness(IsPinned(focus) ? 3 : 2); + } + else if (_minimizing) + { + target.BorderBrush = MinimizeBrush; + target.BorderThickness = new Thickness(2); + } + else if (_closing) + { + target.BorderBrush = WarnBrush; + target.BorderThickness = new Thickness(2); + } + } + } + + private async Task TapFocus(DeckState state, Button target) + { + // Mover con otra app elegida: al foco (una libre entra antes en un panel). + if (_moving == MoveStep.PickPanel && _moveApp is { Handle: { } h } chosen && chosen.State != ListItemState.InFocus) + { + _moving = null; + _moveApp = null; + await Run(true, chosen.PanelId is null ? [new Adopt(h, chosen.Name, DefaultPanel()), new Promote(h)] : [new Promote(h)]); + return; + } + + if (state.Focus is not { } focus) + { + return; + } + + if (InMode) + { + await TapApp(focus); + return; + } + + var menu = MenuFor(focus); + menu.PlacementTarget = target; + menu.IsOpen = true; + } + private List