From 2e3beb90f9c0ac29bc74d31272dbc7b4b489a622 Mon Sep 17 00:00:00 2001 From: NasirAldeen Ishtaiah Date: Sun, 22 Nov 2026 15:48:00 +0200 Subject: [PATCH 1/6] Add top bar position, smaller icons, and tiling shortcut --- README.ja.md | 6 ++-- README.md | 6 ++-- README.pt-BR.md | 6 ++-- README.ru.md | 6 ++-- common/src/style.rs | 11 ++++++-- plugins/topbar/src/main.rs | 51 ++++++++++++++++++++-------------- plugins/topbar/src/run.rs | 13 +++++++++ plugins/topbar/src/settings.rs | 17 ++++++------ 8 files changed, 77 insertions(+), 39 deletions(-) diff --git a/README.ja.md b/README.ja.md index d41a9e3..f0639fd 100644 --- a/README.ja.md +++ b/README.ja.md @@ -40,7 +40,7 @@ UAC が**別の管理者**のパスワードを求めた場合でも、ユーザ |---|---|---| | **rust-search** | すべての NTFS ドライブを対象にしたファイル検索 (Alt+Space)。topbar があれば Win+R で実行モードが開きます: 履歴、フォルダー補完 (Tab)、Ctrl+Shift+Enter で管理者として実行 | Windows 検索サービスを無効にし、SearchHost.exe をブロックし、タスクバーの検索ボックスを隠します | | **rtaskmgr-win32** | タスク マネージャー (Ctrl+Shift+Esc で開きます) | `taskmgr.exe` がこちらにリダイレクトされます (システム ファイルには手を加えません)。ディスク クリーナー **rs-du** も一緒にインストールされます。**速度**ページには、オプトインで元に戻せるスイッチがあります: ゲーム / 作業プロファイル (バックグラウンド サービスを停止し、ランチャーや同期アプリを終了し、再び起動)、メモリのスタンバイ キャッシュの消去 (今すぐ、または topbar の実行中に自動で)、Windows のスタート メニュー、ウィジェット、スマートフォン連携のプロセスのブロック、サードパーティの更新ツールの代わりに週 1 回の `winget upgrade`、ビルド キャッシュとゲーム ライブラリの Defender 除外、高速 NTFS (最終アクセス日時と 8.3 名なし)、広告をブロックする hosts ファイル。**スタートアップ**には、ログオン/起動タスクとサードパーティの自動開始サービスも一覧表示され、それぞれが直近の起動をどれだけ遅くしたか (Windows 自身の起動ログ) が分かります。**遅い原因**には、ドライバーの時間 (DPC/割り込み)、ハングしたウィンドウ、遅いディスク、起動時間が表示されます。アンインストールするとすべて元に戻ります | -| **topbar** | Windows 11 風の下部バー: ウィンドウ、時計、音量、メニュー | 標準のタスクバーを隠します。**reshell** (ホットキー: Win+Ctrl+1/2/3 と Win+\` でデスクトップを切り替え (Win+1..9 はバーのアプリ ボタンを開く)、Win+D でデスクトップを表示、Win+I で設定、Win+E でファイル マネージャーを開く。バーが落ちた場合はタスクバーを復活させます)、**rs-du**、PowerShell プロファイル内のブロック (`zoxide`、`grep`=rg、`ll`=eza、`cat`=bat。存在しなければ何もしません) も一緒にインストールされます。歯車メニューには短いページがあります: テーマ、色と透明度 (バーと WinRust ウィンドウの任意の色、バーの不透明度)、テンプレート (自分の外観を保存して切り替え)、バー (下/左/右の端、サイズ、自動的に隠す、Windows 10 のように左端にボタンを配置)、すべて初期設定に戻す | +| **topbar** | Windows 11 風の下部バー: ウィンドウ、時計、音量、メニュー | 標準のタスクバーを隠します。**reshell** (ホットキー: Win+Ctrl+1/2/3 と Win+\` でデスクトップを切り替え (Win+1..9 はバーのアプリ ボタンを開く)、Win+D でデスクトップを表示、Win+I で設定、Win+E でファイル マネージャーを開く。バーが落ちた場合はタスクバーを復活させます)、**rs-du**、PowerShell プロファイル内のブロック (`zoxide`、`grep`=rg、`ll`=eza、`cat`=bat。存在しなければ何もしません) も一緒にインストールされます。歯車メニューには短いページがあります: テーマ、色と透明度 (バーと WinRust ウィンドウの任意の色、バーの不透明度)、テンプレート (自分の外観を保存して切り替え)、バー (下/上/左/右の端、サイズ、自動的に隠す、Windows 10 のように左端にボタンを配置)、すべて初期設定に戻す | | **rust-explorer** | タブ付きのファイル マネージャーとデスクトップ | フォルダーとドライブはこちらで開き、**エクスプローラーはシェルではなくなります** (topbar が失敗した場合は自動的に戻ります)。新規インストールでは、値をバックアップできる場合に、PcaSvc、InventorySvc、lfsvc、cbdhsvc、DoSvc のスタートアップ設定と svchost のグループ化しきい値を調整します。独自のコピー機能 (SSD では複数ファイルを同時に、大きなファイルはバッファなし、進行状況はステータス行に表示) と、右クリックの **ZIP に圧縮** (全コア) / **ここに展開** (ZIP と 7z)、独自の ZIP エンジン。`.zip` はフォルダーのように開きます (閲覧、コピー、ファイルを開く)。他のプログラムからの「フォルダーで表示」ではファイルが選択されます (ダウンロード、ドキュメント、デスクトップ、ピクチャ、ミュージック、ビデオ、ピン留めしたフォルダーなど。ウィンドウが開いていなくても動作)。マウスの戻る/進むボタンが使えます。デスクトップを右クリックするとアイコンを隠せます。topbar が必要です | | **wiztree** | ディスク使用量マップ (スタートの「WinRust Disk」) | ファイルとショートカット以外は何も変更しません | | **photoview** | 高速なフォト ビューアー | 「プログラムから開く」に追加します (既定にはなりません) | @@ -64,7 +64,9 @@ UAC が**別の管理者**のパスワードを求めた場合でも、ユーザ | **白い道** | 象牙色に金: バー、そのパネル、rust-settings の背後に、淡いローポリの三角形 (一部は金色の線) | | **ルビー** | 深いガーネットに明るいルビーのアクセント: バーとそのパネルの背後に、上から下へのなめらかなグラデーションとやわらかな光沢 | -歯車メニューでは、バーの位置 (下、左、右: 横置きのバーはアイコンのみで、パネルはその隣に開きます) と自動的に隠す設定も変更できます。 +歯車メニューでは、バーの位置 (下、上、左、右: 縦置きのバーはアイコンのみで、パネルはその隣に開きます) と自動的に隠す設定も変更できます。 + +**Ctrl+Alt+T** で、どのテーマでも開いているウィンドウを並べられます。歯車メニューの「ウィンドウを並べて表示」と同じ操作です。 選択内容は `%ProgramData%\WinRust\style.txt` に保存されます。 diff --git a/README.md b/README.md index f771055..02d3a0b 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ On uninstall, `rust-explorer` restores the service startup values and the svchos |---|---|---| | **rust-search** | File search over all NTFS drives, Alt+Space. With topbar, Win+R opens its Run mode: history, folder completion (Tab), Ctrl+Shift+Enter runs as administrator | Disables the Windows Search service, blocks SearchHost.exe, hides the taskbar search box | | **rtaskmgr-win32** | Task Manager (Ctrl+Shift+Esc opens it) | `taskmgr.exe` is redirected to it (the system file is untouched). Also installs the **rs-du** disk cleaner. The **Speed** page has opt-in, reversible switches: Game / Work profiles (stop background services, close launchers or sync apps, start them again), clear the memory standby cache (now, or automatically while topbar runs), block the Windows Start menu, widgets and Phone Link processes, one weekly `winget upgrade` instead of third-party updaters, Defender exclusions for build caches and game libraries, faster NTFS (no last-access times, no 8.3 names), an ad-blocking hosts file. **Startup** also lists logon/boot tasks and third-party auto-start services, with how much each slowed the last boots (Windows' own boot log). **What's slow** shows driver time (DPC/interrupts), hung windows, slow disk and boot times. Uninstall turns all of it back | -| **topbar** | A Windows 11-style bottom bar: windows, clock, volume, menus | Hides the stock taskbar. Also installs **reshell** (hotkeys: Win+Ctrl+1/2/3 and Win+\` switch desktops (Win+1..9 open the bar's app buttons), Win+D shows the desktop, Win+I opens Settings, Win+E the file manager; brings the taskbar back if the bar dies), **rs-du**, and a block in your PowerShell profile (`zoxide`, `grep`=rg, `ll`=eza, `cat`=bat; does nothing if they are missing). The gear menu has short pages: Theme, Colors and transparency (any colour of the bar and the WinRust windows, the bar's opacity), Templates (save your own looks and switch between them), the bar (bottom / left / right edge, size, auto-hide, buttons at the left end like Windows 10) and Reset everything to defaults | +| **topbar** | A Windows 11-style bottom bar: windows, clock, volume, menus | Hides the stock taskbar. Also installs **reshell** (hotkeys: Win+Ctrl+1/2/3 and Win+\` switch desktops (Win+1..9 open the bar's app buttons), Win+D shows the desktop, Win+I opens Settings, Win+E the file manager; brings the taskbar back if the bar dies), **rs-du**, and a block in your PowerShell profile (`zoxide`, `grep`=rg, `ll`=eza, `cat`=bat; does nothing if they are missing). The gear menu has short pages: Theme, Colors and transparency (any colour of the bar and the WinRust windows, the bar's opacity), Templates (save your own looks and switch between them), the bar (bottom / top / left / right edge, size, auto-hide, buttons at the left end like Windows 10) and Reset everything to defaults | | **rust-explorer** | A file manager with tabs, and the desktop | Folders and drives open in it; **Explorer stops being the shell** (comes back by itself if topbar fails). On fresh installs, adjusts the startup settings of PcaSvc, InventorySvc, lfsvc, cbdhsvc and DoSvc, and the svchost grouping threshold, when their values can be backed up. Its own copier (several files at once on SSDs, unbuffered for big files, progress in the status line) and right-click **Compress to ZIP** (all cores) / **Extract here** (ZIP and 7z), our own ZIP engine; a `.zip` opens like a folder (browse, copy out, open files from it). "Show in folder" from other programs selects the file (for the common folders: Downloads, Documents, Desktop, Pictures, Music, Videos and pinned ones, also when no window is open); the mouse back / forward buttons work; right click the desktop to hide its icons. Requires topbar | | **wiztree** | A disk-usage map ("WinRust Disk" in Start) | Nothing, apart from the file and a shortcut | | **photoview** | A fast photo viewer | Adds it to "Open with" (it does not become the default) | @@ -64,7 +64,9 @@ The gear at the left end of the bar opens **Bar settings**; a style picked on it | **White road** | Light ivory with gold: faint low-poly triangles, some traced in gold, behind the bar, its panels and rust-settings | | **Ruby** | Deep garnet with a bright ruby accent: a smooth top-to-bottom gradient with a soft gloss, behind the bar and its panels | -The gear menu also sets the bar position (bottom, left or right: a side bar shows icons only and the panels open next to it) and auto-hide. +The gear menu also sets the bar position (bottom, top, left or right: a side bar shows icons only and the panels open next to it) and auto-hide. + +Press **Ctrl+Alt+T** to tile the open windows from any theme, the same action as **Tile the windows** in the gear menu. The choice is stored in `%ProgramData%\WinRust\style.txt`. diff --git a/README.pt-BR.md b/README.pt-BR.md index d311b8f..0554333 100644 --- a/README.pt-BR.md +++ b/README.pt-BR.md @@ -40,7 +40,7 @@ Na desinstalação, o `rust-explorer` restaura os valores de inicialização dos |---|---|---| | **rust-search** | Pesquisa de arquivos em todas as unidades NTFS, Alt+Espaço. Com a topbar, Win+R abre o modo Executar dele: histórico, preenchimento de pastas (Tab), Ctrl+Shift+Enter executa como administrador | Desativa o serviço Pesquisa do Windows, bloqueia o SearchHost.exe, oculta a caixa de pesquisa da barra de tarefas | | **rtaskmgr-win32** | Gerenciador de Tarefas (Ctrl+Shift+Esc o abre) | O `taskmgr.exe` é redirecionado para ele (o arquivo do sistema não é tocado). Também instala o limpador de disco **rs-du**. A página **Velocidade** tem interruptores opcionais e reversíveis: perfis Jogo / Trabalho (param serviços em segundo plano, fecham lançadores ou apps de sincronização e os iniciam de novo), limpar o cache de espera da memória (agora, ou automaticamente enquanto a topbar roda), bloquear os processos do menu Iniciar, widgets e Phone Link do Windows, um `winget upgrade` semanal no lugar de atualizadores de terceiros, exclusões do Defender para caches de compilação e bibliotecas de jogos, NTFS mais rápido (sem horário do último acesso, sem nomes 8.3), um arquivo hosts que bloqueia anúncios. **Inicialização** também lista tarefas de logon/boot e serviços de início automático de terceiros, com o quanto cada um atrasou as últimas inicializações (o log de boot do próprio Windows). **O que está lento** mostra o tempo de drivers (DPC/interrupções), janelas travadas, disco lento e tempos de boot. Desinstalar reverte tudo | -| **topbar** | Uma barra inferior no estilo do Windows 11: janelas, relógio, volume, menus | Oculta a barra de tarefas original. Também instala o **reshell** (atalhos: Win+Ctrl+1/2/3 e Win+\` alternam áreas de trabalho (Win+1..9 abrem os botões de apps da barra), Win+D mostra a área de trabalho, Win+I abre as Configurações, Win+E o gerenciador de arquivos; traz a barra de tarefas de volta se a barra morrer), o **rs-du** e um bloco no seu perfil do PowerShell (`zoxide`, `grep`=rg, `ll`=eza, `cat`=bat; não faz nada se faltarem). O menu da engrenagem tem páginas curtas: Tema, Cores e transparência (qualquer cor da barra e das janelas da WinRust, a opacidade da barra), Modelos (salve suas próprias aparências e alterne entre elas), a barra (borda inferior / esquerda / direita, tamanho, ocultar automaticamente, botões na ponta esquerda como no Windows 10) e Restaurar tudo ao padrão | +| **topbar** | Uma barra inferior no estilo do Windows 11: janelas, relógio, volume, menus | Oculta a barra de tarefas original. Também instala o **reshell** (atalhos: Win+Ctrl+1/2/3 e Win+\` alternam áreas de trabalho (Win+1..9 abrem os botões de apps da barra), Win+D mostra a área de trabalho, Win+I abre as Configurações, Win+E o gerenciador de arquivos; traz a barra de tarefas de volta se a barra morrer), o **rs-du** e um bloco no seu perfil do PowerShell (`zoxide`, `grep`=rg, `ll`=eza, `cat`=bat; não faz nada se faltarem). O menu da engrenagem tem páginas curtas: Tema, Cores e transparência (qualquer cor da barra e das janelas da WinRust, a opacidade da barra), Modelos (salve suas próprias aparências e alterne entre elas), a barra (borda inferior / superior / esquerda / direita, tamanho, ocultar automaticamente, botões na ponta esquerda como no Windows 10) e Restaurar tudo ao padrão | | **rust-explorer** | Um gerenciador de arquivos com abas, e a área de trabalho | Pastas e unidades abrem nele; **o Explorer deixa de ser o shell** (volta sozinho se a topbar falhar). Em instalações novas, ajusta as configurações de inicialização de PcaSvc, InventorySvc, lfsvc, cbdhsvc e DoSvc, e o limite de agrupamento do svchost, quando os valores podem ser salvos em backup. Copiador próprio (vários arquivos ao mesmo tempo em SSDs, sem buffer para arquivos grandes, progresso na linha de status) e, no botão direito, **Compactar em ZIP** (todos os núcleos) / **Extrair aqui** (ZIP e 7z), com nosso próprio motor de ZIP; um `.zip` abre como uma pasta (navegar, copiar para fora, abrir arquivos dele). "Mostrar na pasta" a partir de outros programas seleciona o arquivo (para as pastas comuns: Downloads, Documentos, Área de Trabalho, Imagens, Músicas, Vídeos e as fixadas, também quando nenhuma janela está aberta); os botões voltar / avançar do mouse funcionam; clique com o botão direito na área de trabalho para ocultar os ícones. Requer a topbar | | **wiztree** | Um mapa de uso de disco ("WinRust Disk" no Iniciar) | Nada, além do arquivo e de um atalho | | **photoview** | Um visualizador de fotos rápido | Adiciona-o a "Abrir com" (ele não vira o padrão) | @@ -64,7 +64,9 @@ A engrenagem na ponta esquerda da barra abre as **Configurações da barra**; um | **Estrada branca** | Marfim claro com dourado: triângulos low-poly suaves, alguns contornados em dourado, atrás da barra, de seus painéis e do rust-settings | | **Rubi** | Granada profunda com destaque rubi brilhante: um degradê suave de cima para baixo com um leve brilho, atrás da barra e de seus painéis | -O menu da engrenagem também define a posição da barra (embaixo, à esquerda ou à direita: uma barra lateral mostra só ícones e os painéis abrem ao lado dela) e o ocultar automático. +O menu da engrenagem também define a posição da barra (embaixo, em cima, à esquerda ou à direita: uma barra lateral mostra só ícones e os painéis abrem ao lado dela) e o ocultar automático. + +Pressione **Ctrl+Alt+T** para colocar as janelas abertas lado a lado em qualquer tema, como a opção **Lado a lado** no menu da engrenagem. A escolha fica em `%ProgramData%\WinRust\style.txt`. diff --git a/README.ru.md b/README.ru.md index d5b0d68..a32e1dc 100644 --- a/README.ru.md +++ b/README.ru.md @@ -40,7 +40,7 @@ |---|---|---| | **rust-search** | Поиск файлов по всем NTFS-дискам, Alt+Space. С topbar Win+R открывает его режим «Выполнить»: история, дополнение папок (Tab), Ctrl+Shift+Enter запускает от администратора | Отключается служба поиска Windows, блокируется SearchHost.exe, прячется строка поиска на панели | | **rtaskmgr-win32** | Диспетчер задач (Ctrl+Shift+Esc открывает его) | Запуск `taskmgr.exe` перенаправляется на него (системный файл не трогается). Заодно ставится чистильщик диска **rs-du**. На странице **«Ускорение»** обратимые переключатели, всё по желанию: профили «Игра» и «Работа» (останавливают фоновые службы, закрывают лаунчеры или синхронизацию и потом запускают обратно), очистка кэша памяти standby (сейчас или автоматически, пока работает topbar), блок процессов меню «Пуск» Windows, виджетов и «Связи с телефоном», один еженедельный `winget upgrade` вместо сторонних апдейтеров, исключения Defender для кэшей сборки и библиотек игр, быстрее NTFS (без времени последнего доступа и имён 8.3), блокировка рекламы через hosts. **«Автозагрузка»** показывает ещё задачи при входе и загрузке и сторонние службы с автозапуском и то, насколько каждая замедлила последние загрузки (журнал самой Windows). **«Что тормозит»** показывает время драйверов (DPC и прерывания), зависшие окна, медленный диск и время загрузки. Удаление всё возвращает | -| **topbar** | Нижняя панель в стиле Windows 11: окна, часы, громкость, меню | Стандартная панель задач прячется. Заодно ставятся **reshell** (хоткеи: Win+Ctrl+1/2/3 и Win+\` переключают рабочие столы (Win+1..9 открывают кнопки панели), Win+D показывает рабочий стол, Win+I открывает Параметры, Win+E файловый менеджер; возвращает панель задач, если topbar упал), **rs-du** и блок в профиле PowerShell (`zoxide`, `grep`=rg, `ll`=eza, `cat`=bat; молчит, если их нет). Меню шестерёнки разбито на короткие страницы: «Тема», «Цвета и прозрачность» (любой цвет панели и окон WinRust, прозрачность панели), «Шаблоны» (свои наборы вида, переключаются в один клик), «Панель» (снизу / слева / справа, размер, автоскрытие, кнопки слева, как в Windows 10) и «Сбросить всё по умолчанию» | +| **topbar** | Нижняя панель в стиле Windows 11: окна, часы, громкость, меню | Стандартная панель задач прячется. Заодно ставятся **reshell** (хоткеи: Win+Ctrl+1/2/3 и Win+\` переключают рабочие столы (Win+1..9 открывают кнопки панели), Win+D показывает рабочий стол, Win+I открывает Параметры, Win+E файловый менеджер; возвращает панель задач, если topbar упал), **rs-du** и блок в профиле PowerShell (`zoxide`, `grep`=rg, `ll`=eza, `cat`=bat; молчит, если их нет). Меню шестерёнки разбито на короткие страницы: «Тема», «Цвета и прозрачность» (любой цвет панели и окон WinRust, прозрачность панели), «Шаблоны» (свои наборы вида, переключаются в один клик), «Панель» (снизу / сверху / слева / справа, размер, автоскрытие, кнопки слева, как в Windows 10) и «Сбросить всё по умолчанию» | | **rust-explorer** | Файловый менеджер с вкладками и рабочий стол | Папки и диски открываются в нём; **Проводник перестаёт быть оболочкой** (возвращается сам, если topbar не работает). При первой установке меняются настройки запуска PcaSvc, InventorySvc, lfsvc, cbdhsvc и DoSvc, а также порог группировки svchost, если удалось сохранить их исходные значения. Своё копирование (на SSD несколько файлов сразу, большие файлы без кэша, прогресс в строке состояния) и в меню правой кнопки **«Compress to ZIP»** (на всех ядрах) и **«Extract here»** (ZIP и 7z), собственный ZIP-движок; `.zip` открывается как папка (просмотр, копирование наружу, открытие файлов оттуда). «Показать в папке» из других программ выделяет файл (для частых папок: Загрузки, Документы, Рабочий стол, Изображения, Музыка, Видео и закреплённых, в том числе когда окно не открыто); работают кнопки мыши «назад / вперёд»; ПКМ по рабочему столу скрывает значки. Нужен topbar | | **wiztree** | Карта занятого места на диске («WinRust Disk» в Пуске) | Ничего, кроме файла и ярлыка | | **photoview** | Быстрый просмотр фото | Добавляется в «Открыть с помощью» (по умолчанию не назначается) | @@ -64,7 +64,9 @@ | **Белая дорога** | Цвет слоновой кости с золотом: еле заметные треугольники, часть с золотой обводкой, за панелью, её окошками и rust-settings | | **Рубин** | Глубокий гранатовый цвет с ярким рубиновым акцентом: плавный градиент сверху вниз с мягким глянцем, за панелью и её окошками | -В меню шестерёнки также выбирается положение панели (снизу, слева или справа: боковая панель показывает только значки, окошки открываются рядом с ней) и автоскрытие. +В меню шестерёнки также выбирается положение панели (снизу, сверху, слева или справа: боковая панель показывает только значки, окошки открываются рядом с ней) и автоскрытие. + +**Ctrl+Alt+T** раскладывает открытые окна плиткой в любой теме — так же, как пункт «Разложить окна плиткой» в меню шестерёнки. Выбор хранится в `%ProgramData%\WinRust\style.txt`. diff --git a/common/src/style.rs b/common/src/style.rs index 7414584..c06932e 100644 --- a/common/src/style.rs +++ b/common/src/style.rs @@ -142,6 +142,7 @@ pub fn set_align_left(on: bool) { #[derive(Clone, Copy, PartialEq, Eq, Debug)] pub enum Side { Bottom, + Top, Left, Right, } @@ -149,6 +150,7 @@ pub enum Side { impl Side { pub fn parse(s: &str) -> Side { match s.trim().to_ascii_lowercase().as_str() { + "top" => Side::Top, "left" => Side::Left, "right" => Side::Right, _ => Side::Bottom, @@ -157,6 +159,7 @@ impl Side { pub fn name(self) -> &'static str { match self { Side::Bottom => "bottom", + Side::Top => "top", Side::Left => "left", Side::Right => "right", } @@ -175,10 +178,11 @@ fn side_code(s: Side) -> u8 { Side::Bottom => 0, Side::Left => 1, Side::Right => 2, + Side::Top => 3, } } -/// The bar's edge (bottom unless %ProgramData%\WinRust\side.txt says left or right). Re-read once a second. +/// The bar's edge (bottom unless %ProgramData%\WinRust\side.txt names another edge). Re-read once a second. pub fn side() -> Side { if now_ms().saturating_sub(SIDE_AT.load(Relaxed)) > 1000 { let s = side_file().and_then(|f| std::fs::read_to_string(f).ok()).map_or(Side::Bottom, |s| Side::parse(&s)); @@ -188,6 +192,7 @@ pub fn side() -> Side { match SIDE.load(Relaxed) { 1 => Side::Left, 2 => Side::Right, + 3 => Side::Top, _ => Side::Bottom, } } @@ -597,8 +602,10 @@ mod tests { assert_eq!(Side::parse(" Left "), Side::Left); assert_eq!(Side::parse("right"), Side::Right); + assert_eq!(Side::parse("TOP"), Side::Top); + assert_eq!(Side::Top.name(), "top"); assert_eq!(Side::parse(""), Side::Bottom); - assert_eq!(Side::parse("top"), Side::Bottom); + assert_eq!(Side::parse("unknown"), Side::Bottom); } } diff --git a/plugins/topbar/src/main.rs b/plugins/topbar/src/main.rs index c82fee1..7905207 100644 --- a/plugins/topbar/src/main.rs +++ b/plugins/topbar/src/main.rs @@ -1,4 +1,4 @@ -// topbar: replaces the Windows taskbar with a panel at the bottom of the screen (the name stayed from when it sat on top), +// topbar: replaces the Windows taskbar with a panel on the chosen screen edge, // drawn in the Windows 11 taskbar palette: Start, pinned apps and open windows in the center; tray apps, language, wifi, // volume, battery and date/time on the right. `--restore` brings the normal taskbar back (used by uninstall). #![windows_subsystem = "windows"] @@ -64,17 +64,17 @@ use windows_sys::Win32::{ fn rr(v: i32) -> i32 { if style().square() { 0 } else { sc(v) } } -/// The bar sits at the top of the screen (tiling) instead of the bottom. +/// The bar sits at the top of the screen (by position setting or tiling theme). fn at_top() -> bool { - style() == Style::Tiling && !vert() + !vert() && (i18n::style::side() == i18n::style::Side::Top || style() == Style::Tiling) } /// The bar stands on the left or right edge of the screen (its "width" is bar_h(), it spans the screen height). fn vert() -> bool { - i18n::style::side() != i18n::style::Side::Bottom + matches!(i18n::style::side(), i18n::style::Side::Left | i18n::style::Side::Right) } -/// The floating dock (a pill in the middle of the bottom edge); a side bar is never a dock. +/// The floating dock (a pill in the middle of the bottom edge). fn dock() -> bool { - style() == Style::Dock && !vert() + style() == Style::Dock && i18n::style::side() == i18n::style::Side::Bottom } /// Screen x of a side bar's current left edge, slid away by the show/hide animation. unsafe fn bar_x() -> i32 { @@ -144,6 +144,7 @@ static WIN_ALONE: AtomicBool = AtomicBool::new(false); static BAR: AtomicIsize = AtomicIsize::new(0); // the bar window, for the hook thread const WIN_NUM: u32 = WM_APP + 15; // posted by the keyboard hook: Win+1..9 (wp 0..8) = the n-th button of the bar const NEXT_LANG: u32 = WM_APP + 16; // posted by the keyboard hook: Win+Space with no explorer (wp 1 = Shift held: previous layout) +const TILE_WINDOWS: u32 = WM_APP + 17; // posted by the keyboard hook: Ctrl+Alt+T const VOLKEY: u32 = WM_APP + 14; // posted by the keyboard hook: a volume key (wp 0 up, 1 down, 2 mute) const SNIP: u32 = WM_APP + 13; // posted by the keyboard hook: PrtSc / Win+Shift+S with no explorer to handle them static EXPLORER_UP: AtomicBool = AtomicBool::new(true); // explorer's taskbar exists (it handles PrtSc itself then); refreshed by the bar @@ -251,11 +252,15 @@ fn wide(s: &str) -> Vec { fn sc(v: i32) -> i32 { (v as f32 * SCALE.get()) as i32 } +/// Taskbar symbols are 70% of their original size; slots and hit targets stay unchanged. +fn icon_sc(v: i32) -> i32 { + sc((v as f32 * 0.70).round() as i32).max(1) +} fn bar_h() -> i32 { let d = [-6, 0, 8][i18n::style::bar_size() as usize % 3]; // small / normal / large if vert() { sc(60 + d) } else { sc(BAR_H + d) } } -/// Screen y of the bar's top edge when it is in place (bottom of the primary monitor, or its top in the tiling style). +/// Screen y of the bar's top edge when it is in place. unsafe fn bar_top() -> i32 { if at_top() { 0 } else { GetSystemMetrics(SM_CYSCREEN) - bar_h() - dock_gap() } } @@ -706,7 +711,7 @@ unsafe fn hide_taskbar_if_shown() { } } -/// Reserves the bottom strip of the primary monitor (maximized windows stay above it). +/// Reserves a strip on the bar's screen edge so maximized windows stay clear of it. unsafe fn place(hwnd: HWND) { apply_opacity(hwnd); let (cx, cy) = (GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); @@ -889,10 +894,10 @@ unsafe fn lnk_icon(lnk: &[u16], target: &str) -> HICON { icon } -/// Size app icons are drawn at (24 logical px, like the Windows 11 taskbar). Icons are loaded at exactly this size: +/// Size app icons are drawn at (about 17 logical px). Icons are loaded at exactly this size: /// a 32 px icon stretched by DrawIconEx comes out jagged. fn icon_px() -> i32 { - sc(24) + icon_sc(24) } /// Icon of a file, shortcut (its target's icon, no arrow) or shell item ("shell:AppsFolder\") rendered by the @@ -1620,7 +1625,7 @@ unsafe fn paint_vert(dc: HDC, cr: RECT, fonts: [HFONT; 4]) { fill(dc, r, mix(mix(mix(pal().bg, pal().hover, th), active_bg, ta), pal().accent, 0.5 * tp), sc(8)); } if i == 0 { - let t = ((sc(8) as f32) * (1.0 + 0.12 * th) * (1.0 - 0.2 * tp)) as i32; + let t = ((icon_sc(8) as f32) * (1.0 + 0.12 * th) * (1.0 - 0.2 * tp)) as i32; let g = sc(1).max(1); let tint = [mix(pal().accent, pal().text, 0.35), mix(pal().accent, pal().text, 0.15), mix(pal().accent, pal().text, 0.15), pal().accent]; for (k, (dx, dy)) in [(-1, -1), (0, -1), (-1, 0), (0, 0)].into_iter().enumerate() { @@ -1654,7 +1659,7 @@ unsafe fn paint_vert(dc: HDC, cr: RECT, fonts: [HFONT; 4]) { glow(dc, TAPP, hot == TAPP, cell(l.apps.0, sc(24)), pal().bg, pal().hover, sc(8)); let turn = ease(hv(TF_KEY, IsWindowVisible(TRAYFLY.get()) != 0)); - chevron(dc, cx, l.apps.0 + sc(12), sc(5), if left { 90.0 } else { 270.0 } + 180.0 * turn, mix(pal().text, pal().accent, turn)); + chevron(dc, cx, l.apps.0 + sc(12), icon_sc(5), if left { 90.0 } else { 270.0 } + 180.0 * turn, mix(pal().text, pal().accent, turn)); SelectObject(dc, f_txt); let bar = bar_idx(); TAPPS.with_borrow(|t| { @@ -1663,7 +1668,8 @@ unsafe fn paint_vert(dc: HDC, cr: RECT, fonts: [HFONT; 4]) { let y = l.apps.0 + i as i32 * sc(24); glow(dc, TAPP + i as i32, hot == TAPP + i as i32, cell(y, sc(24)), pal().bg, pal().hover, sc(8)); if !ti.icon.is_null() { - DrawIconEx(dc, cx - sc(8), y + sc(4), ti.icon, sc(16), sc(16), 0, null_mut(), DI_NORMAL); + let size = icon_sc(16); + DrawIconEx(dc, cx - size / 2, y + (sc(24) - size) / 2, ti.icon, size, size, 0, null_mut(), DI_NORMAL); } } }); @@ -1675,7 +1681,7 @@ unsafe fn paint_vert(dc: HDC, cr: RECT, fonts: [HFONT; 4]) { fill(dc, grp, mix(mix(pal().bg, pal().hover, tg), pal().accent, 0.5 * pg), sc(8)); } text(dc, &lang_name(), cell(l.sys.0, sc(42)), pal().text, DT_CENTER); - net_icon(dc, cx, l.sys.0 + sc(58), sc(17), f_glyph); + net_icon(dc, cx, l.sys.0 + sc(58), icon_sc(17), f_glyph); SelectObject(dc, f_glyph); let (vol, muted) = VOL.get(); let vg = if muted || vol == 0 { "\u{E74F}" } else if vol < 34 { "\u{E993}" } else if vol < 67 { "\u{E994}" } else { "\u{E995}" }; @@ -1683,7 +1689,7 @@ unsafe fn paint_vert(dc: HDC, cr: RECT, fonts: [HFONT; 4]) { let (pct, ac) = BAT.get(); if pct >= 0 { let col = if ac { GOOD } else if pct <= 15 { BAD } else { pal().text }; - let (bw, bh) = (sc(22), sc(11)); + let (bw, bh) = (icon_sc(22), icon_sc(11)); let (bx, by) = (cx - bw / 2 - sc(1), l.sys.0 + sc(111)); fill(dc, RECT { left: bx, top: by, right: bx + bw, bottom: by + bh }, col, sc(4)); fill(dc, RECT { left: bx + sc(1), top: by + sc(1), right: bx + bw - sc(1), bottom: by + bh - sc(1) }, mix(pal().bg, pal().hover, tg), sc(3)); @@ -1738,7 +1744,7 @@ unsafe fn paint(hwnd: HWND) { SetBkMode(dc, TRANSPARENT as i32); let (face, gface) = (wide(ui_face()), wide(winrust_common::style::icon_face())); let font = |f: &[u16], px: i32, wt: i32| CreateFontW(-sc(px), 0, 0, 0, wt, 0, 0, 0, 1, 0, 0, 5, 0, f.as_ptr()); - let (f_txt, f_small, f_glyph, f_bold) = (font(&face, 13, 400), font(&face, 12, 400), font(&gface, 16, 400), font(&face, 13, 600)); + let (f_txt, f_small, f_glyph, f_bold) = (font(&face, 13, 400), font(&face, 12, 400), font(&gface, 11, 400), font(&face, 13, 600)); let of = SelectObject(dc, f_txt); 'horiz: { @@ -1778,7 +1784,7 @@ unsafe fn paint(hwnd: HWND) { } if i == 0 { // Windows logo in four tiles, lit from the top left; grows a little on hover, squeezes on click - let t = ((sc(8) as f32) * (1.0 + 0.12 * th) * (1.0 - 0.2 * tp)) as i32; + let t = ((icon_sc(8) as f32) * (1.0 + 0.12 * th) * (1.0 - 0.2 * tp)) as i32; let (g, cx) = (sc(1).max(1), (r.left + r.right) / 2); let tint = [mix(pal().accent, pal().text, 0.35), mix(pal().accent, pal().text, 0.15), mix(pal().accent, pal().text, 0.15), pal().accent]; for (k, (dx, dy)) in [(-1, -1), (0, -1), (-1, 0), (0, 0)].into_iter().enumerate() { @@ -1821,7 +1827,7 @@ unsafe fn paint(hwnd: HWND) { let open_tf = IsWindowVisible(TRAYFLY.get()) != 0; let turn = ease(hv(TF_KEY, open_tf)); // the chevron turns over as the flyout opens, and back let cc = cell(l.apps.0, sc(24)); - chevron(dc, (cc.left + cc.right) / 2, mid, sc(5), if at_top() { 180.0 } else { 0.0 } + 180.0 * turn, mix(pal().text, pal().accent, turn)); + chevron(dc, (cc.left + cc.right) / 2, mid, icon_sc(5), if at_top() { 180.0 } else { 0.0 } + 180.0 * turn, mix(pal().text, pal().accent, turn)); SelectObject(dc, f_txt); let bar = bar_idx(); TAPPS.with_borrow(|t| { @@ -1830,7 +1836,8 @@ unsafe fn paint(hwnd: HWND) { let x = l.apps.0 + i as i32 * sc(24); glow(dc, TAPP + i as i32, hot == TAPP + i as i32, cell(x, sc(24)), pal().bg, pal().hover, sc(8)); if !ti.icon.is_null() { - DrawIconEx(dc, x + sc(4), mid - sc(8), ti.icon, sc(16), sc(16), 0, null_mut(), DI_NORMAL); + let size = icon_sc(16); + DrawIconEx(dc, x + (sc(24) - size) / 2, mid - size / 2, ti.icon, size, size, 0, null_mut(), DI_NORMAL); } } }); @@ -1846,7 +1853,7 @@ unsafe fn paint(hwnd: HWND) { let mut x = tb.left + sc(10); text(dc, &lang_name(), cell(x, sc(34)), pal().text, DT_LEFT); x += sc(42); - net_icon(dc, x + sc(9), mid, sc(17), f_glyph); + net_icon(dc, x + sc(9), mid, icon_sc(17), f_glyph); x += sc(32); SelectObject(dc, f_glyph); let (vol, muted) = VOL.get(); @@ -1856,7 +1863,8 @@ unsafe fn paint(hwnd: HWND) { let (pct, ac) = BAT.get(); if pct >= 0 { let col = if ac { GOOD } else if pct <= 15 { BAD } else { pal().text }; - let (bw, bh, by) = (sc(22), sc(11), mid - sc(5)); + let (bw, bh) = (icon_sc(22), icon_sc(11)); + let by = mid - bh / 2; fill(dc, RECT { left: x, top: by, right: x + bw, bottom: by + bh }, col, sc(4)); // outline fill(dc, RECT { left: x + sc(1), top: by + sc(1), right: x + bw - sc(1), bottom: by + bh - sc(1) }, mix(pal().bg, pal().hover, tg), sc(3)); let fw = ((bw - sc(4)) * pct / 100).max(sc(1)); @@ -2562,6 +2570,7 @@ unsafe extern "system" fn wndproc(hwnd: HWND, msg: u32, wp: WPARAM, lp: LPARAM) ALT_TAB => alt_tab(wp == 1), WIN_NUM => win_num(wp), NEXT_LANG => next_lang(hwnd, wp == 1), + TILE_WINDOWS => tile_windows(), ALT_UP if wp == 2 => alt_close(), ALT_UP => alt_done(wp == 1), SNIP if wp == 1 => screenshot_notice(hwnd), diff --git a/plugins/topbar/src/run.rs b/plugins/topbar/src/run.rs index b6c2bfb..9d5a1d6 100644 --- a/plugins/topbar/src/run.rs +++ b/plugins/topbar/src/run.rs @@ -1,6 +1,8 @@ //! topbar: run (split out of main.rs; shares its items through `super::*`). use super::*; +static TILE_KEY_DOWN: AtomicBool = AtomicBool::new(false); + /// The Windows "Run" box. `rundll32 shell32.dll,#61` cannot do it: ordinal 61 is RunFileDlg(hwnd, icon, dir, title, /// prompt, flags) and rundll32 passes other arguments. Its own thread: the box runs a modal loop until closed. pub(crate) fn run_dialog() { @@ -53,6 +55,17 @@ pub(crate) unsafe extern "system" fn kb_hook(n: i32, w: WPARAM, l: LPARAM) -> LR // Win+Shift+S is our own region clipper (also under Explorer); without explorer nobody opens the screen // capture either: PrtSc (when Windows is set to snip with it; otherwise it copies the screen by itself) does it here let held = |vk: u16| GetAsyncKeyState(vk as i32) < 0; + // Ctrl+Alt+T runs the same tiling action as the gear menu, once per key press. + if k.vkCode == b'T' as u32 { + if !down0 { + if TILE_KEY_DOWN.swap(false, Relaxed) { return 1; } + } else if held(VK_CONTROL) && held(VK_MENU) && !held(VK_SHIFT) && !held(VK_LWIN) && !held(VK_RWIN) { + if !TILE_KEY_DOWN.swap(true, Relaxed) { + PostMessageW(BAR.load(Relaxed) as HWND, TILE_WINDOWS, 0, 0); + } + return 1; + } + } let snip_key = !EXPLORER_UP.load(Relaxed) && k.vkCode == VK_SNAPSHOT as u32; let win_shift_s = k.vkCode == b'S' as u32 && down0 && (held(VK_LWIN) || held(VK_RWIN)) && held(VK_SHIFT); if snip_key || win_shift_s { diff --git a/plugins/topbar/src/settings.rs b/plugins/topbar/src/settings.rs index 2231134..606a9a2 100644 --- a/plugins/topbar/src/settings.rs +++ b/plugins/topbar/src/settings.rs @@ -12,7 +12,7 @@ pub(crate) unsafe fn style_menu() { fly::MItem::new(t!("Язык", "Language", ja: "言語", pt: "Idioma")).hint(i18n::lang().name()), fly::MItem::head(t!("Панель", "Bar", ja: "バー", pt: "Barra")).sep(), fly::MItem::new(t!("Положение, размер, поведение", "Position, size, behavior", ja: "位置、サイズ、動作", pt: "Posição, tamanho, comportamento")).hint("›"), - fly::MItem::new(t!("Разложить окна плиткой", "Tile the windows", ja: "ウィンドウを並べて表示", pt: "Lado a lado")), + fly::MItem::new(t!("Разложить окна плиткой", "Tile the windows", ja: "ウィンドウを並べて表示", pt: "Lado a lado")).hint("Ctrl+Alt+T"), fly::MItem::new(t!("Сбросить всё по умолчанию…", "Reset everything to defaults…", ja: "すべて初期設定に戻す…", pt: "Restaurar tudo ao padrão…")).danger().sep(), ]; gear_page("\u{E713}", t!("Настройки панели", "Bar settings", ja: "バーの設定", pt: "Configurações da barra"), t!("Вид панели и программ WinRust", "Look of the bar and the WinRust programs", ja: "バーと WinRust プログラムの外観", pt: "Aparência da barra e dos programas da WinRust"), items, |i| match i { @@ -92,11 +92,12 @@ pub(crate) unsafe fn theme_page() { pub(crate) unsafe fn bar_page() { use i18n::style::{self as st, Side}; - let sides = [Side::Bottom, Side::Left, Side::Right]; + let sides = [Side::Bottom, Side::Top, Side::Left, Side::Right]; let items = vec![ back(), fly::MItem::head(t!("Положение", "Position", ja: "位置", pt: "Posição")).sep(), fly::MItem::new(t!("Снизу", "Bottom", ja: "下", pt: "Embaixo")).on(st::side() == Side::Bottom), + fly::MItem::new(t!("Сверху", "Top", ja: "上", pt: "Em cima")).on(st::side() == Side::Top), fly::MItem::new(t!("Слева", "Left", ja: "左", pt: "Esquerda")).on(st::side() == Side::Left), fly::MItem::new(t!("Справа", "Right", ja: "右", pt: "Direita")).on(st::side() == Side::Right), fly::MItem::head(t!("Размер", "Size", ja: "サイズ", pt: "Tamanho")), @@ -110,14 +111,14 @@ pub(crate) unsafe fn bar_page() { ]; gear_page("\u{E8A1}", t!("Панель", "Bar", ja: "バー", pt: "Barra"), t!("Где она, какого размера и как себя ведёт", "Where it sits, its size and behavior", ja: "配置場所、サイズ、動作", pt: "Onde fica, seu tamanho e comportamento"), items, move |i| { match i { - 2..=4 => st::set_side(sides[i - 2]), - 6..=8 => st::set_bar_size((i - 6) as u8), - 10 => st::set_autohide(!st::autohide()), // the reserved strip comes or goes with it - 11 => st::set_align_left(!st::align_left()), - 12 => st::set_alttab_per_monitor(!st::alttab_per_monitor()), + 2..=5 => st::set_side(sides[i - 2]), + 7..=9 => st::set_bar_size((i - 7) as u8), + 11 => st::set_autohide(!st::autohide()), // the reserved strip comes or goes with it + 12 => st::set_align_left(!st::align_left()), + 13 => st::set_alttab_per_monitor(!st::alttab_per_monitor()), _ => return style_menu(), } - relook(i != 12); + relook(i != 13); bar_page(); }); } From 16aa323f4f451f2ad06871def48a2b0491977d09 Mon Sep 17 00:00:00 2001 From: NasirAldeen Ishtaiah Date: Sun, 22 Nov 2026 15:59:16 +0200 Subject: [PATCH 2/6] Make taskbar icon size adjustable --- README.ja.md | 2 ++ README.md | 2 ++ README.pt-BR.md | 2 ++ README.ru.md | 2 ++ common/src/style.rs | 42 ++++++++++++++++++++++++++++++++++ plugins/topbar/src/main.rs | 26 +++++++++++++++++---- plugins/topbar/src/settings.rs | 24 +++++++++++++++---- 7 files changed, 92 insertions(+), 8 deletions(-) diff --git a/README.ja.md b/README.ja.md index f0639fd..2a00ec8 100644 --- a/README.ja.md +++ b/README.ja.md @@ -66,6 +66,8 @@ UAC が**別の管理者**のパスワードを求めた場合でも、ユーザ 歯車メニューでは、バーの位置 (下、上、左、右: 縦置きのバーはアイコンのみで、パネルはその隣に開きます) と自動的に隠す設定も変更できます。 +**バーの設定 → アイコンのサイズ** で 50、60、70、80、90、100% から選べます。初期設定は 60% で、バーの高さとボタンのクリック範囲は変わりません。 + **Ctrl+Alt+T** で、どのテーマでも開いているウィンドウを並べられます。歯車メニューの「ウィンドウを並べて表示」と同じ操作です。 選択内容は `%ProgramData%\WinRust\style.txt` に保存されます。 diff --git a/README.md b/README.md index 02d3a0b..38b6ac4 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,8 @@ The gear at the left end of the bar opens **Bar settings**; a style picked on it The gear menu also sets the bar position (bottom, top, left or right: a side bar shows icons only and the panels open next to it) and auto-hide. +In **Bar settings → Icon size**, choose 50, 60, 70, 80, 90 or 100%. The default is 60%; changing it leaves the bar size and button click targets the same. + Press **Ctrl+Alt+T** to tile the open windows from any theme, the same action as **Tile the windows** in the gear menu. The choice is stored in `%ProgramData%\WinRust\style.txt`. diff --git a/README.pt-BR.md b/README.pt-BR.md index 0554333..6aade82 100644 --- a/README.pt-BR.md +++ b/README.pt-BR.md @@ -66,6 +66,8 @@ A engrenagem na ponta esquerda da barra abre as **Configurações da barra**; um O menu da engrenagem também define a posição da barra (embaixo, em cima, à esquerda ou à direita: uma barra lateral mostra só ícones e os painéis abrem ao lado dela) e o ocultar automático. +Em **Configurações da barra → Tamanho dos ícones**, escolha 50, 60, 70, 80, 90 ou 100%. O padrão é 60%; a altura da barra e as áreas de clique não mudam. + Pressione **Ctrl+Alt+T** para colocar as janelas abertas lado a lado em qualquer tema, como a opção **Lado a lado** no menu da engrenagem. A escolha fica em `%ProgramData%\WinRust\style.txt`. diff --git a/README.ru.md b/README.ru.md index a32e1dc..56ddeab 100644 --- a/README.ru.md +++ b/README.ru.md @@ -66,6 +66,8 @@ В меню шестерёнки также выбирается положение панели (снизу, сверху, слева или справа: боковая панель показывает только значки, окошки открываются рядом с ней) и автоскрытие. +В **Настройки панели → Размер значков** можно выбрать 50, 60, 70, 80, 90 или 100 %. По умолчанию — 60 %; размер панели и области нажатия кнопок не меняются. + **Ctrl+Alt+T** раскладывает открытые окна плиткой в любой теме — так же, как пункт «Разложить окна плиткой» в меню шестерёнки. Выбор хранится в `%ProgramData%\WinRust\style.txt`. diff --git a/common/src/style.rs b/common/src/style.rs index c06932e..027dc5b 100644 --- a/common/src/style.rs +++ b/common/src/style.rs @@ -435,6 +435,7 @@ pub fn save_themes(t: &[Theme]) { pub fn reset_all() { set_side(Side::Bottom); set_bar_size(1); + set_icon_size(60); set_autohide(false); set_align_left(false); set_alttab_per_monitor(false); @@ -607,6 +608,15 @@ mod tests { assert_eq!(Side::parse(""), Side::Bottom); assert_eq!(Side::parse("unknown"), Side::Bottom); } + + #[test] + fn icon_size_accepts_menu_choices_only() { + assert_eq!(valid_icon_size(50), Some(50)); + assert_eq!(valid_icon_size(60), Some(60)); + assert_eq!(valid_icon_size(100), Some(100)); + assert_eq!(valid_icon_size(55), None); + assert_eq!(valid_icon_size(0), None); + } } fn size_file() -> Option { @@ -635,6 +645,38 @@ pub fn set_bar_size(v: u8) { } } +fn icon_size_file() -> Option { + std::env::var_os("ProgramData").map(|p| PathBuf::from(p).join("WinRust").join("icon-size.txt")) +} + +static ICON_SIZE: AtomicU8 = AtomicU8::new(60); +static ICON_SIZE_AT: AtomicU64 = AtomicU64::new(0); + +fn valid_icon_size(v: u8) -> Option { + (50..=100).contains(&v).then_some(v).filter(|v| v % 10 == 0) +} + +/// Icon size as a percentage of the original, 60 by default. Re-read once a second. +pub fn icon_size() -> u8 { + if now_ms().saturating_sub(ICON_SIZE_AT.load(Relaxed)) > 1000 { + let v = icon_size_file().and_then(|f| std::fs::read_to_string(f).ok()) + .and_then(|s| s.trim().parse::().ok()).and_then(valid_icon_size).unwrap_or(60); + ICON_SIZE.store(v, Relaxed); + ICON_SIZE_AT.store(now_ms(), Relaxed); + } + ICON_SIZE.load(Relaxed) +} + +pub fn set_icon_size(v: u8) { + let v = valid_icon_size(v).unwrap_or(60); + ICON_SIZE.store(v, Relaxed); + ICON_SIZE_AT.store(now_ms(), Relaxed); + if let Some(f) = icon_size_file() { + let _ = std::fs::create_dir_all(f.parent().unwrap()); + let _ = std::fs::write(f, v.to_string()); + } +} + fn mon_file() -> Option { std::env::var_os("ProgramData").map(|p| PathBuf::from(p).join("WinRust").join("alttab-monitor.txt")) } diff --git a/plugins/topbar/src/main.rs b/plugins/topbar/src/main.rs index 7905207..d4895f9 100644 --- a/plugins/topbar/src/main.rs +++ b/plugins/topbar/src/main.rs @@ -252,9 +252,9 @@ fn wide(s: &str) -> Vec { fn sc(v: i32) -> i32 { (v as f32 * SCALE.get()) as i32 } -/// Taskbar symbols are 70% of their original size; slots and hit targets stay unchanged. +/// Taskbar symbols use the chosen size; slots and hit targets stay unchanged. fn icon_sc(v: i32) -> i32 { - sc((v as f32 * 0.70).round() as i32).max(1) + sc((v as f32 * i18n::style::icon_size() as f32 / 100.0).round() as i32).max(1) } fn bar_h() -> i32 { let d = [-6, 0, 8][i18n::style::bar_size() as usize % 3]; // small / normal / large @@ -894,7 +894,7 @@ unsafe fn lnk_icon(lnk: &[u16], target: &str) -> HICON { icon } -/// Size app icons are drawn at (about 17 logical px). Icons are loaded at exactly this size: +/// Size app icons are drawn at. Icons are loaded at exactly this size: /// a 32 px icon stretched by DrawIconEx comes out jagged. fn icon_px() -> i32 { icon_sc(24) @@ -923,6 +923,24 @@ thread_local! { static EXE_ICONS: RefCell> = RefCell::new(HashMap::new()); // crisp icons of running apps, by exe } +/// Recreate cached app icons after the size changes so they remain crisp. +unsafe fn reload_icons() { + PINS.with_borrow_mut(|pins| { + for pin in pins.iter_mut() { + let icon = lnk_icon(&pin.lnk, &pin.target); + if !pin.icon.is_null() { DestroyIcon(pin.icon); } + pin.icon = icon; + } + }); + EXE_ICONS.with_borrow_mut(|icons| { + for icon in icons.values() { + if !icon.is_null() { DestroyIcon(*icon); } + } + icons.clear(); + }); + refresh_buttons(); +} + /// Icon of a running window for its bar button: its exe's icon at the exact size (cached), else what the window reports. /// Apps run by a generic host (Store apps in ApplicationFrameHost, Java games in javaw, scripts in python...) would all /// get the host's icon: those keep the window's own icon. @@ -1744,7 +1762,7 @@ unsafe fn paint(hwnd: HWND) { SetBkMode(dc, TRANSPARENT as i32); let (face, gface) = (wide(ui_face()), wide(winrust_common::style::icon_face())); let font = |f: &[u16], px: i32, wt: i32| CreateFontW(-sc(px), 0, 0, 0, wt, 0, 0, 0, 1, 0, 0, 5, 0, f.as_ptr()); - let (f_txt, f_small, f_glyph, f_bold) = (font(&face, 13, 400), font(&face, 12, 400), font(&gface, 11, 400), font(&face, 13, 600)); + let (f_txt, f_small, f_glyph, f_bold) = (font(&face, 13, 400), font(&face, 12, 400), font(&gface, (16.0 * i18n::style::icon_size() as f32 / 100.0).round() as i32, 400), font(&face, 13, 600)); let of = SelectObject(dc, f_txt); 'horiz: { diff --git a/plugins/topbar/src/settings.rs b/plugins/topbar/src/settings.rs index 606a9a2..8a77c91 100644 --- a/plugins/topbar/src/settings.rs +++ b/plugins/topbar/src/settings.rs @@ -104,6 +104,7 @@ pub(crate) unsafe fn bar_page() { fly::MItem::new(t!("Маленькая", "Small", ja: "小", pt: "Pequeno")).on(st::bar_size() == 0), fly::MItem::new(t!("Обычная", "Normal", ja: "通常", pt: "Normal")).on(st::bar_size() == 1), fly::MItem::new(t!("Большая", "Large", ja: "大", pt: "Grande")).on(st::bar_size() == 2), + fly::MItem::new(format!("{} ({} %)", t!("Размер значков", "Icon size", ja: "アイコンのサイズ", pt: "Tamanho dos ícones"), st::icon_size())).hint("›"), fly::MItem::head(t!("Поведение", "Behavior", ja: "動作", pt: "Comportamento")), fly::MItem::new(t!("Скрывать автоматически", "Hide automatically", ja: "自動的に隠す", pt: "Ocultar automaticamente")).on(st::autohide()), fly::MItem::new(t!("Кнопки слева, как в Windows 10", "Buttons on the left, like Windows 10", ja: "ボタンを左に配置 (Windows 10 風)", pt: "Botões à esquerda, como no Windows 10")).on(st::align_left()), @@ -113,16 +114,31 @@ pub(crate) unsafe fn bar_page() { match i { 2..=5 => st::set_side(sides[i - 2]), 7..=9 => st::set_bar_size((i - 7) as u8), - 11 => st::set_autohide(!st::autohide()), // the reserved strip comes or goes with it - 12 => st::set_align_left(!st::align_left()), - 13 => st::set_alttab_per_monitor(!st::alttab_per_monitor()), + 10 => return icon_size_page(), + 12 => st::set_autohide(!st::autohide()), // the reserved strip comes or goes with it + 13 => st::set_align_left(!st::align_left()), + 14 => st::set_alttab_per_monitor(!st::alttab_per_monitor()), _ => return style_menu(), } - relook(i != 13); + relook(i != 14); bar_page(); }); } +pub(crate) unsafe fn icon_size_page() { + use i18n::style as st; + const SIZES: [u8; 6] = [50, 60, 70, 80, 90, 100]; + let mut items = vec![back(), fly::MItem::head(t!("Размер значков", "Icon size", ja: "アイコンのサイズ", pt: "Tamanho dos ícones")).sep()]; + items.extend(SIZES.iter().map(|&size| fly::MItem::new(format!("{size} %")).on(st::icon_size() == size))); + gear_page("\u{E8A1}", t!("Размер значков", "Icon size", ja: "アイコンのサイズ", pt: "Tamanho dos ícones"), t!("Размер значков на панели", "Size of icons on the bar", ja: "バーのアイコンサイズ", pt: "Tamanho dos ícones na barra"), items, move |i| { + let Some(&size) = i.checked_sub(2).and_then(|n| SIZES.get(n)) else { return bar_page() }; + st::set_icon_size(size); + reload_icons(); + relook(false); + icon_size_page(); + }); +} + /// Bar transparency from the colours page (the window is layered; 100 % = opaque). pub(crate) unsafe fn apply_opacity(hwnd: HWND) { SetLayeredWindowAttributes(hwnd, 0, (255 * i18n::style::bar_opacity() as u32 / 100) as u8, LWA_ALPHA); From 7cca5ec67aa519196e65b56d0feb276334d16c6c Mon Sep 17 00:00:00 2001 From: NasirAldeen Ishtaiah Date: Sun, 22 Nov 2026 16:00:25 +0200 Subject: [PATCH 3/6] Clarify icon size settings path --- README.ja.md | 2 +- README.md | 2 +- README.pt-BR.md | 2 +- README.ru.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.ja.md b/README.ja.md index 2a00ec8..7c50c96 100644 --- a/README.ja.md +++ b/README.ja.md @@ -66,7 +66,7 @@ UAC が**別の管理者**のパスワードを求めた場合でも、ユーザ 歯車メニューでは、バーの位置 (下、上、左、右: 縦置きのバーはアイコンのみで、パネルはその隣に開きます) と自動的に隠す設定も変更できます。 -**バーの設定 → アイコンのサイズ** で 50、60、70、80、90、100% から選べます。初期設定は 60% で、バーの高さとボタンのクリック範囲は変わりません。 +**バーの設定 → 位置、サイズ、動作 → アイコンのサイズ** で 50、60、70、80、90、100% から選べます。初期設定は 60% で、バーの高さとボタンのクリック範囲は変わりません。 **Ctrl+Alt+T** で、どのテーマでも開いているウィンドウを並べられます。歯車メニューの「ウィンドウを並べて表示」と同じ操作です。 diff --git a/README.md b/README.md index 38b6ac4..8500592 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ The gear at the left end of the bar opens **Bar settings**; a style picked on it The gear menu also sets the bar position (bottom, top, left or right: a side bar shows icons only and the panels open next to it) and auto-hide. -In **Bar settings → Icon size**, choose 50, 60, 70, 80, 90 or 100%. The default is 60%; changing it leaves the bar size and button click targets the same. +In **Bar settings → Position, size, behavior → Icon size**, choose 50, 60, 70, 80, 90 or 100%. The default is 60%; changing it leaves the bar size and button click targets the same. Press **Ctrl+Alt+T** to tile the open windows from any theme, the same action as **Tile the windows** in the gear menu. diff --git a/README.pt-BR.md b/README.pt-BR.md index 6aade82..2166020 100644 --- a/README.pt-BR.md +++ b/README.pt-BR.md @@ -66,7 +66,7 @@ A engrenagem na ponta esquerda da barra abre as **Configurações da barra**; um O menu da engrenagem também define a posição da barra (embaixo, em cima, à esquerda ou à direita: uma barra lateral mostra só ícones e os painéis abrem ao lado dela) e o ocultar automático. -Em **Configurações da barra → Tamanho dos ícones**, escolha 50, 60, 70, 80, 90 ou 100%. O padrão é 60%; a altura da barra e as áreas de clique não mudam. +Em **Configurações da barra → Posição, tamanho, comportamento → Tamanho dos ícones**, escolha 50, 60, 70, 80, 90 ou 100%. O padrão é 60%; a altura da barra e as áreas de clique não mudam. Pressione **Ctrl+Alt+T** para colocar as janelas abertas lado a lado em qualquer tema, como a opção **Lado a lado** no menu da engrenagem. diff --git a/README.ru.md b/README.ru.md index 56ddeab..1bf8704 100644 --- a/README.ru.md +++ b/README.ru.md @@ -66,7 +66,7 @@ В меню шестерёнки также выбирается положение панели (снизу, сверху, слева или справа: боковая панель показывает только значки, окошки открываются рядом с ней) и автоскрытие. -В **Настройки панели → Размер значков** можно выбрать 50, 60, 70, 80, 90 или 100 %. По умолчанию — 60 %; размер панели и области нажатия кнопок не меняются. +В **Настройки панели → Положение, размер, поведение → Размер значков** можно выбрать 50, 60, 70, 80, 90 или 100 %. По умолчанию — 60 %; размер панели и области нажатия кнопок не меняются. **Ctrl+Alt+T** раскладывает открытые окна плиткой в любой теме — так же, как пункт «Разложить окна плиткой» в меню шестерёнки. From 41b51b601ebc8066fa45d23e2bc913a5ba7f89bc Mon Sep 17 00:00:00 2001 From: NasirAldeen Ishtaiah Date: Sun, 22 Nov 2026 16:18:50 +0200 Subject: [PATCH 4/6] Keep desktop icons clear of top bar and add desktop sizing --- README.ja.md | 2 + README.md | 2 + README.pt-BR.md | 2 + README.ru.md | 2 + plugins/rust-explorer/src/main.rs | 119 +++++++++++++++++++++++++----- 5 files changed, 108 insertions(+), 19 deletions(-) diff --git a/README.ja.md b/README.ja.md index 7c50c96..e573d2b 100644 --- a/README.ja.md +++ b/README.ja.md @@ -68,6 +68,8 @@ UAC が**別の管理者**のパスワードを求めた場合でも、ユーザ **バーの設定 → 位置、サイズ、動作 → アイコンのサイズ** で 50、60、70、80、90、100% から選べます。初期設定は 60% で、バーの高さとボタンのクリック範囲は変わりません。 +WinRust デスクトップの空白部分を右クリックし、**Desktop size (icons and text)** から 75、85、100、125% を選べます。バーを上または下へ移動すると、デスクトップアイコンの領域も追従します。 + **Ctrl+Alt+T** で、どのテーマでも開いているウィンドウを並べられます。歯車メニューの「ウィンドウを並べて表示」と同じ操作です。 選択内容は `%ProgramData%\WinRust\style.txt` に保存されます。 diff --git a/README.md b/README.md index 8500592..a3796fa 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,8 @@ The gear menu also sets the bar position (bottom, top, left or right: a side bar In **Bar settings → Position, size, behavior → Icon size**, choose 50, 60, 70, 80, 90 or 100%. The default is 60%; changing it leaves the bar size and button click targets the same. +On the WinRust desktop, right-click empty space and choose **Desktop size (icons and text)** for 75, 85, 100 or 125%. The desktop icon area follows the bar when it moves to the top or bottom. + Press **Ctrl+Alt+T** to tile the open windows from any theme, the same action as **Tile the windows** in the gear menu. The choice is stored in `%ProgramData%\WinRust\style.txt`. diff --git a/README.pt-BR.md b/README.pt-BR.md index 2166020..d1693e2 100644 --- a/README.pt-BR.md +++ b/README.pt-BR.md @@ -68,6 +68,8 @@ O menu da engrenagem também define a posição da barra (embaixo, em cima, à e Em **Configurações da barra → Posição, tamanho, comportamento → Tamanho dos ícones**, escolha 50, 60, 70, 80, 90 ou 100%. O padrão é 60%; a altura da barra e as áreas de clique não mudam. +Na área de trabalho do WinRust, clique com o botão direito em um espaço vazio e escolha **Desktop size (icons and text)** para 75, 85, 100 ou 125%. A área dos ícones acompanha a barra quando ela se move para cima ou para baixo. + Pressione **Ctrl+Alt+T** para colocar as janelas abertas lado a lado em qualquer tema, como a opção **Lado a lado** no menu da engrenagem. A escolha fica em `%ProgramData%\WinRust\style.txt`. diff --git a/README.ru.md b/README.ru.md index 1bf8704..861da73 100644 --- a/README.ru.md +++ b/README.ru.md @@ -68,6 +68,8 @@ В **Настройки панели → Положение, размер, поведение → Размер значков** можно выбрать 50, 60, 70, 80, 90 или 100 %. По умолчанию — 60 %; размер панели и области нажатия кнопок не меняются. +На рабочем столе WinRust щёлкните правой кнопкой по пустому месту и выберите **Desktop size (icons and text)**: 75, 85, 100 или 125 %. Область значков следует за панелью при её перемещении вверх или вниз. + **Ctrl+Alt+T** раскладывает открытые окна плиткой в любой теме — так же, как пункт «Разложить окна плиткой» в меню шестерёнки. Выбор хранится в `%ProgramData%\WinRust\style.txt`. diff --git a/plugins/rust-explorer/src/main.rs b/plugins/rust-explorer/src/main.rs index 751a6ce..ecaabd1 100644 --- a/plugins/rust-explorer/src/main.rs +++ b/plugins/rust-explorer/src/main.rs @@ -37,7 +37,12 @@ fn virt() -> (i32, i32, i32, i32) { fn place_desk_list(list: HWND) { let (vx, vy, ..) = virt(); let (sw, sh) = unsafe { (GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)) }; - unsafe { MoveWindow(list, -vx, -vy + desk_top(), sw, (sh - desk_top() - desk_bottom()).max(0), 1) }; + let (top, bottom) = (desk_top(), desk_bottom()); + let (x, y, h) = (-vx, -vy + top, (sh - top - bottom).max(0)); + let mut current: RECT = unsafe { std::mem::zeroed() }; + let unchanged = unsafe { GetWindowRect(list, &mut current) != 0 } + && (current.left, current.top, current.right, current.bottom) == (0, top, sw, top + h); + if !unchanged { unsafe { MoveWindow(list, x, y, sw, h, 1) }; } } /// Renders the wallpaper for the current monitor layout (at start and when monitors change), freeing the old one. fn reload_wall() { @@ -72,11 +77,31 @@ fn saved_place() -> Option<(bool, RECT)> { let (max, r) = parse_place(&fs::read_to_string(place_file()).ok()?)?; (!unsafe { MonitorFromRect(&r, MONITOR_DEFAULTTONULL) }.is_null()).then_some((max, r)) } -/// What the bar reserves at the top and bottom of the screen: the work area topbar sets when there is no explorer. +/// The bar's actual edge wins over a stale work area left by its previous position. +fn bar_strips(side: winrust_common::style::Side, theme: winrust_common::style::Style, autohide: bool, b: RECT, sh: i32) -> (i32, i32) { + use winrust_common::style::{Side, Style}; + if autohide || (theme == Style::Dock && side == Side::Bottom) { return (0, 0); } + if side == Side::Top || (side == Side::Bottom && theme == Style::Tiling) { + (b.bottom.max(0), 0) + } else if side == Side::Bottom { + (0, (sh - b.top).max(0)) + } else { + (0, 0) + } +} + +/// What the bar reserves at the top and bottom of the screen. fn work_strips() -> (i32, i32) { let mut r: RECT = unsafe { std::mem::zeroed() }; if unsafe { SystemParametersInfoW(SPI_GETWORKAREA, 0, &mut r as *mut _ as *mut _, 0) } == 0 { return (0, 0); } - (r.top.max(0), (unsafe { GetSystemMetrics(SM_CYSCREEN) } - r.bottom).max(0)) + let sh = unsafe { GetSystemMetrics(SM_CYSCREEN) }; + let fallback = (r.top.max(0), (sh - r.bottom).max(0)); + let bar = unsafe { FindWindowW(w("topbar").as_ptr(), ptr::null()) }; + if bar.is_null() { return fallback; } + use winrust_common::style; + let mut b: RECT = unsafe { std::mem::zeroed() }; + if unsafe { GetWindowRect(bar, &mut b) } == 0 { return fallback; } + bar_strips(style::side(), style::style(), style::autohide(), b, sh) } /// Margins of the desktop's icon list, from the bar's real size: its reserved strip (any height, top or bottom). /// The dock style reserves nothing but floats over the bottom edge, so it gets a fixed gap while topbar runs. @@ -391,15 +416,51 @@ fn item_menu(h: HWND, dir: &Path, paths: &[PathBuf]) { /// "Hide desktop icons" is a marker file, so it survives restarts. fn icons_marker() -> PathBuf { PathBuf::from(env::var_os("APPDATA").unwrap_or_default()).join(r"WinRust\desktop-icons-hidden.txt") } fn small_marker() -> PathBuf { icons_marker().with_file_name("small-icons") } -/// Desktop icon size: the system's large (32 px, default) or small (16 px) icons with a tighter grid. Same icon indexes in both. +fn desktop_scale_file() -> PathBuf { icons_marker().with_file_name("desktop-scale.txt") } +fn desktop_scale() -> u32 { + fs::read_to_string(desktop_scale_file()).ok().and_then(|s| s.trim().parse::().ok()) + .filter(|v| [75, 85, 100, 125].contains(v)) + .unwrap_or(if small_marker().exists() { 75 } else { 100 }) +} +thread_local! { + static DESK_IL: std::cell::Cell = const { std::cell::Cell::new(0) }; + static DESK_FONT: std::cell::Cell = const { std::cell::Cell::new(0) }; + static DESK_ICON_MAP: std::cell::RefCell> = std::cell::RefCell::new(std::collections::HashMap::new()); +} +/// Resize an icon from the shell's system list into the desktop's chosen image list. #[allow(unsafe_op_in_unsafe_fn)] -unsafe fn apply_icon_size(list: HWND) { - let small = small_marker().exists(); +unsafe fn desktop_icon(system_index: i32) -> i32 { + if system_index < 0 { return I_IMAGENONE; } + if let Some(index) = DESK_ICON_MAP.with_borrow(|map| map.get(&system_index).copied()) { return index; } let mut fi: SHFILEINFOW = std::mem::zeroed(); - let il = SHGetFileInfoW(w("C:\\").as_ptr(), 0, &mut fi, size_of::() as u32, SHGFI_SYSICONINDEX | if small { SHGFI_SMALLICON } else { SHGFI_LARGEICON }); + let source = SHGetFileInfoW(w("C:\\").as_ptr(), 0, &mut fi, size_of::() as u32, SHGFI_SYSICONINDEX | SHGFI_LARGEICON); + let icon = ImageList_GetIcon(source as _, system_index, ILD_NORMAL as u32); + if icon.is_null() { return I_IMAGENONE; } + let px = ui::sc((32 * desktop_scale() as i32 + 50) / 100).max(1); + let resized = CopyImage(icon as _, IMAGE_ICON, px, px, 0) as HICON; + let index = ImageList_ReplaceIcon(DESK_IL.get() as _, -1, if resized.is_null() { icon } else { resized }); + if !resized.is_null() { DestroyIcon(resized); } + DestroyIcon(icon); + if index >= 0 { DESK_ICON_MAP.with_borrow_mut(|map| { map.insert(system_index, index); }); } + index +} +/// Change desktop icons, labels, and grid spacing together. The regular file manager keeps its own scale. +#[allow(unsafe_op_in_unsafe_fn)] +unsafe fn apply_icon_size(list: HWND) { + let scale = desktop_scale() as i32; + let px = ui::sc((32 * scale + 50) / 100).max(1); + let il = ImageList_Create(px, px, ILC_COLOR32 | ILC_MASK, 64, 64); + if il == 0 { return; } + let old = DESK_IL.replace(il as isize); + DESK_ICON_MAP.with_borrow_mut(|map| map.clear()); put(list, LVM_SETIMAGELIST, LVSIL_NORMAL as usize, il as isize); - let (cx, cy) = if small { (76, 64) } else { (88, 96) }; + if old != 0 { ImageList_Destroy(old as _); } + let (cx, cy) = ((88 * scale + 50) / 100, (96 * scale + 50) / 100); put(list, LVM_SETICONSPACING, 0, ((ui::sc(cy) as isize) << 16) | ui::sc(cx) as isize); + let font = windows_sys::Win32::Graphics::Gdi::CreateFontW(-ui::sc((13 * scale + 50) / 100), 0, 0, 0, 400, 0, 0, 0, 1, 0, 0, 4, 0, w(ui::ui_face()).as_ptr()); + put(list, WM_SETFONT, font as usize, 1); + let old_font = DESK_FONT.replace(font as isize); + if old_font != 0 { windows_sys::Win32::Graphics::Gdi::DeleteObject(old_font as _); } } fn icons_hidden() -> bool { icons_marker().exists() } fn set_icons_hidden(hide: bool) { @@ -418,7 +479,14 @@ unsafe fn bg_menu(h: HWND) { if disk.is_some() { AppendMenuW(m, MF_STRING, 6, w("Disk usage (WinRust Disk)").as_ptr()); } if desk() { for (id, l) in [(8usize, "Sort icons by name"), (9, "Sort icons by date"), (10, "Sort icons by size"), (11, "Arrange icons")] { AppendMenuW(m, MF_STRING, id, w(l).as_ptr()); } } if !desk() { AppendMenuW(m, MF_STRING, 13, w(if group_on() { "No grouping" } else { "Group by date" }).as_ptr()); } - if desk() { AppendMenuW(m, MF_STRING, 12, w(if small_marker().exists() { "Large icons" } else { "Small icons" }).as_ptr()); } + if desk() { + let sizes = CreatePopupMenu(); + for (id, size) in [(20usize, 75), (21, 85), (22, 100), (23, 125)] { + let label = format!("{size}%{}", if desktop_scale() == size { " ✓" } else { "" }); + AppendMenuW(sizes, MF_STRING, id, w(&label).as_ptr()); + } + AppendMenuW(m, MF_POPUP, sizes as usize, w("Desktop size (icons and text)").as_ptr()); + } if desk() { AppendMenuW(m, MF_STRING, 7, w(if icons_hidden() { "Show desktop icons" } else { "Hide desktop icons" }).as_ptr()); } let mut pt: POINT = std::mem::zeroed(); GetCursorPos(&mut pt); @@ -431,11 +499,12 @@ unsafe fn bg_menu(h: HWND) { let k = group_marker(); if group_on() { let _ = fs::remove_file(&k); } else { if let Some(d) = k.parent() { let _ = fs::create_dir_all(d); } let _ = fs::write(&k, "1"); } } - 12 => { // the grid changes with the size: icons are laid out again - let k = small_marker(); - if k.exists() { let _ = fs::remove_file(&k); } else { let _ = fs::write(&k, "1"); } + 20..=23 => { // keep the saved icon positions, mapped to the new grid + let size = [75, 85, 100, 125][id as usize - 20]; + let k = desktop_scale_file(); + if let Some(parent) = k.parent() { let _ = fs::create_dir_all(parent); } + let _ = fs::write(k, size.to_string()); apply_icon_size(ST.with_borrow(|st| st.list)); - let _ = fs::remove_file(desk::pos_file()); } 8..=11 => { // the saved cells are dropped: reload lays every icon out again, down the columns in sort order if id != 11 { SORT_COL.store([0, 1, 3][id as usize - 8], Relaxed); SORT_ASC.store(true, Relaxed); } @@ -1505,9 +1574,6 @@ unsafe extern "system" fn proc(h: HWND, m: u32, wp: WPARAM, lp: LPARAM) -> LRESU let il = SHGetFileInfoW(w("C:\\").as_ptr(), 0, &mut fi, size_of::() as u32, SHGFI_SYSICONINDEX | SHGFI_SMALLICON); put(list, LVM_SETIMAGELIST, LVSIL_SMALL as usize, il as isize); if desk() { - // system large icons; indexes are shared with the small list, so icon_of() works unchanged - let big = SHGetFileInfoW(w("C:\\").as_ptr(), 0, &mut fi, size_of::() as u32, SHGFI_SYSICONINDEX | SHGFI_LARGEICON); - put(list, LVM_SETIMAGELIST, LVSIL_NORMAL as usize, big as isize); apply_icon_size(list); // transparent background (the desktop paints it) and shadowed labels, readable on light wallpapers too let ex = LVS_EX_TRANSPARENTBKGND | 0x0080_0000; // LVS_EX_TRANSPARENTSHADOWTEXT @@ -1516,7 +1582,6 @@ unsafe extern "system" fn proc(h: HWND, m: u32, wp: WPARAM, lp: LPARAM) -> LRESU put(list, LVM_SETTEXTCOLOR, 0, 0x00FF_FFFF); reload_wall(); // grey (not ClearType) smoothing: on a live wallpaper the labels sit on a colour key, where ClearType leaves coloured fringes - put(list, WM_SETFONT, windows_sys::Win32::Graphics::Gdi::CreateFontW(-ui::sc(13), 0, 0, 0, 400, 0, 0, 0, 1, 0, 0, 4, 0, w(ui::ui_face()).as_ptr()) as usize, 1); // like explorer's desktop: wallpaper apps look for a SHELLDLL_DefView under Progman CreateWindowExW(0, w("SHELLDLL_DefView").as_ptr(), ptr::null(), WS_CHILD, 0, 0, 0, 0, h, 0 as _, inst, ptr::null()); SetTimer(h, 7, 2000, None); // live wallpaper on / off (desk::check_live) @@ -1659,7 +1724,7 @@ unsafe extern "system" fn proc(h: HWND, m: u32, wp: WPARAM, lp: LPARAM) -> LRESU it.iImage = if r.thumb >= 0 { r.thumb } else { I_IMAGENONE }; } else if it.mask & LVIF_IMAGE != 0 { if r.icon < 0 { r.icon = icon_of(&dir.join(&r.name), r.dir); } - it.iImage = r.icon; + it.iImage = if desk() { desktop_icon(r.icon) } else { r.icon }; } }); } @@ -1820,7 +1885,12 @@ unsafe extern "system" fn proc(h: HWND, m: u32, wp: WPARAM, lp: LPARAM) -> LRESU // icons hidden: the list is not shown, so the click lands on the desktop itself; the menu must still open WM_CONTEXTMENU if desk() && icons_hidden() => { bg_menu(h); 0 } desk::SPAWN_WORKERW if desk() => { desk::spawn_workerw(h); 0 } - WM_TIMER if desk() && wp == 7 => { desk::check_live(ST.with_borrow(|st| st.list)); 0 } + WM_TIMER if desk() && wp == 7 => { + let list = ST.with_borrow(|st| st.list); + place_desk_list(list); // catches a bar move even if the work-area broadcast was missed + desk::check_live(list); + 0 + } WM_DESTROY => { if !desk() { save_place(h); } shellwin::revoke(); PostQuitMessage(0); 0 } _ => DefWindowProcW(h, m, wp, lp), } @@ -1914,6 +1984,17 @@ fn main() { #[cfg(test)] mod tests { + #[test] + fn desktop_follows_the_bars_current_edge() { + use winrust_common::style::{Side, Style}; + let top = super::RECT { left: 0, top: 0, right: 1920, bottom: 34 }; + let bottom = super::RECT { left: 0, top: 1046, right: 1920, bottom: 1080 }; + assert_eq!(super::bar_strips(Side::Top, Style::Normal, false, top, 1080), (34, 0)); + assert_eq!(super::bar_strips(Side::Bottom, Style::Normal, false, bottom, 1080), (0, 34)); + assert_eq!(super::bar_strips(Side::Bottom, Style::Tiling, false, top, 1080), (34, 0)); + assert_eq!(super::bar_strips(Side::Top, Style::Normal, true, top, 1080), (0, 0)); + } + #[test] fn window_place_parses_and_rejects_junk() { let (max, r) = super::parse_place("max 10 20 1010 680").unwrap(); From 23dbb1ae84db9080a5b4cd3527e70ee723f70f7a Mon Sep 17 00:00:00 2001 From: NasirAldeen Ishtaiah Date: Sun, 22 Nov 2026 16:23:22 +0200 Subject: [PATCH 5/6] Let desktop icons use the bottom row --- plugins/rust-explorer/src/main.rs | 54 +++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/plugins/rust-explorer/src/main.rs b/plugins/rust-explorer/src/main.rs index ecaabd1..36422f6 100644 --- a/plugins/rust-explorer/src/main.rs +++ b/plugins/rust-explorer/src/main.rs @@ -107,8 +107,9 @@ fn work_strips() -> (i32, i32) { /// The dock style reserves nothing but floats over the bottom edge, so it gets a fixed gap while topbar runs. fn desk_top() -> i32 { work_strips().0 + ui::sc(8) } fn desk_bottom() -> i32 { - let reserved = work_strips().1; + let (top, reserved) = work_strips(); if reserved > 0 { return reserved + ui::sc(4); } + if top > 0 { return 0; } // a top bar leaves the bottom edge available for desktop icons let bar_up = unsafe { !FindWindowW(w("topbar").as_ptr(), ptr::null()).is_null() }; if bar_up && winrust_common::style::style() == winrust_common::style::Style::Dock { ui::sc(52) } else { ui::sc(8) } } @@ -422,6 +423,25 @@ fn desktop_scale() -> u32 { .filter(|v| [75, 85, 100, 125].contains(v)) .unwrap_or(if small_marker().exists() { 75 } else { 100 }) } +/// Fit one more usable row when the remaining desktop height is nearly a full icon cell. +fn desktop_row_spacing(height: i32, desired: i32) -> i32 { + if height <= 0 || desired <= 0 { return desired; } + let rows = (height + desired - 1) / desired; + let fitted = height / rows; + if fitted * 5 >= desired * 4 { fitted } else { desired } +} +fn set_desktop_spacing(list: HWND) -> bool { + let scale = desktop_scale() as i32; + let (cx, desired_cy) = ((88 * scale + 50) / 100, (96 * scale + 50) / 100); + let mut client: RECT = unsafe { std::mem::zeroed() }; + unsafe { GetClientRect(list, &mut client) }; + let height = if client.bottom > 0 { client.bottom } else { (unsafe { GetSystemMetrics(SM_CYSCREEN) }) - desk_top() - desk_bottom() }; + let cy = desktop_row_spacing(height, ui::sc(desired_cy)); + let want = ((cy as isize) << 16) | ui::sc(cx) as isize; + if put(list, LVM_GETITEMSPACING, 0, 0) == want { return false; } + put(list, LVM_SETICONSPACING, 0, want); + true +} thread_local! { static DESK_IL: std::cell::Cell = const { std::cell::Cell::new(0) }; static DESK_FONT: std::cell::Cell = const { std::cell::Cell::new(0) }; @@ -455,8 +475,7 @@ unsafe fn apply_icon_size(list: HWND) { DESK_ICON_MAP.with_borrow_mut(|map| map.clear()); put(list, LVM_SETIMAGELIST, LVSIL_NORMAL as usize, il as isize); if old != 0 { ImageList_Destroy(old as _); } - let (cx, cy) = ((88 * scale + 50) / 100, (96 * scale + 50) / 100); - put(list, LVM_SETICONSPACING, 0, ((ui::sc(cy) as isize) << 16) | ui::sc(cx) as isize); + set_desktop_spacing(list); let font = windows_sys::Win32::Graphics::Gdi::CreateFontW(-ui::sc((13 * scale + 50) / 100), 0, 0, 0, 400, 0, 0, 0, 1, 0, 0, 4, 0, w(ui::ui_face()).as_ptr()); put(list, WM_SETFONT, font as usize, 1); let old_font = DESK_FONT.replace(font as isize); @@ -1888,6 +1907,7 @@ unsafe extern "system" fn proc(h: HWND, m: u32, wp: WPARAM, lp: LPARAM) -> LRESU WM_TIMER if desk() && wp == 7 => { let list = ST.with_borrow(|st| st.list); place_desk_list(list); // catches a bar move even if the work-area broadcast was missed + if set_desktop_spacing(list) { reload(h); } desk::check_live(list); 0 } @@ -1984,6 +2004,34 @@ fn main() { #[cfg(test)] mod tests { + #[test] + fn desktop_grid_reaches_the_bottom_row() { + let cy = super::desktop_row_spacing(1038, 82); + assert_eq!(cy, 79); + assert_eq!(1038 / cy, 13); + assert_eq!(super::desktop_row_spacing(120, 96), 96); // do not squeeze short views excessively + } + + #[test] + fn desktop_icons_render_in_a_custom_size_list() { + unsafe { + let _ = super::InitCommonControlsEx(&super::INITCOMMONCONTROLSEX { + dwSize: std::mem::size_of::() as u32, + dwICC: super::ICC_LISTVIEW_CLASSES, + }); + let list = super::ImageList_Create(27, 27, super::ILC_COLOR32 | super::ILC_MASK, 1, 1); + assert_ne!(list, 0); + super::DESK_IL.set(list as isize); + let index = super::desktop_icon(0); + assert!(index >= 0); + let icon = super::ImageList_GetIcon(list, index, super::ILD_NORMAL as u32); + assert!(!icon.is_null()); + super::DestroyIcon(icon); + super::ImageList_Destroy(list); + super::DESK_IL.set(0); + } + } + #[test] fn desktop_follows_the_bars_current_edge() { use winrust_common::style::{Side, Style}; From 725454e1693ec577fa804647bd0cb7ac87412aee Mon Sep 17 00:00:00 2001 From: NasirAldeen Ishtaiah Date: Wed, 25 Nov 2026 14:39:58 +0200 Subject: [PATCH 6/6] Reclaim topbar work area after Explorer resets it --- plugins/topbar/src/main.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/plugins/topbar/src/main.rs b/plugins/topbar/src/main.rs index d4895f9..b670d69 100644 --- a/plugins/topbar/src/main.rs +++ b/plugins/topbar/src/main.rs @@ -244,6 +244,7 @@ thread_local! { static EXP_TRAY: Cell = const { Cell::new(null_mut()) }; // explorer's taskbar we registered with static APP_FG: Cell = const { Cell::new(null_mut()) }; // last foreground window that is not ours: the language button acts on it static LANG_TRY: Cell<(u32, usize, usize)> = const { Cell::new((0, 0, 0)) }; // (thread, layout before, layout asked for) of the last switch, checked by timer 7 + static BAR_WORK: Cell<(i32, i32, i32, i32)> = const { Cell::new((-1, -1, -1, -1)) }; // last work area reserved by place() } fn wide(s: &str) -> Vec { @@ -742,9 +743,9 @@ unsafe fn place(hwnd: HWND) { // No explorer (rs-shell / rust-explorer): nobody handles appbars, so set the work area ourselves. Without it maximized // windows slide under the bar and, covering the whole monitor, count as "fullscreen" and hide the bar. // Also with Explorer: it does not always honour the appbar when its own taskbar is hidden (#89). - { - set_work_area(if vert() { if ab.uEdge == ABE_LEFT { RECT { left: ab.rc.right, top: 0, right: cx, bottom: cy } } else { RECT { left: 0, top: 0, right: ab.rc.left, bottom: cy } } } else if at_top() { RECT { left: 0, top: ab.rc.bottom, right: cx, bottom: cy } } else { RECT { left: 0, top: 0, right: cx, bottom: ab.rc.top } }); - } + let work = if vert() { if ab.uEdge == ABE_LEFT { RECT { left: ab.rc.right, top: 0, right: cx, bottom: cy } } else { RECT { left: 0, top: 0, right: ab.rc.left, bottom: cy } } } else if at_top() { RECT { left: 0, top: ab.rc.bottom, right: cx, bottom: cy } } else { RECT { left: 0, top: 0, right: cx, bottom: ab.rc.top } }; + BAR_WORK.set((work.left, work.top, work.right, work.bottom)); + set_work_area(work); let (x, w) = bar_x_w(); // the dock is a pill; the other styles a plain strip SetWindowRgn(hwnd, if dock() { CreateRoundRectRgn(0, 0, w + 1, bar_h() + 1, bar_h(), bar_h()) } else { null_mut() }, 1); @@ -767,6 +768,15 @@ unsafe fn set_work_area(mut want: RECT) { } } +/// Explorer and display changes can reset the work area after the bar has already claimed its edge. +unsafe fn work_area_drifted() -> bool { + let want = BAR_WORK.get(); + if want.0 < 0 { return false; } + let mut current: RECT = zeroed(); + SystemParametersInfoW(SPI_GETWORKAREA, 0, &mut current as *mut _ as *mut _, 0) != 0 + && (current.left, current.top, current.right, current.bottom) != want +} + /// A window that was already maximized keeps its old height when the work area shrinks: trim it (size only, no restore). unsafe extern "system" fn fit_maximized(h: HWND, lp: isize) -> i32 { let want = &*(lp as *const RECT); @@ -2604,6 +2614,7 @@ unsafe extern "system" fn wndproc(hwnd: HWND, msg: u32, wp: WPARAM, lp: LPARAM) WM_DROPFILES => on_drop(hwnd, wp as HDROP), WM_TIMER => { hide_taskbar_if_shown(); + if work_area_drifted() { place(hwnd); } refresh(); // repaint (GDI+, the costly part) only when something shown changed; every 10th tick anyway as a safety net let (last, quiet) = SIG.get(); @@ -2668,6 +2679,9 @@ unsafe extern "system" fn wndproc(hwnd: HWND, msg: u32, wp: WPARAM, lp: LPARAM) } } WM_DISPLAYCHANGE => place(hwnd), + WM_SETTINGCHANGE if wp == SPI_SETWORKAREA as usize => { + if work_area_drifted() { place(hwnd); } + } WM_DESTROY => { let mut ab: APPBARDATA = zeroed(); ab.cbSize = size_of::() as u32;