A new style desktop shell for Windows 11: menu bar, Dock, Finder, Spotlight, Control Center and Liquid Glass, in native C++.
Rust
Support the Dock on all displays and improve App Exposé and snapping
Eternity070628d34febe4328b
diff --git a/src/ajustes/paginas.cpp b/src/ajustes/paginas.cppindex 8d2fc56..54510de 100644--- a/src/ajustes/paginas.cpp+++ b/src/ajustes/paginas.cpp@@ -1937,7 +1937,7 @@ Page MesaDock() {}, [](int i) { SetSetting(L"dock_posicao", i == 0 ? L"esquerda" : i == 2 ? L"direita" : L"baixo"); });// Monitor do Dock (dock_monitor = nome do monitor, ex. \\.\DISPLAY2; vazio = o principal). A barra de// menus fica em todos; o Dock só neste.- std::vector<std::wstring> monDev{ L"" }, monName{ L"Tela principal" };+ std::vector<std::wstring> monDev{ L"todos", L"principal" }, monName{ L"Todos os monitores", L"Tela principal" };{struct Ctx { std::vector<std::wstring>*dev, *name; } ctx{ &monDev, &monName };EnumDisplayMonitors(nullptr, nullptr, [](HMONITOR hm, HDC, LPRECT, LPARAM p) -> BOOL {@@ -1956,7 +1956,7 @@ Page MesaDock() {Row monRow = Popup(L"Monitor do Dock", monName,[monDev] { std::wstring v = Setting(L"dock_monitor", L""); for (int i = 0; i < (int)monDev.size(); i++) if (!_wcsicmp(v.c_str(), monDev[i].c_str())) return i; return 0; },[monDev](int i) { SetSetting(L"dock_monitor", monDev[std::clamp(i, 0, (int)monDev.size() - 1)]); });- monRow.enabled = monDev.size() > 1;+ monRow.enabled = monDev.size() > 2;// Inteligente: só esconde quando uma janela encosta no Dock (pedido de um usuário no Reddit)// issue #179: "Desligado" tira o Dock de vez (para usar outro, como o MyDockFinder), sem reservar espaçoRow hide = Popup(L"Ocultar o Dock", { L"Nunca", L"Automaticamente", L"Quando uma janela encostar nele", L"Desligado (nunca aparece)" },diff --git a/src/comum/idioma_en.inc b/src/comum/idioma_en.incindex 20c7459..0f6f8c0 100644--- a/src/comum/idioma_en.inc+++ b/src/comum/idioma_en.inc@@ -1029,6 +1029,7 @@{ L"Data de Adição", L"Date Added" },{ L"Leque", L"Fan" },{ L"Grade", L"Grid" },+{ L"Todos os monitores", L"All displays" },{ L"Preencher", L"Fill" },{ L"Parte de Cima", L"Top" },{ L"Parte de Baixo", L"Bottom" },diff --git a/src/comum/idioma_es.inc b/src/comum/idioma_es.incindex 16a3d59..2a9a8ed 100644--- a/src/comum/idioma_es.inc+++ b/src/comum/idioma_es.inc@@ -1017,6 +1017,7 @@{ L"Data de Adição", L"Fecha de añadido" },{ L"Leque", L"Abanico" },{ L"Grade", L"Cuadrícula" },+{ L"Todos os monitores", L"Todas las pantallas" },{ L"Preencher", L"Rellenar" },{ L"Parte de Cima", L"Parte superior" },{ L"Parte de Baixo", L"Parte inferior" },diff --git a/src/janelas/macjanela.cpp b/src/janelas/macjanela.cppindex f89fcfd..6832051 100644--- a/src/janelas/macjanela.cpp+++ b/src/janelas/macjanela.cpp@@ -2521,27 +2521,28 @@ LRESULT CALLBACK OwnerProc(HWND h, UINT m, WPARAM w, LPARAM l, UINT_PTR, DWORD_Preturn 1;}if (m == g_msgTile && g_msgTile) {- // o Shell encaixou a janela arrastada até a borda (encaixe.cpp). w = l = 0: preencher (o "ampliar");- // senão o retângulo visível pedido: l = esquerda/topo, w = direita/baixo (16 bits cada)+ // Retângulo visível pedido pelo Shell: l = esquerda/topo, w = direita/baixo (16 bits cada).RECT s = in->lastStart; // do arrasto que acabou agora (Win+←/→ não arrasta: o retângulo de agora)if (s.right <= s.left || GetTickCount() - in->lastStartAt > 3000) GetWindowRect(h, &s);- if (!w && !l) {- if (in->custom) { if (!IsZoomed(h)) ShowWindow(h, SW_MAXIMIZE); in->tiled = false; return 1; }- if (!in->zoomed) { in->before = s; ToggleZoom(in); in->before = s; }- in->tiled = false;- return 1;- }+ if (!w && !l) return 0;RECT t{ (short)LOWORD(l), (short)HIWORD(l), (short)LOWORD(w), (short)HIWORD(w) };- if (!in->tiled && !in->zoomed) in->before = s;+ if (!in->tiled && !in->zoomed) {+ if (IsZoomed(h)) {+ WINDOWPLACEMENT placement{ sizeof(placement) };+ if (GetWindowPlacement(h, &placement)) s = placement.rcNormalPosition;+ }+ in->before = s;+ }if (in->zoomed) { in->zoomed = false; RemovePropW(h, L"MacJanelaAmpliada"); }if (IsZoomed(h)) ShowWindow(h, SW_RESTORE);int il, it, ir, ib;Insets(in, il, it, ir, ib); // bordas invisíveis ficam para fora, como no ampliar- SetWindowPos(h, nullptr, t.left - il, t.top - it, (t.right - t.left) + il + ir, (t.bottom - t.top) + it + ib, SWP_NOZORDER | SWP_NOACTIVATE);+ if (!SetWindowPos(h, nullptr, t.left - il, t.top - it, (t.right - t.left) + il + ir,+ (t.bottom - t.top) + it + ib, SWP_NOZORDER | SWP_NOACTIVATE)) return 0;{ // tamanho mínimo maior que o quarto: nos cantos de baixo/direita a janela saía da tela (#205); sobe até caber- RECT now; GetWindowRect(h, &now);+ RECT now{};MONITORINFO mi{ sizeof(mi) };- if (GetMonitorInfoW(MonitorFromRect(&t, MONITOR_DEFAULTTONEAREST), &mi)) {+ if (GetWindowRect(h, &now) && GetMonitorInfoW(MonitorFromRect(&t, MONITOR_DEFAULTTONEAREST), &mi)) {LONG dx = 0, dy = 0;if (now.bottom - ib > t.bottom && t.bottom >= mi.rcWork.bottom) dy = t.bottom - (now.bottom - ib);if (now.right - ir > t.right && t.right >= mi.rcWork.right) dx = t.right - (now.right - ir);diff --git a/src/shell/apps.cpp b/src/shell/apps.cppindex 4de3fde..e9ce542 100644--- a/src/shell/apps.cpp+++ b/src/shell/apps.cpp@@ -9,6 +9,7 @@#include <memory>#include <thread>#include <shlobj.h>+#include <shlwapi.h>#include <shobjidl.h>#include <wincodec.h>#include <propkey.h>@@ -193,7 +194,7 @@ static std::wstring DisplayNameOf(const std::wstring& parsing) {}// Destino (.exe) e AUMID de um atalho.-static void ReadLink(const std::wstring& lnk, std::wstring& target, std::wstring& aumid) {+static void ReadLink(const std::wstring& lnk, std::wstring& target, std::wstring& aumid, std::wstring* icon = nullptr) {IShellLinkW* sl = nullptr;if (FAILED(CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&sl)))) return;IPersistFile* pf = nullptr;@@ -201,6 +202,8 @@ static void ReadLink(const std::wstring& lnk, std::wstring& target, std::wstringif (SUCCEEDED(pf->Load(lnk.c_str(), STGM_READ))) {wchar_t p[MAX_PATH] = {};if (SUCCEEDED(sl->GetPath(p, MAX_PATH, nullptr, 0))) target = p;+ int index = 0;+ if (icon && SUCCEEDED(sl->GetIconLocation(p, MAX_PATH, &index))) *icon = p;IPropertyStore* ps = nullptr;if (SUCCEEDED(sl->QueryInterface(IID_PPV_ARGS(&ps)))) {PROPVARIANT v; PropVariantInit(&v);@@ -277,18 +280,36 @@ static bool IsTaskbarWindow(HWND h) {bool apps::IsAppWindow(HWND h) { return IsTaskbarWindow(h); }+static bool ChromeExe(const std::wstring& exe) {+ return exe.ends_with(L"\\chrome.exe") && exe.find(L"\\google\\") != std::wstring::npos;+}++static std::wstring WindowProperty(HWND h, REFPROPERTYKEY key) {+ IPropertyStore* store = nullptr;+ if (!h || FAILED(SHGetPropertyStoreForWindow(h, IID_PPV_ARGS(&store)))) return {};+ PROPVARIANT value; PropVariantInit(&value);+ std::wstring result;+ if (SUCCEEDED(store->GetValue(key, &value)) && value.vt == VT_LPWSTR && value.pwszVal) result = value.pwszVal;+ PropVariantClear(&value);+ store->Release();+ return result;+}+App* apps::OfWindow(HWND h) {+ for (auto& a : list)+ for (const auto& w : a.wins)+ if (w.hwnd == h) return &a;std::wstring id = IdOfWindow(h);if (App* a = FindById(id)) return a;std::wstring exe = Lower(ExeOfWindow(h));- for (auto& a : list) if (!a.exe.empty() && a.exe == exe) return &a;+ if (!ChromeExe(exe)) for (auto& a : list) if (!a.exe.empty() && a.exe == exe) return &a;return nullptr;}void apps::Save() {// atômico (.tmp + troca): o Shell encerrado no meio da gravação deixava o dock.txt vazio e o Dock sem apps fixosstd::wstring s;- for (auto& a : list) if (a.pinned && !a.finder) s += a.id + L"\t" + a.launch + L"\t" + a.name + L"\t" + a.exe + L"\n";+ for (auto& a : list) if (a.pinned && !a.finder) s += a.id + L"\t" + a.launch + L"\t" + a.name + L"\t" + a.exe + (a.chromeIcon.empty() ? L"" : L"\t" + a.chromeIcon) + L"\n";ajarq::GravarTexto(DataDir() + L"\\dock.txt", s);}@@ -313,6 +334,7 @@ void apps::Load(const std::wstring& finderExe) {if (p.size() < 3) continue;if (p[0] == L"aumid:microsoft.windows.explorer") continue; // o Finder já está no DockApp x; x.id = p[0]; x.launch = p[1]; x.name = p[2]; x.exe = p.size() > 3 ? p[3] : L""; x.pinned = true;+ if (p.size() > 4 && ChromeExe(x.exe)) x.chromeIcon = p[4];if (std::wstring o = OurName(x.exe.empty() ? x.launch : x.exe); !o.empty()) x.name = o;list.push_back(x);}@@ -366,6 +388,32 @@ static bool ExeDeUmApp(const std::wstring& exeLower) {return um;}++static bool ChromeBrowser(const std::wstring& id, const std::wstring& exe) {+ return ChromeExe(exe) && id.find(L"._crx_") == std::wstring::npos && id.find(L"._app_") == std::wstring::npos;+}++std::wstring apps::ExposeId(const std::wstring& id, const std::wstring& exe) {+ return ChromeBrowser(id, exe) ? exe : id;+}++std::wstring apps::ExposeId(HWND h) {+ std::wstring id = IdOfWindow(h), exe = Lower(ExeOfWindow(h));+ if (ChromeBrowser(id, exe)) return exe;+ for (const auto& a : list)+ for (const auto& w : a.wins)+ if (w.hwnd == h) return a.id;+ return id;+}++static std::wstring ChromeWindowIcon(HWND h) {+ std::wstring icon = WindowProperty(h, PKEY_AppUserModel_RelaunchIconResource);+ if (icon.empty()) return {};+ PathParseIconLocationW(icon.data());+ icon.resize(wcslen(icon.c_str()));+ return Lower(icon).ends_with(L"\\google profile.ico") ? icon : L"";+}+bool apps::Refresh() {struct Ctx {std::map<std::wstring, std::vector<AppWin>> found; // id -> janelas (ordem Z)@@ -383,7 +431,8 @@ bool apps::Refresh() {for (auto& a : list) if (a.id == id && a.pinned) { idFixo = true; break; }if (!idFixo) for (auto& a : list)if (a.id != id && !a.exe.empty() && Lower(a.exe) == exe &&- (id.rfind(L"aumid:", 0) != 0 || a.id.rfind(L"aumid:", 0) != 0 || (a.pinned && ExeDeUmApp(exe)))) { id = a.id; break; }+ (ChromeExe(exe) ? a.pinned && a.id == exe && id == L"aumid:chrome" :+ (id.rfind(L"aumid:", 0) != 0 || a.id.rfind(L"aumid:", 0) != 0 || (a.pinned && ExeDeUmApp(exe))))) { id = a.id; break; }// app fixo que se atualizou enquanto o Shell rodava (o .exe novo está numa pasta de versão nova): é o mesmo// ícone do Dock, e o caminho guardado passa a ser o novoif (id.rfind(L"aumid:", 0) != 0 && exe.find_first_of(L"0123456789") != std::wstring::npos)@@ -423,12 +472,23 @@ bool apps::Refresh() {for (auto& a : list) before += a.id + L"|" + std::to_wstring(a.wins.size()) + (a.recent ? L"r" : L"") + L";";for (auto& a : list) for (auto& w : a.wins) if (w.minimized) before += L"m" + std::to_wstring((ULONG_PTR)w.hwnd);+ bool chromeIconChanged = false, saveProfiles = false;+ auto updateChromeIcon = [&](App& a) {+ if (a.wins.empty() || !a.chromeIcon.empty() || !ChromeBrowser(a.id, a.exe)) return;+ std::wstring icon = ChromeWindowIcon(a.wins.front().hwnd);+ if (!icon.empty() && icon != a.chromeIcon) {+ a.chromeIcon = std::move(icon);+ a.icon.clear();+ a.mac = false;+ chromeIconChanged = true;+ saveProfiles |= a.pinned;+ }+ };for (auto& a : list) {auto it = found.find(a.id);- bool was = !a.wins.empty();a.wins = it != found.end() ? it->second : std::vector<AppWin>{};if (!a.wins.empty()) { a.launchedAt = 0; a.recent = false; }- (void)was;+ updateChromeIcon(a);}for (auto& id : order) { // abertos que não estão no Dockif (FindById(id)) continue;@@ -436,6 +496,7 @@ bool apps::Refresh() {x.id = id;x.exe = exeOf[id];x.wins = found[id];+ updateChromeIcon(x);// o nome bonito (descrição do .exe, nome do pacote) vem de uma thread: o GetFileVersionInfo carrega o .exe do// disco e segurou a interface 8 s neste tique de 1 s (pilha de 22/11/2026 19:59, issue #32). Até chegar, o do arquivo.bool pacote = id.rfind(L"aumid:", 0) == 0;@@ -446,14 +507,23 @@ bool apps::Refresh() {if (arq.empty()) { arq = (pacote ? x.exe : x.launch); arq = arq.substr(arq.find_last_of(L'\\') + 1); if (arq.size() > 4) arq.resize(arq.size() - 4); }x.name = arq;}- std::thread([id, pacote, launch = x.launch, exe = x.exe, provisorio = x.name] {+ std::thread([id, pacote, launch = x.launch, exe = x.exe, provisorio = x.name, window = x.wins.front().hwnd] {HRESULT ci = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);- std::wstring n = pacote ? DisplayNameOf(launch) : ExeName(launch);+ std::wstring n;+ if (ChromeBrowser(id, exe)) {+ n = WindowProperty(window, PKEY_AppUserModel_RelaunchDisplayNameResource);+ if (n.starts_with(L"@")) {+ wchar_t display[512]{};+ if (SUCCEEDED(SHLoadIndirectString(n.c_str(), display, ARRAYSIZE(display), nullptr))) n = display;+ else n.clear();+ }+ }+ if (n.empty()) n = pacote ? DisplayNameOf(launch) : ExeName(launch);if (n.empty()) n = ExeName(exe);if (SUCCEEDED(ci)) CoUninitialize();if (n.empty() || n == provisorio) return;shell::NaInterface([id, n, provisorio] {- for (auto& a : apps::list) if (a.id == id && a.name == provisorio) { a.name = n; dock::Update(); break; }+ for (auto& a : apps::list) if (a.id == id && a.name == provisorio) { a.name = n; if (a.pinned) Save(); dock::Update(); break; }});}).detach();list.push_back(x);@@ -470,7 +540,9 @@ bool apps::Refresh() {std::wstring after;for (auto& a : list) after += a.id + L"|" + std::to_wstring(a.wins.size()) + (a.recent ? L"r" : L"") + L";";for (auto& a : list) for (auto& w : a.wins) if (w.minimized) after += L"m" + std::to_wstring((ULONG_PTR)w.hwnd); // minimizar/restaurar também conta- return before != after;+ if (saveProfiles) Save();+ if (chromeIconChanged) dock::IconsChanged(false);+ return chromeIconChanged || before != after;}// Ícone do pacote do Sequoia para o app: pelo nome, pelo .exe ou por um apelido conhecido.@@ -796,8 +868,28 @@ std::wstring apps::PackIconByName(const std::wstring& name, const std::wstring&return PackIconFor(a);}+static std::wstring ChromeProfileIcon(const App& a) {+ if (!ChromeBrowser(a.id, a.exe)) return {};+ if (!a.chromeIcon.empty()) return a.chromeIcon;+ if (Lower(a.launch).ends_with(L".lnk")) {+ std::wstring icon;+ std::wstring target, aumid;+ ReadLink(a.launch, target, aumid, &icon);+ if (Lower(icon).ends_with(L"\\google profile.ico")) return icon;+ }+ return {};+}+void apps::EnsureIcon(App& a, int px) {if (!a.icon.empty() && (a.mac || (int)std::max(a.iw, a.ih) >= px)) return;+ if (ChromeBrowser(a.id, a.exe) && CustomIcon(a.name, a.exe).empty()) {+ std::wstring icon = ChromeProfileIcon(a);+ if (!icon.empty() && (ui::LoadPng(icon, a.iw, a.ih, a.icon) || ui::ShellImage(icon, px, a.iw, a.ih, a.icon, false))) {+ a.mac = false;+ ui::TrimToSquare(a.iw, a.ih, a.icon);+ return;+ }+ }std::wstring png = PackIconFor(a);if (!png.empty() && ui::LoadPng(png, a.iw, a.ih, a.icon)) { a.mac = true; return; }if (a.finder) return;@@ -1106,6 +1198,20 @@ static void LaunchNow(App a, const std::wstring& args) {for (auto& x : apps::list) if (x.id == id0) { x.id = id; x.exe = exe; x.launch = launch; apps::Save(); break; }});}+ if (ChromeBrowser(a.id, a.exe) && !Lower(a.launch).ends_with(L".lnk") &&+ Lower(a.chromeIcon).ends_with(L"\\google profile.ico")) {+ size_t end = a.chromeIcon.find_last_of(L'\\'), start = a.chromeIcon.find_last_of(L'\\', end - 1);+ if (start != std::wstring::npos) {+ std::wstring profile = a.chromeIcon.substr(start + 1, end - start - 1);+ std::wstring folder = a.chromeIcon.substr(0, start);+ if (folder.find(L'"') == std::wstring::npos && profile.find(L'"') == std::wstring::npos) {+ std::wstring flags = L"--user-data-dir=\"" + folder + L"\" --profile-directory=\"" + profile + L"\"";+ if (!args.empty()) flags += L" " + args;+ if (apps::LaunchNoOcclusion(a.exe, flags, a.exe) ||+ (INT_PTR)ShellExecuteW(nullptr, L"open", a.exe.c_str(), flags.c_str(), nullptr, SW_SHOWNORMAL) > 32) return;+ }+ }+ }for (const std::wstring* c : { &a.launch, &a.exe }) {std::wstring aumid = PackagedAumid(*c);if (aumid.empty()) continue;@@ -1307,7 +1413,7 @@ bool apps::PinPath(const std::wstring& path, int at) {// já está no Dock (fixo ou aberto): só fixafor (auto& a : list) {if (a.finder) continue;- if (a.id == id || (!t.empty() && Lower(a.exe) == t)) { if (!a.pinned) SetPinned(a, true); return true; }+ if (a.id == id || (!t.empty() && !ChromeExe(t) && Lower(a.exe) == t)) { if (!a.pinned) SetPinned(a, true); return true; }}App x;x.id = id;diff --git a/src/shell/cantos.cpp b/src/shell/cantos.cppindex 3258e19..9be2243 100644--- a/src/shell/cantos.cpp+++ b/src/shell/cantos.cpp@@ -39,7 +39,7 @@ void Run(int c) {HWND fg = GetForegroundWindow();HWND root = fg ? GetAncestor(fg, GA_ROOTOWNER) : nullptr;apps::Refresh();- if (App* ap = root && !apps::IsShellWindow(root) ? apps::OfWindow(root) : nullptr) missioncontrol::ToggleApp(ap->id, ap->name);+ if (App* ap = root && !apps::IsShellWindow(root) ? apps::OfWindow(root) : nullptr) missioncontrol::ToggleApp(apps::ExposeId(ap->id, ap->exe), ap->name);}else if (a == L"mesa") mesa::WinKey('D');else if (a == L"launchpad") launchpad::Toggle();diff --git a/src/shell/dock.cpp b/src/shell/dock.cppindex 7f8ab94..ae4581c 100644--- a/src/shell/dock.cpp+++ b/src/shell/dock.cpp@@ -11,6 +11,8 @@#include <algorithm>#include <cmath>#include <map>+#include <memory>+#include <shellscalingapi.h>#include <mutex>#include <thread>#include "../comum/idioma.h"@@ -18,9 +20,8 @@namespace {enum ItemKind { I_APP, I_SEP, I_DOWNLOADS, I_TRASH, I_LAUNCHPAD, I_MINWIN, I_GHOST, I_FOLDER }; // I_FOLDER: pasta do usuário (issue #108)-struct Item { ItemKind kind; int app; float cx = 0, size = 0; HWND win = nullptr; bool leaving = false; int ghost = -1; int folder = -1; }; // ghost: app saindo (índice em g_ghosts) // win: janela minimizada (I_MINWIN); leaving: saindo do Dock // folder: índice em g_folders (I_FOLDER)+struct Item { ItemKind kind; int app; float cx = 0, size = 0; HWND win = nullptr; bool leaving = false; int ghost = -1; int folder = -1; }; // ghost: app saindo (índice em View().ghosts) // win: janela minimizada (I_MINWIN); leaving: saindo do Dock // folder: índice em g_folders (I_FOLDER)-float g_tile = 48; // tamanho do ícone (pt)// Personalização (Ajustes > Mesa e Dock > Personalizar o Dock, pedido de 20/11/2026, "como o MyDockFinder"). Valor// negativo = o padrão medido do Mac (as medidas de cada tema logo abaixo continuam valendo).float g_espaco = 0; // dock_espaco: espaço a mais entre os ícones (pt)@@ -38,16 +39,11 @@ bool g_mostraFinder = true;int g_indicador = 0; // dock_indicador: 0 ponto, 1 traçobool g_minNoIcone = false; // dock_minimizar_no_icone (issue #8): minimizada vai para o ícone do app, sem miniatura no Dockbool g_rotulos = true; // dock_rotulos: o nome do app ao passar o ponteiro-bool g_sepHover, g_resizing; // separador: arrastar para cima/baixo muda o tamanho (como no Mac)-LONG g_resizeY;-float g_resizeTile;float g_large = 128; // tamanho máximo na ampliaçãobool g_magnify = false;bool g_autohide = false;bool g_desligado = false; // ocultar=desligado (issue #179): o Dock nunca aparece e não reserva espaçobool g_smart = false; // ocultação inteligente: só esconde quando uma janela encosta no Dock-bool g_covered = false; // alguma janela por cima da área do Dock agora-DWORD g_coverAt = 0;// Proporções medidas no vídeo do Sequoia (ícone de 80 px): os ícones encostam uns nos outros// (o espaço é a margem do próprio desenho), o fundo é o ícone + ~9% embaixo (onde fica o ponto),// ~4% dos lados e fica a ~10% da borda da tela; o separador ocupa meio ícone.@@ -63,87 +59,125 @@ const DWORD ACR_DARK = 0x401E1C1C, ACR_LIGHT = 0x40F6F6F6; // AABBGGRR// Mac OS X Leopard: a Dock é uma prateleira de vidro em perspectiva encostada no pé da tela; os ícones ficam em pé// sobre ela, refletidos no tampo, e o app aberto ganha a luz azul na frente da prateleira (desenho em Paint)#define LEO_DOCK (liquid::Leopard())-#define PAD_TOP (g_tile * (TAHOE_DOCK ? 0.156f : LEO_DOCK ? 0.06f : 0.099f))-#define PAD_BOTTOM (g_tile * (TAHOE_DOCK ? 0.148f : LEO_DOCK ? 0.36f : 0.196f)) // Leopard: a frente ~0,32 ícone abaixo do pé (fotos de referência)+#define PAD_TOP (View().tile * (TAHOE_DOCK ? 0.156f : LEO_DOCK ? 0.06f : 0.099f))+#define PAD_BOTTOM (View().tile * (TAHOE_DOCK ? 0.148f : LEO_DOCK ? 0.36f : 0.196f)) // Leopard: a frente ~0,32 ícone abaixo do pé (fotos de referência)// Tahoe, guia macOS26-Theme-Reference (seção 36, medido com ícone de 64): cada ícone ocupa 68 × 84 (passo// 1,0625), 8 de margem antes do primeiro, separador de 31 (0,484); a altura reservada dá os 90 medidos-#define PAD_X (g_tile * (TAHOE_DOCK ? 0.125f : LEO_DOCK ? 0.55f : 0.041f))-#define MARGIN (g_margemPt >= 0 ? g_margemPt : g_tile * (LEO_DOCK ? 0.f : 0.10f)) // Leopard: a prateleira encosta no pé da tela-#define SEP_W (g_tile * (TAHOE_DOCK ? 0.484f : LEO_DOCK ? 0.80f : 0.40f)) // Leopard: o vão largo da faixa zebrada (~0,85 ícone na captura)+#define PAD_X (View().tile * (TAHOE_DOCK ? 0.125f : LEO_DOCK ? 0.55f : 0.041f))+#define MARGIN (g_margemPt >= 0 ? g_margemPt : View().tile * (LEO_DOCK ? 0.f : 0.10f)) // Leopard: a prateleira encosta no pé da tela+#define SEP_W (View().tile * (TAHOE_DOCK ? 0.484f : LEO_DOCK ? 0.80f : 0.40f)) // Leopard: o vão largo da faixa zebrada (~0,85 ícone na captura)// Leopard (comparado com as fotos de referência): passo de ~1,17 ícone entre os desenhos-#define SLOT (g_tile * (TAHOE_DOCK ? 1.0625f : LEO_DOCK ? 1.17f : 1.076f) + g_espaco) // Leopard: passo de ~1,17 ícone (medido nas fotos de referência do usuário)-#define DOCK_RADIUS (g_raioPct >= 0 ? (g_tile + PAD_TOP + PAD_BOTTOM) * 0.5f * g_raioPct : g_tile * (TAHOE_DOCK ? 0.40f : 0.28f)) // Tahoe: 0,5 A (medido); Sequoia: 0,3 A+#define SLOT (View().tile * (TAHOE_DOCK ? 1.0625f : LEO_DOCK ? 1.17f : 1.076f) + g_espaco) // Leopard: passo de ~1,17 ícone (medido nas fotos de referência do usuário)+#define DOCK_RADIUS (g_raioPct >= 0 ? (View().tile + PAD_TOP + PAD_BOTTOM) * 0.5f * g_raioPct : View().tile * (TAHOE_DOCK ? 0.40f : 0.28f)) // Tahoe: 0,5 A (medido); Sequoia: 0,3 Aconst float ART_PACK_0 = 1.0f; // PNGs do pacote: já têm a margem do Mac (desenho = 80%)const float ART_WIN_0 = 0.80f; // ícones do Windows (recortados): mesmo corpo visual// Leopard: o desenho do ícone ocupa o espaço inteiro (no 10.5 os ícones quase se encostam, sem a margem de hoje)#define ART_PACK (LEO_DOCK ? 1.25f : ART_PACK_0)#define ART_WIN (LEO_DOCK ? 1.0f : ART_WIN_0)-HWND g_back, g_icons, g_owner;+HWND g_owner;// Janelas minimizadas (como no Mac: miniatura da janela entre Downloads e a Lixeira, com o ícone do app// no canto). A miniatura é do DWM (o conteúdo de verdade); fica numa janela própria ENTRE o fundo e a dos// ícones, porque a miniatura do DWM é sempre desenhada por cima da janela onde está — assim o seletinho do// app (desenhado na janela dos ícones) fica por cima dela.-HWND g_thumbWnd;-std::vector<HWND> g_minOrder; // ordem em que foram minimizadas-std::map<HWND, HTHUMBNAIL> g_thumbs;// o espaço de uma minimizada abre e fecha aos poucos, como no Mac (antes o Dock pulava de tamanho no fim)const double SLOT_MS = 300;-std::map<HWND, double> g_appear; // quando entrou (abrindo o espaço)-std::map<HWND, std::pair<double, int>> g_leave; // saindo: quando começou e o app dela-float SlotFactor(const Item& it) {- double now = anim::Now();- if (it.leaving) { auto f = g_leave.find(it.win); return f == g_leave.end() ? 0.f : 1 - anim::Ease(std::min(1.f, (float)((now - f->second.first) / SLOT_MS))); }- auto f = g_appear.find(it.win);- return f == g_appear.end() ? 1.f : anim::Ease(std::min(1.f, (float)((now - f->second) / SLOT_MS)));-}// Apps entrando e saindo do Dock: o espaço abre/fecha aos poucos e o ícone cresce/encolhe junto (como no// Mac; antes os vizinhos pulavam de lugar). O que sai fica como "fantasma" até o espaço fechar.struct Ghost { std::wstring id; bool mac = false, finder = false; double t0 = 0; int pos = 0; };-std::vector<Ghost> g_ghosts;-std::map<std::wstring, double> g_appIn; // id -> quando entrou-std::vector<std::pair<std::wstring, bool>> g_prevApps; // ordem anterior (id, ícone do pacote)-bool g_builtOnce;// "puf" do Mac ao tirar um ícone do Dock: nuvenzinha que estoura e some-struct Poof { float x = 0, y = 0; double t0 = 0; } g_poof;+struct Poof { float x = 0, y = 0; double t0 = 0; };const double POOF_MS = 420;std::map<std::wstring, DWORD> g_nudge; // id -> pulo único (notificação nova)std::map<std::wstring, int> g_lastBadge;+struct DockView {+ HWND back{}, icons{};+ HMONITOR monitor{};+ IDropTarget* drop{};+ unsigned users{};+ Poof poof{};+ HWND thumbWnd{};+ std::vector<HWND> minOrder{};+ std::map<HWND, HTHUMBNAIL> thumbs{};+ std::vector<RECT> thumbRegion{};+ std::map<HWND, double> appear{};+ std::map<HWND, std::pair<double, int>> leave{};+ std::vector<Ghost> ghosts{};+ std::map<std::wstring, double> appIn{};+ std::vector<std::pair<std::wstring, bool>> prevApps{};+ bool builtOnce{};+ ui::Surface sb{};+ ui::GpuSurface gi{};+ RECT win{};+ D2D1_RECT_F lastBg{};+ std::vector<Item> items{};+ std::map<std::wstring, ID2D1Bitmap*> bmps{};+ ID2D1RenderTarget* bmpRt{};+ float mouseX = -1;+ float lastMouseX = -1;+ float magAmt = 0;+ double lastFrame{};+ int hover = -1;+ int press = -1;+ bool dragging = false;+ bool dragOut = false;+ int dragTo = -1;+ POINT pressPt{};+ float dragX = 0;+ bool glass = false;+ bool fullscreen = false;+ bool hidden = false;+ float reveal = 1;+ D2D1_RECT_F bg{};+ int dropHit = -1;+ float tile = 48;+ bool sepHover{};+ bool resizing{};+ LONG resizeY{};+ float resizeTile{};+ bool covered = false;+ DWORD coverAt = 0;+};+DockView g_primaryDock;+DockView* g_currentDock = &g_primaryDock;+std::map<HMONITOR, std::unique_ptr<DockView>> g_docks;+bool g_allMonitors = false;++DockView& View() { return *g_currentDock; }++struct UseDock {+ DockView* previous;+ explicit UseDock(DockView& d) : previous(g_currentDock) { g_currentDock = &d; ++d.users; }+ ~UseDock() { --g_currentDock->users; g_currentDock = previous; }+};++template<class F> void ForEachDock(F f) {+ { UseDock scope(g_primaryDock); f(); }+ for (auto& [monitor, view] : g_docks) { UseDock scope(*view); f(); }+}++float SlotFactor(const Item& it) {+ double now = anim::Now();+ if (it.leaving) { auto f = View().leave.find(it.win); return f == View().leave.end() ? 0.f : 1 - anim::Ease(std::min(1.f, (float)((now - f->second.first) / SLOT_MS))); }+ auto f = View().appear.find(it.win);+ return f == View().appear.end() ? 1.f : anim::Ease(std::min(1.f, (float)((now - f->second) / SLOT_MS)));+}+float AppFactor(const Item& it) {double now = anim::Now();if (it.kind == I_GHOST) {- if (it.ghost < 0 || it.ghost >= (int)g_ghosts.size()) return 0.f;- return 1 - anim::Ease(std::min(1.f, (float)((now - g_ghosts[it.ghost].t0) / SLOT_MS)));+ if (it.ghost < 0 || it.ghost >= (int)View().ghosts.size()) return 0.f;+ return 1 - anim::Ease(std::min(1.f, (float)((now - View().ghosts[it.ghost].t0) / SLOT_MS)));}if (it.kind != I_APP) return 1.f;- auto f = g_appIn.find(apps::list[it.app].id);- return f == g_appIn.end() ? 1.f : anim::Ease(std::min(1.f, (float)((now - f->second) / SLOT_MS)));+ auto f = View().appIn.find(apps::list[it.app].id);+ return f == View().appIn.end() ? 1.f : anim::Ease(std::min(1.f, (float)((now - f->second) / SLOT_MS)));}bool SlotSettled(const Item& it) { return !it.leaving && SlotFactor(it) >= 0.999f && !genio::Busy(it.win); }-ui::Surface g_sb;-ui::GpuSurface g_gi; // ícones: GPU (DirectComposition), quadros no ritmo do monitor-RECT g_win{}; // janela dos ícones dentro da faixa de baixo da tela (px)-D2D1_RECT_F g_lastBg{};const UINT WM_DOCKFRAME = WM_APP + 40;+const UINT_PTR TIMER_DISPLAYS = 7102;const UINT_PTR TIMER_HIDECHECK = 7101; // ocultação parada: olha o mouse e as janelas sem redesenhar-std::vector<Item> g_items;-std::map<std::wstring, ID2D1Bitmap*> g_bmps;-ID2D1RenderTarget* g_bmpRt;IDWriteTextFormat* g_tfLabel;-float g_mouseX = -1; // pt, na janela dos ícones; -1 = fora-float g_lastMouseX = -1; // última posição dentro (a ampliação encolhe dali ao sair)-float g_magAmt = 0; // quanto da ampliação está aplicado (0..1): entra e sai suave, como no Mac-double g_lastFrame; // ms de anim::Now do último quadro (animações por tempo, não por quadro)-int g_hover = -1, g_press = -1;-bool g_dragging = false, g_dragOut = false;-int g_dragTo = -1; // durante o arrasto: posição de destino em apps::list (-1: nenhuma)-POINT g_pressPt;-float g_dragX = 0;-bool g_glass = false; // vidro da Composição (backdrop.cpp) no fundo-bool g_fullscreen = false; // app em tela cheia na frente: Dock escondido-bool g_hidden = false; // ocultação automática: escondido agora-float g_reveal = 1; // 0 = escondido, 1 = à mostra (animação)-D2D1_RECT_F g_bg; // fundo atual (pt, coordenadas da janela dos ícones)bool g_trashFull = false;// Lixeira cheia ou vazia, numa thread: o SHQueryRecycleBin passa pela lixeira de todos os discos (HD externo@@ -171,10 +205,13 @@ void PedirLixeira() {});}).detach();}-int g_dropHit = -1;void LeftClick(int i);-float Sc() { return ui::Scale(g_icons); }+float Sc() {+ UINT x = 0, y = 0;+ if (View().monitor && SUCCEEDED(GetDpiForMonitor(View().monitor, MDT_EFFECTIVE_DPI, &x, &y)) && x) return x / 96.f;+ return ui::Scale(View().icons);+}// Posição na tela (Ajustes > Mesa e Dock > Posição na tela: dock_posicao=baixo|esquerda|direita). Todo o layout é feito// "ao longo do Dock": x corre pelos ícones e y vai de dentro da tela (0) até a borda onde o Dock encosta (WinH). Embaixo// isso é a própria janela; dos lados, a mesma conta girada (ToWin/ToLocal). Os ícones, os números e as etiquetas são@@ -189,6 +226,7 @@ float WinH() { return g_large + PAD_TOP + PAD_BOTTOM + MARGIN + (Vert() ? 280 :// vazio = o principal). Antes era o monitor onde a janela estava, e com dois monitores o Dock passava de um// para o outro. Guardado por 2 s: monitor ligado/desligado entra sozinho.HMONITOR DockMon() {+ if (View().monitor) return View().monitor;static std::wstring lastKey;static HMONITOR cached;static DWORD at;@@ -197,7 +235,7 @@ HMONITOR DockMon() {if (cached && want == lastKey && now - at < 2000) return cached;lastKey = want; at = now;struct Find { const std::wstring* name; HMONITOR found; } f{ &want, nullptr };- if (!want.empty())+ if (!want.empty() && want != L"todos" && want != L"principal")EnumDisplayMonitors(nullptr, nullptr, [](HMONITOR hm, HDC, LPRECT, LPARAM p) -> BOOL {auto* f = (Find*)p;MONITORINFOEXW mi{}; mi.cbSize = sizeof(mi);@@ -275,17 +313,17 @@ D2D1_POINT_2F ScreenToLocal(POINT p) {LONG Inward(POINT c) { return Pos() == 1 ? c.x : Pos() == 2 ? -c.x : -c.y; }// Muitos apps abertos: o Dock encolhe para caber na tela (como no Mac), em vez de passar da borda (e entrar-// no outro monitor). g_tileWant é o tamanho escolhido; g_tile, o usado agora.+// no outro monitor). g_tileWant é o tamanho escolhido; View().tile, o usado agora.float g_tileWant = 48;void FitTile() {- g_tile = g_tileWant;- float sc = ui::Scale(g_icons);+ View().tile = g_tileWant;+ float sc = ui::Scale(View().icons);if (sc <= 0) sc = 1;float W = AxisLen() - 16; // um respiro de cada lado- float units = 0; // largura em múltiplos de g_tile- for (auto& it : g_items) units += it.kind == I_SEP ? SEP_W / g_tile : SLOT / g_tile;- units += 2 * PAD_X / g_tile;- if (units > 0 && g_tile * units > W) g_tile = std::max(16.f, W / units);+ float units = 0; // largura em múltiplos de View().tile+ for (auto& it : View().items) units += it.kind == I_SEP ? SEP_W / View().tile : SLOT / View().tile;+ units += 2 * PAD_X / View().tile;+ if (units > 0 && View().tile * units > W) View().tile = std::max(16.f, W / units);}// ---- pastas do usuário no lado direito do Dock (issue #108): uma por linha em %APPDATA%\Shell\dock-pastas.txt@@ -350,66 +388,66 @@ std::wstring FolderIcon(const std::wstring& path) {return L"folder default";}-void BuildItems() {- g_items.clear();+void BuildViewItems() {+ View().items.clear();bool sep = false;for (int i = 0; i < (int)apps::list.size(); i++) {auto& a = apps::list[i];// sem divisória entre fixos e abertos: uma só, antes de Downloads e Lixeira- if (!(a.finder && !g_mostraFinder && a.wins.empty())) g_items.push_back({ I_APP, i });- if (a.finder && !LEO_DOCK && g_mostraLaunchpad) g_items.push_back({ I_LAUNCHPAD, -1 }); // como no Mac: Launchpad logo depois do Finder+ if (!(a.finder && !g_mostraFinder && a.wins.empty())) View().items.push_back({ I_APP, i });+ if (a.finder && !LEO_DOCK && g_mostraLaunchpad) View().items.push_back({ I_LAUNCHPAD, -1 }); // como no Mac: Launchpad logo depois do Finder}{ // quem entrou e quem saiu desde a última vezdouble now0 = anim::Now();std::vector<std::pair<std::wstring, bool>> cur;for (auto& a : apps::list) cur.push_back({ a.id, a.mac });- if (g_builtOnce && !g_dragging) {+ if (View().builtOnce && !View().dragging) {for (auto& [id, mac] : cur) {- bool was = false; for (auto& [pid, pm] : g_prevApps) if (pid == id) was = true;- if (!was) g_appIn[id] = now0;+ bool was = false; for (auto& [pid, pm] : View().prevApps) if (pid == id) was = true;+ if (!was) View().appIn[id] = now0;}- for (int k = 0; k < (int)g_prevApps.size(); k++) {- bool still = false; for (auto& [id, mac] : cur) if (id == g_prevApps[k].first) still = true;- bool ghosted = false; for (auto& gh : g_ghosts) if (gh.id == g_prevApps[k].first) ghosted = true;- if (!still && !ghosted) { Ghost gh; gh.id = g_prevApps[k].first; gh.mac = g_prevApps[k].second; gh.t0 = now0; gh.pos = k; g_ghosts.push_back(gh); }+ for (int k = 0; k < (int)View().prevApps.size(); k++) {+ bool still = false; for (auto& [id, mac] : cur) if (id == View().prevApps[k].first) still = true;+ bool ghosted = false; for (auto& gh : View().ghosts) if (gh.id == View().prevApps[k].first) ghosted = true;+ if (!still && !ghosted) { Ghost gh; gh.id = View().prevApps[k].first; gh.mac = View().prevApps[k].second; gh.t0 = now0; gh.pos = k; View().ghosts.push_back(gh); }}}- g_builtOnce = true;- g_prevApps = cur;- for (auto it = g_appIn.begin(); it != g_appIn.end();) it = now0 - it->second > SLOT_MS + 30 ? g_appIn.erase(it) : std::next(it);- g_ghosts.erase(std::remove_if(g_ghosts.begin(), g_ghosts.end(), [&](const Ghost& gh) { return now0 - gh.t0 > SLOT_MS + 30; }), g_ghosts.end());+ View().builtOnce = true;+ View().prevApps = cur;+ for (auto it = View().appIn.begin(); it != View().appIn.end();) it = now0 - it->second > SLOT_MS + 30 ? View().appIn.erase(it) : std::next(it);+ View().ghosts.erase(std::remove_if(View().ghosts.begin(), View().ghosts.end(), [&](const Ghost& gh) { return now0 - gh.t0 > SLOT_MS + 30; }), View().ghosts.end());// fantasmas no lugar onde estavam (entre os apps)- for (int gi = 0; gi < (int)g_ghosts.size(); gi++) {- int seen = 0; size_t at = g_items.size();- for (size_t k = 0; k < g_items.size(); k++) {- if (g_items[k].kind != I_APP) continue;- if (seen >= g_ghosts[gi].pos) { at = k; break; }+ for (int gi = 0; gi < (int)View().ghosts.size(); gi++) {+ int seen = 0; size_t at = View().items.size();+ for (size_t k = 0; k < View().items.size(); k++) {+ if (View().items[k].kind != I_APP) continue;+ if (seen >= View().ghosts[gi].pos) { at = k; break; }seen++;}Item gitem{ I_GHOST, -1 }; gitem.ghost = gi;- g_items.insert(g_items.begin() + at, gitem);+ View().items.insert(View().items.begin() + at, gitem);}}// issue #49: os apps abertos que não estão no Dock (e os recentes) ficam depois de uma divisória, como no Mac com// "Mostrar apps sugeridos e recentes": os fixos de um lado, os outros do outro. dock_separar_abertos=0 tira.if (g_separaAbertos && !LEO_DOCK) {bool temFixo = false;- for (size_t k = 0; k < g_items.size(); k++) {- if (g_items[k].kind != I_APP) continue;- const auto& a = apps::list[g_items[k].app];+ for (size_t k = 0; k < View().items.size(); k++) {+ if (View().items[k].kind != I_APP) continue;+ const auto& a = apps::list[View().items[k].app];if (a.pinned || a.finder) { temFixo = true; continue; }- if (temFixo) g_items.insert(g_items.begin() + k, Item{ I_SEP, -1 });+ if (temFixo) View().items.insert(View().items.begin() + k, Item{ I_SEP, -1 });break;}}- if (g_mostraSep || LEO_DOCK) g_items.push_back({ I_SEP, -1 });+ if (g_mostraSep || LEO_DOCK) View().items.push_back({ I_SEP, -1 });// Leopard: a pasta Aplicativos (que abre o Launchpad) fica à direita, depois da divisória, junto de Downloads e da// Lixeira, como as Pilhas do 10.5- if (LEO_DOCK) g_items.push_back({ I_LAUNCHPAD, -1 });+ if (LEO_DOCK) View().items.push_back({ I_LAUNCHPAD, -1 });// Ajustes > Mesa e Dock > "Mostrar a pasta Downloads no Dock" (dock_downloads=0 tira)- if (shell::Setting(L"dock_downloads", L"1") != L"0") g_items.push_back({ I_DOWNLOADS, -1 });+ if (shell::Setting(L"dock_downloads", L"1") != L"0") View().items.push_back({ I_DOWNLOADS, -1 });// as pastas do usuário (dock-pastas.txt), entre o Downloads e as minimizadas (issue #108)- for (int i = 0; i < (int)g_folders.size(); i++) { Item fi{ I_FOLDER, -1 }; fi.folder = i; g_items.push_back(fi); }+ for (int i = 0; i < (int)g_folders.size(); i++) { Item fi{ I_FOLDER, -1 }; fi.folder = i; View().items.push_back(fi); }// minimizadas: as que continuam minimizadas ficam na ordem; as novas entram no fimstd::vector<std::pair<HWND, int>> mins;for (int i = 0; i < (int)apps::list.size(); i++)@@ -418,33 +456,41 @@ void BuildItems() {double now = anim::Now();for (int i = 0; i < (int)apps::list.size(); i++) // restaurando pelo Dock: o espaço fecha aos poucosfor (auto& w : apps::list[i].wins)- if (genio::Phase(w.hwnd) == 2 && !g_leave.count(w.hwnd)) g_leave[w.hwnd] = { now, i };- for (auto it = g_leave.begin(); it != g_leave.end();) it = now - it->second.first > SLOT_MS + 30 ? g_leave.erase(it) : std::next(it);- for (auto& [mh, ai] : mins) if (!g_appear.count(mh)) g_appear[mh] = now;- for (auto it = g_appear.begin(); it != g_appear.end();) {+ if (genio::Phase(w.hwnd) == 2 && !View().leave.count(w.hwnd)) View().leave[w.hwnd] = { now, i };+ for (auto it = View().leave.begin(); it != View().leave.end();) it = now - it->second.first > SLOT_MS + 30 ? View().leave.erase(it) : std::next(it);+ for (auto& [mh, ai] : mins) if (!View().appear.count(mh)) View().appear[mh] = now;+ for (auto it = View().appear.begin(); it != View().appear.end();) {bool still = false; for (auto& [mh, ai] : mins) if (mh == it->first) still = true;- it = still ? std::next(it) : g_appear.erase(it);+ it = still ? std::next(it) : View().appear.erase(it);}auto inMins = [&](HWND h) { for (auto& [mh, ai] : mins) if (mh == h) return ai; return -1; };std::vector<HWND> keep;- for (HWND h : g_minOrder) if (inMins(h) >= 0 || g_leave.count(h)) keep.push_back(h);+ for (HWND h : View().minOrder) if (inMins(h) >= 0 || View().leave.count(h)) keep.push_back(h);for (auto& [mh, ai] : mins) if (std::find(keep.begin(), keep.end(), mh) == keep.end()) keep.push_back(mh);- g_minOrder = keep;- if (g_minNoIcone) g_minOrder.clear(); // no ícone do app: sem miniaturas (as que havia saem e soltam a miniatura do DWM)- for (HWND h : g_minOrder) {+ View().minOrder = keep;+ if (g_minNoIcone) View().minOrder.clear(); // no ícone do app: sem miniaturas (as que havia saem e soltam a miniatura do DWM)+ for (HWND h : View().minOrder) {int ai = inMins(h);- Item it{ I_MINWIN, ai >= 0 ? ai : g_leave[h].second }; it.win = h; it.leaving = ai < 0;- if (it.app >= 0 && it.app < (int)apps::list.size()) g_items.push_back(it);+ Item it{ I_MINWIN, ai >= 0 ? ai : View().leave[h].second }; it.win = h; it.leaving = ai < 0;+ if (it.app >= 0 && it.app < (int)apps::list.size()) View().items.push_back(it);}- for (auto it = g_thumbs.begin(); it != g_thumbs.end();) { // miniaturas de janelas que voltaram- if (std::find(g_minOrder.begin(), g_minOrder.end(), it->first) == g_minOrder.end()) { DwmUnregisterThumbnail(it->second); it = g_thumbs.erase(it); }+ for (auto it = View().thumbs.begin(); it != View().thumbs.end();) { // miniaturas de janelas que voltaram+ if (std::find(View().minOrder.begin(), View().minOrder.end(), it->first) == View().minOrder.end()) { DwmUnregisterThumbnail(it->second); it = View().thumbs.erase(it); }else ++it;}- g_items.push_back({ I_TRASH, -1 });+ View().items.push_back({ I_TRASH, -1 });PedirLixeira();FitTile();}+void BuildItems() {+ ForEachDock([] {+ if (!View().icons) return;+ BuildViewItems();+ InvalidateRect(View().icons, nullptr, FALSE);+ });+}+// Posições e tamanhos (com ampliação), centralizado na tela.void Layout() {float W = AxisLen(); // ao longo do Dock (dos lados, a altura abaixo da barra de menus)@@ -452,64 +498,64 @@ void Layout() {// largura base para achar os centros sem ampliaçãofloat base = PAD_X;std::vector<float> c0;- for (auto& it : g_items) { float w = it.kind == I_SEP ? SEP_W : slot; c0.push_back(base + w / 2); base += w; }+ for (auto& it : View().items) { float w = it.kind == I_SEP ? SEP_W : slot; c0.push_back(base + w / 2); base += w; }base += PAD_X;float left0 = (W - base) / 2;// Tahoe (guia, seção 63): curva cos² com alcance de ~3,5 ícones para cada lado (medido 85/82/74/65 com 64 de base)- float M = g_large / g_tile, R = TAHOE_DOCK ? 3.5f : 2.6f;+ float M = g_large / View().tile, R = TAHOE_DOCK ? 3.5f : 2.6f;std::vector<float> wv;float total = PAD_X * 2;- for (size_t i = 0; i < g_items.size(); i++) {+ for (size_t i = 0; i < View().items.size(); i++) {float s = 1;- float mx = g_mouseX >= 0 ? g_mouseX : g_lastMouseX;- if (g_magnify && mx >= 0 && g_magAmt > 0.001f && g_items[i].kind != I_SEP && !g_dragging) {+ float mx = View().mouseX >= 0 ? View().mouseX : View().lastMouseX;+ if (g_magnify && mx >= 0 && View().magAmt > 0.001f && View().items[i].kind != I_SEP && !View().dragging) {float d = std::fabs(mx - (left0 + c0[i])) / slot;- if (d < R) { float k = std::cos(d / R * 3.14159f / 2); s = 1 + (M - 1) * k * k * g_magAmt; }+ if (d < R) { float k = std::cos(d / R * 3.14159f / 2); s = 1 + (M - 1) * k * k * View().magAmt; }}float sepS = 1; // Tahoe (guia, seção 63): o separador também cresce perto do ponteiro (31 → 40 com 64)- if (TAHOE_DOCK && g_magnify && mx >= 0 && g_magAmt > 0.001f && g_items[i].kind == I_SEP && !g_dragging) {+ if (TAHOE_DOCK && g_magnify && mx >= 0 && View().magAmt > 0.001f && View().items[i].kind == I_SEP && !View().dragging) {float d = std::fabs(mx - (left0 + c0[i])) / slot;- if (d < R) { float k = std::cos(d / R * 3.14159f / 2); sepS = 1 + (40.f / 31.f - 1) * k * k * g_magAmt; }+ if (d < R) { float k = std::cos(d / R * 3.14159f / 2); sepS = 1 + (40.f / 31.f - 1) * k * k * View().magAmt; }}- g_items[i].size = g_items[i].kind == I_SEP ? 0 : g_tile * s;- wv.push_back(g_items[i].kind == I_SEP ? SEP_W * sepS : slot * s * (g_items[i].kind == I_MINWIN ? SlotFactor(g_items[i]) : AppFactor(g_items[i])));+ View().items[i].size = View().items[i].kind == I_SEP ? 0 : View().tile * s;+ wv.push_back(View().items[i].kind == I_SEP ? SEP_W * sepS : slot * s * (View().items[i].kind == I_MINWIN ? SlotFactor(View().items[i]) : AppFactor(View().items[i])));total += wv.back();}// Arrastando um app fixo: os outros abrem espaço ao vivo onde ele cairia (como no Mac); arrastado- // para fora do Dock, o lugar dele fecha. g_dragTo guarda a posição de destino (índice em apps::list).+ // para fora do Dock, o lugar dele fecha. View().dragTo guarda a posição de destino (índice em apps::list).std::vector<int> order;- for (int i = 0; i < (int)g_items.size(); i++) order.push_back(i);+ for (int i = 0; i < (int)View().items.size(); i++) order.push_back(i);// App aberto ou recente (depois da divisória) também: levado para cima dos fixos, abre o espaço e, solto ali, fica// fixo nesse lugar (como no Mac). Longe dos fixos ele fica onde está.- int drag = g_dragging && g_press >= 0 && g_press < (int)g_items.size() && g_items[g_press].kind == I_APP && !apps::list[g_items[g_press].app].finder ? g_press : -1;- bool dragFixo = drag >= 0 && apps::list[g_items[drag].app].pinned;- g_dragTo = -1;+ int drag = View().dragging && View().press >= 0 && View().press < (int)View().items.size() && View().items[View().press].kind == I_APP && !apps::list[View().items[View().press].app].finder ? View().press : -1;+ bool dragFixo = drag >= 0 && apps::list[View().items[drag].app].pinned;+ View().dragTo = -1;if (drag >= 0) {order.erase(std::find(order.begin(), order.end(), drag));total -= wv[drag];bool longe = false; // não fixo e o ponteiro fora da área dos fixos: sem espaço aberto- if (!dragFixo && !g_dragOut) {+ if (!dragFixo && !View().dragOut) {float xx = (W - total - wv[drag]) / 2 + PAD_X, fimFixos = -1;for (int k = 0; k < (int)order.size(); k++) {- auto& it = g_items[order[k]];+ auto& it = View().items[order[k]];xx += wv[order[k]];if (it.kind == I_APP && (apps::list[it.app].pinned || apps::list[it.app].finder)) fimFixos = xx;}- longe = fimFixos < 0 || g_mouseX > fimFixos + wv[drag] * 0.5f;+ longe = fimFixos < 0 || View().mouseX > fimFixos + wv[drag] * 0.5f;}- if (longe || (g_dragOut && !dragFixo)) {+ if (longe || (View().dragOut && !dragFixo)) {order.insert(order.begin() + std::min(drag, (int)order.size()), drag);total += wv[drag];- } else if (!g_dragOut) {+ } else if (!View().dragOut) {// centros sem o arrastado; o lugar novo fica entre os fixos, depois do Finder e do Launchpadfloat xx = (W - total - wv[drag]) / 2 + PAD_X;int pos = -1, firstPinned = -1, lastPinned = -1;for (int k = 0; k < (int)order.size(); k++) {- auto& it = g_items[order[k]];+ auto& it = View().items[order[k]];bool pinned = it.kind == I_APP && apps::list[it.app].pinned && !apps::list[it.app].finder;if (pinned) { if (firstPinned < 0) firstPinned = k; lastPinned = k; }float c = xx + wv[order[k]] / 2;- if (pos < 0 && pinned && g_mouseX < c) pos = k;+ if (pos < 0 && pinned && View().mouseX < c) pos = k;xx += wv[order[k]];}if (firstPinned < 0) firstPinned = lastPinned = (int)order.size() - 1;@@ -517,29 +563,29 @@ void Layout() {pos = std::clamp(pos, firstPinned, lastPinned + 1);order.insert(order.begin() + pos, drag);total += wv[drag];- int from = g_items[drag].app;- if (pos > firstPinned) { int prev = g_items[order[pos - 1]].app; g_dragTo = prev + (prev < from ? 1 : 0); }- else if (pos + 1 < (int)order.size() && g_items[order[pos + 1]].kind == I_APP) g_dragTo = g_items[order[pos + 1]].app - (g_items[order[pos + 1]].app > from ? 1 : 0);- else g_dragTo = from;+ int from = View().items[drag].app;+ if (pos > firstPinned) { int prev = View().items[order[pos - 1]].app; View().dragTo = prev + (prev < from ? 1 : 0); }+ else if (pos + 1 < (int)order.size() && View().items[order[pos + 1]].kind == I_APP) View().dragTo = View().items[order[pos + 1]].app - (View().items[order[pos + 1]].app > from ? 1 : 0);+ else View().dragTo = from;}}float x = (W - total) / 2 + PAD_X;for (int i : order) {float target = x + wv[i] / 2;// desliza até o lugar novo em vez de pular (só durante o arrasto; o relógio de quadros está ligado)- g_items[i].cx = g_dragging && g_items[i].cx > 0 ? g_items[i].cx + (target - g_items[i].cx) * 0.35f : target;+ View().items[i].cx = View().dragging && View().items[i].cx > 0 ? View().items[i].cx + (target - View().items[i].cx) * 0.35f : target;x += wv[i];}- if (drag >= 0 && g_dragOut) g_items[drag].cx = -1000;+ if (drag >= 0 && View().dragOut) View().items[drag].cx = -1000;float H = WinH();- float hide = (1 - anim::EaseInOut(g_reveal)) * (g_tile + PAD_TOP + PAD_BOTTOM + MARGIN + 2); // ocultar/mostrar com a curva do Mac+ float hide = (1 - anim::EaseInOut(View().reveal)) * (View().tile + PAD_TOP + PAD_BOTTOM + MARGIN + 2); // ocultar/mostrar com a curva do Macfloat bottom = H - MARGIN + hide;- g_bg = D2D1::RectF((W - total) / 2, bottom - (g_tile + PAD_TOP + PAD_BOTTOM), (W + total) / 2, bottom);+ View().bg = D2D1::RectF((W - total) / 2, bottom - (View().tile + PAD_TOP + PAD_BOTTOM), (W + total) / 2, bottom);}// Ícone do pacote do Sequoia por nome (Downloads, Lixeira), em cache por render target.ID2D1Bitmap* PackBitmap(ID2D1RenderTarget* rt, const std::wstring& name) {- if (g_bmpRt != rt) { for (auto& [k, b] : g_bmps) if (b) b->Release(); g_bmps.clear(); g_bmpRt = rt; }+ if (View().bmpRt != rt) { for (auto& [k, b] : View().bmps) if (b) b->Release(); View().bmps.clear(); View().bmpRt = rt; }// Tahoe: estilo dos ícones na chave — só para apps (o Launchpad/Apps); a pasta Downloads e a Lixeira ficam como são// (como no macOS 26, o estilo Transparente/Tingido não muda as pastas nem a Lixeira do Dock)bool keep = name.rfind(L"folder", 0) == 0 || name.rfind(L"trash", 0) == 0;@@ -547,8 +593,8 @@ ID2D1Bitmap* PackBitmap(ID2D1RenderTarget* rt, const std::wstring& name) {// os papéis da Lixeira ficam cinza): só tons de cinza, sem virar peça de vidrobool gray = keep && ui::IconStyle() == L"transparente" && ui::Dark();std::wstring st = keep ? L"padrao" : ui::IconStyle(), key = L"pack:" + (keep ? st + (gray ? L"/cinza" : L"") : ui::IconStyleKey()) + L":" + name;- auto it = g_bmps.find(key);- if (it != g_bmps.end()) return it->second;+ auto it = View().bmps.find(key);+ if (it != View().bmps.end()) return it->second;UINT w = 0, h = 0; std::vector<BYTE> px;std::wstring path = ui::PackIcon(name);bool ok = !path.empty() && ui::LoadPng(path, w, h, px);@@ -559,7 +605,7 @@ ID2D1Bitmap* PackBitmap(ID2D1RenderTarget* rt, const std::wstring& name) {px[i] = px[i + 1] = px[i + 2] = std::min(l, px[i + 3]);}ID2D1Bitmap* b = ok ? ui::Bitmap(rt, w, h, px) : nullptr;- g_bmps[key] = b;+ View().bmps[key] = b;return b;}@@ -584,7 +630,7 @@ void RefreshStack(int px) {if (paths == g_stackPaths) return;g_stackPaths = paths;g_stackBusy = true;- HWND w = g_icons;+ HWND w = View().icons;std::thread([paths, px, w] {HRESULT co = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);std::vector<StackImg> v;@@ -734,6 +780,34 @@ void MenusPorCima() {SetWindowPos(*it, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);}+void RaiseLayers() {+ for (HWND window : { View().back, View().thumbWnd, View().icons })+ if (window) SetWindowPos(window, HWND_TOPMOST, 0, 0, 0, 0,+ SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOOWNERZORDER);+ MenusPorCima();+}++void KeepMagnifiedOnTop() {+ if (!g_magnify || View().mouseX < 0 || View().fullscreen || IsRectEmpty(&View().win)) return;+ RECT strip{};+ if (!GetWindowRect(View().icons, &strip)) return;+ RECT area = View().win;+ OffsetRect(&area, strip.left, strip.top);+ for (HWND w = GetWindow(View().icons, GW_HWNDPREV); w; w = GetWindow(w, GW_HWNDPREV)) {+ if (shell::Nossa(w) || !IsWindowVisible(w) || !(GetWindowLongPtrW(w, GWL_EXSTYLE) & WS_EX_TOPMOST)) continue;+ DWORD cloak = 0;+ DwmGetWindowAttribute(w, DWMWA_CLOAKED, &cloak, sizeof(cloak));+ RECT frame{}, hit{};+ if (cloak || !GetWindowRect(w, &frame) || !IntersectRect(&hit, &area, &frame)) continue;+ wchar_t cls[32]{};+ GetClassNameW(w, cls, ARRAYSIZE(cls));+ if (wcscmp(cls, L"#32768") && wcscmp(cls, L"tooltips_class32")) {+ RaiseLayers();+ return;+ }+ }+}+// Ícone próprio do usuário (Ajustes > Personalizar o Dock > Ícones próprios): um PNG em %APPDATA%\Shell\icones-dock com o// nome do .exe (chrome.png, discord.png) ou o nome do app como aparece no Dock (Google Chrome.png). Vale como os do// pacote do Mac (o desenho já tem a margem). Vazio = sem ícone próprio.@@ -746,9 +820,9 @@ std::map<std::wstring, bool> g_customIcon; // app -> tem ícone próprio (desen// O ícone próprio do Launchpad no Dock (pedido no Discord, 24/11/2026): Launchpad.png na pasta dos ícones próprios,// escolhido pelo botão direito > Alterar Ícone…; nullptr = o do pacoteID2D1Bitmap* LaunchpadProprio(ID2D1RenderTarget* rt) {- if (g_bmpRt != rt) { for (auto& [k, b] : g_bmps) if (b) b->Release(); g_bmps.clear(); g_bmpRt = rt; }- auto ck = g_bmps.find(L"proprio:launchpad");- if (ck != g_bmps.end()) return ck->second;+ if (View().bmpRt != rt) { for (auto& [k, b] : View().bmps) if (b) b->Release(); View().bmps.clear(); View().bmpRt = rt; }+ auto ck = View().bmps.find(L"proprio:launchpad");+ if (ck != View().bmps.end()) return ck->second;auto known = g_customIcon.find(L"launchpad:");if (known != g_customIcon.end() && !known->second) return nullptr;std::wstring f = apps::CustomIcon(L"Launchpad", L"");@@ -759,15 +833,15 @@ ID2D1Bitmap* LaunchpadProprio(ID2D1RenderTarget* rt) {std::wstring st = ui::IconStyle();if (st != L"padrao") ui::StyleIcon(w, h, px, st);ID2D1Bitmap* b = ui::Bitmap(rt, w, h, px);- g_bmps[L"proprio:launchpad"] = b;+ View().bmps[L"proprio:launchpad"] = b;return b;}ID2D1Bitmap* IconBitmap(ID2D1RenderTarget* rt, App& a) {- if (g_bmpRt != rt) { for (auto& [k, b] : g_bmps) if (b) b->Release(); g_bmps.clear(); g_bmpRt = rt; }+ if (View().bmpRt != rt) { for (auto& [k, b] : View().bmps) if (b) b->Release(); View().bmps.clear(); View().bmpRt = rt; }{- auto ck = g_bmps.find(L"proprio:" + a.id);- if (ck != g_bmps.end()) return ck->second;+ auto ck = View().bmps.find(L"proprio:" + a.id);+ if (ck != View().bmps.end()) return ck->second;auto known = g_customIcon.find(a.id);if (known == g_customIcon.end() || known->second) {std::wstring f = CustomIconPath(a);@@ -778,7 +852,7 @@ ID2D1Bitmap* IconBitmap(ID2D1RenderTarget* rt, App& a) {std::wstring st = ui::IconStyle();if (st != L"padrao") ui::StyleIcon(w, h, px, st);ID2D1Bitmap* b = ui::Bitmap(rt, w, h, px);- g_bmps[L"proprio:" + a.id] = b;+ View().bmps[L"proprio:" + a.id] = b;if (b) return b;}}@@ -789,14 +863,14 @@ ID2D1Bitmap* IconBitmap(ID2D1RenderTarget* rt, App& a) {if (a.icon.empty()) apps::EnsureIcon(a, (int)std::lround(std::min(256.f, g_large * Sc()))); // só a 1ª vez (ícone do Windows pequeno releria a cada quadro)bool jail = TAHOE_DOCK && !a.mac && !a.finder && shell::Setting(L"dock_icones_cinza", L"1") == L"1";std::wstring st = ui::IconStyle(), key = ui::IconStyleKey() + (jail ? L"|j:" : L":") + a.id; // Tahoe: estilo dos ícones (Escuro, Transparente, Tingido)- auto it = g_bmps.find(key);- if (it != g_bmps.end()) return it->second;+ auto it = View().bmps.find(key);+ if (it != View().bmps.end()) return it->second;ID2D1Bitmap* b = nullptr;std::vector<BYTE> base = a.icon;if (jail && !IsTileShaped(a.iw, a.ih, base)) base = Jail(a.iw, a.ih, base, st == L"escuro");if (st == L"padrao") b = ui::Bitmap(rt, a.iw, a.ih, base);else { ui::StyleIcon(a.iw, a.ih, base, st); b = ui::Bitmap(rt, a.iw, a.ih, base); }- g_bmps[key] = b;+ View().bmps[key] = b;return b;}@@ -805,18 +879,18 @@ float BounceOffset(const App& a) {double now = anim::Tick();auto hop = [](double ms, float period) { float u = (float)std::fmod(ms / period, 1.0); return 4 * u * (1 - u); };if (a.launchedAt && now - a.launchedAt < 8000 && shell::Setting(L"animar_abertura", L"1") == L"1")- return -hop(now - a.launchedAt, 620) * g_tile * 0.5f;+ return -hop(now - a.launchedAt, 620) * View().tile * 0.5f;if (a.attentionAt && now - a.attentionAt < 1860) // pedindo atenção: três pulos mais altos- return -hop(now - a.attentionAt, 620) * g_tile * 0.65f;+ return -hop(now - a.attentionAt, 620) * View().tile * 0.65f;auto n = g_nudge.find(a.id); // notificação nova: um pulo só- if (n != g_nudge.end() && now - n->second < 620) return -hop(now - n->second, 620) * g_tile * 0.45f;+ if (n != g_nudge.end() && now - n->second < 620) return -hop(now - n->second, 620) * View().tile * 0.45f;return 0;}// Ocultação inteligente: a janela em foco (ou um diálogo dela) cobre a área do Dock à mostra?// Como a "ocultação inteligente" dos docks do Windows: janela maximizada ou arrastada até embaixo esconde o Dock.bool WindowOverDock() {- RECT dk = ToScreenRect({ g_bg.left, WinH() - (g_tile + PAD_TOP + PAD_BOTTOM + MARGIN), g_bg.right, WinH() });+ RECT dk = ToScreenRect({ View().bg.left, WinH() - (View().tile + PAD_TOP + PAD_BOTTOM + MARGIN), View().bg.right, WinH() });if (dk.right <= dk.left) return false;// só o app em foco conta (issue #38: "só a que tem o foco"): a janela da frente e as janelas do mesmo dono (os// diálogos dela). Uma janela de trás encostando no Dock não o esconde mais; a mesa ou o WacOS na frente o mostram.@@ -869,19 +943,19 @@ bool WantHidden() {// distância do ponteiro até a borda do Dock (embaixo, a de baixo; dos lados, a esquerda ou a direita)bool along = Vert() ? c.y >= mon.top && c.y < mon.bottom : c.x >= mon.left && c.x < mon.right;LONG dist = Pos() == 1 ? c.x - mon.left : Pos() == 2 ? mon.right - 1 - c.x : mon.bottom - 1 - c.y;- bool nearEdge = along && dist >= 0 && (dist <= 1 || (g_reveal > 0.5f && dist < (LONG)((g_bg.bottom - g_bg.top + 30) * sc)));- if (g_smart && GetTickCount() - g_coverAt >= 100) { g_coverAt = GetTickCount(); g_covered = WindowOverDock(); }- return (!g_smart || g_covered) && !nearEdge && g_press < 0;+ bool nearEdge = along && dist >= 0 && (dist <= 1 || (View().reveal > 0.5f && dist < (LONG)((View().bg.bottom - View().bg.top + 30) * sc)));+ if (g_smart && GetTickCount() - View().coverAt >= 100) { View().coverAt = GetTickCount(); View().covered = WindowOverDock(); }+ return (!g_smart || View().covered) && !nearEdge && View().press < 0;}bool Animating() {for (auto& a : apps::list) if ((a.launchedAt && GetTickCount() - a.launchedAt < 8000) || (a.attentionAt && GetTickCount() - a.attentionAt < 1800)) return true;for (auto& [id, t] : g_nudge) if (GetTickCount() - t < 640) return true;- { double nw = anim::Now(); for (auto& gh : g_ghosts) if (nw - gh.t0 < SLOT_MS + 20) return true; for (auto& [id, t] : g_appIn) if (nw - t < SLOT_MS + 20) return true; }- if ((g_poof.t0 > 0 && anim::Now() - g_poof.t0 < POOF_MS)) return true;- if (g_magnify && ((g_mouseX >= 0 && g_magAmt < 0.999f) || (g_mouseX < 0 && g_magAmt > 0.001f))) return true; // ampliação entrando/saindo- for (auto& it : g_items) if (it.kind == I_MINWIN && (it.leaving || SlotFactor(it) < 0.999f || genio::Busy(it.win))) return true;- return g_dragging || (g_autohide && ((g_hidden && g_reveal > 0) || (!g_hidden && g_reveal < 1)));+ { double nw = anim::Now(); for (auto& gh : View().ghosts) if (nw - gh.t0 < SLOT_MS + 20) return true; for (auto& [id, t] : View().appIn) if (nw - t < SLOT_MS + 20) return true; }+ if ((View().poof.t0 > 0 && anim::Now() - View().poof.t0 < POOF_MS)) return true;+ if (g_magnify && ((View().mouseX >= 0 && View().magAmt < 0.999f) || (View().mouseX < 0 && View().magAmt > 0.001f))) return true; // ampliação entrando/saindo+ for (auto& it : View().items) if (it.kind == I_MINWIN && (it.leaving || SlotFactor(it) < 0.999f || genio::Busy(it.win))) return true;+ return View().dragging || (g_autohide && ((View().hidden && View().reveal > 0) || (!View().hidden && View().reveal < 1)));}std::wstring Label(const Item& it) {@@ -898,15 +972,15 @@ std::wstring Label(const Item& it) {void PaintBack() {float sc = Sc();- RECT bgs = ToScreenRect(g_bg); // dos lados o fundo fica em pé (mais alto que largo)+ RECT bgs = ToScreenRect(View().bg); // dos lados o fundo fica em pé (mais alto que largo)int x = bgs.left, y = bgs.top, w = bgs.right - bgs.left, h = bgs.bottom - bgs.top;- if (g_reveal <= 0.01f || LEO_DOCK) { ShowWindow(g_back, SW_HIDE); g_lastBg = {}; return; } // Leopard: sem vidro atrás (a prateleira é desenhada com os ícones)- if (!memcmp(&g_bg, &g_lastBg, sizeof(g_bg)) && IsWindowVisible(g_back)) return; // nada mudou- g_lastBg = g_bg;+ if (View().reveal <= 0.01f || LEO_DOCK) { ShowWindow(View().back, SW_HIDE); View().lastBg = {}; return; } // Leopard: sem vidro atrás (a prateleira é desenhada com os ícones)+ if (!memcmp(&View().bg, &View().lastBg, sizeof(View().bg)) && IsWindowVisible(View().back)) return; // nada mudou+ View().lastBg = View().bg;float rad = DOCK_RADIUS;bool dark = ui::Dark();- if (g_glass) { // vidro da Composição: recorte com a mesma curva do Dock- SetWindowPos(g_back, g_thumbWnd ? g_thumbWnd : g_icons, x, y, w, h, SWP_NOACTIVATE | SWP_SHOWWINDOW);+ if (View().glass) { // vidro da Composição: recorte com a mesma curva do Dock+ SetWindowPos(View().back, View().thumbWnd ? View().thumbWnd : View().icons, x, y, w, h, SWP_NOACTIVATE | SWP_SHOWWINDOW);D2D1_COLOR_F tint = dark ? D2D1::ColorF(0.13f, 0.14f, 0.15f, 0.50f) : D2D1::ColorF(0.98f, 0.98f, 0.99f, 0.38f);// Tahoe: cor do vidro medida na tela (guia macOS26-Theme-Reference, seções 52 e 60): saída ≈ 0,61 × fundo + 0,11// no escuro (39 % de um cinza 0,28 por cima do fundo desfocado); no claro a média sobe ~0,11 (cinza 0,56)@@ -917,14 +991,14 @@ void PaintBack() {else if (g_vidroCor == 2) tint = D2D1::ColorF(0.10f, 0.10f, 0.11f, tint.a);else if (g_vidroCor == 3) { D2D1_COLOR_F ac = ui::Accent(); tint = D2D1::ColorF(ac.r, ac.g, ac.b, tint.a); }if (g_vidroOpac >= 0) tint.a = g_vidroOpac;- backdrop::Set(g_back, (float)w, (float)h, rad * sc, tint);+ backdrop::Set(View().back, (float)w, (float)h, rad * sc, tint);return;}// Sem a Composição: acrílico com o canto de 8 do DWM, encolhido para caber dentro da curva.int in = rad > 8 ? (int)std::ceil((rad - 8) * sc * 0.293f) + 1 : 0;x += in; y += in; w -= 2 * in; h -= 2 * in;- SetWindowPos(g_back, g_thumbWnd ? g_thumbWnd : g_icons, x, y, w, h, SWP_NOACTIVATE | SWP_SHOWWINDOW);- auto* rt = ui::Begin(g_sb, w, h, sc);+ SetWindowPos(View().back, View().thumbWnd ? View().thumbWnd : View().icons, x, y, w, h, SWP_NOACTIVATE | SWP_SHOWWINDOW);+ auto* rt = ui::Begin(View().sb, w, h, sc);if (!rt) return;ID2D1SolidColorBrush* br = nullptr;D2D1_COLOR_F fill = dark ? D2D1::ColorF(0.11f, 0.11f, 0.12f, 0.30f) : D2D1::ColorF(1, 1, 1, 0.20f);@@ -935,7 +1009,7 @@ void PaintBack() {rt->CreateSolidColorBrush(fill, &br);rt->FillRectangle(D2D1::RectF(0, 0, w / sc, h / sc), br);br->Release();- ui::End(g_sb, false);+ ui::End(View().sb, false);}// onde fica a miniatura de uma janela minimizada (pt, na janela dos ícones, já em pé): cabe num@@ -943,9 +1017,9 @@ void PaintBack() {D2D1_RECT_F MinThumbRect(const Item& it, float baseline) {float box = it.size * 0.92f;float ww = 16, wh = 10;- auto f = g_thumbs.find(it.win);+ auto f = View().thumbs.find(it.win);SIZE sz{};- if (f != g_thumbs.end() && SUCCEEDED(DwmQueryThumbnailSourceSize(f->second, &sz)) && sz.cx > 0 && sz.cy > 0) { ww = (float)sz.cx; wh = (float)sz.cy; }+ if (f != View().thumbs.end() && SUCCEEDED(DwmQueryThumbnailSourceSize(f->second, &sz)) && sz.cx > 0 && sz.cy > 0) { ww = (float)sz.cx; wh = (float)sz.cy; }else { RECT r{}; WINDOWPLACEMENT wp{ sizeof(wp) }; if (GetWindowPlacement(it.win, &wp)) r = wp.rcNormalPosition; if (r.right > r.left) { ww = (float)(r.right - r.left); wh = (float)(r.bottom - r.top); } }float k = std::min(box / ww, box / wh);float w = ww * k, h = wh * k;@@ -955,52 +1029,60 @@ D2D1_RECT_F MinThumbRect(const Item& it, float baseline) {// miniaturas do DWM das minimizadas, na janela própria entre o fundo e a dos íconesvoid UpdateThumbs(float baseline) {- if (!g_thumbWnd) return;+ if (!View().thumbWnd) return;float sc = Sc();RECT strip = Strip();std::vector<std::pair<const Item*, RECT>> rects;- bool show = !g_fullscreen && g_reveal > 0.5f;- for (auto& it : g_items) {+ bool show = !View().fullscreen && View().reveal > 0.5f;+ for (auto& it : View().items) {if (it.kind != I_MINWIN) continue;if (!SlotSettled(it)) { // chegando ou saindo: sem miniatura aqui- auto f = g_thumbs.find(it.win);- if (f != g_thumbs.end()) { DWM_THUMBNAIL_PROPERTIES tp{}; tp.dwFlags = DWM_TNP_VISIBLE; tp.fVisible = FALSE; DwmUpdateThumbnailProperties(f->second, &tp); }+ auto f = View().thumbs.find(it.win);+ if (f != View().thumbs.end()) { DWM_THUMBNAIL_PROPERTIES tp{}; tp.dwFlags = DWM_TNP_VISIBLE; tp.fVisible = FALSE; DwmUpdateThumbnailProperties(f->second, &tp); }continue;}- if (!g_thumbs.count(it.win)) { HTHUMBNAIL th = nullptr; if (SUCCEEDED(DwmRegisterThumbnail(g_thumbWnd, it.win, &th))) g_thumbs[it.win] = th; }+ if (!View().thumbs.count(it.win)) { HTHUMBNAIL th = nullptr; if (SUCCEEDED(DwmRegisterThumbnail(View().thumbWnd, it.win, &th))) View().thumbs[it.win] = th; }D2D1_RECT_F r = MinThumbRect(it, baseline);RECT px{ strip.left + (LONG)std::lround(r.left * sc), strip.top + (LONG)std::lround(r.top * sc), strip.left + (LONG)std::lround(r.right * sc), strip.top + (LONG)std::lround(r.bottom * sc) };rects.push_back({ &it, px });}- if (rects.empty() || !show) { ShowWindow(g_thumbWnd, SW_HIDE); return; }- // A janela fica sempre com a faixa inteira, como a dos ícones (cuja imagem nunca é recriada, então nada pisca).- // Antes ela era redimensionada para a caixa das miniaturas a cada quadro da ampliação e as miniaturas DWM- // piscavam quando o mouse deslizava sobre elas (o resize da janela hospedeira faz o DWM redesenhar em branco- // por um quadro). Agora a janela é fixa e só o destino de cada miniatura muda dentro dela. O clique continua- // passando através (WM_NCHITTEST = HTTRANSPARENT), por isso cobrir a faixa toda não atrapalha.- RECT cur; GetWindowRect(g_thumbWnd, &cur);- if (!IsWindowVisible(g_thumbWnd) || cur.left != strip.left || cur.top != strip.top || cur.right != strip.right || cur.bottom != strip.bottom) {- SetWindowPos(g_thumbWnd, g_icons, strip.left, strip.top, strip.right - strip.left, strip.bottom - strip.top, SWP_NOACTIVATE | SWP_SHOWWINDOW);- }- // O HTTRANSPARENT só passa o clique para janelas da mesma thread: cobrindo a faixa inteira, a janela engolia os- // cliques dos outros programas logo acima do Dock (achado no teste do Rust, 27/11/2026). A região da janela fica só- // nas miniaturas (o tamanho não muda, então nada pisca); fora delas o clique vai para quem está embaixo.- {- static std::vector<RECT> ultima;- std::vector<RECT> agora;- for (auto& [it, px] : rects) agora.push_back({ px.left - strip.left, px.top - strip.top, px.right - strip.left, px.bottom - strip.top });- bool igual = ultima.size() == agora.size();- for (size_t i = 0; igual && i < agora.size(); i++) igual = EqualRect(&ultima[i], &agora[i]) != FALSE;- if (!igual) {- HRGN rgn = CreateRectRgn(0, 0, 0, 0);- for (auto& r : agora) { HRGN p = CreateRectRgn(r.left, r.top, r.right, r.bottom); CombineRgn(rgn, rgn, p, RGN_OR); DeleteObject(p); }- SetWindowRgn(g_thumbWnd, rgn, TRUE); // a janela fica dona da região- ultima = agora;+ if (rects.empty() || !show) { ShowWindow(View().thumbWnd, SW_HIDE); return; }+ // Mantém a faixa estável para o DWM e recorta somente a região das miniaturas.+ // HTTRANSPARENT sozinho não passa cliques a processos atrás do Dock.+ RECT current{};+ GetWindowRect(View().thumbWnd, ¤t);+ if (!IsWindowVisible(View().thumbWnd) || !EqualRect(¤t, &strip)) {+ SetWindowPos(View().thumbWnd, View().icons, strip.left, strip.top, strip.right - strip.left,+ strip.bottom - strip.top, SWP_NOACTIVATE | SWP_SHOWWINDOW);+ }+ std::vector<RECT> region;+ region.reserve(rects.size());+ for (const auto& entry : rects) {+ RECT bounds = entry.second;+ OffsetRect(&bounds, -strip.left, -strip.top);+ region.push_back(bounds);+ }+ const auto& previous = View().thumbRegion;+ if (region.size() != previous.size() ||+ !std::equal(region.begin(), region.end(), previous.begin(), [](const RECT& a, const RECT& b) { return EqualRect(&a, &b); })) {+ HRGN mask = CreateRectRgn(0, 0, 0, 0);+ HRGN part = CreateRectRgn(0, 0, 0, 0);+ if (mask && part) {+ for (const RECT& bounds : region) {+ SetRectRgn(part, bounds.left, bounds.top, bounds.right, bounds.bottom);+ CombineRgn(mask, mask, part, RGN_OR);+ }+ if (SetWindowRgn(View().thumbWnd, mask, TRUE)) {+ View().thumbRegion = std::move(region);+ mask = nullptr;+ }}+ if (mask) DeleteObject(mask);+ if (part) DeleteObject(part);}for (auto& [it, px] : rects) {- auto f = g_thumbs.find(it->win);- if (f == g_thumbs.end()) continue;+ auto f = View().thumbs.find(it->win);+ if (f == View().thumbs.end()) continue;DWM_THUMBNAIL_PROPERTIES tp{};tp.dwFlags = DWM_TNP_RECTDESTINATION | DWM_TNP_VISIBLE | DWM_TNP_OPACITY | DWM_TNP_SOURCECLIENTAREAONLY;tp.rcDestination = { px.left - strip.left, px.top - strip.top, px.right - strip.left, px.bottom - strip.top };@@ -1083,6 +1165,7 @@ void DrawBadge(ID2D1RenderTarget* rt, ID2D1SolidColorBrush* br, D2D1_RECT_F ib,void Paint();void CALLBACK FgEvent(HWINEVENTHOOK, DWORD, HWND h, LONG obj, LONG, DWORD, DWORD) {if (obj != OBJID_WINDOW || !h) return;+ if (g_magnify && View().mouseX >= 0 && !View().fullscreen) RaiseLayers();if (App* a = apps::OfWindow(h)) {bool had = BadgeCount(*a) > 0;g_seen[a->id] = NowFt();@@ -1094,11 +1177,11 @@ void CALLBACK FgEvent(HWINEVENTHOOK, DWORD, HWND h, LONG obj, LONG, DWORD, DWORD// dos lados, ao lado do ícone com a setinha apontando para ele (como no Mac com o Dock à esquerda ou à direita).struct LabelBox { D2D1_RECT_F r{}; D2D1_POINT_2F tri[3]{}; D2D1_POINT_2F in{}; std::wstring t; }; // in: da base da setinha para a pontabool LabelGeom(int lab, LabelBox& L) {- if (!g_rotulos || lab < 0 || lab >= (int)g_items.size() || g_items[lab].kind == I_SEP || g_reveal <= 0.9f) return false;- auto& it = g_items[lab];+ if (!g_rotulos || lab < 0 || lab >= (int)View().items.size() || View().items[lab].kind == I_SEP || View().reveal <= 0.9f) return false;+ auto& it = View().items[lab];L.t = Label(it);float tw = ui::TextWidth(g_tfLabel, L.t) + 22, th = 26;- float baseline = g_bg.top + PAD_TOP + g_tile;+ float baseline = View().bg.top + PAD_TOP + View().tile;if (!Vert()) {float top = baseline - it.size - 14 - th;L.r = { it.cx - tw / 2, top, it.cx + tw / 2, top + th };@@ -1124,36 +1207,42 @@ bool LabelGeom(int lab, LabelBox& L) {void JumpIds(const App& a, std::wstring& exe, std::wstring& aumid);void Paint() {- if (g_icons && g_desligado) { // Dock desligado (issue #179): tudo escondido, sem reserva na área de trabalho- ShowWindow(g_icons, SW_HIDE); if (g_back) ShowWindow(g_back, SW_HIDE); if (g_thumbWnd) ShowWindow(g_thumbWnd, SW_HIDE);+ if (g_desligado) {+ for (HWND window : { View().icons, View().back, View().thumbWnd })+ if (window) ShowWindow(window, SW_HIDE);+ return;+ }+ FitTile();+ if (!View().icons || View().fullscreen) {+ if (View().thumbWnd) ShowWindow(View().thumbWnd, SW_HIDE);return;}- if (!g_icons || g_fullscreen) { if (g_thumbWnd) ShowWindow(g_thumbWnd, SW_HIDE); return; }Layout();float sc = Sc();RECT strip = Strip();int W = strip.right - strip.left, H = strip.bottom - strip.top;+ if (W <= 0 || H <= 0) return;// Janela justa no Dock; inteira (espaço para a etiqueta e a ampliação) só com o mouse em cima ou// animando, assim o resto da faixa de baixo da tela continua clicável.- bool active = g_mouseX >= 0 || g_dragging || g_resizing || g_press >= 0 || g_dropHit >= 0 || Animating();+ bool active = View().mouseX >= 0 || View().dragging || View().resizing || View().press >= 0 || View().dropHit >= 0 || Animating();LabelBox lbox;- bool hasLabel = LabelGeom(g_dragging ? -1 : g_hover, lbox);- D2D1_RECT_F bgw = RectToWin(g_bg);+ bool hasLabel = LabelGeom(View().dragging ? -1 : View().hover, lbox);+ D2D1_RECT_F bgw = RectToWin(View().bg);RECT want{ (LONG)std::floor(bgw.left * sc) - 2, (LONG)std::floor(bgw.top * sc) - 2, (LONG)std::ceil(bgw.right * sc) + 2, (LONG)std::ceil(bgw.bottom * sc) + 2 };{ // o vidro do Dock (px da janela, 16 bits cada: esquerda, topo, direita, baixo) para os menus não passarem por// cima dele (src\menu\context_menu.cpp OpenLevel)auto u16 = [](LONG v) { return (ULONG_PTR)(std::clamp<LONG>(v, 0, 0xFFFF)); };ULONG_PTR pk = u16(want.left) | (u16(want.top) << 16);if (sizeof(ULONG_PTR) >= 8) pk |= ((ULONG_PTR)u16(want.right) << 16 << 16) | ((ULONG_PTR)u16(want.bottom) << 16 << 16 << 16);- SetPropW(g_icons, L"WacOSDockVidro", (HANDLE)pk);+ SetPropW(View().icons, L"WacOSDockVidro", (HANDLE)pk);}- bool poofing = g_poof.t0 > 0 && anim::Now() - g_poof.t0 < POOF_MS;- if (active && (!Vert() || g_dragging || g_resizing || poofing)) want = RECT{ 0, 0, W, H };+ bool poofing = View().poof.t0 > 0 && anim::Now() - View().poof.t0 < POOF_MS;+ if (active && (!Vert() || View().dragging || View().resizing || poofing)) want = RECT{ 0, 0, W, H };else if (active) {// dos lados a janela é larga (cabe a etiqueta): só a coluna dos ícones (com a ampliação e o pulo) e a// etiqueta recebem o mouse; o resto continua clicável para as janelas atrás- float head = std::max(g_magnify ? g_large - g_tile : 0.f, g_tile * 0.7f) + 8;- D2D1_RECT_F a = RectToWin({ 0, g_bg.top - head, AxisLen(), WinH() });+ float head = std::max(g_magnify ? g_large - View().tile : 0.f, View().tile * 0.7f) + 8;+ D2D1_RECT_F a = RectToWin({ 0, View().bg.top - head, AxisLen(), WinH() });if (hasLabel) { a.left = std::min(a.left, lbox.r.left - 2); a.right = std::max(a.right, lbox.r.right + 2); }want = { (LONG)std::floor(a.left * sc), (LONG)std::floor(a.top * sc), (LONG)std::ceil(a.right * sc), (LONG)std::ceil(a.bottom * sc) };}@@ -1163,19 +1252,19 @@ void Paint() {if (want.right <= want.left) want.right = want.left + 1;// A imagem tem sempre o tamanho da faixa inteira (nunca é recriada, então nada pisca); só a// janela muda de tamanho e o conteúdo é deslocado para casar.- auto* rt = ui::GpuBegin(g_gi, W, H, sc);+ auto* rt = ui::GpuBegin(View().gi, W, H, sc);if (!rt) return;// desenho do Dock no sistema dele (dockT: dos lados, girado); ícones, números e etiquetas em pé (base)D2D1_MATRIX_3X2_F base; rt->GetTransform(&base);D2D1_MATRIX_3X2_F dockT = DockMatrix() * base;rt->SetTransform(dockT);- bool moved = !EqualRect(&want, &g_win);+ bool moved = !EqualRect(&want, &View().win);bool dark = ui::Dark();ID2D1SolidColorBrush* br = nullptr;rt->CreateSolidColorBrush(D2D1::ColorF(0, 0, 0, 0.004f), &br);float rad = DOCK_RADIUS;// quase transparente: só para o fundo do Dock receber o clique- rt->FillRoundedRectangle(D2D1::RoundedRect(g_bg, rad, rad), br);+ rt->FillRoundedRectangle(D2D1::RoundedRect(View().bg, rad, rad), br);float px = 1 / sc;// bordas do vidro (como no Sequoia): 1 px escuro por fora, 1 px claro logo por dentro// (com o Liquid Glass quem desenha o contorno especular é o próprio vidro, em backdrop.cpp)@@ -1193,14 +1282,14 @@ void Paint() {if (gs) gs->Release();};if (leo) {- float base = g_bg.top + PAD_TOP + g_tile;- leoBack = base - g_tile * 0.52f; leoFront = g_bg.bottom - std::max(2.f, g_tile * 0.04f); leoIn = (leoFront - leoBack) * 0.95f;+ float base = View().bg.top + PAD_TOP + View().tile;+ leoBack = base - View().tile * 0.52f; leoFront = View().bg.bottom - std::max(2.f, View().tile * 0.04f); leoIn = (leoFront - leoBack) * 0.95f;ID2D1Factory* fac = nullptr; rt->GetFactory(&fac);if (fac && SUCCEEDED(fac->CreatePathGeometry(&shelf))) {ID2D1GeometrySink* sk = nullptr;if (SUCCEEDED(shelf->Open(&sk))) {- sk->BeginFigure({ g_bg.left + leoIn, leoBack }, D2D1_FIGURE_BEGIN_FILLED);- sk->AddLine({ g_bg.right - leoIn, leoBack }); sk->AddLine({ g_bg.right, leoFront }); sk->AddLine({ g_bg.left, leoFront });+ sk->BeginFigure({ View().bg.left + leoIn, leoBack }, D2D1_FIGURE_BEGIN_FILLED);+ sk->AddLine({ View().bg.right - leoIn, leoBack }); sk->AddLine({ View().bg.right, leoFront }); sk->AddLine({ View().bg.left, leoFront });sk->EndFigure(D2D1_FIGURE_END_CLOSED);sk->Close(); sk->Release();}@@ -1213,14 +1302,14 @@ void Paint() {// frente: a borda fina do vidro — um fio escuro e, embaixo, o fio claro// a borda da frente do vidro: a quina clara e brilhante (o fio branco forte) e a face fina embaixo, mais clara que o tampobr->SetColor(D2D1::ColorF(1, 1, 1, 0.92f));- rt->FillRectangle(D2D1::RectF(g_bg.left, leoFront, g_bg.right, leoFront + px), br);- lin({ 0, leoFront + px }, { 0, g_bg.bottom }, { { 0, D2D1::ColorF(0.86f, 0.86f, 0.88f, 0.80f) }, { 1, D2D1::ColorF(0.62f, 0.62f, 0.65f, 0.80f) } },- [&](ID2D1Brush* b) { rt->FillRectangle(D2D1::RectF(g_bg.left, leoFront + px, g_bg.right, g_bg.bottom), b); });+ rt->FillRectangle(D2D1::RectF(View().bg.left, leoFront, View().bg.right, leoFront + px), br);+ lin({ 0, leoFront + px }, { 0, View().bg.bottom }, { { 0, D2D1::ColorF(0.86f, 0.86f, 0.88f, 0.80f) }, { 1, D2D1::ColorF(0.62f, 0.62f, 0.65f, 0.80f) } },+ [&](ID2D1Brush* b) { rt->FillRectangle(D2D1::RectF(View().bg.left, leoFront + px, View().bg.right, View().bg.bottom), b); });br->SetColor(D2D1::ColorF(1, 1, 1, 0.70f)); // a borda do fundo (o fio de luz atrás dos ícones) e os lados- rt->DrawLine({ g_bg.left + leoIn, leoBack }, { g_bg.right - leoIn, leoBack }, br, px);+ rt->DrawLine({ View().bg.left + leoIn, leoBack }, { View().bg.right - leoIn, leoBack }, br, px);br->SetColor(D2D1::ColorF(1, 1, 1, 0.35f));- rt->DrawLine({ g_bg.left + leoIn, leoBack }, { g_bg.left, leoFront }, br, px);- rt->DrawLine({ g_bg.right - leoIn, leoBack }, { g_bg.right, leoFront }, br, px);+ rt->DrawLine({ View().bg.left + leoIn, leoBack }, { View().bg.left, leoFront }, br, px);+ rt->DrawLine({ View().bg.right - leoIn, leoBack }, { View().bg.right, leoFront }, br, px);}// reflexo no tampo da prateleira (Leopard): o desenho do ícone espelhado no pé dele, recortado pelo tampo e sumindo// para a frente@@ -1229,7 +1318,7 @@ void Paint() {D2D1_GRADIENT_STOP st[2] = { { 0, D2D1::ColorF(1, 1, 1, 0.30f) }, { 1, D2D1::ColorF(1, 1, 1, 0) } }; // reflexo sutil e curto (captura do 10.5)ID2D1GradientStopCollection* gs = nullptr; ID2D1LinearGradientBrush* lb = nullptr;if (SUCCEEDED(rt->CreateGradientStopCollection(st, 2, &gs)) &&- SUCCEEDED(rt->CreateLinearGradientBrush(D2D1::LinearGradientBrushProperties({ 0, baseY }, { 0, baseY + g_tile * 0.42f }), gs, &lb))) {+ SUCCEEDED(rt->CreateLinearGradientBrush(D2D1::LinearGradientBrushProperties({ 0, baseY }, { 0, baseY + View().tile * 0.42f }), gs, &lb))) {rt->PushLayer(D2D1::LayerParameters(D2D1::InfiniteRect(), shelf, D2D1_ANTIALIAS_MODE_PER_PRIMITIVE, D2D1::IdentityMatrix(), 1, lb), nullptr);D2D1_MATRIX_3X2_F old; rt->GetTransform(&old);rt->SetTransform(D2D1::Matrix3x2F::Scale(1, -1, { 0, baseY }) * old);@@ -1240,27 +1329,27 @@ void Paint() {if (lb) lb->Release();if (gs) gs->Release();};- if (!leo && !(g_glass && backdrop::Liquid())) {+ if (!leo && !(View().glass && backdrop::Liquid())) {br->SetColor(dark ? D2D1::ColorF(0, 0, 0, 0.40f) : D2D1::ColorF(0, 0, 0, 0.10f));- rt->DrawRoundedRectangle(D2D1::RoundedRect(D2D1::RectF(g_bg.left + px / 2, g_bg.top + px / 2, g_bg.right - px / 2, g_bg.bottom - px / 2), rad - px / 2, rad - px / 2), br, px);+ rt->DrawRoundedRectangle(D2D1::RoundedRect(D2D1::RectF(View().bg.left + px / 2, View().bg.top + px / 2, View().bg.right - px / 2, View().bg.bottom - px / 2), rad - px / 2, rad - px / 2), br, px);br->SetColor(dark ? D2D1::ColorF(1, 1, 1, 0.16f) : D2D1::ColorF(1, 1, 1, 0.55f));- rt->DrawRoundedRectangle(D2D1::RoundedRect(D2D1::RectF(g_bg.left + px * 1.5f, g_bg.top + px * 1.5f, g_bg.right - px * 1.5f, g_bg.bottom - px * 1.5f), rad - px * 1.5f, rad - px * 1.5f), br, px);+ rt->DrawRoundedRectangle(D2D1::RoundedRect(D2D1::RectF(View().bg.left + px * 1.5f, View().bg.top + px * 1.5f, View().bg.right - px * 1.5f, View().bg.bottom - px * 1.5f), rad - px * 1.5f, rad - px * 1.5f), br, px);}- float baseline = g_bg.top + PAD_TOP + g_tile; // pé dos ícones- for (int i = 0; i < (int)g_items.size(); i++) {- auto& it = g_items[i];+ float baseline = View().bg.top + PAD_TOP + View().tile; // pé dos ícones+ for (int i = 0; i < (int)View().items.size(); i++) {+ auto& it = View().items[i];if (it.kind == I_SEP && leo) {// Leopard: a "faixa de pedestres" do 10.5 — barrinhas brancas horizontais empilhadas do fundo até a frente,// em perspectiva (mais largas e mais altas na frente), seguindo a fuga do tampo- float w = g_bg.right - g_bg.left, t = w > 0 ? (it.cx - g_bg.left) / w : 0.5f;- float bx = it.cx + (g_bg.left + leoIn + t * (w - 2 * leoIn) - it.cx) * 0.35f; // a captura mostra a coluna quase em pé (só um pouco de fuga)+ float w = View().bg.right - View().bg.left, t = w > 0 ? (it.cx - View().bg.left) / w : 0.5f;+ float bx = it.cx + (View().bg.left + leoIn + t * (w - 2 * leoIn) - it.cx) * 0.35f; // a captura mostra a coluna quase em pé (só um pouco de fuga)const int N = 7;for (int d = 0; d < N; d++) {float a = (d + 0.15f) / N, b2 = (d + 0.62f) / N;float ya = leoBack + (leoFront - leoBack) * a, yb = leoBack + (leoFront - leoBack) * b2;float xa = bx + (it.cx - bx) * a, xb = bx + (it.cx - bx) * b2;- float ha = g_tile * (0.10f + 0.09f * a), hb = g_tile * (0.10f + 0.09f * b2);+ float ha = View().tile * (0.10f + 0.09f * a), hb = View().tile * (0.10f + 0.09f * b2);ID2D1Factory* f2 = nullptr; rt->GetFactory(&f2);ID2D1PathGeometry* g2 = nullptr;if (f2 && SUCCEEDED(f2->CreatePathGeometry(&g2))) {@@ -1280,11 +1369,11 @@ void Paint() {}if (it.kind == I_SEP) {br->SetColor(dark ? D2D1::ColorF(1, 1, 1, 0.22f) : D2D1::ColorF(0, 0, 0, 0.18f));- float h = g_tile * 0.93f, cy = (g_bg.top + g_bg.bottom) / 2;+ float h = View().tile * 0.93f, cy = (View().bg.top + View().bg.bottom) / 2;rt->DrawLine({ it.cx, cy - h / 2 }, { it.cx, cy + h / 2 }, br, 1);continue;}- if (g_dragging && i == g_press && it.kind == I_APP) continue; // está na mão do usuário+ if (View().dragging && i == View().press && it.kind == I_APP) continue; // está na mão do usuárioif (it.kind == I_MINWIN) {if (!SlotSettled(it)) continue; // chegando ou saindo: o gênio está desenhando a janelafloat s2 = it.size, box = s2 * 0.92f;@@ -1305,13 +1394,13 @@ void Paint() {}float s = it.size * AppFactor(it);if (it.kind == I_GHOST) { // saindo: encolhe junto com o espaço- if (it.ghost < 0 || it.ghost >= (int)g_ghosts.size() || s < 1) continue;- auto& gh = g_ghosts[it.ghost];- auto f = g_bmps.find(gh.id);+ if (it.ghost < 0 || it.ghost >= (int)View().ghosts.size() || s < 1) continue;+ auto& gh = View().ghosts[it.ghost];+ auto f = View().bmps.find(gh.id);float art = s * (gh.mac ? ART_PACK : ART_WIN);D2D1_RECT_F ir{ it.cx - art / 2, baseline - (s + art) / 2, it.cx + art / 2, baseline - (s - art) / 2 };rt->SetTransform(base);- if (f != g_bmps.end() && f->second) rt->DrawBitmap(f->second, Up(ir), 1, D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC);+ if (f != View().bmps.end() && f->second) rt->DrawBitmap(f->second, Up(ir), 1, D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC);rt->SetTransform(dockT);continue;}@@ -1349,8 +1438,8 @@ void Paint() {float m = mac ? (iw.right - iw.left) * 0.10f : 0; // PNG do pacote: corpo = 80% do desenhoDrawBadge(rt, br, D2D1::RectF(iw.left + m, iw.top + m, iw.right - m, iw.bottom - m), n);}- if ((i == g_press && !g_dragging && GetKeyState(VK_LBUTTON) < 0) || i == g_dropHit) { // pressionado: escurece- br->SetColor(D2D1::ColorF(0, 0, 0, i == g_dropHit ? 0.25f : 0.35f));+ if ((i == View().press && !View().dragging && GetKeyState(VK_LBUTTON) < 0) || i == View().dropHit) { // pressionado: escurece+ br->SetColor(D2D1::ColorF(0, 0, 0, i == View().dropHit ? 0.25f : 0.35f));rt->FillRoundedRectangle(D2D1::RoundedRect(iw, art * 0.22f, art * 0.22f), br);}rt->SetTransform(dockT);@@ -1361,8 +1450,8 @@ void Paint() {// Leopard: a luz azul do app aberto, acesa no tampo junto da borda da frente (miolo branco e o brilho// azul-ciano espalhado para os lados)// medido: miolo (247,252,255) de ~2 px, halo (141,173,223) de ~6 px, a ~0,13 ícone da borda de baixo- D2D1_POINT_2F lc{ it.cx, g_bg.bottom - g_tile * 0.13f };- float rx = std::max(3.f, g_tile * 0.14f), ry = std::max(1.5f, g_tile * 0.06f);+ D2D1_POINT_2F lc{ it.cx, View().bg.bottom - View().tile * 0.13f };+ float rx = std::max(3.f, View().tile * 0.14f), ry = std::max(1.5f, View().tile * 0.06f);D2D1_GRADIENT_STOP st[3] = { { 0, D2D1::ColorF(1, 1, 1, 1) }, { 0.32f, D2D1::ColorF(0.72f, 0.87f, 1, 0.95f) }, { 1, D2D1::ColorF(0.40f, 0.58f, 0.92f, 0) } };ID2D1GradientStopCollection* gs = nullptr; ID2D1RadialGradientBrush* rb = nullptr;if (SUCCEEDED(rt->CreateGradientStopCollection(st, 3, &gs)) &&@@ -1374,23 +1463,23 @@ void Paint() {bool tahoe = TAHOE_DOCK; // Tahoe: ponto pequeno, um pouco acima da borda; escuro no claro, claro no escuroif (tahoe) br->SetColor(dark ? D2D1::ColorF(1, 1, 1, 0.85f) : D2D1::ColorF(0.05f, 0.07f, 0.20f, 0.85f));else br->SetColor(dark ? D2D1::ColorF(1, 1, 1, 0.55f) : D2D1::ColorF(0, 0, 0, 0.50f));- float dr = std::max(1.25f, g_tile * (tahoe ? 0.028f : 0.034f));- float dy = g_bg.bottom - g_tile * (tahoe ? 0.088f : 0.068f);+ float dr = std::max(1.25f, View().tile * (tahoe ? 0.028f : 0.034f));+ float dy = View().bg.bottom - View().tile * (tahoe ? 0.088f : 0.068f);if (g_indicador == 1) { // traço (Personalizar o Dock): uma barrinha arredondada de ~1/3 do ícone- float hw = g_tile * 0.16f;+ float hw = View().tile * 0.16f;rt->FillRoundedRectangle(D2D1::RoundedRect(D2D1::RectF(it.cx - hw, dy - dr * 0.8f, it.cx + hw, dy + dr * 0.8f), dr * 0.8f, dr * 0.8f), br);} else rt->FillEllipse(D2D1::Ellipse({ it.cx, dy }, dr, dr), br);}}}- if (g_poof.t0 > 0 && anim::Now() - g_poof.t0 < POOF_MS) { // o "puf": bolinhas de fumaça que se abrem e somem- float u = (float)((anim::Now() - g_poof.t0) / POOF_MS), e = 1 - (1 - u) * (1 - u);- float R = g_tile * (0.30f + 0.55f * e), alpha = (1 - u) * (1 - u);+ if (View().poof.t0 > 0 && anim::Now() - View().poof.t0 < POOF_MS) { // o "puf": bolinhas de fumaça que se abrem e somem+ float u = (float)((anim::Now() - View().poof.t0) / POOF_MS), e = 1 - (1 - u) * (1 - u);+ float R = View().tile * (0.30f + 0.55f * e), alpha = (1 - u) * (1 - u);const int N = 7;for (int k = 0; k < N; k++) {- float ang = k * 6.2832f / N + 0.4f, r = g_tile * (0.10f + 0.42f * e);- float px2 = g_poof.x + std::cos(ang) * r, py2 = g_poof.y + std::sin(ang) * r * 0.8f;+ float ang = k * 6.2832f / N + 0.4f, r = View().tile * (0.10f + 0.42f * e);+ float px2 = View().poof.x + std::cos(ang) * r, py2 = View().poof.y + std::sin(ang) * r * 0.8f;float pr = R * (0.42f + 0.10f * ((k * 37) % 5) / 4.f);br->SetColor(dark ? D2D1::ColorF(0.86f, 0.86f, 0.88f, 0.85f * alpha) : D2D1::ColorF(0.97f, 0.97f, 0.98f, 0.95f * alpha));rt->FillEllipse(D2D1::Ellipse({ px2, py2 }, pr, pr), br);@@ -1398,7 +1487,7 @@ void Paint() {rt->DrawEllipse(D2D1::Ellipse({ px2, py2 }, pr, pr), br, 0.8f);}br->SetColor(dark ? D2D1::ColorF(0.93f, 0.93f, 0.95f, 0.9f * alpha) : D2D1::ColorF(1, 1, 1, alpha));- rt->FillEllipse(D2D1::Ellipse({ g_poof.x, g_poof.y }, R * 0.55f, R * 0.5f), br);+ rt->FillEllipse(D2D1::Ellipse({ View().poof.x, View().poof.y }, R * 0.55f, R * 0.5f), br);}// etiqueta com o nome, acima do ícone (dos lados, ao lado dele); em pé, nas coordenadas da janela@@ -1439,15 +1528,15 @@ void Paint() {}}// ícone sendo arrastado- if (g_dragging && g_press >= 0 && g_items[g_press].kind == I_APP) {- App& a = apps::list[g_items[g_press].app];+ if (View().dragging && View().press >= 0 && View().items[View().press].kind == I_APP) {+ App& a = apps::list[View().items[View().press].app];POINT c; GetCursorPos(&c);float mx = (c.x - strip.left) / sc, my = (c.y - strip.top) / sc; // na janela (em pé)- float art = g_tile * (a.mac ? ART_PACK : ART_WIN);+ float art = View().tile * (a.mac ? ART_PACK : ART_WIN);D2D1_RECT_F ir{ mx - art / 2, my - art / 2, mx + art / 2, my + art / 2 };if (a.finder) ui::DrawFolder(rt, ir, L'');- else if (ID2D1Bitmap* b = IconBitmap(rt, a)) rt->DrawBitmap(b, ir, g_dragOut ? 0.5f : 1.f, D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC);- if (g_dragOut && !a.finder) {+ else if (ID2D1Bitmap* b = IconBitmap(rt, a)) rt->DrawBitmap(b, ir, View().dragOut ? 0.5f : 1.f, D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC);+ if (View().dragOut && !a.finder) {std::wstring t = Tr(L"Remover");float tw = ui::TextWidth(g_tfLabel, t) + 22;D2D1_RECT_F r{ mx - tw / 2, ir.top - 34, mx + tw / 2, ir.top - 10 };@@ -1459,36 +1548,37 @@ void Paint() {}br->Release();if (shelf) shelf->Release();- ui::GpuEnd(g_gi);+ ui::GpuEnd(View().gi);if (moved) {// A janela fica sempre com a faixa inteira e o desenho sem deslocar; só a região (onde ela recebe o// mouse) muda. Antes a janela mudava de tamanho e o desenho era deslocado junto, mas as duas coisas// chegavam à tela em quadros diferentes: os ícones sumiam por um quadro ao passar o mouse (piscava).- bool first = IsRectEmpty(&g_win);- g_win = want;- SetWindowRgn(g_icons, CreateRectRgn(want.left, want.top, want.right, want.bottom), TRUE);- RECT cur; GetWindowRect(g_icons, &cur);- if (first || !EqualRect(&cur, &strip) || !IsWindowVisible(g_icons)) {- ui::GpuOffset(g_gi, 0.f, 0.f);- SetWindowPos(g_icons, HWND_TOPMOST, strip.left, strip.top, W, H, SWP_NOACTIVATE | SWP_SHOWWINDOW);+ bool first = IsRectEmpty(&View().win);+ View().win = want;+ SetWindowRgn(View().icons, CreateRectRgn(want.left, want.top, want.right, want.bottom), TRUE);+ RECT cur; GetWindowRect(View().icons, &cur);+ if (first || !EqualRect(&cur, &strip) || !IsWindowVisible(View().icons)) {+ ui::GpuOffset(View().gi, 0.f, 0.f);+ SetWindowPos(View().icons, HWND_TOPMOST, strip.left, strip.top, W, H, SWP_NOACTIVATE | SWP_SHOWWINDOW);MenusPorCima();}}PaintBack();- UpdateThumbs(g_bg.top + PAD_TOP + g_tile); // depois do fundo: fica entre ele e os ícones+ UpdateThumbs(View().bg.top + PAD_TOP + View().tile); // depois do fundo: fica entre ele e os ícones+ KeepMagnifiedOnTop();}bool HitSep(float x, float y) {- if (y < g_bg.top || y > g_bg.bottom) return false;- for (auto& it : g_items) if (it.kind == I_SEP && std::fabs(x - it.cx) < SEP_W / 2) return true;+ if (y < View().bg.top || y > View().bg.bottom) return false;+ for (auto& it : View().items) if (it.kind == I_SEP && std::fabs(x - it.cx) < SEP_W / 2) return true;return false;}int HitTest(float x, float y) {- if (y < g_bg.top - (g_magnify ? g_large - g_tile : 0) || y > g_bg.bottom + MARGIN) return -1;- for (int i = 0; i < (int)g_items.size(); i++) {- float half = (g_items[i].kind == I_SEP ? SEP_W : std::max(g_items[i].size, g_tile)) / 2;- if (x >= g_items[i].cx - half && x < g_items[i].cx + half && g_items[i].kind != I_SEP && g_items[i].kind != I_GHOST) return i;+ if (y < View().bg.top - (g_magnify ? g_large - View().tile : 0) || y > View().bg.bottom + MARGIN) return -1;+ for (int i = 0; i < (int)View().items.size(); i++) {+ float half = (View().items[i].kind == I_SEP ? SEP_W : std::max(View().items[i].size, View().tile)) / 2;+ if (x >= View().items[i].cx - half && x < View().items[i].cx + half && View().items[i].kind != I_SEP && View().items[i].kind != I_GHOST) return i;}return -1;}@@ -1507,7 +1597,7 @@ ctxmenu::Item MSep() { ctxmenu::Item i; i.separator = true; return i; }int ShowMenu(int itemIndex, const std::vector<ctxmenu::Item>& items) {ctxmenu::PlainNext(); // o menu do Dock no Mac não tem ícones (nem no Tahoe)float sc = Sc();- POINT pt = ToScreen(g_items[itemIndex].cx, g_bg.top - 8);+ POINT pt = ToScreen(View().items[itemIndex].cx, View().bg.top - 8);if (!Vert()) {// embaixo: o menu abre para cima, centrado no ícone, com a borda de baixo a 8 pt do Dock (como no Mac). A altura// de verdade vem do próprio menu (antes: 22 pt por linha contando os separadores, e o menu ficava alto demais)@@ -1562,9 +1652,9 @@ void JumpIds(const App& a, std::wstring& exe, std::wstring& aumid) {}void ContextMenu(int i) {- auto& it = g_items[i];+ auto& it = View().items[i];if (it.kind == I_DOWNLOADS) { // como no Mac: ordenar, ver como (Leque, Grade, Lista) e abrir a pasta- pilhas::Menu(ToScreen(it.cx, g_bg.top - 4));+ pilhas::Menu(ToScreen(it.cx, View().bg.top - 4));g_stackAt = 0; g_stackPaths.clear(); // ordem ou "Exibir como" podem ter mudadoPaint();return;@@ -1673,7 +1763,7 @@ void ContextMenu(int i) {case 22: apps::Renomear(IconName(*ap), IconExe(*ap)); break;case 23: shell::SetSetting(L"dock_finder", g_mostraFinder ? L"0" : L"1"); dock::ReloadSettings(); break;case 19: apps::RestoreIcon(IconName(*ap), IconExe(*ap)); break;- case 13: missioncontrol::ToggleApp(ap->id, ap->name); break; // como no Mac: o Exposé do app+ case 13: missioncontrol::ToggleApp(apps::ExposeId(ap->id, ap->exe), ap->name); break; // como no Mac: o Exposé do appcase 14: apps::Hide(*ap); break;case 15: apps::Quit(*ap); break;case 16: apps::Launch(*ap); dock::Update(); break;@@ -1693,7 +1783,7 @@ void BackgroundMenu() {POINT c; GetCursorPos(&c);ShowWindow(g_owner, SW_SHOWNA); // escondida fora do menu: visível, recebia o foco ao minimizar a janela da frente (#199)SetForegroundWindow(g_owner);- if (!Vert()) { c.y = ToScreen(0, g_bg.top - 8).y; ctxmenu::AboveNext(); } // como o menu dos ícones: logo acima do Dock+ if (!Vert()) { c.y = ToScreen(0, View().bg.top - 8).y; ctxmenu::AboveNext(); } // como o menu dos ícones: logo acima do Dockstd::wstring tema = shell::Setting(L"tema", L"auto");int id = ctxmenu::ShowItems(g_owner, c, { MI(Tr(L"Ativar Ocultação"), 1, g_autohide && !g_smart), MI(Tr(L"Ocultação Inteligente"), 7, g_smart),MI(Tr(L"Ativar Ampliação"), 2, g_magnify), MSep(),@@ -1710,8 +1800,8 @@ void BackgroundMenu() {if (id == 1 || id == 7) {bool smart = id == 7 ? !g_smart : false, on = id == 7 ? smart : !(g_autohide && !g_smart);shell::SetSetting(L"ocultar", !on ? L"0" : smart ? L"inteligente" : L"1");- g_autohide = on; g_smart = smart; g_covered = false; g_coverAt = 0; g_hidden = false;- shell::ApplyWorkArea(); ui::FrameClock(g_icons, WM_DOCKFRAME, true);+ g_autohide = on; g_smart = smart; View().covered = false; View().coverAt = 0; View().hidden = false;+ shell::ApplyWorkArea(); ui::FrameClock(View().icons, WM_DOCKFRAME, true);}if (id == 2) g_magnify = !g_magnify;if (id == 3) shell::OpenSettings(L"dock");@@ -1720,15 +1810,15 @@ void BackgroundMenu() {// o quadrado do ícone de um item na tela (sem ampliação: a posição de descanso)RECT IconSlotRect(const Item& it) {- float s = g_tile, top = g_bg.top + PAD_TOP;+ float s = View().tile, top = View().bg.top + PAD_TOP;return ToScreenRect({ it.cx - s / 2, top, it.cx + s / 2, top + s });}void LeftClick(int i) {- auto& it = g_items[i];+ auto& it = View().items[i];if (it.kind == I_MINWIN) { // volta para a tela pelo funil (gênio ao contrário) e sai do DockHWND h = it.win;- float s = it.size, top = g_bg.top + PAD_TOP + g_tile - s;+ float s = it.size, top = View().bg.top + PAD_TOP + View().tile - s;RECT from = ToScreenRect({ it.cx - s / 2, top, it.cx + s / 2, top + s });if (genio::Restore(h, from)) { apps::Refresh(); BuildItems(); Paint(); return; }shell::Restaurar(h);@@ -1744,7 +1834,7 @@ void LeftClick(int i) {return GetClassNameW(win.hwnd, cls, _countof(cls)) && !wcscmp(cls, L"ArquivosJanela");})) {OpenFinder(L"");- ui::FrameClock(g_icons, WM_DOCKFRAME, true);+ ui::FrameClock(View().icons, WM_DOCKFRAME, true);return;}// o app já está na frente: o clique oculta (as janelas somem e voltam no próximo clique)@@ -1769,14 +1859,14 @@ void LeftClick(int i) {for (auto& w : a.wins) if (w.minimized && !apps::IsHidden(w.hwnd)) { m = w.hwnd; break; }if (!anyShown && m && genio::Restore(m, IconSlotRect(it))) { apps::Refresh(); BuildItems(); Paint(); return; }}- apps::Activate(a); ui::FrameClock(g_icons, WM_DOCKFRAME, true); return;+ apps::Activate(a); ui::FrameClock(View().icons, WM_DOCKFRAME, true); return;}if (it.kind == I_TRASH) { OpenFinder(L"shell:RecycleBinFolder"); return; } // a Lixeira no Finder, não no Exploradorif (it.kind == I_FOLDER) { if (it.folder >= 0 && it.folder < (int)g_folders.size()) OpenFinder(g_folders[it.folder]); return; } // a pasta no Finderif (it.kind == I_LAUNCHPAD && LEO_DOCK) { dock::OpenAppsStack(); return; } // Leopard: a pasta Aplicativos como Pilha em Grade (10.5)if (it.kind == I_LAUNCHPAD) { launchpad::Toggle(); return; }if (it.kind == I_DOWNLOADS && shell::Setting(L"pilhas", L"1") == L"1") { // Pilha em grade, como no Mac- pilhas::Show(ToScreen(it.cx, g_bg.top - 4));+ pilhas::Show(ToScreen(it.cx, View().bg.top - 4));return;}if (it.kind == I_DOWNLOADS) {@@ -1794,13 +1884,15 @@ void LeftClick(int i) {// ---- soltar arquivos no Dock: na Lixeira apaga (com desfazer), num app abre com elestruct DockDrop : IDropTarget {+ DockView& view;+ explicit DockDrop(DockView& target) : view(target) {}LONG ref = 1;STDMETHODIMP QueryInterface(REFIID iid, void** o) override {if (iid == IID_IUnknown || iid == IID_IDropTarget) { *o = this; AddRef(); return S_OK; }*o = nullptr; return E_NOINTERFACE;}STDMETHODIMP_(ULONG) AddRef() override { return ++ref; }- STDMETHODIMP_(ULONG) Release() override { return --ref; }+ STDMETHODIMP_(ULONG) Release() override { ULONG remaining = --ref; if (!remaining) delete this; return remaining; }int At(POINTL p) {D2D1_POINT_2F q = ScreenToLocal(POINT{ p.x, p.y });return HitTest(q.x, q.y);@@ -1822,13 +1914,13 @@ struct DockDrop : IDropTarget {}bool PinSpot(int i) { // fora da Lixeira, dos Downloads e das janelas minimizadasif (!programs) return false;- return i < 0 || g_items[i].kind == I_APP || g_items[i].kind == I_SEP || g_items[i].kind == I_LAUNCHPAD;+ return i < 0 || View().items[i].kind == I_APP || View().items[i].kind == I_SEP || View().items[i].kind == I_LAUNCHPAD;}DWORD Effect(int i) {if (PinSpot(i)) return DROPEFFECT_LINK;if (i < 0) return DROPEFFECT_NONE;- if (g_items[i].kind == I_TRASH || g_items[i].kind == I_FOLDER) return DROPEFFECT_MOVE; // pasta: move para dentro (issue #108)- if (g_items[i].kind == I_APP) return DROPEFFECT_COPY;+ if (View().items[i].kind == I_TRASH || View().items[i].kind == I_FOLDER) return DROPEFFECT_MOVE; // pasta: move para dentro (issue #108)+ if (View().items[i].kind == I_APP) return DROPEFFECT_COPY;return DROPEFFECT_NONE;}STDMETHODIMP DragEnter(IDataObject* d, DWORD, POINTL p, DWORD* e) override {@@ -1838,19 +1930,21 @@ struct DockDrop : IDropTarget {return DragOver(0, p, e);}STDMETHODIMP DragOver(DWORD, POINTL p, DWORD* e) override {+ UseDock scope(view);int i = At(p);*e = Effect(i);int hl = *e && !PinSpot(i) ? i : -1; // fixando: sem o destaque de "abrir com"- if (hl != g_dropHit) { g_dropHit = hl; Paint(); }+ if (hl != View().dropHit) { View().dropHit = hl; Paint(); }return S_OK;}- STDMETHODIMP DragLeave() override { g_dropHit = -1; Paint(); return S_OK; }+ STDMETHODIMP DragLeave() override { UseDock scope(view); View().dropHit = -1; Paint(); return S_OK; }STDMETHODIMP Drop(IDataObject* d, DWORD, POINTL p, DWORD* e) override {+ UseDock scope(view);int i = At(p);*e = Effect(i);- g_dropHit = -1;+ View().dropHit = -1;if (*e && PinSpot(i)) { // fixa cada programa no lugar onde foi solto (antes do app embaixo do mouse)- int at = i >= 0 && g_items[i].kind == I_APP ? g_items[i].app : -1;+ int at = i >= 0 && View().items[i].kind == I_APP ? View().items[i].app : -1;bool any = false;for (auto& f : Files(d)) if (apps::PinPath(f, at)) { any = true; if (at > 0) at++; }programs = false;@@ -1869,8 +1963,8 @@ struct DockDrop : IDropTarget {GlobalUnlock(sm.hGlobal);ReleaseStgMedium(&sm);}- if (!files.empty() && g_items[i].kind == I_FOLDER) { // pasta do usuário no Dock (issue #108, PR #110): move para ela- int fi = g_items[i].folder;+ if (!files.empty() && View().items[i].kind == I_FOLDER) { // pasta do usuário no Dock (issue #108, PR #110): move para ela+ int fi = View().items[i].folder;if (fi >= 0 && fi < (int)g_folders.size()) {std::wstring from;int n = 0;@@ -1881,9 +1975,9 @@ struct DockDrop : IDropTarget {}from += L'\0';std::wstring to = g_folders[fi] + L'\0' + L'\0';- if (n) { SHFILEOPSTRUCTW op{ g_icons, FO_MOVE, from.c_str(), to.c_str(), FOF_ALLOWUNDO }; SHFileOperationW(&op); } // com desfazer, como na Lixeira+ if (n) { SHFILEOPSTRUCTW op{ View().icons, FO_MOVE, from.c_str(), to.c_str(), FOF_ALLOWUNDO }; SHFileOperationW(&op); } // com desfazer, como na Lixeira}- } else if (!files.empty() && g_items[i].kind == I_TRASH) {+ } else if (!files.empty() && View().items[i].kind == I_TRASH) {// issue #100: pastas especiais (Downloads, Documentos, Mesa...) e raízes de disco nunca vão para a Lixeira por// aqui; o resto vai e fica no shell.logstd::wstring from;@@ -1894,29 +1988,36 @@ struct DockDrop : IDropTarget {from += f; from += L'\0'; n++;}from += L'\0';- if (n) { SHFILEOPSTRUCTW op{ g_icons, FO_DELETE, from.c_str(), nullptr, FOF_ALLOWUNDO }; SHFileOperationW(&op); }+ if (n) { SHFILEOPSTRUCTW op{ View().icons, FO_DELETE, from.c_str(), nullptr, FOF_ALLOWUNDO }; SHFileOperationW(&op); }BuildItems();- } else if (!files.empty() && g_items[i].kind == I_APP) {+ } else if (!files.empty() && View().items[i].kind == I_APP) {std::wstring args;for (auto& f : files) args += L"\"" + f + L"\" ";- apps::Launch(apps::list[g_items[i].app], args);+ apps::Launch(apps::list[View().items[i].app], args);}Paint();return S_OK;}-} g_drop;+};+bool CreateView(HINSTANCE hi);+void SyncDisplays();LRESULT CALLBACK IconsProc(HWND h, UINT m, WPARAM w, LPARAM l) {+ if (m == WM_NCCREATE)+ SetWindowLongPtrW(h, GWLP_USERDATA, (LONG_PTR)((CREATESTRUCTW*)l)->lpCreateParams);+ auto* dock = (DockView*)GetWindowLongPtrW(h, GWLP_USERDATA);+ if (!dock || !dock->icons) return DefWindowProcW(h, m, w, l);+ UseDock scope(*dock);float sc = Sc();// teste (clicar no ícone sem mexer no mouse do PC): wParam = uma janela; devolve o meio do ícone do app dela em// coordenadas desta janela (MAKELONG), ou -1. Quem testa posta WM_LBUTTONDOWN/UP ali.static UINT testeIcone = RegisterWindowMessageW(L"ShellDockTesteIcone");if (m == testeIcone && testeIcone) {- for (auto& it : g_items) {+ for (auto& it : View().items) {if (it.kind != I_APP || it.app < 0 || it.app >= (int)apps::list.size()) continue;for (auto& win : apps::list[it.app].wins)if (win.hwnd == (HWND)w) {- D2D1_POINT_2F p = ToWin(it.cx, g_bg.top + PAD_TOP + g_tile / 2);+ D2D1_POINT_2F p = ToWin(it.cx, View().bg.top + PAD_TOP + View().tile / 2);return MAKELONG((int)std::lround(p.x * sc), (int)std::lround(p.y * sc));}}@@ -1924,95 +2025,102 @@ LRESULT CALLBACK IconsProc(HWND h, UINT m, WPARAM w, LPARAM l) {}switch (m) {case WM_MOUSEACTIVATE: return MA_NOACTIVATE;+ case WM_PAINT: { PAINTSTRUCT ps; BeginPaint(h, &ps); EndPaint(h, &ps); Paint(); return 0; }+ case WM_DPICHANGED:+ View().win = {}; View().lastBg = {};+ ui::FrameClock(h, WM_DOCKFRAME, true);+ return 0;case WM_SETCURSOR:- if (g_sepHover || g_resizing) { SetCursor(LoadCursorW(nullptr, Vert() ? IDC_SIZEWE : IDC_SIZENS)); return TRUE; } // setinha ↕ no separador (↔ dos lados)+ if (View().sepHover || View().resizing) { SetCursor(LoadCursorW(nullptr, Vert() ? IDC_SIZEWE : IDC_SIZENS)); return TRUE; } // setinha ↕ no separador (↔ dos lados)break;case WM_MOUSEMOVE: {D2D1_POINT_2F lp = ToLocal(GET_X_LPARAM(l) / sc, GET_Y_LPARAM(l) / sc); // no sistema do Dockfloat x = lp.x, y = lp.y;- if (g_resizing) { // arrastando o separador: para cima aumenta, para baixo diminui+ if (View().resizing) { // arrastando o separador: para cima aumenta, para baixo diminuiPOINT c; GetCursorPos(&c);- g_tile = g_tileWant = std::clamp(g_resizeTile + (Inward(c) - g_resizeY) / sc, 16.f, 128.f);- g_large = std::max(g_large, g_tile);+ View().tile = g_tileWant = std::clamp(View().resizeTile + (Inward(c) - View().resizeY) / sc, 16.f, 128.f);+ g_large = std::max(g_large, View().tile);Paint();return 0;}- g_sepHover = HitSep(x, y);+ View().sepHover = HitSep(x, y);TRACKMOUSEEVENT t{ sizeof(t), TME_LEAVE, h, 0 };TrackMouseEvent(&t);- if (g_press >= 0 && !g_dragging && (w & MK_LBUTTON)) {+ if (View().press >= 0 && !View().dragging && (w & MK_LBUTTON)) {POINT c; GetCursorPos(&c);- if (std::abs(c.x - g_pressPt.x) + std::abs(c.y - g_pressPt.y) > 6 * sc && g_items[g_press].kind == I_APP && !apps::list[g_items[g_press].app].finder) {- g_dragging = true;- ui::FrameClock(g_icons, WM_DOCKFRAME, true);+ if (std::abs(c.x - View().pressPt.x) + std::abs(c.y - View().pressPt.y) > 6 * sc && View().items[View().press].kind == I_APP && !apps::list[View().items[View().press].app].finder) {+ View().dragging = true;+ ui::FrameClock(View().icons, WM_DOCKFRAME, true);}}- if (g_dragging) {- g_dragOut = y < g_bg.top - g_tile * 1.2f;- g_mouseX = x;+ if (View().dragging) {+ View().dragOut = y < View().bg.top - View().tile * 1.2f;+ View().mouseX = x;Paint();return 0;}// acima dos ícones (fora da ampliação) já é fora do Dock: solta a faixa na hora, senão ela segurava// o clique de quem vai do Dock para algo logo acima dele (a etiqueta some, como no Mac)- float head = g_magnify ? g_large - g_tile : 0;- if (y < g_bg.top - head || x < g_bg.left - g_tile || x > g_bg.right + g_tile) {- if (g_mouseX >= 0 || g_hover >= 0) { g_mouseX = -1; g_hover = -1; if (Animating()) ui::FrameClock(g_icons, WM_DOCKFRAME, true); Paint(); }+ float head = g_magnify ? g_large - View().tile : 0;+ if (y < View().bg.top - head || x < View().bg.left - View().tile || x > View().bg.right + View().tile) {+ if (View().mouseX >= 0 || View().hover >= 0) { View().mouseX = -1; View().hover = -1; if (Animating()) ui::FrameClock(View().icons, WM_DOCKFRAME, true); Paint(); }return 0;}- g_mouseX = g_lastMouseX = x;- if (Animating()) ui::FrameClock(g_icons, WM_DOCKFRAME, true);+ bool entering = View().mouseX < 0;+ View().mouseX = View().lastMouseX = x;+ if (entering && g_magnify) RaiseLayers();+ if (Animating()) ui::FrameClock(View().icons, WM_DOCKFRAME, true);int hv = HitTest(x, y);- if (hv != g_hover || g_magnify) { g_hover = hv; Paint(); }+ if (hv != View().hover || g_magnify) { View().hover = hv; Paint(); }return 0;}case WM_MOUSELEAVE:- if (!g_dragging) { g_mouseX = -1; g_hover = -1; if (Animating()) ui::FrameClock(g_icons, WM_DOCKFRAME, true); Paint(); }+ if (!View().dragging) { View().mouseX = -1; View().hover = -1; if (Animating()) ui::FrameClock(View().icons, WM_DOCKFRAME, true); Paint(); }return 0;case WM_LBUTTONDOWN: {D2D1_POINT_2F lp = ToLocal(GET_X_LPARAM(l) / sc, GET_Y_LPARAM(l) / sc);if (HitSep(lp.x, lp.y)) {POINT c; GetCursorPos(&c);- g_resizing = true; g_resizeY = Inward(c); g_resizeTile = g_tile;+ View().resizing = true; View().resizeY = Inward(c); View().resizeTile = View().tile;SetCapture(h);return 0;}- g_press = HitTest(lp.x, lp.y);- GetCursorPos(&g_pressPt);+ View().press = HitTest(lp.x, lp.y);+ GetCursorPos(&View().pressPt);SetCapture(h);Paint();return 0;}case WM_LBUTTONUP: {- if (g_resizing) {- g_resizing = false;+ if (View().resizing) {+ View().resizing = false;ReleaseCapture();- shell::SetSetting(L"tamanho", std::to_wstring((int)std::lround(g_tile)));+ shell::SetSetting(L"tamanho", std::to_wstring((int)std::lround(View().tile)));shell::ApplyWorkArea();Paint();return 0;}ReleaseCapture();- int p = g_press;- g_press = -1;- if (g_dragging) {- g_dragging = false;- if (p >= 0 && g_items[p].kind == I_APP) {- App& a = apps::list[g_items[p].app];- if (g_dragOut) { // o "puf" do Mac+ int p = View().press;+ View().press = -1;+ if (View().dragging) {+ View().dragging = false;+ if (p >= 0 && View().items[p].kind == I_APP) {+ App& a = apps::list[View().items[p].app];+ if (View().dragOut) { // o "puf" do Macif (a.pinned) {POINT c; GetCursorPos(&c);D2D1_POINT_2F q = ScreenToLocal(c);- g_poof = { q.x, q.y, anim::Now() };+ View().poof = { q.x, q.y, anim::Now() };apps::SetPinned(a, false); shell::Sound(L"poof_item_off_dock");- ui::FrameClock(g_icons, WM_DOCKFRAME, true);+ ui::FrameClock(View().icons, WM_DOCKFRAME, true);}}- else if (a.pinned && g_dragTo >= 0 && g_dragTo != g_items[p].app) // o lugar aberto ao vivo no Dock- apps::Move(g_items[p].app, std::clamp(g_dragTo, 1, (int)apps::list.size() - 1));- else if (!a.pinned && g_dragTo >= 0) { // app aberto/recente solto entre os fixos: fica fixo ali+ else if (a.pinned && View().dragTo >= 0 && View().dragTo != View().items[p].app) // o lugar aberto ao vivo no Dock+ apps::Move(View().items[p].app, std::clamp(View().dragTo, 1, (int)apps::list.size() - 1));+ else if (!a.pinned && View().dragTo >= 0) { // app aberto/recente solto entre os fixos: fica fixo alistd::wstring id = a.id;- int to = g_dragTo;+ int to = View().dragTo;apps::SetPinned(a, true); // vai para o fim dos fixosint idx = -1;for (int k = 0; k < (int)apps::list.size(); k++) if (apps::list[k].id == id) { idx = k; break; }@@ -2020,7 +2128,7 @@ LRESULT CALLBACK IconsProc(HWND h, UINT m, WPARAM w, LPARAM l) {Log(L"dock: %ls fixado no Dock pelo arraste (lugar %d)", id.c_str(), to);}}- g_dragOut = false;+ View().dragOut = false;BuildItems();Paint();return 0;@@ -2035,7 +2143,7 @@ LRESULT CALLBACK IconsProc(HWND h, UINT m, WPARAM w, LPARAM l) {D2D1_POINT_2F lp = ToLocal(GET_X_LPARAM(l) / sc, GET_Y_LPARAM(l) / sc);int i = HitTest(lp.x, lp.y);if (i < 0) return 0;- auto& it = g_items[i];+ auto& it = View().items[i];if (it.kind == I_APP) {App& a = apps::list[it.app];std::wstring exe = a.exe.substr(a.exe.find_last_of(L'\\') + 1);@@ -2044,7 +2152,7 @@ LRESULT CALLBACK IconsProc(HWND h, UINT m, WPARAM w, LPARAM l) {if (a.finder) OpenFinder(L"");else apps::Launch(a, chromium ? L"--new-window" : L"");Log(L"dock: nova janela de %ls (botão do meio)", a.name.c_str());- ui::FrameClock(g_icons, WM_DOCKFRAME, true); // pula enquanto abre+ ui::FrameClock(View().icons, WM_DOCKFRAME, true); // pula enquanto abre} else if (it.kind == I_TRASH) OpenFinder(L"shell:RecycleBinFolder");else if (it.kind == I_DOWNLOADS) OpenFinder(L"shell:Downloads");Paint();@@ -2053,41 +2161,42 @@ LRESULT CALLBACK IconsProc(HWND h, UINT m, WPARAM w, LPARAM l) {case WM_RBUTTONUP: {D2D1_POINT_2F lp = ToLocal(GET_X_LPARAM(l) / sc, GET_Y_LPARAM(l) / sc);int i = HitTest(lp.x, lp.y);- g_hover = -1;+ View().hover = -1;if (i >= 0) ContextMenu(i);- else if (lp.y >= g_bg.top) BackgroundMenu();+ else if (lp.y >= View().bg.top) BackgroundMenu();Paint();return 0;}case WM_DOCKSTACK: Paint(); return 0;case WM_TIMER:+ if (w == TIMER_DISPLAYS) { SyncDisplays(); return 0; }if (w == TIMER_HIDECHECK) {if (!g_autohide) { KillTimer(h, TIMER_HIDECHECK); return 0; }- if (WantHidden() != g_hidden) { KillTimer(h, TIMER_HIDECHECK); ui::FrameClock(g_icons, WM_DOCKFRAME, true); }+ if (WantHidden() != View().hidden) { KillTimer(h, TIMER_HIDECHECK); ui::FrameClock(View().icons, WM_DOCKFRAME, true); }return 0;}break; // as imagens da pilha de Downloads chegaramcase WM_DOCKFRAME: {double now = anim::Now();- float dt = g_lastFrame ? (float)std::clamp((now - g_lastFrame) / 1000.0, 0.0, 0.05) : 0.016f;- g_lastFrame = now;+ float dt = View().lastFrame ? (float)std::clamp((now - View().lastFrame) / 1000.0, 0.0, 0.05) : 0.016f;+ View().lastFrame = now;// ampliação: chega ao alvo em ~0,15 s (exponencial por tempo, igual em 60 ou 144 Hz)- float magTarget = g_mouseX >= 0 && !g_dragging ? 1.f : 0.f;- g_magAmt += (magTarget - g_magAmt) * (1 - std::exp(-dt / 0.05f));- if (std::fabs(magTarget - g_magAmt) < 0.002f) g_magAmt = magTarget;+ float magTarget = View().mouseX >= 0 && !View().dragging ? 1.f : 0.f;+ View().magAmt += (magTarget - View().magAmt) * (1 - std::exp(-dt / 0.05f));+ if (std::fabs(magTarget - View().magAmt) < 0.002f) View().magAmt = magTarget;if (g_autohide) { // aparece com o mouse na borda de baixo- g_hidden = WantHidden();- g_reveal = std::clamp(g_reveal + (g_hidden ? -dt : dt) / 0.32f, 0.f, 1.f); // 0,32 s, com a curva do Mac- } else g_reveal = 1;- for (auto& it : g_items) if (it.kind == I_MINWIN && it.leaving && SlotFactor(it) <= 0.001f) { BuildItems(); break; } // o espaço fechou: sai da lista+ View().hidden = WantHidden();+ View().reveal = std::clamp(View().reveal + (View().hidden ? -dt : dt) / 0.32f, 0.f, 1.f); // 0,32 s, com a curva do Mac+ } else View().reveal = 1;+ for (auto& it : View().items) if (it.kind == I_MINWIN && it.leaving && SlotFactor(it) <= 0.001f) { BuildViewItems(); break; } // o espaço fechou: sai da listabool anim = Animating();Paint();- if (!anim && !g_autohide) ui::FrameClock(g_icons, WM_DOCKFRAME, false);+ if (!anim && !g_autohide) ui::FrameClock(View().icons, WM_DOCKFRAME, false);// ocultação parada (toda escondida ou toda à mostra): sem quadro a cada atualização da tela, só uma// olhada a cada 100 ms no mouse e nas janelas (antes o Dock se redesenhava sem parar, pesado em GPU fraca)- else if (!anim && g_autohide && g_reveal == (g_hidden ? 0.f : 1.f)) {- ui::FrameClock(g_icons, WM_DOCKFRAME, false);- SetTimer(g_icons, TIMER_HIDECHECK, 100, nullptr);+ else if (!anim && g_autohide && View().reveal == (View().hidden ? 0.f : 1.f)) {+ ui::FrameClock(View().icons, WM_DOCKFRAME, false);+ SetTimer(View().icons, TIMER_HIDECHECK, 100, nullptr);}}return 0;@@ -2103,41 +2212,41 @@ LRESULT CALLBACK BackProc(HWND h, UINT m, WPARAM w, LPARAM l) {} // namespace-HWND dock::Hwnd() { return g_icons; }-HWND dock::Fundo() { return g_back; }+HWND dock::Hwnd() { return g_primaryDock.icons; }+HWND dock::Fundo() { return g_primaryDock.back; }// o vidro do Dock na tela (o que o último desenho guardou em "WacOSDockVidro"); false = Dock fora da tela/ocultobool dock::Vidro(RECT* out) {- if (!g_icons || !IsWindowVisible(g_icons) || sizeof(ULONG_PTR) < 8) return false;- ULONG_PTR pk = (ULONG_PTR)GetPropW(g_icons, L"WacOSDockVidro");+ if (!View().icons || !IsWindowVisible(View().icons) || sizeof(ULONG_PTR) < 8) return false;+ ULONG_PTR pk = (ULONG_PTR)GetPropW(View().icons, L"WacOSDockVidro");RECT wr;- if (!pk || !GetWindowRect(g_icons, &wr)) return false;+ if (!pk || !GetWindowRect(View().icons, &wr)) return false;*out = { wr.left + (LONG)(pk & 0xFFFF), wr.top + (LONG)((pk >> 16) & 0xFFFF), wr.left + (LONG)((pk >> 16 >> 16) & 0xFFFF), wr.top + (LONG)((pk >> 16 >> 16 >> 16) & 0xFFFF) };MONITORINFO mi{ sizeof(mi) };RECT x;return GetMonitorInfoW(MonitorFromRect(out, MONITOR_DEFAULTTONEAREST), &mi) && IntersectRect(&x, out, &mi.rcMonitor) && EqualRect(&x, out);}-HMONITOR dock::MonitorHandle() { return DockMon(); }+HMONITOR dock::MonitorHandle() { UseDock scope(g_primaryDock); return DockMon(); }int dock::Posicao() { return Pos(); }int dock::ReservedHeight() { // a espessura do Dock na borda dele (embaixo, à esquerda ou à direita: dock::Posicao)- if (!g_icons || g_autohide || g_desligado) return 0;+ if (!View().icons || g_autohide || g_desligado) return 0;// + a folga (dock_folga): no Mac a janela maximizada encosta no Dock. A folga fixa de 4 pt (issue #8) deixava o// Dock "descolado" da janela (21/11/2026); agora é opcional, 0 por padrão. Na escala da tela; com o Dock oculto// (automático ou inteligente) não há reserva nem folga- return (int)std::lround((g_tile + PAD_TOP + PAD_BOTTOM + MARGIN + g_folgaPt) * Sc());+ return (int)std::lround((View().tile + PAD_TOP + PAD_BOTTOM + MARGIN + g_folgaPt) * Sc());}static void ReadSettings() {- g_tile = (float)_wtof(shell::Setting(L"tamanho", L"48").c_str());+ View().tile = (float)_wtof(shell::Setting(L"tamanho", L"48").c_str());g_large = (float)_wtof(shell::Setting(L"ampliacao_tamanho", L"128").c_str());g_magnify = shell::Setting(L"ampliacao", L"0") == L"1";std::wstring oc = shell::Setting(L"ocultar", L"0"); // 0, 1 (sempre) ou inteligenteg_autohide = oc == L"1" || oc == L"inteligente";g_desligado = oc == L"desligado";g_smart = oc == L"inteligente";- g_tile = g_tileWant = std::clamp(g_tile, 16.f, 128.f);- g_large = std::clamp(g_large, g_tile, 256.f);+ View().tile = g_tileWant = std::clamp(View().tile, 16.f, 128.f);+ g_large = std::clamp(g_large, View().tile, 256.f);// personalização (vazio = o padrão do Mac)auto num = [](const wchar_t* k, float def) { std::wstring v = shell::Setting(k, L""); return v.empty() ? def : (float)_wtof(v.c_str()); };g_espaco = std::clamp(num(L"dock_espaco", 0), 0.f, 48.f);@@ -2169,39 +2278,132 @@ void dock::BadgesChanged() {if (f != g_lastBadge.end() && n > f->second && shell::Setting(L"pulo_notificacao", L"1") == L"1") { g_nudge[a.id] = GetTickCount(); any = true; }g_lastBadge[a.id] = n;}- if (any && g_icons) ui::FrameClock(g_icons, WM_DOCKFRAME, true);- if (g_icons) Paint();+ ForEachDock([&] {+ if (!View().icons) return;+ if (any) ui::FrameClock(View().icons, WM_DOCKFRAME, true);+ Paint();+ });}-void dock::IconsChanged() {- for (auto& [k, b] : g_bmps) if (b) b->Release();- g_bmps.clear();- g_customIcon.clear(); // ícone próprio escolhido ou restaurado (apps::ReloadIcons)- if (g_icons) Paint();+void dock::IconsChanged(bool repaint) {+ g_customIcon.clear();+ ForEachDock([&] {+ for (auto& [key, bitmap] : View().bmps) if (bitmap) bitmap->Release();+ View().bmps.clear();+ if (repaint && View().icons) Paint();+ });}void dock::ReloadSettings() {- bool hide = g_autohide, smart = g_smart;+ SyncDisplays();+ bool hide = g_autohide, smart = g_smart, desligado = g_desligado;int pos = g_pos, reserva = dock::ReservedHeight();ReadSettings();- if (!g_icons) return;+ if (!View().icons) return;if (pos != g_pos) { // mudou de lado: a área de trabalho reserva a borda nova (e as janelas maximizadas se ajeitam)Log(L"Dock: posição %ls", g_pos == 1 ? L"esquerda" : g_pos == 2 ? L"direita" : L"embaixo");- g_mouseX = g_lastMouseX = -1; g_hover = -1; g_magAmt = 0;+ ForEachDock([] { View().mouseX = View().lastMouseX = -1; View().hover = -1; View().magAmt = 0; });// arrasto em andamento (ícone ou separador) é cancelado: a referência era do lado antigo (20/11/2026, o// separador arrastado durante a troca levou o tamanho a 128, depois a 16, e gravou um valor qualquer)- if (g_resizing || g_dragging || g_press >= 0) { g_resizing = g_dragging = g_dragOut = false; g_press = -1; ReleaseCapture(); }- for (auto& it : g_items) it.cx = 0;- }- if (hide != g_autohide || smart != g_smart) { g_hidden = false; g_covered = false; g_coverAt = 0; ui::FrameClock(g_icons, WM_DOCKFRAME, true); }- g_win = {}; g_lastBg = {};- for (auto& [k, b] : g_bmps) if (b) b->Release(); // ícones próprios novos ou tirados- g_bmps.clear();+ if (View().resizing || View().dragging || View().press >= 0) { View().resizing = View().dragging = View().dragOut = false; View().press = -1; ReleaseCapture(); }+ for (auto& it : View().items) it.cx = 0;+ }+ if (hide != g_autohide || smart != g_smart || desligado != g_desligado) ForEachDock([] {+ View().hidden = false; View().covered = false; View().coverAt = 0;+ ui::FrameClock(View().icons, WM_DOCKFRAME, true);+ });+ View().win = {}; View().lastBg = {};+ IconsChanged(false);BuildItems(); // a pasta Downloads, a divisória ou o Launchpad podem ter entrado ou saído- Paint();+ ForEachDock([] { View().win = {}; View().lastBg = {}; Paint(); });if (pos != g_pos || reserva != dock::ReservedHeight()) shell::ApplyWorkArea(); // lado, tamanho, margem ou folga}+namespace {++void DestroyView(DockView& view) {+ UseDock scope(view);+ if (view.icons) {+ KillTimer(view.icons, TIMER_HIDECHECK);+ ui::FrameClock(view.icons, WM_DOCKFRAME, false);+ RevokeDragDrop(view.icons);+ }+ if (view.drop) { view.drop->Release(); view.drop = nullptr; }+ for (auto& [w, thumbnail] : view.thumbs) if (thumbnail) DwmUnregisterThumbnail(thumbnail);+ for (auto& [key, bitmap] : view.bmps) if (bitmap) bitmap->Release();+ ui::Free(view.sb);+ ui::GpuFree(view.gi);+ if (view.glass) backdrop::Detach(view.back);+ for (HWND w : { view.thumbWnd, view.back, view.icons }) {+ if (!w) continue;+ auto& own = apps::ours;+ own.erase(std::remove(own.begin(), own.end(), w), own.end());+ DestroyWindow(w);+ }+}++bool CreateView(HINSTANCE hi) {+ View().icons = CreateWindowExW(WS_EX_TOPMOST | WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE | WS_EX_NOREDIRECTIONBITMAP, L"ShellDock", L"Dock", WS_POPUP,+ 0, 0, 10, 10, nullptr, nullptr, hi, &View());+ // Fundo: vidro da Composição (curva suave de qualquer raio); se não der, o acrílico antigo.+ View().back = CreateWindowExW(WS_EX_TOPMOST | WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE | WS_EX_NOREDIRECTIONBITMAP, L"ShellDockFundo", L"", WS_POPUP,+ 0, 0, 10, 10, nullptr, nullptr, hi, nullptr);+ View().glass = View().back && backdrop::Attach(View().back);+ if (!View().glass) {+ if (View().back) DestroyWindow(View().back);+ View().back = CreateWindowExW(WS_EX_TOPMOST | WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE, L"ShellDockFundo", L"", WS_POPUP,+ 0, 0, 10, 10, nullptr, nullptr, hi, nullptr);+ }+ View().thumbWnd = CreateWindowExW(WS_EX_TOPMOST | WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE | WS_EX_NOREDIRECTIONBITMAP, L"ShellDockMinimizadas", L"", WS_POPUP, 0, 0, 1, 1, nullptr, nullptr, hi, nullptr);+ if (!View().icons || !View().back) return false;+ for (HWND w : { View().icons, View().back, View().thumbWnd }) if (w) apps::ours.push_back(w);+ View().gi.hwnd = View().icons; View().sb.hwnd = View().back;+ DWORD corner = View().glass ? 1 : 2; // com a Composição quem arredonda é o recorte; sem ela, o DWM (raio 8)+ DwmSetWindowAttribute(View().back, 33, &corner, sizeof(corner));+ COLORREF noBorder = 0xFFFFFFFE; // DWMWA_COLOR_NONE: sem a borda que o DWM põe em janelas arredondadas+ DwmSetWindowAttribute(View().back, 34 /*DWMWA_BORDER_COLOR*/, &noBorder, sizeof(noBorder));+ if (!View().glass) ui::Acrylic(View().back, ui::Dark() ? ACR_DARK : ACR_LIGHT);+ View().drop = new DockDrop(View());+ RegisterDragDrop(View().icons, View().drop);+ BuildViewItems();+ RECT strip = Strip();+ SetWindowPos(View().icons, nullptr, strip.left, strip.top, strip.right - strip.left, strip.bottom - strip.top,+ SWP_NOACTIVATE | SWP_NOZORDER);+ Paint();+ if (g_autohide) ui::FrameClock(View().icons, WM_DOCKFRAME, true);+ return true;+}++void SyncDisplays() {+ if (!g_primaryDock.icons || ctxmenu::IsOpen()) return;+ std::wstring selected = shell::Setting(L"dock_monitor", L"todos");+ g_allMonitors = selected.empty() || selected == L"todos";+ std::vector<HMONITOR> monitors;+ if (g_allMonitors)+ EnumDisplayMonitors(nullptr, nullptr, [](HMONITOR hm, HDC, LPRECT, LPARAM p) -> BOOL {+ auto& out = *(std::vector<HMONITOR>*)p;+ MONITORINFO mi{ sizeof(mi) };+ if (GetMonitorInfoW(hm, &mi) && !(mi.dwFlags & MONITORINFOF_PRIMARY)) out.push_back(hm);+ return TRUE;+ }, (LPARAM)&monitors);+ for (auto it = g_docks.begin(); it != g_docks.end();) {+ if (std::find(monitors.begin(), monitors.end(), it->first) != monitors.end() ||+ it->second->users || it->second->icons == GetCapture() || it->second->dropHit >= 0) { ++it; continue; }+ DestroyView(*it->second);+ it = g_docks.erase(it);+ }+ for (auto hm : monitors) {+ if (g_docks.count(hm)) continue;+ auto view = std::make_unique<DockView>();+ view->monitor = hm;+ UseDock scope(*view);+ if (CreateView(shell::inst)) g_docks.emplace(hm, std::move(view));+ else DestroyView(*view);+ }+}++} // namespace+bool dock::Create(HINSTANCE hi) {ReadSettings();g_shellStart = NowFt();@@ -2215,17 +2417,6 @@ bool dock::Create(HINSTANCE hi) {WNDCLASSW oc{}; oc.lpfnWndProc = DefWindowProcW; oc.hInstance = hi; oc.lpszClassName = L"ShellDockDono";RegisterClassW(&oc);- g_icons = CreateWindowExW(WS_EX_TOPMOST | WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE | WS_EX_NOREDIRECTIONBITMAP, ic.lpszClassName, L"Dock", WS_POPUP,- 0, 0, 10, 10, nullptr, nullptr, hi, nullptr);- // Fundo: vidro da Composição (curva suave de qualquer raio); se não der, o acrílico antigo.- g_back = CreateWindowExW(WS_EX_TOPMOST | WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE | WS_EX_NOREDIRECTIONBITMAP, bc.lpszClassName, L"", WS_POPUP,- 0, 0, 10, 10, nullptr, nullptr, hi, nullptr);- g_glass = g_back && backdrop::Attach(g_back);- if (!g_glass) {- if (g_back) DestroyWindow(g_back);- g_back = CreateWindowExW(WS_EX_TOPMOST | WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE, bc.lpszClassName, L"", WS_POPUP,- 0, 0, 10, 10, nullptr, nullptr, hi, nullptr);- }g_owner = CreateWindowExW(WS_EX_TOOLWINDOW | WS_EX_LAYERED, oc.lpszClassName, L"", WS_POPUP, -32000, -32000, 1, 1, nullptr, nullptr, hi, nullptr);WNDCLASSW tc{}; tc.lpfnWndProc = [](HWND h, UINT m, WPARAM w, LPARAM l) -> LRESULT {if (m == WM_MOUSEACTIVATE) return MA_NOACTIVATE;@@ -2234,92 +2425,122 @@ bool dock::Create(HINSTANCE hi) {};tc.hInstance = hi; tc.lpszClassName = L"ShellDockMinimizadas";RegisterClassW(&tc);- g_thumbWnd = CreateWindowExW(WS_EX_TOPMOST | WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE | WS_EX_NOREDIRECTIONBITMAP, tc.lpszClassName, L"", WS_POPUP, 0, 0, 1, 1, nullptr, nullptr, hi, nullptr);SetLayeredWindowAttributes(g_owner, 0, 0, LWA_ALPHA);- if (!g_icons || !g_back) return false;- for (HWND w : { g_icons, g_back, g_owner, g_thumbWnd }) if (w) apps::ours.push_back(w);- g_gi.hwnd = g_icons; g_sb.hwnd = g_back;- DWORD corner = g_glass ? 1 : 2; // com a Composição quem arredonda é o recorte; sem ela, o DWM (raio 8)- DwmSetWindowAttribute(g_back, 33, &corner, sizeof(corner));- COLORREF noBorder = 0xFFFFFFFE; // DWMWA_COLOR_NONE: sem a borda que o DWM põe em janelas arredondadas- DwmSetWindowAttribute(g_back, 34 /*DWMWA_BORDER_COLOR*/, &noBorder, sizeof(noBorder));- if (!g_glass) ui::Acrylic(g_back, ui::Dark() ? ACR_DARK : ACR_LIGHT);+ if (g_owner) apps::ours.push_back(g_owner);g_tfLabel = ui::Format(13, DWRITE_FONT_WEIGHT_NORMAL, false, DWRITE_TEXT_ALIGNMENT_CENTER);- RegisterDragDrop(g_icons, &g_drop);- BuildItems();- ShowWindow(g_icons, SW_SHOWNOACTIVATE);- Paint();- if (g_autohide) ui::FrameClock(g_icons, WM_DOCKFRAME, true);+ if (!CreateView(hi)) return false;+ SyncDisplays();+ SetTimer(g_primaryDock.icons, TIMER_DISPLAYS, 500, nullptr);return true;}+DockView& DockForWindow(HWND h) {+ if (h) {+ auto it = g_docks.find(MonitorFromWindow(h, MONITOR_DEFAULTTONEAREST));+ if (it != g_docks.end()) return *it->second;+ }+ return g_primaryDock;+}+RECT dock::MinimizeTarget(HWND h) {+ UseDock scope(DockForWindow(h));if (g_minNoIcone && h) { // "no ícone do aplicativo": o gênio vai para o ícone do app dono da janelaif (App* a = apps::OfWindow(h))- for (auto& it : g_items) if (it.kind == I_APP && it.app >= 0 && it.app < (int)apps::list.size() && &apps::list[it.app] == a) return IconSlotRect(it);+ for (auto& it : View().items) if (it.kind == I_APP && it.app >= 0 && it.app < (int)apps::list.size() && &apps::list[it.app] == a) return IconSlotRect(it);}- for (auto& it : g_items) if (it.kind == I_TRASH) {+ for (auto& it : View().items) if (it.kind == I_TRASH) {// o lugar logo antes da Lixeira (dos lados, o mesmo quadrado girado com o Dock)- float cx = it.cx - SLOT / 2, s = g_tile, top = g_bg.top + PAD_TOP;+ float cx = it.cx - SLOT / 2, s = View().tile, top = View().bg.top + PAD_TOP;return ToScreenRect({ cx - s / 2, top, cx + s / 2, top + s });}return { 0, 0, 0, 0 };}RECT dock::AppIconTarget(HWND h) {+ UseDock scope(DockForWindow(h));if (App* a = h ? apps::OfWindow(h) : nullptr)- for (auto& it : g_items) if (it.kind == I_APP && it.app >= 0 && it.app < (int)apps::list.size() && &apps::list[it.app] == a) return IconSlotRect(it);+ for (auto& it : View().items) if (it.kind == I_APP && it.app >= 0 && it.app < (int)apps::list.size() && &apps::list[it.app] == a) return IconSlotRect(it);return { 0, 0, 0, 0 };}void dock::Update() {BuildItems();- g_lastFrame = 0;- if (Animating()) ui::FrameClock(g_icons, WM_DOCKFRAME, true);- Paint();+ ForEachDock([] {+ View().lastFrame = 0;+ if (View().icons && Animating()) ui::FrameClock(View().icons, WM_DOCKFRAME, true);+ Paint();+ });}-void dock::SetFullscreen(bool on) {- if (!g_icons || on == g_fullscreen) return;- g_fullscreen = on;- // as miniaturas das janelas minimizadas também (ficavam por cima do YouTube em tela cheia, 19/11/2026)- if (on) { ShowWindow(g_icons, SW_HIDE); ShowWindow(g_back, SW_HIDE); if (g_thumbWnd) ShowWindow(g_thumbWnd, SW_HIDE); return; }- g_win = {}; g_lastBg = {}; // força reposicionar e mostrar- Paint();+void dock::SetFullscreen(bool on, HMONITOR monitor) {+ ForEachDock([&] {+ bool hide = on && (!monitor || DockMon() == monitor);+ if (!View().icons || hide == View().fullscreen) return;+ View().fullscreen = hide;+ if (hide) {+ for (HWND w : { View().icons, View().back, View().thumbWnd }) if (w) ShowWindow(w, SW_HIDE);+ return;+ }+ View().win = {};+ View().lastBg = {};+ Paint();+ });+}++bool dock::OnMonitor(HMONITOR monitor) {+ return (g_allMonitors && g_docks.count(monitor)) || monitor == MonitorHandle();+}++int dock::ReservedOn(HMONITOR monitor) {+ if (auto it = g_docks.find(monitor); it != g_docks.end()) {+ UseDock scope(*it->second);+ return ReservedHeight();+ }+ if (monitor != MonitorHandle()) return 0;+ UseDock scope(g_primaryDock);+ return ReservedHeight();+}++void dock::StopSecondary() {+ if (g_primaryDock.icons) KillTimer(g_primaryDock.icons, TIMER_DISPLAYS);+ for (auto& [monitor, view] : g_docks) DestroyView(*view);+ g_docks.clear();}void dock::ApplyTheme() {- if (!g_icons) return;- if (!g_glass) ui::Acrylic(g_back, ui::Dark() ? ACR_DARK : ACR_LIGHT);- g_lastBg = {}; // repinta a tinta do fundo- Paint();+ ForEachDock([] {+ if (!View().icons) return;+ if (!View().glass) ui::Acrylic(View().back, ui::Dark() ? ACR_DARK : ACR_LIGHT);+ View().lastBg = {}; // repinta a tinta do fundo+ Paint();+ });}// Leopard: abre a pasta Aplicativos (o item do Launchpad, à direita) como Pilha em Grade, saindo do ícone delavoid dock::OpenAppsStack() {- for (auto& it : g_items) {+ for (auto& it : View().items) {if (it.kind != I_LAUNCHPAD) continue;- POINT a = ToScreen(it.cx, g_bg.top - 4);+ POINT a = ToScreen(it.cx, View().bg.top - 4);pilhas::ShowApps(a);return;}}void dock::OpenDownloadsStack() {- for (auto& it : g_items) {+ for (auto& it : View().items) {if (it.kind != I_DOWNLOADS) continue;- POINT a = ToScreen(it.cx, g_bg.top - 4);+ POINT a = ToScreen(it.cx, View().bg.top - 4);pilhas::Show(a);return;}}-void dock::Raise() { // por cima de janelas de tela inteira nossas (Launchpad)- if (!g_icons) return;- auto alheias = shell::AlheiasNoTopo();- SetWindowPos(g_back, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);- SetWindowPos(g_icons, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);- if (g_thumbWnd) SetWindowPos(g_thumbWnd, g_icons, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); // miniaturas acima do vidro- MenusPorCima();- shell::DevolveAlheias(alheias);+void dock::Raise() {+ ForEachDock([] { // por cima de janelas de tela inteira nossas (Launchpad)+ if (!View().icons) return;+ if (g_magnify && View().mouseX >= 0) { RaiseLayers(); return; }+ auto alheias = shell::AlheiasNoTopo();+ RaiseLayers();+ shell::DevolveAlheias(alheias);+ });}diff --git a/src/shell/encaixe.cpp b/src/shell/encaixe.cppindex d664a8f..b1b1d56 100644--- a/src/shell/encaixe.cpp+++ b/src/shell/encaixe.cpp@@ -11,6 +11,7 @@// bordas invisíveis e guarda o tamanho de antes); as outras o Shell move direto.#include "shell.h"#include <dwmapi.h>+#include <shellscalingapi.h>#include <algorithm>#include <cmath>#include <map>@@ -52,6 +53,7 @@ void SilenceWindows() {}RECT Visible(HWND h, RECT& wr) {+ wr = {};GetWindowRect(h, &wr);RECT vis = wr, box;if (FAILED(DwmGetWindowAttribute(h, DWMWA_EXTENDED_FRAME_BOUNDS, &vis, sizeof(vis)))) vis = wr;@@ -62,20 +64,39 @@ RECT Visible(HWND h, RECT& wr) {// alvo pelo ponteiro: 0 nada, 1 metade/quarto em *t, 2 preencher (a área de trabalho)int Target(HWND h, RECT* t) {- POINT c; GetCursorPos(&c);+ POINT c{};+ if (!GetCursorPos(&c)) return 0;+ HMONITOR monitor = MonitorFromPoint(c, MONITOR_DEFAULTTONEAREST);MONITORINFO mi{ sizeof(mi) };- if (!GetMonitorInfoW(MonitorFromPoint(c, MONITOR_DEFAULTTONEAREST), &mi)) return 0;- RECT m = mi.rcMonitor, wa = mi.rcWork;- float sc = ui::Scale(h);- int e = (int)(4 * sc), q = (int)(60 * sc);- bool L = c.x <= m.left + e, R = c.x >= m.right - 1 - e, T = c.y <= std::max<LONG>(m.top + e, wa.top);- LONG mx = (wa.left + wa.right) / 2, my = (wa.top + wa.bottom) / 2;- if (L || R) {- *t = L ? RECT{ wa.left, wa.top, mx, wa.bottom } : RECT{ mx, wa.top, wa.right, wa.bottom };- if (c.y <= wa.top + q) t->bottom = my; else if (c.y >= wa.bottom - q) t->top = my;+ if (!GetMonitorInfoW(monitor, &mi)) return 0;+ const RECT& m = mi.rcMonitor;+ RECT wa = shell::WorkAreaFor(monitor);+ if (IsRectEmpty(&wa)) wa = mi.rcWork;+ UINT dpiX = 0, dpiY = 0;+ float sc = SUCCEEDED(GetDpiForMonitor(monitor, MDT_EFFECTIVE_DPI, &dpiX, &dpiY)) && dpiX ? dpiX / 96.f : ui::Scale(h);+ int edge = std::max(1, (int)(12 * sc));+ LONG available = std::min(wa.right - wa.left, wa.bottom - wa.top);+ int corner = std::clamp((int)(available * 0.15f), (int)(72 * sc), (int)(160 * sc));+ LONG left = std::max(m.left, wa.left) + edge, right = std::min(m.right, wa.right) - 1 - edge;+ LONG top = std::max(m.top, wa.top) + edge, bottom = std::min(m.bottom, wa.bottom) - 1 - edge;+ LONG mx = wa.left + (wa.right - wa.left) / 2, my = wa.top + (wa.bottom - wa.top) / 2;+ bool leftSide = c.x <= left, rightSide = c.x >= right;+ bool nearTop = c.y <= top + corner, nearBottom = c.y >= bottom - corner;+ bool leftCorner = (leftSide && (nearTop || nearBottom)) ||+ ((c.y <= top || c.y >= bottom) && c.x <= left + corner);+ bool rightCorner = (rightSide && (nearTop || nearBottom)) ||+ ((c.y <= top || c.y >= bottom) && c.x >= right - corner);+ if (leftCorner || rightCorner) {+ bool lower = nearBottom && (!nearTop || c.y > my);+ *t = leftCorner ? RECT{ wa.left, wa.top, mx, wa.bottom } : RECT{ mx, wa.top, wa.right, wa.bottom };+ if (lower) t->top = my; else t->bottom = my;+ return 1;+ }+ if (leftSide || rightSide) {+ *t = leftSide ? RECT{ wa.left, wa.top, mx, wa.bottom } : RECT{ mx, wa.top, wa.right, wa.bottom };return 1;}- if (T) { *t = wa; return 2; }+ if (c.y <= top) { *t = wa; return 2; }return 0;}@@ -167,26 +188,29 @@ void Place(HWND h, RECT want) {SetWindowPos(h, nullptr, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_NOZORDER | SWP_NOACTIVATE);// tamanho mínimo maior que o quarto: a janela crescia para baixo/direita a partir do canto de cima e, nos cantos de// baixo (ou à direita), saía da tela (#205). Encostada na borda de baixo/direita, sobe/vai para a esquerda até caber- RECT now; GetWindowRect(h, &now);- MONITORINFO mi{ sizeof(mi) };- if (GetMonitorInfoW(MonitorFromRect(&want, MONITOR_DEFAULTTONEAREST), &mi)) {+ RECT now{};+ RECT area = shell::WorkAreaFor(MonitorFromRect(&want, MONITOR_DEFAULTTONEAREST));+ if (GetWindowRect(h, &now) && !IsRectEmpty(&area)) {LONG dx = 0, dy = 0;- if (now.bottom > r.bottom && want.bottom >= mi.rcWork.bottom) dy = r.bottom - now.bottom;- if (now.right > r.right && want.right >= mi.rcWork.right) dx = r.right - now.right;+ if (now.bottom > r.bottom && want.bottom >= area.bottom) dy = r.bottom - now.bottom;+ if (now.right > r.right && want.right >= area.right) dx = r.right - now.right;if (dx || dy) SetWindowPos(h, nullptr, now.left + dx, now.top + dy, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);}}UINT TileMsg() { static UINT m = RegisterWindowMessageW(L"MacJanelaEncaixar"); return m; }-// manda a janela para o alvo (kind 1: retângulo visível t; 2: preencher)-void Apply(HWND h, int kind, RECT t, RECT start) {- if (GetPropW(h, L"MacJanela")) { // a DLL encaixa (bordas invisíveis, tamanho de antes, "ampliar" animado)- if (kind == 2) PostMessageW(h, TileMsg(), 0, 0);- else PostMessageW(h, TileMsg(), MAKEWPARAM((WORD)(short)t.right, (WORD)(short)t.bottom), MAKELPARAM((WORD)(short)t.left, (WORD)(short)t.top));- return;+// Encaixa na área visível pedida e guarda o tamanho para restaurar no arrasto seguinte.+void Apply(HWND h, RECT t, RECT start) {+ if (GetPropW(h, L"MacJanela")) {+ DWORD_PTR applied = 0;+ if (SendMessageTimeoutW(h, TileMsg(), MAKEWPARAM((WORD)(short)t.right, (WORD)(short)t.bottom),+ MAKELPARAM((WORD)(short)t.left, (WORD)(short)t.top), SMTO_ABORTIFHUNG | SMTO_ERRORONEXIT,+ 120, &applied) && applied) return;}- if (!g_before.count(h)) g_before[h] = start;+ auto last = g_tiled.find(h);+ if (last == g_tiled.end() || last->second.right - last->second.left != start.right - start.left ||+ last->second.bottom - last->second.top != start.bottom - start.top) g_before[h] = start;Place(h, t);RECT now; GetWindowRect(h, &now);g_tiled[h] = now;@@ -210,7 +234,7 @@ bool Candidate(HWND h) {void CALLBACK OnEvent(HWINEVENTHOOK, DWORD ev, HWND h, LONG obj, LONG, DWORD, DWORD) {if (obj != OBJID_WINDOW) return;if (ev == EVENT_SYSTEM_MOVESIZESTART) {- if (!Candidate(h) || !Enabled()) return;+ if (g_drag || !Candidate(h) || !Enabled()) return;SilenceWindows(); // (o Ajustes pode ter religado)// arrastar ou redimensionar? o ponto em que o botão desceu diz (borda = redimensionar)POINT c; GetCursorPos(&c);@@ -228,16 +252,14 @@ void CALLBACK OnEvent(HWINEVENTHOOK, DWORD ev, HWND h, LONG obj, LONG, DWORD, DWHide();if (!IsWindow(d)) return;RECT t; int k = Target(d, &t);- RECT now; GetWindowRect(d, &now);+ RECT now{};+ if (!Enabled() || !GetWindowRect(d, &now)) return;bool hasDll = GetPropW(d, L"MacJanela") != nullptr;- if (!hasDll && (now.right - now.left != g_start.right - g_start.left || now.bottom - now.top != g_start.bottom - g_start.top)) return; // redimensionou+ if (!hasDll && (now.right - now.left != g_start.right - g_start.left ||+ now.bottom - now.top != g_start.bottom - g_start.top)) return; // redimensionouif (k) {- if (k == 2 && !hasDll) {- MONITORINFO mi{ sizeof(mi) }; GetMonitorInfoW(MonitorFromRect(&t, MONITOR_DEFAULTTONEAREST), &mi);- t = mi.rcWork;- }- Log(L"encaixe: %ls (%ld,%ld %ldx%ld)", k == 2 ? L"preencher" : L"borda", t.left, t.top, t.right - t.left, t.bottom - t.top);- Apply(d, k, t, g_start);+ Log(L"encaixe: %ls (%ld,%ld %ldx%ld)", k == 2 ? L"preencher" : L"zona", t.left, t.top, t.right - t.left, t.bottom - t.top);+ Apply(d, t, g_start);return;}// sem a DLL: arrastou uma janela encaixada por nós para longe da borda -> volta ao tamanho de antes,@@ -289,8 +311,15 @@ void encaixe::Half(HWND h, bool right) {if (!h || !IsWindow(h)) return;MONITORINFO mi{ sizeof(mi) };GetMonitorInfoW(MonitorFromWindow(h, MONITOR_DEFAULTTONEAREST), &mi);- RECT a = mi.rcWork, s; GetWindowRect(h, &s);- LONG cx = (a.left + a.right) / 2;+ RECT a = shell::WorkAreaFor(MonitorFromWindow(h, MONITOR_DEFAULTTONEAREST)), s{};+ if (IsRectEmpty(&a)) a = mi.rcWork;+ if (!GetWindowRect(h, &s)) return;+ LONG cx = a.left + (a.right - a.left) / 2;RECT t = right ? RECT{ cx, a.top, a.right, a.bottom } : RECT{ a.left, a.top, cx, a.bottom };- Apply(h, 1, t, s);+ Apply(h, t, s);+}++void encaixe::Tile(HWND h, RECT target) {+ RECT start{};+ if (GetWindowRect(h, &start)) Apply(h, target, start);}diff --git a/src/shell/limites.cpp b/src/shell/limites.cppindex 4b500a9..2dc67cf 100644--- a/src/shell/limites.cpp+++ b/src/shell/limites.cpp@@ -87,7 +87,7 @@ void Clamp(HWND h, bool naHora = false) {if (vis.top + dy + newH > wa.bottom && resizable) newH = wa.bottom - (vis.top + dy);// Dock à esquerda ou à direita (Ajustes > Posição na tela): a mesma conta na horizontal, só do lado deleint dx = 0, newW = w;- if (dock::Posicao() != 0 && hm == dock::MonitorHandle()) {+ if (dock::Posicao() != 0 && dock::OnMonitor(hm)) {if (dock::Posicao() == 1 && vis.left < wa.left) dx = wa.left - vis.left;else if (dock::Posicao() == 2 && vis.right > wa.right) dx = -std::min((int)(vis.right - wa.right), std::max(0, (int)(vis.left - wa.left)));// à direita, mais larga que a área: encolhe até o Dock (à esquerda, empurrar para dentro já basta)diff --git a/src/shell/main.cpp b/src/shell/main.cppindex f051330..ac092a6 100644--- a/src/shell/main.cpp+++ b/src/shell/main.cpp@@ -749,8 +749,8 @@ RECT shell::WorkAreaFor(HMONITOR hm) {if (!GetMonitorInfoW(hm, &mi)) return {};RECT want = mi.rcMonitor;want.top += menubar::ReservedOn(hm); // secundário sem barra (barra_todos_monitores=0): o topo é das janelas- if (hm == dock::MonitorHandle()) { // o Dock na borda escolhida (Ajustes > Posição na tela)- int r = dock::ReservedHeight();+ if (dock::OnMonitor(hm)) {+ int r = dock::ReservedOn(hm);if (dock::Posicao() == 1) want.left += r;else if (dock::Posicao() == 2) want.right -= r;else want.bottom -= std::max(r, menubar::ReservedBottom(hm)); // barra embaixo: com o Dock oculto, a altura dela@@ -798,6 +798,7 @@ static void Restore() {encaixe::Stop();memoria::Stop();barras::Stop();+ dock::StopSecondary();sombras::Stop();alertas::Stop();progresso::Stop(); // as janelas de progresso do Windows voltam para a tela@@ -979,11 +980,22 @@ static bool IsFullscreen(HWND fg) {}wchar_t cls[64] = {}; GetClassNameW(fg, cls, 64);if (mesa::IsDeskClass(cls) || !wcscmp(cls, L"Shell_TrayWnd")) return false;- if (IsZoomed(fg) && (GetWindowLongW(fg, GWL_STYLE) & WS_CAPTION) == WS_CAPTION) return false; // só maximizada+ DWORD cloak = 0;+ if (SUCCEEDED(DwmGetWindowAttribute(fg, DWMWA_CLOAKED, &cloak, sizeof(cloak))) && cloak) return false;+ if (GetPropW(fg, L"MacJanelaAmpliada")) return false;MONITORINFO mi{ sizeof(mi) };- if (!GetMonitorInfoW(MonitorFromWindow(fg, MONITOR_DEFAULTTONEAREST), &mi)) return false;- RECT r; if (!GetWindowRect(fg, &r)) return false;- return r.left <= mi.rcMonitor.left && r.top <= mi.rcMonitor.top && r.right >= mi.rcMonitor.right && r.bottom >= mi.rcMonitor.bottom;+ HMONITOR monitor = MonitorFromWindow(fg, MONITOR_DEFAULTTONEAREST);+ if (!GetMonitorInfoW(monitor, &mi)) return false;+ RECT r{};+ POINT origin{};+ if (!GetClientRect(fg, &r) || !ClientToScreen(fg, &origin)) return false;+ OffsetRect(&r, origin.x, origin.y);+ const RECT& screen = mi.rcMonitor;+ bool coversMonitor = r.left <= screen.left && r.top <= screen.top && r.right >= screen.right && r.bottom >= screen.bottom;+ if (!coversMonitor) return false;+ if (!IsZoomed(fg)) return true;+ RECT usable = shell::WorkAreaFor(monitor);+ return !IsRectEmpty(&usable) && !EqualRect(&usable, &screen);}// Jogo/vídeo em tela cheia no monitor `mon` (ou o Windows em modo "não incomodar": Direct3D exclusivo,@@ -1024,7 +1036,7 @@ static void CheckFullscreen() {}visto = fs ? fg : nullptr;}- dock::SetFullscreen(locked || (fs && fm == dock::MonitorHandle()));+ dock::SetFullscreen(locked || fs, locked ? nullptr : fm);menubar::SetFullscreen(locked || fs, fm, fs ? fg : nullptr);ilha::SetFullscreen(locked); // a ilha confere sozinha a tela cheia do monitor principal (jogo, vídeo, app)}@@ -1359,7 +1371,7 @@ static LRESULT CALLBACK MsgProc(HWND h, UINT m, WPARAM w, LPARAM l) {if (!a) { Log(L"Exposé do app: a janela da frente não é de um app do Dock"); return 0; }if (launchpad::IsOpen()) launchpad::Toggle();shell::LiberaFrente(); // permite ao Exposé vir para a frente- missioncontrol::ToggleApp(a->id, a->name);+ missioncontrol::ToggleApp(apps::ExposeId(a->id, a->exe), a->name);return 0;}case WM_APP_MACKEY: {diff --git a/src/shell/mesas.cpp b/src/shell/mesas.cppindex 2c20eeb..d44ba48 100644--- a/src/shell/mesas.cpp+++ b/src/shell/mesas.cpp@@ -57,7 +57,9 @@ IVDMI* Open(std::vector<IVD*>& desks) {auto reg = RegistryIds();UINT n = 0;IObjectArray* arr = nullptr;- bool ok = SUCCEEDED(m->GetCount(&n)) && n == reg.size() && n > 0 && SUCCEEDED(m->GetDesktops(&arr)) && arr;+ bool firstDesktop = reg.empty();+ bool ok = SUCCEEDED(m->GetCount(&n)) && n > 0 && n == (firstDesktop ? 1 : reg.size()) &&+ SUCCEEDED(m->GetDesktops(&arr)) && arr;if (ok) {UINT c = 0; arr->GetCount(&c);ok = c == n;@@ -65,7 +67,7 @@ IVDMI* Open(std::vector<IVD*>& desks) {IVD* d = nullptr;if (FAILED(arr->GetAt(i, IID_IVD, (void**)&d)) || !d) { ok = false; break; }GUID g{};- if (FAILED(d->GetID(&g)) || memcmp(&g, ®[i], sizeof(GUID))) ok = false;+ if (FAILED(d->GetID(&g)) || g == GUID_NULL || (!firstDesktop && g != reg[i])) ok = false;desks.push_back(d);}}@@ -89,6 +91,40 @@ struct IAVC : IUnknown {virtual HRESULT STDMETHODCALLTYPE GetViewForHwnd(HWND h, IUnknown** view) = 0;};+IUnknown* ViewOf(IServiceProvider* sp, HWND h) {+ IAVC* collection = nullptr;+ IUnknown* view = nullptr;+ if (SUCCEEDED(sp->QueryService(IID_IAVC, IID_IAVC, (void**)&collection)) && collection) {+ collection->GetViewForHwnd(h, &view);+ collection->Release();+ }+ return view;+}++IUnknown* ViewOf(HWND h) {+ IServiceProvider* sp = nullptr;+ if (FAILED(CoCreateInstance(CLSID_ImmersiveShell, nullptr, CLSCTX_LOCAL_SERVER, IID_PPV_ARGS(&sp)))) return nullptr;+ IUnknown* view = ViewOf(sp, h);+ sp->Release();+ return view;+}++bool WindowDesktop(HWND h, GUID& id) {+ IVirtualDesktopManager* vdm = nullptr;+ if (FAILED(CoCreateInstance(CLSID_VirtualDesktopManager, nullptr, CLSCTX_ALL, IID_PPV_ARGS(&vdm)))) return false;+ HRESULT hr = vdm->GetWindowDesktopId(h, &id);+ vdm->Release();+ return SUCCEEDED(hr);+}++IVD* FindDesktop(const std::vector<IVD*>& desks, const GUID& id) {+ for (IVD* d : desks) {+ GUID key{};+ if (SUCCEEDED(d->GetID(&key)) && key == id) return d;+ }+ return nullptr;+}+void Free(IVDMI* m, std::vector<IVD*>& desks) {for (auto* d : desks) d->Release();desks.clear();@@ -97,6 +133,17 @@ void Free(IVDMI* m, std::vector<IVD*>& desks) {} // namespace+bool mesas::SwitchToWindow(HWND h) {+ GUID id{};+ if (!WindowDesktop(h, id) || id == GUID_NULL) return false;+ std::vector<IVD*> desks;+ IVDMI* m = Open(desks);+ IVD* d = FindDesktop(desks, id);+ bool ok = d && SUCCEEDED(m->SwitchDesktop(d));+ Free(m, desks);+ return ok;+}+bool mesas::Switch(int index) {std::vector<IVD*> d;IVDMI* m = Open(d);@@ -122,21 +169,11 @@ bool mesas::MoveWindow(HWND h, int index) {IVDMI* m = Open(d);bool ok = false;if (m && index >= 0 && index < (int)d.size()) {- IServiceProvider* sp = nullptr;- if (SUCCEEDED(CoCreateInstance(CLSID_ImmersiveShell, nullptr, CLSCTX_LOCAL_SERVER, IID_PPV_ARGS(&sp))) && sp) {- IAVC* c = nullptr;- if (SUCCEEDED(sp->QueryService(IID_IAVC, IID_IAVC, (void**)&c)) && c) {- IUnknown* view = nullptr;- HRESULT hr = c->GetViewForHwnd(h, &view);- if (SUCCEEDED(hr) && view) {- hr = m->MoveViewToDesktop(view, d[index]);- ok = SUCCEEDED(hr);- view->Release();- }- if (!ok) Log(L"mesas: mover janela falhou (0x%08X)", (unsigned)hr);- c->Release();- }- sp->Release();+ if (IUnknown* view = ViewOf(h)) {+ HRESULT hr = m->MoveViewToDesktop(view, d[index]);+ view->Release();+ ok = SUCCEEDED(hr);+ if (!ok) Log(L"mesas: mover janela falhou (0x%08X)", (unsigned)hr);}}Free(m, d);diff --git a/src/shell/missioncontrol.cpp b/src/shell/missioncontrol.cppindex 236f356..ee90012 100644--- a/src/shell/missioncontrol.cpp+++ b/src/shell/missioncontrol.cpp@@ -31,6 +31,7 @@ struct Win {RECT src{}; // parte da janela mostrada (sem a borda invisível)D2D1_RECT_F from{}, to{};std::wstring title;+ bool placeholder = false;// compositor: a foto da janelaIDCompositionSurface* snap = nullptr;IDCompositionVisual* sv = nullptr;@@ -74,7 +75,8 @@ int g_cur = 0;std::wstring g_appId, g_appName; // Exposé do app: só as janelas deste app (vazio = Mission Control)bool g_appNext; // ToggleApp pediu: a abertura que vem é o Exposé do app// a faixa de Mesas (no Exposé do app ela não existe; no Leopard também não: o Exposé do 10.5 só espalha as janelas)-bool Bar() { return g_appId.empty() && !liquid::Leopard(); }+bool AppExpose() { return !g_appId.empty(); }+bool Bar() { return !AppExpose() && !liquid::Leopard(); }int g_hoverDesk = -1; // Mesa sob o mouse na barra aberta (mostra o X)bool g_hoverX = false; // mouse em cima do XHWND g_xWnd, g_xFor, g_xPending; // X de fechar a janela sob o mouse (mais abaixo)@@ -150,20 +152,27 @@ void WinCtrl(WORD vk) { // Win+Ctrl+tecla: o Windows troca ou cria a área de t// ---- Janelas da mesa atualbool Wanted(HWND h, IVirtualDesktopManager* vdm) {- if (!IsWindowVisible(h) || IsIconic(h) || apps::IsShellWindow(h)) return false;+ if (!IsWindowVisible(h) || apps::IsShellWindow(h) || shell::Nossa(h)) return false;LONG ex = GetWindowLongW(h, GWL_EXSTYLE);if ((ex & WS_EX_TOOLWINDOW) && !(ex & WS_EX_APPWINDOW)) return false;bool lone = GetWindow(h, GW_OWNER) && !(ex & WS_EX_APPWINDOW) && apps::LoneOwned(h);if (GetWindow(h, GW_OWNER) && !(ex & WS_EX_APPWINDOW) && !lone) return false;DWORD cloaked = 0;DwmGetWindowAttribute(h, DWMWA_CLOAKED, &cloaked, sizeof(cloaked));- if (cloaked) return false;+ if (cloaked && (!AppExpose() || (cloaked & ~DWM_CLOAKED_SHELL))) return false;if (GetWindowTextLengthW(h) == 0 && !lone) return false;wchar_t cls[64]; GetClassNameW(h, cls, 64);if (mesa::IsDeskClass(cls) || !wcscmp(cls, L"Shell_TrayWnd")) return false;BOOL on = TRUE;+ if (AppExpose()) return apps::ExposeId(h) == g_appId;if (vdm && SUCCEEDED(vdm->IsWindowOnCurrentVirtualDesktop(h, &on)) && !on) return false;- RECT r;+ RECT r{};+ if (IsIconic(h)) {+ WINDOWPLACEMENT placement{ sizeof(placement) };+ if (!GetWindowPlacement(h, &placement)) return false;+ return MonitorFromRect(&placement.rcNormalPosition, MONITOR_DEFAULTTONEAREST) ==+ MonitorFromRect(&g_mon, MONITOR_DEFAULTTONEAREST);+ }if (FAILED(DwmGetWindowAttribute(h, DWMWA_EXTENDED_FRAME_BOUNDS, &r, sizeof(r)))) GetWindowRect(h, &r);if (r.right - r.left < 60 || r.bottom - r.top < 40) return false;RECT x;@@ -174,11 +183,11 @@ void Collect() {for (auto& w : g_wins) { if (w.th) DwmUnregisterThumbnail(w.th); if (w.mini) DwmUnregisterThumbnail(w.mini); }g_wins.clear();IVirtualDesktopManager* vdm = nullptr;- if (!mesa::Standalone()) // sem o Explorador não há mesas virtuais (a interface é dele)+ if (!AppExpose() && !mesa::Standalone())CoCreateInstance(CLSID_VirtualDesktopManager, nullptr, CLSCTX_ALL, IID_PPV_ARGS(&vdm));std::vector<HWND> hs;for (HWND h = GetTopWindow(nullptr); h; h = GetWindow(h, GW_HWNDNEXT))- if (Wanted(h, vdm) && (Bar() || apps::IdOfWindow(h) == g_appId)) hs.push_back(h);+ if (Wanted(h, vdm)) hs.push_back(h);if (vdm) vdm->Release();// registra de baixo para cima: a miniatura registrada por último fica por cimafor (auto it = hs.rbegin(); it != hs.rend(); ++it) {@@ -187,8 +196,19 @@ void Collect() {if (FAILED(DwmGetWindowAttribute(w.h, DWMWA_EXTENDED_FRAME_BOUNDS, &w.frame, sizeof(w.frame)))) w.frame = wr;w.src = { w.frame.left - wr.left, w.frame.top - wr.top, w.frame.right - wr.left, w.frame.bottom - wr.top };wchar_t t[256]; GetWindowTextW(w.h, t, 256); w.title = t;- if (FAILED(DwmRegisterThumbnail(g_wnd, w.h, &w.th))) continue;- DwmRegisterThumbnail(g_wnd, w.h, &w.mini);+ DWORD cloaked = 0;+ DwmGetWindowAttribute(w.h, DWMWA_CLOAKED, &cloaked, sizeof(cloaked));+ w.placeholder = IsIconic(w.h) || cloaked != 0;+ if (w.placeholder) {+ WINDOWPLACEMENT placement{ sizeof(placement) };+ if (GetWindowPlacement(w.h, &placement)) w.frame = placement.rcNormalPosition;+ if (w.frame.right - w.frame.left < 60 || w.frame.bottom - w.frame.top < 40)+ w.frame = { g_mon.left, g_mon.top, g_mon.left + 640, g_mon.top + 400 };+ } else if (FAILED(DwmRegisterThumbnail(g_wnd, w.h, &w.th))) {+ w.placeholder = true;+ }+ if (IsRectEmpty(&w.frame)) w.frame = { g_mon.left, g_mon.top, g_mon.left + 640, g_mon.top + 400 };+ if (Bar() && !w.placeholder) DwmRegisterThumbnail(g_wnd, w.h, &w.mini);wchar_t cls[64]; GetClassNameW(w.h, cls, 64);Log(L"mission control: janela \"%ls\" (%ls) %dx%d ex=%08X", w.title.c_str(), cls, w.frame.right - w.frame.left, w.frame.bottom - w.frame.top,(unsigned)GetWindowLongW(w.h, GWL_EXSTYLE));@@ -321,10 +341,10 @@ void UpdateThumbs() {p.dwFlags = DWM_TNP_RECTDESTINATION | DWM_TNP_RECTSOURCE | DWM_TNP_VISIBLE | DWM_TNP_OPACITY | DWM_TNP_SOURCECLIENTAREAONLY;p.rcDestination = { (LONG)std::lround(c.left), (LONG)std::lround(c.top), (LONG)std::lround(c.right), (LONG)std::lround(c.bottom) };p.rcSource = w.src;- p.fVisible = !g_compAnim;+ p.fVisible = !g_compAnim && !w.placeholder && !IsIconic(w.h);p.opacity = 255;p.fSourceClientAreaOnly = FALSE;- DwmUpdateThumbnailProperties(w.th, &p);+ if (w.th) DwmUpdateThumbnailProperties(w.th, &p);}}@@ -461,11 +481,34 @@ void Paint() {layer->Release();}windows:+ for (size_t i = 0; i < g_wins.size(); ++i) {+ const Win& w = g_wins[i];+ bool card = w.placeholder || IsIconic(w.h);+ if (!card && (!AppExpose() || (int)i == g_hover || g_closing)) continue;+ D2D1_RECT_F r = Current(w);+ r = { r.left / sc, r.top / sc, r.right / sc, r.bottom / sc };+ D2D1_RECT_F title{ r.left, r.bottom + 5, r.right, r.bottom + 24 };+ if (card) {+ bool dark = ui::Dark();+ br->SetColor(dark ? D2D1::ColorF(0.12f, 0.13f, 0.15f, 0.98f) : D2D1::ColorF(0.92f, 0.93f, 0.95f, 0.98f));+ dc->FillRoundedRectangle(D2D1::RoundedRect(r, 10, 10), br);+ br->SetColor(D2D1::ColorF(dark ? 0xA0A4AB : 0x525863, 0.75f));+ dc->DrawRoundedRectangle(D2D1::RoundedRect(r, 10, 10), br);+ title = { r.left + 10, (r.top + r.bottom) / 2 - 10, r.right - 10, (r.top + r.bottom) / 2 + 10 };+ br->SetColor(D2D1::ColorF(dark ? 0xFFFFFF : 0x1A1D20));+ } else br->SetColor(D2D1::ColorF(1, 1, 1, 0.90f));+ dc->DrawTextW(w.title.c_str(), (UINT32)w.title.size(), g_tfTitle, title, br, D2D1_DRAW_TEXT_OPTIONS_CLIP);+ }// janela sob o mouse: contorno azul e o título embaixoif (g_hover >= 0 && g_hover < (int)g_wins.size() && !g_closing && !g_compAnim) {D2D1_RECT_F c = Current(g_wins[g_hover]);D2D1_RECT_F d = { c.left / sc, c.top / sc, c.right / sc, c.bottom / sc };+ if (g_wins[g_hover].placeholder || IsIconic(g_wins[g_hover].h)) {+ br->SetColor(D2D1::ColorF(0.04f, 0.52f, 1.f));+ dc->DrawRoundedRectangle(D2D1::RoundedRect(d, 10, 10), br, 3.f);+ goto hoverDone;+ }if (liquid::Leopard()) { // Leopard: a janela clareia um pouco e o título vem numa pílula escura no meio delabr->SetColor(D2D1::ColorF(1, 1, 1, 0.10f));dc->FillRectangle(d, br);@@ -710,14 +753,17 @@ void Close(HWND pick) {g_closing = true;g_pick = pick;g_hover = -1;- for (auto& w : g_wins) { w.from = Current(w); w.to = FrameF(w); }+ for (auto& w : g_wins) { w.from = Current(w); w.to = w.placeholder ? w.from : FrameF(w); }// a escolhida volta por cima das outrasif (pick)for (size_t i = 0; i < g_wins.size(); i++)if (g_wins[i].h == pick && i + 1 < g_wins.size()) {Win w = g_wins[i];- DwmUnregisterThumbnail(w.th);- DwmRegisterThumbnail(g_wnd, w.h, &w.th);+ if (w.th) {+ DwmUnregisterThumbnail(w.th);+ w.th = nullptr;+ DwmRegisterThumbnail(g_wnd, w.h, &w.th);+ }g_wins.erase(g_wins.begin() + i);g_wins.push_back(w);break;@@ -759,10 +805,14 @@ void Finish() {if (g_xWnd) ShowWindow(g_xWnd, SW_HIDE);g_xFor = nullptr; g_xHot = false;if (g_cd && g_cwins) { g_cwins->RemoveAllVisuals(); g_wallFx->SetOpacity(1.f); g_barFx->SetOpacity(1.f); g_cd->Commit(); }- if (g_pick) {+ if (g_pick && IsWindow(g_pick)) {+ DWORD cloak = 0;+ if (AppExpose() && SUCCEEDED(DwmGetWindowAttribute(g_pick, DWMWA_CLOAKED, &cloak, sizeof(cloak))) &&+ (cloak & DWM_CLOAKED_SHELL)) mesas::SwitchToWindow(g_pick);+ if (IsIconic(g_pick)) ShowWindowAsync(g_pick, SW_RESTORE);shell::TrazPraFrente(g_pick);- g_pick = nullptr;}+ g_pick = nullptr;if (g_wall) { g_wall->Release(); g_wall = nullptr; }}@@ -1132,17 +1182,18 @@ void missioncontrol::Toggle() {SystemParametersInfoW(SPI_GETDESKWALLPAPER, MAX_PATH, path, 0);if (g_wall) { g_wall->Release(); g_wall = nullptr; }LoadDeskWall(path);- g_comp = shell::Setting(L"mc_motor", L"composicao") == L"composicao" && CompInit();+ LoadDesks();+ SetWindowPos(g_wnd, HWND_TOPMOST, g_mon.left, g_mon.top, (int)W(), (int)H(), SWP_NOACTIVATE);+ Collect();+ bool hasCards = std::any_of(g_wins.begin(), g_wins.end(), [](const Win& w) { return w.placeholder; });+ g_comp = !hasCards && !AppExpose() && shell::Setting(L"mc_motor", L"composicao") == L"composicao" && CompInit();if (!g_comp) {UINT ww = 0, wh = 0; std::vector<BYTE> px;if (path[0] && ui::LoadPng(path, ww, wh, px)) g_wall = ui::Bitmap(ui::Gpu(), ww, wh, px);}- LoadDesks();- SetWindowPos(g_wnd, HWND_TOPMOST, g_mon.left, g_mon.top, (int)W(), (int)H(), SWP_NOACTIVATE);- Collect();- for (auto& w : g_wins) w.from = FrameF(w);g_barFrom = g_barTo = 0;Layout(0);+ for (auto& w : g_wins) w.from = w.placeholder ? w.to : FrameF(w);g_open = true; g_closing = false; g_hover = -1; g_pick = nullptr; g_hoverDesk = -1; g_hoverX = false; g_lDown = false;g_animAt = g_openAt = anim::Now();g_durMs = liquid::On() ? 300.f : std::min(550.f, anim::SpringDuration(RESPONSE, DAMPING) * 1000);diff --git a/src/shell/shell.h b/src/shell/shell.hindex 18bbabd..6eb5a28 100644--- a/src/shell/shell.h+++ b/src/shell/shell.h@@ -147,6 +147,7 @@ struct App {std::wstring launch; // .lnk, .exe ou shell:AppsFolder\AUMIDstd::wstring name;std::wstring exe; // .exe de destino em minúsculas (casa janelas sem AUMID com o atalho fixo)+ std::wstring chromeIcon; // ícone composto que o Chrome fornece para o perfilbool pinned = false;bool finder = false; // o Arquivos (sempre o primeiro)bool recent = false; // fechado há pouco (seção de recentes)@@ -168,6 +169,8 @@ void Relabel(); // nomes dos nossos apps no idioma escolhido (Ajustes > Geral >std::wstring OurName(const std::wstring& exe); // nome de um dos nossos apps no idioma escolhido (caminho ou nome do .exe); vazio: não é nossobool Refresh(); // relê as janelas; true se algo mudoustd::wstring IdOfWindow(HWND h);+std::wstring ExposeId(const std::wstring& id, const std::wstring& exe);+std::wstring ExposeId(HWND h);App* FindById(const std::wstring& id);App* OfWindow(HWND h);void EnsureIcon(App& a, int px);@@ -320,6 +323,7 @@ namespace encaixe { // encaixe.cpp: arrastar a janela até a borda = metade/quavoid Start();void Stop(); // o encaixe do Windows volta como estavavoid Half(HWND h, bool right); // Win+← / Win+→+void Tile(HWND h, RECT target);}namespace memoria { // memoria.cpp: pressão de memória, soneca de apps (App Nap) e memória descartável, como no Macvoid Start();@@ -421,7 +425,8 @@ void Pausar(bool p); // modo jogo: sem o gancho global do mousevoid Foreground(HWND h);bool Owns(HWND h); // janela minimizada por "mostrar a mesa" (não vai para o Dock)}-namespace mesas { // áreas de trabalho virtuais pela interface interna do Explorer (mesas.cpp); false = use os atalhos+namespace mesas { // áreas de trabalho virtuais pela interface interna do Explorer (mesas.cpp)+bool SwitchToWindow(HWND h);bool Switch(int index);bool Create();bool Remove(int index);@@ -608,8 +613,11 @@ void OpenAppsStack(); // Leopard: a pasta Aplicativos como Pilha em Gradevoid OpenDownloadsStack(); // a pilha Downloads (testes: ShellAbrirPainel 15)void ReloadSettings(); // o Ajustes do Sistema mudou tamanho, ampliação...void ApplyTheme(); // claro/escuro mudou-void IconsChanged(); // o pacote de ícones mudou (tema Sequoia/Tahoe): solta os ícones guardados-void SetFullscreen(bool on); // app em tela cheia na frente: some+void IconsChanged(bool repaint = true); // o pacote de ícones mudou (tema Sequoia/Tahoe): solta os ícones guardados+void SetFullscreen(bool on, HMONITOR monitor = nullptr);+bool OnMonitor(HMONITOR monitor);+int ReservedOn(HMONITOR monitor);+void StopSecondary();RECT MinimizeTarget(HWND h = nullptr);RECT AppIconTarget(HWND h); // tela: o ícone do app dono da janela (vazio se não está no Dock) // tela: onde a janela minimizada vai parar (h: no ícone do app com dock_minimizar_no_icone)void BadgesChanged(); // chegou ou saiu notificação: redesenha os badges vermelhosdiff --git a/src/shell/verde.cpp b/src/shell/verde.cppindex e8c515c..39c25ea 100644--- a/src/shell/verde.cpp+++ b/src/shell/verde.cpp@@ -28,11 +28,7 @@ RECT Visible(HWND h, RECT& wr) {}void Place(HWND h, RECT want) {- if (IsZoomed(h)) ShowWindow(h, SW_RESTORE);- RECT wr, vis = Visible(h, wr);- // a borda invisível volta em volta do retângulo pedido- RECT r{ want.left - (vis.left - wr.left), want.top - (vis.top - wr.top), want.right + (wr.right - vis.right), want.bottom + (wr.bottom - vis.bottom) };- SetWindowPos(h, nullptr, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_NOZORDER | SWP_NOACTIVATE);+ encaixe::Tile(h, want);SetForegroundWindow(h);}@@ -309,18 +305,13 @@ void Executar(HWND target, int id) {if (!id || !IsWindow(target)) return;MONITORINFO mi{ sizeof(mi) };GetMonitorInfoW(MonitorFromWindow(target, MONITOR_DEFAULTTONEAREST), &mi);- RECT a = mi.rcWork;- LONG cx = (a.left + a.right) / 2, cy = (a.top + a.bottom) / 2;+ RECT a = shell::WorkAreaFor(MonitorFromWindow(target, MONITOR_DEFAULTTONEAREST));+ if (IsRectEmpty(&a)) a = mi.rcWork;+ LONG cx = a.left + (a.right - a.left) / 2, cy = a.top + (a.bottom - a.top) / 2;const LONG G = 0; // sem vão (o Windows também encaixa colado)Log(L"menu verde: opção %d", id);switch (id) {- case 1:- if (GetPropW(target, L"MacJanela")) { // a nossa barra: o "ampliar" animado da DLL- static UINT zoom = RegisterWindowMessageW(L"MacJanelaAmpliar");- if (!GetPropW(target, L"MacJanelaAmpliada")) PostMessageW(target, zoom, 0, 0);- SetForegroundWindow(target);- } else Place(target, a);- break;+ case 1: Place(target, a); break;case 2: {RECT wr, v = Visible(target, wr);LONG w = std::min(v.right - v.left, a.right - a.left), hh = std::min(v.bottom - v.top, a.bottom - a.top);@@ -362,7 +353,7 @@ void Executar(HWND target, int id) {SetForegroundWindow(target);break;}- case 40: ShowWindow(target, SW_MAXIMIZE); SetForegroundWindow(target); break; // Tela Inteira+ case 40: ShowWindowAsync(target, SW_MAXIMIZE); SetForegroundWindow(target); break;case 41: Place(target, { mi.rcMonitor.left, a.top, cx, a.bottom }); break; // Esquerda da Telacase 42: Place(target, { cx, a.top, mi.rcMonitor.right, a.bottom }); break; // Direita da Tela}