A new style desktop shell for Windows 11: menu bar, Dock, Finder, Spotlight, Control Center and Liquid Glass, in native C++.
Rust
Save dialogs wait for busy apps and resolve special folders (issue #15), laptop brightness via WMI (issue #25), fewer fights with self-maximizing apps (issue #24), issue #8 fixes
Eternity070628a01ba9d28e65
diff --git a/docs/registro-mudancas.txt b/docs/registro-mudancas.txtindex 577057c..a12c848 100644--- a/docs/registro-mudancas.txt+++ b/docs/registro-mudancas.txt@@ -1085,3 +1085,29 @@ Compilado (tudo), instalado, Shell e reserva do Finder reiniciados às 23:07 semsrc\shell\limites.cpp (limites::Maximizada) e main.cpp (OnWinEvent, EVENT_OBJECT_LOCATIONCHANGE de janelas de topo): janela maximizada com barra de título, sem a DLL, que passa da área de trabalho volta para ela, com as bordas invisíveis para fora; no máximo 3 vezes por janela em 10 s.Conferido: Bloco de Notas maximizado ficou em 0,30-3440,1342 (log "limites: maximizada 'Notepad'..."). Compilado e instalado o Shell.DESFAZER: reverter o commit.++[2026-11-22 05:45] Issue #25 (brilho da Central de Controle não funciona).+ O brilho só ia por DDC/CI (monitor externo); a tela embutida de notebook não fala DDC/CI e o controle ficava parado.+ src\shell\central.cpp: sem DDC/CI, lê e grava pelo WMI (root\WMI: WmiMonitorBrightness e WmiMonitorBrightnessMethods.WmiSetBrightness), o mesmo do controle de brilho do Windows, sem administrador. A thread de gravação (BrightWorker) segue a mesma.+ Conferido: compila; neste PC (monitor sem tela embutida) a leitura WMI não acha nada e fica como antes. Não testado num notebook.+ DESFAZER: reverter o commit.++[2026-11-22 05:45] Issue #15 de novo (Photoshop, Illustrator, Figma salvam no lugar errado), reproduzido com o Photoshop 2026 deste PC.+ Causas achadas (src\shell\dialogs.cpp, troca do Abrir/Salvar por fora):+ 1. Depois de trocar de pasta a janela original do Photoshop fica ocupada; as mensagens com 300 ms de espera desistiam em silêncio: o nome escolhido não entrava no campo e o OK ia mesmo assim (o arquivo saía com o nome original, "teste-wacos.psd já existe" no teste). Agora Responde() espera a janela ficar livre, PoeTexto() escreve e confere (até 5 vezes) e as esperas são de segundos.+ 2. Pastas especiais (Mesa, Downloads, Documentos, Bibliotecas) aparecem na barra de endereço pelo nome ("Address: Área de Trabalho"), não pelo caminho: a pasta atual saía vazia, o Finder abria em Documentos em vez de onde o app estava e a entrada na pasta escolhida não se confirmava. KnownFolderByName() resolve pelo nome (o da pasta conhecida, o traduzido da própria pasta e o do disco; com o mesmo nome em duas, fica a do usuário).+ 3. Escolher pasta (Illustrator Exportar para Telas, Figma exportar várias): o "confirma a pasta atual" ia depois de 400 ms fixos; agora só quando a original está mesmo na pasta escolhida (ou depois de ~2,5 s).+ Conferido no Photoshop (Salvar Como e Folder.selectDialog, resultado escolhido gravado e o Finder fechado com código 0): pasta comum e Mesa no OneDrive com nome novo saem certos em ~1 s; a janela de pasta devolve a pasta escolhida. Arquivos de teste apagados. (O Photoshop deste PC cai sozinho às vezes: estouro de pilha numa thread de rede dele, winhttp, sem nada do WacOS na pilha.)+ DESFAZER: reverter o commit.++[2026-11-22 05:45] Issue #24, ajuste: limites::Maximizada brigava 3 vezes com o Photoshop a cada maximizar (ele maximiza com a borda para fora, sem moldura do DWM, e volta). Agora até 3 correções por maximização, mas para quando a janela volta exatamente para onde estava antes da correção ("insistiu"). Bloco de Notas: 2 correções, fica em 0,30-3440,1342; Photoshop: 1 correção e fica como quer.+ DESFAZER: reverter o commit.++[2026-11-22 05:45] Issue #8 (comentário novo do carlosjrrr):+ - Gênio ao restaurar pela Dock maior que a janela e "salto para dentro" no fim: src\shell\genio.cpp lembra (g_lembradas) onde a janela estava de verdade ao minimizar e volta para lá enquanto a posição normal do Windows for a mesma (encaixada/ajustada, a posição normal é a de antes, maior). Log "gênio: volta para onde a janela estava". Não testado com clique na Dock (sem SendInput).+ - Quick Look com rolagem no texto: src\shell\quicklook.cpp (roda, setas, Page Up/Down, Home/End; barrinha fina; lê até 1 MB) e src\finder\main.cpp (painel dos outros temas: roda, até 20000 linhas). Conferido com foto só do painel: rola e a barrinha desce.+ - Central de Notificações: o título "Central de Notificações" e os avisos soltos eram sempre brancos e sumiam sobre janela clara; MedeFundo() olha o topo da coluna antes de aparecer e, claro (> 0,62), escreve escuro. Log da medida.+ - Alerta de Desligar/Reiniciar/Encerrar Sessão do menu da maçã: usava sempre a foto do Mac Studio; agora o mesmo ícone do Sobre Este Mac (o computador em alumínio no modo "este PC", sym:pc em alertas.cpp). O lugar do ícone (em cima à esquerda) continua o do alerta do macOS 26/27 medido.+ - Apps lembram lugar e tamanho: src\comum\app2d.h (CreateMain) grava ao fechar em %APPDATA%\Shell\janela-<classe>.txt e restaura ao abrir (maximizada também), se ainda cair num monitor. Vale para Calendário, Clima, Contatos, Fotos, Lembretes, Música, Relógio, TextEdit, Time Machine e Forçar Encerrar. Conferido no Calendário: mudado para 300,200 1500x900, fechado e reaberto no mesmo lugar.+ Compilados e instalados Shell, Finder e os apps.+ DESFAZER: reverter o commit.diff --git a/src/comum/app2d.h b/src/comum/app2d.hindex 1147091..768e27d 100644--- a/src/comum/app2d.h+++ b/src/comum/app2d.h@@ -447,6 +447,50 @@ inline std::wstring DueText(long long m, bool withTime) {return d;}+// ---- lugar e tamanho da janela lembrados entre uma vez e outra (issue #8, carlosjrrr, 22/11/2026: os apps do WacOS+// podiam ser redimensionados, mas reabriam sempre no tamanho de fábrica, no meio da tela). Um arquivo por app em+// %APPDATA%\Shell (janela-<classe>.txt): "esquerda cima direita baixo maximizada", na posição normal do Windows.+inline std::wstring LembrarArquivo(HWND h) {+ wchar_t cls[64] = {}; GetClassNameW(h, cls, 64);+ return DataPath((std::wstring(L"janela-") + cls + L".txt").c_str());+}+inline LRESULT CALLBACK LembrarSub(HWND h, UINT m, WPARAM w, LPARAM l, UINT_PTR id, DWORD_PTR maxPend) {+ if (m == WM_SHOWWINDOW && w && maxPend) { // estava maximizada: volta maximizada na primeira vez que aparece+ SetWindowSubclass(h, LembrarSub, id, 0);+ PostMessageW(h, WM_SYSCOMMAND, SC_MAXIMIZE, 0);+ }+ if (m == WM_DESTROY) {+ WINDOWPLACEMENT wp{ sizeof(wp) };+ if (GetWindowPlacement(h, &wp)) {+ RECT r = wp.rcNormalPosition;+ bool maxed = wp.showCmd == SW_SHOWMAXIMIZED || (wp.showCmd == SW_SHOWMINIMIZED && (wp.flags & WPF_RESTORETOMAXIMIZED));+ if (r.right - r.left >= 200 && r.bottom - r.top >= 120)+ WriteLines(LembrarArquivo(h), { std::to_wstring(r.left) + L" " + std::to_wstring(r.top) + L" " + std::to_wstring(r.right) + L" " ++ std::to_wstring(r.bottom) + L" " + (maxed ? L"1" : L"0") });+ }+ RemoveWindowSubclass(h, LembrarSub, id);+ }+ return DefSubclassProc(h, m, w, l);+}+inline void Lembrar(HWND h) {+ bool maxed = false;+ auto v = ReadLines(LembrarArquivo(h));+ if (!v.empty()) {+ RECT r{}; int mx = 0;+ if (swscanf_s(v[0].c_str(), L"%ld %ld %ld %ld %d", &r.left, &r.top, &r.right, &r.bottom, &mx) == 5 &&+ r.right - r.left >= 200 && r.bottom - r.top >= 120) {+ // só se ainda cai num monitor que existe (o monitor de antes pode ter sido desligado)+ WINDOWPLACEMENT wp{ sizeof(wp) };+ GetWindowPlacement(h, &wp);+ wp.rcNormalPosition = r; wp.showCmd = SW_HIDE; wp.flags = 0;+ RECT tela = r; // a posição normal é relativa à área de trabalho; o monitor é achado pelo meio dela+ POINT meio{ (tela.left + tela.right) / 2, tela.top + 20 };+ if (MonitorFromPoint(meio, MONITOR_DEFAULTTONULL)) { SetWindowPlacement(h, &wp); maxed = mx != 0; }+ }+ }+ SetWindowSubclass(h, LembrarSub, 0x4C4D, maxed ? 1 : 0);+}+inline HWND CreateMain(HINSTANCE hi, const wchar_t* cls, const wchar_t* title, WNDPROC proc, int w, int h) {WNDCLASSEXW wc{ sizeof(wc) };wc.style = CS_DBLCLKS;@@ -470,6 +514,7 @@ inline HWND CreateMain(HINSTANCE hi, const wchar_t* cls, const wchar_t* title, WSetWindowSubclass(wnd, UnifiedSub, 0x55A1, 0);SetWindowPos(wnd, nullptr, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);}+ if (wnd) Lembrar(wnd);return wnd;}diff --git a/src/finder/main.cpp b/src/finder/main.cppindex c732df1..7d00798 100644--- a/src/finder/main.cpp+++ b/src/finder/main.cpp@@ -3550,6 +3550,9 @@ static bool g_ql;static DWORD g_qlOpenedAt; // para a animação de abrir (zoom + fade)static std::wstring g_qlTextPath;static std::vector<std::wstring> g_qlLines;+// texto com rolagem (issue #8, 22/11/2026): a roda rola a folha; antes só cabia a primeira tela (e no máximo 400 linhas)+static float g_qlTextScroll, g_qlTextMax;+static bool g_qlTextShown; // o Quick Look desenhou uma folha de texto no último quadrostatic IDWriteTextFormat *g_tfMono, *g_tfQlTitle, *g_tfQlButton, *g_tfQlGlyph, *g_tfQlTime, *g_tfQlArtist;const DWORD QL_ANIM_MS = 240, QL_CLOSE_MS = 190;// Quick Look sai do ícone do arquivo e volta para ele ao fechar (como no Mac)@@ -3571,12 +3574,14 @@ static void LoadQlText(const std::wstring& path) {if (path == g_qlTextPath) return;g_qlTextPath = path;g_qlLines.clear();+ g_qlTextScroll = 0;HANDLE h = CreateFileW(path.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr);if (h == INVALID_HANDLE_VALUE) return;- std::vector<char> buf(65536);+ std::vector<char> buf(1024 * 1024);DWORD n = 0;ReadFile(h, buf.data(), (DWORD)buf.size(), &n, nullptr);CloseHandle(h);+ if (n == buf.size()) { int k = 0; while (n > 0 && k < 4 && ((BYTE)buf[n - 1] & 0x80)) { n--; k++; } } // não corta uma letra UTF-8std::wstring text;if (n >= 2 && (BYTE)buf[0] == 0xFF && (BYTE)buf[1] == 0xFE) {text.assign((const wchar_t*)(buf.data() + 2), (n - 2) / 2);@@ -3590,11 +3595,35 @@ static void LoadQlText(const std::wstring& path) {}std::wstring line;for (wchar_t c : text) {- if (c == L'\n') { g_qlLines.push_back(line); line.clear(); if (g_qlLines.size() >= 400) break; }+ if (c == L'\n') { g_qlLines.push_back(line); line.clear(); if (g_qlLines.size() >= 20000) break; }else if (c == L'\t') line += L" ";else if (c != L'\r') line += c;}- if (!line.empty() && g_qlLines.size() < 400) g_qlLines.push_back(line);+ if (!line.empty() && g_qlLines.size() < 20000) g_qlLines.push_back(line);+}++// as linhas visíveis da folha, a partir da rolagem, e a barrinha fina à direita quando há mais texto+static void QlTextLines(ID2D1DeviceContext* dc, ID2D1SolidColorBrush* br, D2D1_RECT_F page, float top, float left, bool dark) {+ const float LH = 17;+ float vis = page.bottom - page.top;+ g_qlTextMax = std::max(0.f, g_qlLines.size() * LH + top + 12 - vis);+ g_qlTextScroll = std::clamp(g_qlTextScroll, 0.f, g_qlTextMax);+ g_qlTextShown = true;+ size_t first = (size_t)(g_qlTextScroll / LH);+ float y = page.top + top - g_qlTextScroll + first * LH;+ for (size_t i = first; i < g_qlLines.size(); i++) {+ if (y > page.bottom) break;+ auto& ln = g_qlLines[i];+ dc->DrawTextW(ln.c_str(), (UINT32)ln.size(), g_tfMono, D2D1::RectF(page.left + left, y, page.right - 10, y + LH), br, D2D1_DRAW_TEXT_OPTIONS_CLIP);+ y += LH;+ }+ if (g_qlTextMax > 0) {+ float tot = vis + g_qlTextMax, th = std::max(28.f, vis * vis / tot), ty = page.top + 3 + (vis - 6 - th) * (g_qlTextScroll / g_qlTextMax);+ D2D1_COLOR_F old = br->GetColor();+ br->SetColor(dark ? D2D1::ColorF(1, 1, 1, 0.35f) : D2D1::ColorF(0, 0, 0, 0.30f));+ dc->FillRoundedRectangle(D2D1::RoundedRect(D2D1::RectF(page.right - 12, ty, page.right - 7.5f, ty + th), 2.25f, 2.25f), br);+ br->SetColor(old);+ }}static int QlItem() {@@ -3932,12 +3961,7 @@ static void DrawQuickLookLeopard(ID2D1DeviceContext* dc, ID2D1SolidColorBrush* bdc->FillRectangle(page, br);dc->PushAxisAlignedClip(Inflate(page, -8), D2D1_ANTIALIAS_MODE_ALIASED);br->SetColor(D2D1::ColorF(0, 0, 0, 0.9f));- float y = page.top + 10;- for (auto& ln : g_qlLines) {- if (y > page.bottom) break;- dc->DrawTextW(ln.c_str(), (UINT32)ln.size(), g_tfMono, D2D1::RectF(page.left + 12, y, page.right - 10, y + 17), br, D2D1_DRAW_TEXT_OPTIONS_CLIP);- y += 17;- }+ QlTextLines(dc, br, page, 10, 12, false);dc->PopAxisAlignedClip();} else { // ícone grande e, embaixo, o nome e as informações em brancofloat size = std::min(200.f, (body.bottom - body.top) - 110);@@ -4010,6 +4034,7 @@ static void DrawQuickLookLeopard(ID2D1DeviceContext* dc, ID2D1SolidColorBrush* b}static void DrawQuickLook(ID2D1DeviceContext* dc, const Palette& pal, ID2D1SolidColorBrush* br) {+ g_qlTextShown = false; // a folha de texto marca de novo se for desenhadaint i = QlItem();if (i < 0) { g_ql = false; return; }const Entry& e = g_items[i];@@ -4136,12 +4161,7 @@ static void DrawQuickLook(ID2D1DeviceContext* dc, const Palette& pal, ID2D1Soliddc->FillRoundedRectangle(D2D1::RoundedRect(page, 6, 6), br);dc->PushAxisAlignedClip(Inflate(page, -10), D2D1_ANTIALIAS_MODE_ALIASED);br->SetColor(pal.text);- float y = page.top + 12;- for (auto& ln : g_qlLines) {- if (y > page.bottom) break;- dc->DrawTextW(ln.c_str(), (UINT32)ln.size(), g_tfMono, D2D1::RectF(page.left + 14, y, page.right - 10, y + 17), br, D2D1_DRAW_TEXT_OPTIONS_CLIP);- y += 17;- }+ QlTextLines(dc, br, page, 12, 14, g_dark);dc->PopAxisAlignedClip();} else { // pasta ou arquivo sem prévia: ícone grande e informaçõesfloat size = std::min(200.f, (body.bottom - body.top) - 120);@@ -6638,6 +6658,11 @@ static LRESULT CALLBACK WndProc(HWND h, UINT m, WPARAM w, LPARAM l) {POINT mp{ GET_X_LPARAM(l), GET_Y_LPARAM(l) }; // em coordenadas de telaScreenToClient(h, &mp);if (QlWheel(ToDip(mp.x, mp.y), delta)) return 0; // foto do Quick Look: zoom+ if (g_ql && !g_qlClosing && g_qlTextShown) { // texto do Quick Look: rola a folha+ g_qlTextScroll = std::clamp(g_qlTextScroll - delta / (float)WHEEL_DELTA * 51.f, 0.f, g_qlTextMax);+ Invalidate();+ return 0;+ }if (ToDip(mp.x, mp.y).x < Lay::SIDEBAR_W) { // sobre a barra lateral: rola só elag_sideScroll = std::clamp(g_sideScroll - delta / (float)WHEEL_DELTA * 52.f, 0.f, SideMaxScroll());Invalidate();diff --git a/src/shell/alertas.cpp b/src/shell/alertas.cppindex 6ac846c..f9bbf4f 100644--- a/src/shell/alertas.cpp+++ b/src/shell/alertas.cpp@@ -20,6 +20,7 @@#include <algorithm>#include <cmath>#include "../comum/idioma.h"+#include "../comum/simbolos.h"namespace {@@ -60,6 +61,7 @@ void SetIcon(const std::wstring& exe) {if (g.icon) { g.icon->Release(); g.icon = nullptr; }g.px.clear(); g.iw = g.ih = 0;g.iconOf = exe;+ if (exe == L"sym:pc") return; // desenhado na hora (DrawIcone)if (exe.rfind(L"pack:", 0) == 0) { // ícone do pacote (ex.: o computador no alerta de desligar)std::wstring png = ui::PackIcon(exe.substr(5));if (png.empty() || !ui::LoadPng(png, g.iw, g.ih, g.px)) ui::ShellImage(L"shell:MyComputerFolder", 128, g.iw, g.ih, g.px, true);@@ -102,6 +104,24 @@ float TextH(const std::wstring& s, float size, DWRITE_FONT_WEIGHT w, float widthreturn h;}+// O ícone no lugar r. "sym:pc": o computador em alumínio do Sobre Este Mac no modo "este PC" (o padrão), o mesmo dos+// Ajustes; antes o alerta de desligar/reiniciar mostrava sempre a foto do Mac Studio (issue #8, carlosjrrr, 22/11/2026)+void DrawIcone(ID2D1DeviceContext* dc, D2D1_RECT_F r) {+ if (g.iconOf == L"sym:pc") {+ bool dark = ui::Dark();+ D2D1_GRADIENT_STOP st[2] = { { 0, dark ? D2D1::ColorF(0.86f, 0.86f, 0.88f, 1) : D2D1::ColorF(0.62f, 0.62f, 0.65f, 1) },+ { 1, dark ? D2D1::ColorF(0.58f, 0.58f, 0.61f, 1) : D2D1::ColorF(0.36f, 0.36f, 0.39f, 1) } };+ ID2D1GradientStopCollection* gs = nullptr; ID2D1LinearGradientBrush* lb = nullptr;+ if (SUCCEEDED(dc->CreateGradientStopCollection(st, 2, &gs)) &&+ SUCCEEDED(dc->CreateLinearGradientBrush(D2D1::LinearGradientBrushProperties({ 0, r.top }, { 0, r.bottom }), gs, &lb)))+ simbolo::Draw(dc, L"desktopcomputer", r, lb);+ if (lb) lb->Release();+ if (gs) gs->Release();+ return;+ }+ if (g.icon) dc->DrawBitmap(g.icon, r, 1, D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC);+}+// Alerta do macOS 26 (Tahoe), medido na referência do usuário (alerta de 260 pt de largura): ícone de 52 pt no canto// de cima à ESQUERDA (22 pt da borda, 24 do topo); título em negrito 13 e texto 13, os dois alinhados à esquerda com// 22 pt de margem; botões em cápsula de 28 pt, um por linha, de borda a borda (16 pt de margem, 8 pt entre eles),@@ -193,7 +213,7 @@ void Paint() {dc->FillRoundedRectangle(D2D1::RoundedRect(D2D1::RectF(0, 0, AW, H), R, R), br);br->SetColor(D2D1::ColorF(0, 0, 0, 0.40f));dc->DrawRoundedRectangle(D2D1::RoundedRect(D2D1::RectF(0.5f, 0.5f, AW - 0.5f, H - 0.5f), R - 0.5f, R - 0.5f), br, 1);- if (g.icon) dc->DrawBitmap(g.icon, D2D1::RectF(24, L_TOP, 24 + 64, L_TOP + 64), 1, D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC);+ DrawIcone(dc, D2D1::RectF(24, L_TOP, 24 + 64, L_TOP + 64));IDWriteTextFormat* tb = ui::FormatFace(L"Lucida Sans Unicode", 13, DWRITE_FONT_WEIGHT_BOLD);IDWriteTextFormat* ti = ui::FormatFace(L"Lucida Sans Unicode", 11, DWRITE_FONT_WEIGHT_NORMAL);for (auto* f : { tb, ti }) if (f) { f->SetWordWrapping(DWRITE_WORD_WRAPPING_WRAP); f->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_NEAR); }@@ -262,7 +282,7 @@ void Paint() {dc->FillEllipse(D2D1::Ellipse(c, 7, 7), br);semaforo::Gloss(dc, c, 7, br);}- if (g.icon) dc->DrawBitmap(g.icon, D2D1::RectF(20, 36, 52, 68), 1, D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC);+ DrawIcone(dc, D2D1::RectF(20, 36, 52, 68));IDWriteTextFormat* ti = ui::Format(13, DWRITE_FONT_WEIGHT_NORMAL, false, DWRITE_TEXT_ALIGNMENT_LEADING);if (ti) ti->SetWordWrapping(DWRITE_WORD_WRAPPING_WRAP);br->SetColor(text);@@ -301,7 +321,7 @@ void Paint() {}if (GoldenAlert()) {D2D1_COLOR_F text = dark ? D2D1::ColorF(1, 1, 1, 0.92f) : D2D1::ColorF(0, 0, 0, 0.88f);- if (g.icon) dc->DrawBitmap(g.icon, D2D1::RectF(G_IX, G_IY, G_IX + G_ICON, G_IY + G_ICON), 1, D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC);+ DrawIcone(dc, D2D1::RectF(G_IX, G_IY, G_IX + G_ICON, G_IY + G_ICON));float y = G_IY + G_ICON + 19;IDWriteTextFormat* tb = ui::Format(13, DWRITE_FONT_WEIGHT_BOLD, false, DWRITE_TEXT_ALIGNMENT_LEADING);IDWriteTextFormat* ti = ui::Format(13, DWRITE_FONT_WEIGHT_NORMAL, false, DWRITE_TEXT_ALIGNMENT_LEADING);@@ -351,7 +371,7 @@ void Paint() {}if (TahoeAlert()) {D2D1_COLOR_F text = dark ? D2D1::ColorF(1, 1, 1, 0.92f) : D2D1::ColorF(0, 0, 0, 0.88f);- if (g.icon) dc->DrawBitmap(g.icon, D2D1::RectF(AW / 2 - T_ICON / 2, T_TOP, AW / 2 + T_ICON / 2, T_TOP + T_ICON), 1, D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC);+ DrawIcone(dc, D2D1::RectF(AW / 2 - T_ICON / 2, T_TOP, AW / 2 + T_ICON / 2, T_TOP + T_ICON));float y = T_TOP + T_ICON + 12;IDWriteTextFormat* tb = ui::Format(13, DWRITE_FONT_WEIGHT_BOLD, false, DWRITE_TEXT_ALIGNMENT_CENTER);IDWriteTextFormat* ti = ui::Format(11, DWRITE_FONT_WEIGHT_NORMAL, false, DWRITE_TEXT_ALIGNMENT_CENTER);@@ -398,7 +418,7 @@ void Paint() {return;}float cx = AW / 2;- if (g.icon) dc->DrawBitmap(g.icon, D2D1::RectF(cx - AICON / 2, APAD, cx + AICON / 2, APAD + AICON), 1, D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC);+ DrawIcone(dc, D2D1::RectF(cx - AICON / 2, APAD, cx + AICON / 2, APAD + AICON));D2D1_COLOR_F text = dark ? D2D1::ColorF(1, 1, 1, 0.92f) : D2D1::ColorF(0, 0, 0, 0.86f);float y = APAD + AICON + 12;IDWriteTextFormat* tb = ui::Format(13, DWRITE_FONT_WEIGHT_BOLD, false, DWRITE_TEXT_ALIGNMENT_CENTER);diff --git a/src/shell/central.cpp b/src/shell/central.cppindex a9a62f5..4e3286c 100644--- a/src/shell/central.cpp+++ b/src/shell/central.cpp@@ -40,6 +40,8 @@#pragma comment(lib, "windowsapp.lib")#pragma comment(lib, "dxva2.lib")+#include <wbemidl.h>+#pragma comment(lib, "wbemuuid.lib")namespace wdr = winrt::Windows::Devices::Radios;namespace wmc = winrt::Windows::Media::Control;@@ -492,16 +494,83 @@ template <class F> void WithMonitor(F f) {DestroyPhysicalMonitors(n, pm.data());}+// Brilho da tela embutida de notebook (issue #25, 22/11/2026): ela não fala DDC/CI (só monitor externo fala), então o+// controle ficava parado. O Windows expõe o brilho dela pelo WMI (root\WMI, WmiMonitorBrightness e o método+// WmiSetBrightness), o mesmo que o controle de brilho do Windows usa; funciona sem administrador.+static IWbemServices* WmiAbre() {+ IWbemLocator* loc = nullptr; IWbemServices* sv = nullptr;+ if (FAILED(CoCreateInstance(CLSID_WbemLocator, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&loc)))) return nullptr;+ BSTR ns = SysAllocString(L"ROOT\\WMI");+ HRESULT hr = loc->ConnectServer(ns, nullptr, nullptr, nullptr, 0, nullptr, nullptr, &sv);+ SysFreeString(ns); loc->Release();+ if (FAILED(hr) || !sv) return nullptr;+ CoSetProxyBlanket(sv, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, nullptr, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, nullptr, EOAC_NONE);+ return sv;+}+static IWbemClassObject* WmiPrimeiro(IWbemServices* sv, const wchar_t* consulta) {+ IEnumWbemClassObject* en = nullptr; IWbemClassObject* o = nullptr; ULONG n = 0;+ BSTR lang = SysAllocString(L"WQL"), q = SysAllocString(consulta);+ if (SUCCEEDED(sv->ExecQuery(lang, q, WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, nullptr, &en)) && en) {+ if (en->Next(3000, 1, &o, &n) != S_OK || !n) o = nullptr;+ en->Release();+ }+ SysFreeString(lang); SysFreeString(q);+ return o;+}+static float WmiBrilhoLe(IWbemServices* sv) { // 0..1, ou -1 se não há tela embutida com brilho+ float r = -1;+ if (IWbemClassObject* o = WmiPrimeiro(sv, L"SELECT CurrentBrightness FROM WmiMonitorBrightness WHERE Active=TRUE")) {+ VARIANT v; VariantInit(&v);+ if (SUCCEEDED(o->Get(L"CurrentBrightness", 0, &v, nullptr, nullptr)) && SUCCEEDED(VariantChangeType(&v, &v, 0, VT_I4)))+ r = std::clamp(v.lVal / 100.f, 0.f, 1.f);+ VariantClear(&v); o->Release();+ }+ return r;+}+static bool WmiBrilhoGrava(IWbemServices* sv, float f) {+ bool ok = false;+ IWbemClassObject* o = WmiPrimeiro(sv, L"SELECT * FROM WmiMonitorBrightnessMethods WHERE Active=TRUE");+ if (!o) return false;+ VARIANT path; VariantInit(&path);+ IWbemClassObject *cls = nullptr, *def = nullptr, *in = nullptr;+ BSTR cn = SysAllocString(L"WmiMonitorBrightnessMethods"), mt = SysAllocString(L"WmiSetBrightness");+ if (SUCCEEDED(o->Get(L"__PATH", 0, &path, nullptr, nullptr)) && path.vt == VT_BSTR &&+ SUCCEEDED(sv->GetObject(cn, 0, nullptr, &cls, nullptr)) && cls &&+ SUCCEEDED(cls->GetMethod(mt, 0, &def, nullptr)) && def && SUCCEEDED(def->SpawnInstance(0, &in)) && in) {+ VARIANT t; VariantInit(&t); t.vt = VT_I4; t.lVal = 0;+ VARIANT b; VariantInit(&b); b.vt = VT_UI1; b.bVal = (BYTE)std::lround(std::clamp(f, 0.f, 1.f) * 100);+ in->Put(L"Timeout", 0, &t, 0);+ in->Put(L"Brightness", 0, &b, 0);+ ok = SUCCEEDED(sv->ExecMethod(path.bstrVal, mt, 0, nullptr, in, nullptr, nullptr));+ }+ if (in) in->Release();+ if (def) def->Release();+ if (cls) cls->Release();+ SysFreeString(cn); SysFreeString(mt); VariantClear(&path); o->Release();+ return ok;+}+// brilho (DDC/CI é lento): gravado numa thread que sempre usa o último valor pedidostd::atomic<float> g_brightWant{ -1 };std::atomic<bool> g_brightBusy{ false };+std::atomic<bool> g_brightWmi{ false }; // a tela é de notebook: o brilho vai pelo WMIvoid BrightWorker() {+ HRESULT ci = CoInitializeEx(nullptr, COINIT_MULTITHREADED);+ IWbemServices* sv = nullptr;float v;- while ((v = g_brightWant.exchange(-1)) >= 0)+ while ((v = g_brightWant.exchange(-1)) >= 0) {+ if (g_brightWmi) {+ if (!sv) sv = WmiAbre();+ if (sv) WmiBrilhoGrava(sv, v);+ continue;+ }WithMonitor([&](HANDLE h) {DWORD mn = 0, cur = 0, mx = 100;if (GetMonitorBrightness(h, &mn, &cur, &mx)) SetMonitorBrightness(h, mn + (DWORD)std::lround(v * (mx - mn)));});+ }+ if (sv) sv->Release();+ if (SUCCEEDED(ci)) CoUninitialize();g_brightBusy = false;}@@ -2199,6 +2268,12 @@ void central::Toggle() {std::thread([] {float b = -1;WithMonitor([&](HANDLE h) { DWORD mn = 0, cur = 0, mx = 100; if (GetMonitorBrightness(h, &mn, &cur, &mx) && mx > mn) b = (float)(cur - mn) / (mx - mn); });+ if (b < 0) { // sem DDC/CI: tela de notebook (WMI)+ HRESULT ci = CoInitializeEx(nullptr, COINIT_MULTITHREADED);+ if (IWbemServices* sv = WmiAbre()) { b = WmiBrilhoLe(sv); sv->Release(); }+ if (SUCCEEDED(ci)) CoUninitialize();+ g_brightWmi = b >= 0;+ } else g_brightWmi = false;{ std::lock_guard<std::mutex> l(g_mx); g_st.bright = b; }if (g_wnd) PostMessageW(g_wnd, WM_CC_UPDATE, 0, 0);}).detach();diff --git a/src/shell/dialogs.cpp b/src/shell/dialogs.cppindex 4f8a04e..0e37299 100644--- a/src/shell/dialogs.cpp+++ b/src/shell/dialogs.cpp@@ -34,12 +34,39 @@ std::map<HWND, DWORD> g_finderTid;std::map<HWND, HWND> g_finderWnd; // ou a janela do Finder reserva que atendestd::atomic<bool> g_stopping{ false }; // o Shell está saindo: não responde mais nada às originais // o Finder que atende cada um (para fechar se o Shell sair)+thread_local DWORD g_textMs = 300; // Finish espera mais: a original pode estar ocupada (abaixo)std::wstring Text(HWND h) {wchar_t buf[2048] = {};- SendMessageTimeoutW(h, WM_GETTEXT, 2048, (LPARAM)buf, SMTO_ABORTIFHUNG, 300, nullptr);+ SendMessageTimeoutW(h, WM_GETTEXT, 2048, (LPARAM)buf, SMTO_ABORTIFHUNG, g_textMs, nullptr);return buf;}+// A original responde a mensagens? Depois de trocar de pasta a janela do Photoshop/Illustrator fica alguns segundos+// ocupada (o programa trabalha a cada troca de pasta); as mensagens com 300 ms de espera desistiam em silêncio: o nome+// escolhido não entrava no campo, o OK (postado) ia mesmo assim e o arquivo saía com o nome original, ou a janela de+// escolher pasta confirmava a pasta de antes (issue #15, 22/11/2026). Espera ela ficar livre, até ms.+bool Responde(HWND dlg, DWORD ms) {+ ULONGLONG fim = GetTickCount64() + ms;+ do {+ DWORD_PTR r = 0;+ if (SendMessageTimeoutW(dlg, WM_NULL, 0, 0, SMTO_NORMAL, 250, &r)) return true;+ if (!IsWindow(dlg)) return false;+ Sleep(50);+ } while (GetTickCount64() < fim);+ return false;+}++// Escreve no campo e confere (até 5 vezes, esperando a janela ficar livre entre elas).+bool PoeTexto(HWND dlg, HWND edit, const std::wstring& v) {+ for (int k = 0; k < 5 && IsWindow(edit); k++) {+ Responde(dlg, 3000);+ SendMessageTimeoutW(edit, WM_SETTEXT, 0, (LPARAM)v.c_str(), SMTO_NORMAL, 3000, nullptr);+ if (Text(edit) == v) return true;+ Sleep(100);+ }+ return false;+}+// Controle pelo id em qualquer nível. Nas janelas antigas com modelo próprio (GetSaveFileName com// template, ex.: o Ableton), o campo do nome (1148) e o dos tipos (1136) ficam dentro da área do// Explorador (DUIViewWndClassName), não como filhos diretos: GetDlgItem não acha.@@ -151,9 +178,68 @@ void CALLBACK VeilTimer(HWND, UINT, UINT_PTR, DWORD) { // segurança: nada ficaif (g_veiled.empty()) { KillTimer(nullptr, g_veilTimer); g_veilTimer = 0; }}+// Pastas especiais pelo nome que a barra de endereço mostra. Nelas a barra não traz o caminho, e sim o nome+// ("Address: Desktop", "Endereço: Área de Trabalho", "Bibliotecas\Documentos"): a pasta atual saía vazia, o Finder+// abria em Documentos em vez de onde o programa estava e a entrada da original na pasta escolhida não se confirmava+// (issue #15, 22/11/2026). Nome → caminho de todas as pastas conhecidas do Windows que têm caminho, montado uma vez.+std::wstring KnownFolderByName(const std::wstring& name) {+ static std::mutex mu;+ static std::map<std::wstring, std::wstring> byName;+ static bool built = false;+ std::lock_guard<std::mutex> lk(mu);+ if (!built) {+ built = true;+ HRESULT ci = CoInitializeEx(nullptr, COINIT_MULTITHREADED);+ IKnownFolderManager* km = nullptr;+ if (SUCCEEDED(CoCreateInstance(CLSID_KnownFolderManager, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&km))) && km) {+ KNOWNFOLDERID* ids = nullptr; UINT n = 0;+ if (SUCCEEDED(km->GetFolderIds(&ids, &n))) {+ for (UINT i = 0; i < n; i++) {+ IKnownFolder* kf = nullptr;+ if (FAILED(km->GetFolder(ids[i], &kf)) || !kf) continue;+ PWSTR path = nullptr;+ if (SUCCEEDED(kf->GetPath(0, &path)) && path) {+ DWORD a = GetFileAttributesW(path);+ if (a != INVALID_FILE_ATTRIBUTES && (a & FILE_ATTRIBUTE_DIRECTORY)) {+ // os nomes que a barra pode mostrar: o da pasta conhecida ("Desktop"), o da própria pasta+ // traduzido ("Área de Trabalho", que a barra usa) e o nome no disco+ std::vector<std::wstring> nomes{ PathFindFileNameW(path) };+ auto nome = [&](IShellItem* it) {+ PWSTR dn = nullptr;+ if (it && SUCCEEDED(it->GetDisplayName(SIGDN_NORMALDISPLAY, &dn)) && dn) { nomes.push_back(dn); CoTaskMemFree(dn); }+ if (it) it->Release();+ };+ IShellItem* it = nullptr;+ if (SUCCEEDED(kf->GetShellItem(0, IID_PPV_ARGS(&it)))) nome(it);+ it = nullptr;+ if (SUCCEEDED(SHCreateItemFromParsingName(path, nullptr, IID_PPV_ARGS(&it)))) nome(it);+ // o mesmo nome em duas (a Mesa do usuário e a pública): fica a do usuário+ static const std::wstring perfil = [] { wchar_t p[MAX_PATH] = {}; GetEnvironmentVariableW(L"USERPROFILE", p, MAX_PATH); return std::wstring(p); }();+ auto doUsuario = [&](const std::wstring& p) { return !perfil.empty() && !_wcsnicmp(p.c_str(), perfil.c_str(), perfil.size()); };+ for (auto& n : nomes) {+ std::wstring k = n; for (auto& ch : k) ch = towlower(ch);+ auto [pos, novo] = byName.emplace(k, path);+ if (!novo && !doUsuario(pos->second) && doUsuario(path)) pos->second = path;+ }+ }+ }+ if (path) CoTaskMemFree(path);+ kf->Release();+ }+ CoTaskMemFree(ids);+ }+ km->Release();+ }+ if (SUCCEEDED(ci)) CoUninitialize();+ }+ std::wstring k = name; for (auto& ch : k) ch = towlower(ch);+ auto it = byName.find(k);+ return it == byName.end() ? L"" : it->second;+}+// Pasta onde a janela original está: a barra de endereço tem o texto "Endereço: C:\..." / "Address: ...".std::wstring CurrentFolder(HWND dlg) {- struct C { std::wstring found; } c;+ struct C { std::wstring found, name; } c;EnumChildWindows(dlg, [](HWND w, LPARAM p) -> BOOL {wchar_t cls[32]; GetClassNameW(w, cls, 32);if (wcscmp(cls, L"ToolbarWindow32")) return TRUE;@@ -163,11 +249,25 @@ std::wstring CurrentFolder(HWND dlg) {std::wstring path = t.substr(colon + 2);DWORD a = GetFileAttributesW(path.c_str());if (a != INVALID_FILE_ATTRIBUTES && (a & FILE_ATTRIBUTE_DIRECTORY)) { ((C*)p)->found = path; return FALSE; }+ if (((C*)p)->name.empty() && !path.empty()) ((C*)p)->name = path; // pasta especial: só o nomereturn TRUE;}, (LPARAM)&c);+ if (c.found.empty() && !c.name.empty()) {+ std::wstring n = c.name;+ if (size_t s = n.find_last_of(L'\\'); s != std::wstring::npos) n = n.substr(s + 1); // "Bibliotecas\Documentos"+ c.found = KnownFolderByName(n);+ }return c.found;}+bool SameFolder(const std::wstring& a, const std::wstring& b) {+ if (a.empty() || b.empty()) return false;+ std::wstring x = a, y = b;+ while (x.size() > 3 && x.back() == L'\\') x.pop_back();+ while (y.size() > 3 && y.back() == L'\\') y.pop_back();+ return !_wcsicmp(x.c_str(), y.c_str());+}+struct Request {HWND dlg, owner;int mode = 0; // 0 abrir, 1 salvar, 2 pasta@@ -221,18 +321,20 @@ ULONGLONG g_lastSavedAt = 0;void Finish(const Request& r, const std::vector<std::wstring>& paths, int type) {if (!IsWindow(r.dlg)) return; // o programa já fechou a janelaif (paths.empty()) { PostMessageW(r.dlg, WM_COMMAND, IDCANCEL, 0); return; }+ g_textMs = 2000;+ Responde(r.dlg, 10000);if (r.mode == 1) { std::lock_guard<std::mutex> lk(g_lastMu); g_lastSaved = paths[0]; g_lastSavedAt = GetTickCount64(); }if (HWND combo = TypeCombo(r.dlg); combo && type >= 0 && type != r.type) {- SendMessageTimeoutW(combo, CB_SETCURSEL, type, 0, SMTO_ABORTIFHUNG, 300, nullptr);- SendMessageTimeoutW(r.dlg, WM_COMMAND, MAKEWPARAM(1136, CBN_SELCHANGE), (LPARAM)combo, SMTO_ABORTIFHUNG, 300, nullptr);+ SendMessageTimeoutW(combo, CB_SETCURSEL, type, 0, SMTO_NORMAL, 3000, nullptr);+ SendMessageTimeoutW(r.dlg, WM_COMMAND, MAKEWPARAM(1136, CBN_SELCHANGE), (LPARAM)combo, SMTO_NORMAL, 3000, nullptr);}HWND edit = NameEdit(r.dlg);if (!edit) edit = FolderEdit(r.dlg);std::wstring value = paths[0];if (paths.size() > 1) { // vários: entra na pasta e depois lista os nomes entre aspasstd::wstring dir = paths[0].substr(0, paths[0].find_last_of(L'\\'));- SendMessageTimeoutW(edit, WM_SETTEXT, 0, (LPARAM)dir.c_str(), SMTO_ABORTIFHUNG, 300, nullptr);- SendMessageTimeoutW(r.dlg, WM_COMMAND, IDOK, 0, SMTO_ABORTIFHUNG, 2000, nullptr);+ PoeTexto(r.dlg, edit, dir);+ SendMessageTimeoutW(r.dlg, WM_COMMAND, IDOK, 0, SMTO_NORMAL, 10000, nullptr);value.clear();for (auto& p : paths) value += L"\"" + std::wstring(PathFindFileNameW(p.c_str())) + L"\" ";} else if (r.mode != 2 && edit == NameEdit(r.dlg)) {@@ -242,34 +344,40 @@ void Finish(const Request& r, const std::vector<std::wstring>& paths, int type)size_t cut = paths[0].find_last_of(L'\\');std::wstring dir = cut == std::wstring::npos ? L"" : paths[0].substr(0, cut);if (dir.size() == 2) dir += L'\\';- if (!dir.empty() && _wcsicmp(CurrentFolder(r.dlg).c_str(), dir.c_str())) {- SendMessageTimeoutW(edit, WM_SETTEXT, 0, (LPARAM)dir.c_str(), SMTO_ABORTIFHUNG, 300, nullptr);- SendMessageTimeoutW(r.dlg, WM_COMMAND, IDOK, (LPARAM)GetDlgItem(r.dlg, IDOK), SMTO_ABORTIFHUNG, 2000, nullptr);+ if (!dir.empty() && !SameFolder(CurrentFolder(r.dlg), dir)) {+ PoeTexto(r.dlg, edit, dir);+ SendMessageTimeoutW(r.dlg, WM_COMMAND, IDOK, (LPARAM)GetDlgItem(r.dlg, IDOK), SMTO_NORMAL, 10000, nullptr);bool entrou = false;- for (int i = 0; i < 30 && IsWindow(r.dlg) && !entrou; i++) { Sleep(40); entrou = !_wcsicmp(CurrentFolder(r.dlg).c_str(), dir.c_str()); }+ ULONGLONG ate = GetTickCount64() + 10000; // pasta do OneDrive/rede e programa ocupado podem demorar+ while (IsWindow(r.dlg) && !entrou && GetTickCount64() < ate) { Sleep(40); if (Responde(r.dlg, 2000)) entrou = SameFolder(CurrentFolder(r.dlg), dir); }if (!IsWindow(r.dlg)) return;if (entrou) value = PathFindFileNameW(paths[0].c_str()); // sem confirmar a pasta, segue com o caminho inteiro- Log(L" original na pasta escolhida: %ls", entrou ? L"sim" : L"não (vai o caminho inteiro)");+ Log(L" original na pasta escolhida: %ls (está em '%ls')", entrou ? L"sim" : L"não (vai o caminho inteiro)", CurrentFolder(r.dlg).c_str());}}- SendMessageTimeoutW(edit, WM_SETTEXT, 0, (LPARAM)value.c_str(), SMTO_ABORTIFHUNG, 300, nullptr);+ // a janela pode refazer o campo do nome ao trocar de pasta: o de antes já não vale+ Responde(r.dlg, 10000);+ if (HWND e2 = NameEdit(r.dlg); e2 && e2 != edit && r.mode != 2) { Log(L" o campo do nome mudou ao trocar de pasta"); edit = e2; }+ if (!PoeTexto(r.dlg, edit, value)) Log(L" o campo do nome não ficou com o escolhido ('%ls')", Text(edit).c_str());PostMessageW(r.dlg, WM_COMMAND, IDOK, (LPARAM)GetDlgItem(r.dlg, IDOK));// A original (fora da tela) pode abrir uma pergunta depois do OK: "já existe, substituir?" ou um aviso de nome// inválido, que nascia fora da tela junto: o programa ficava travado até alguém apertar Esc (Firefox, issue #8,// 21/11/2026). Caixas de mensagem (#32770) viram o alerta do Mac no meio da tela (alertas.cpp, que agora não usa// mais o lugar da original quando ela está fora da tela); qualquer outra vem para o meio da tela, à frente.bool reenviou = false;- for (int i = 0; i < 40 && IsWindow(r.dlg); i++) {+ for (int i = 0; i < 60 && IsWindow(r.dlg); i++) {Sleep(50);HWND pop = GetWindow(r.dlg, GW_ENABLEDPOPUP);if (!pop || pop == r.dlg) {// escolher pasta (VS Code "Abrir Pasta", issue #8): com o caminho de uma pasta no campo, o OK da original// entra nela em vez de devolvê-la e a janela continuava aberta fora da tela (o programa não fazia nada).- // Já dentro da pasta, o campo vazio + OK escolhe a pasta atual.- if (r.mode == 2 && !reenviou && i >= 8) {+ // Já dentro da pasta, o campo vazio + OK escolhe a pasta atual. Só depois de ela estar MESMO na pasta+ // escolhida: com 400 ms fixos, numa pasta que demora a abrir (OneDrive, rede, PC mais lento) o OK ia antes+ // e o programa recebia a pasta onde a janela abriu (Illustrator, Figma, Photoshop: issue #15, 22/11/2026).+ if (r.mode == 2 && !reenviou && i >= 4 && Responde(r.dlg, 5000) && (SameFolder(CurrentFolder(r.dlg), paths[0]) || i >= 50)) {reenviou = true;- Log(L" a original entrou na pasta: confirma a pasta atual");- if (edit) SendMessageTimeoutW(edit, WM_SETTEXT, 0, (LPARAM)L"", SMTO_ABORTIFHUNG, 300, nullptr);+ Log(L" a original entrou na pasta: confirma a pasta atual (%ls)", SameFolder(CurrentFolder(r.dlg), paths[0]) ? L"a escolhida" : L"não confirmada");+ if (edit) PoeTexto(r.dlg, edit, L"");PostMessageW(r.dlg, WM_COMMAND, IDOK, (LPARAM)GetDlgItem(r.dlg, IDOK));}continue;diff --git a/src/shell/genio.cpp b/src/shell/genio.cppindex de39f56..7162d8f 100644--- a/src/shell/genio.cpp+++ b/src/shell/genio.cpp@@ -553,6 +553,13 @@ LRESULT CALLBACK Proc(HWND h, UINT m, WPARAM w, LPARAM l) {}// retângulo visível da janela na tela, mesmo minimizada (posição normal ou maximizada)+// Onde a janela estava de verdade ao minimizar. Encaixada (meia tela, cantos) ou ajustada pelo Shell, a posição "normal"+// do Windows é a de antes do encaixe, maior: ao restaurar pela Dock o gênio crescia até esse tamanho e, no fim, a janela+// saltava para dentro, para o tamanho de verdade (issue #8, carlosjrrr, 22/11/2026; mais visível no Firefox). Vale enquanto+// a posição normal for a mesma de quando ela minimizou.+struct Lembrada { RECT normal, vis, src; int inset; };+std::map<HWND, Lembrada> g_lembradas;+bool WindowArea(HWND h, RECT& vis, RECT& src) {WINDOWPLACEMENT wp{ sizeof(wp) };if (!GetWindowPlacement(h, &wp)) return false;@@ -580,6 +587,16 @@ bool WindowArea(HWND h, RECT& vis, RECT& src) {vis = fb;inset = fb.left - wr.left;src = { inset, fb.top - wr.top, (wr.right - wr.left) - (wr.right - fb.right), (wr.bottom - wr.top) - (wr.bottom - fb.bottom) };+ if (g_lembradas.size() > 128) g_lembradas.clear();+ g_lembradas[h] = { wp.rcNormalPosition, vis, src, inset };+ } else if (!maxed && IsIconic(h)) {+ auto it = g_lembradas.find(h);+ if (it != g_lembradas.end() && EqualRect(&it->second.normal, &wp.rcNormalPosition)) {+ if (!EqualRect(&vis, &it->second.vis))+ Log(L"gênio: volta para onde a janela estava (%d,%d %dx%d), não para a posição normal (%d,%d %dx%d)", it->second.vis.left, it->second.vis.top,+ it->second.vis.right - it->second.vis.left, it->second.vis.bottom - it->second.vis.top, vis.left, vis.top, vis.right - vis.left, vis.bottom - vis.top);+ vis = it->second.vis; src = it->second.src; inset = it->second.inset;+ }}g_a.inset = inset; g_a.maxed = maxed;return vis.right > vis.left && vis.bottom > vis.top;diff --git a/src/shell/limites.cpp b/src/shell/limites.cppindex f02fbe8..3ee4fb7 100644--- a/src/shell/limites.cpp+++ b/src/shell/limites.cpp@@ -8,6 +8,7 @@#include <cmath>#include <vector>#include <map>+#include <set>#include <thread>#include <mutex>@@ -172,19 +173,30 @@ void limites::Stop() {// área de trabalho, com as bordas invisíveis dela para fora (como uma maximizada comum). Só janelas com barra de título// (tela cheia de jogo/vídeo não tem) e no máximo 3 vezes por janela em 10 s, para não brigar com um app que insista.void limites::Maximizada(HWND h) {- if (!h || !IsWindowVisible(h) || !IsZoomed(h) || IsIconic(h) || apps::IsShellWindow(h)) return;+ // Até 3 vezes a cada vez que ela é maximizada (o Bloco de Notas refaz o tamanho depois da primeira e só a segunda+ // acerta). Quem volta exatamente para onde estava antes da correção insiste no lugar dele (o Photoshop maximiza com a+ // borda de redimensionar para fora, sem moldura do DWM): fica como quer, sem briga.+ static std::set<HWND> feitas;+ static std::map<HWND, std::pair<RECT, int>> antes; // onde estava antes da última correção, e quantas foram+ if (!h) return;+ if (!IsZoomed(h) || IsIconic(h)) { feitas.erase(h); antes.erase(h); return; }+ if (!IsWindowVisible(h) || apps::IsShellWindow(h) || feitas.count(h)) return;if ((GetWindowLongW(h, GWL_STYLE) & WS_CAPTION) != WS_CAPTION || GetPropW(h, L"MacJanela")) return; // a da DLL usa o ampliarHMONITOR hm = MonitorFromWindow(h, MONITOR_DEFAULTTONEAREST);RECT wa = shell::WorkAreaFor(hm), wr, fb;if (!GetWindowRect(h, &wr)) return;if (FAILED(DwmGetWindowAttribute(h, DWMWA_EXTENDED_FRAME_BOUNDS, &fb, sizeof(fb)))) fb = wr;if (fb.top >= wa.top - 1 && fb.bottom <= wa.bottom + 1) return; // dentro da área: nada a fazer- static std::map<HWND, std::pair<ULONGLONG, int>> vezes;- ULONGLONG agora = GetTickCount64();- auto& v = vezes[h];- if (agora - v.first > 10000) v = { agora, 0 };- if (++v.second > 3) return;- if (vezes.size() > 64) vezes.clear();+ if (feitas.size() > 64) feitas.clear();+ if (antes.size() > 64) antes.clear();+ auto& a = antes[h];+ if (a.second >= 3 || (a.second > 0 && EqualRect(&a.first, &wr))) {+ feitas.insert(h);+ wchar_t c[64] = {}; GetClassNameW(h, c, 64);+ Log(L"limites: maximizada '%ls' fica onde o programa quer (insistiu)", c);+ return;+ }+ a.first = wr; a.second++;int dl = fb.left - wr.left, dt = fb.top - wr.top, dr = wr.right - fb.right, db = wr.bottom - fb.bottom;SetWindowPos(h, nullptr, wa.left - dl, wa.top - dt, (wa.right - wa.left) + dl + dr, (wa.bottom - wa.top) + dt + db,SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER);diff --git a/src/shell/menubar.cpp b/src/shell/menubar.cppindex 9ac81bc..838d188 100644--- a/src/shell/menubar.cpp+++ b/src/shell/menubar.cpp@@ -3,6 +3,7 @@// Controle e relógio. Ver docs/dock-e-barra-de-menus.md.#include "shell.h"#include "../comum/simbolos.h"+static const wchar_t* IconePC() { return shell::Setting(L"sobre_mac", L"pc") == L"macstudio" ? L"pack:macstudio" : L"sym:pc"; }#include "../menu/context_menu.h"#include <shellapi.h>#include <dwmapi.h>@@ -1126,11 +1127,12 @@ void Run(int id, App* app) {case 102: Open(L"ms-windows-store:"); break;case 103: shell::OpenForceQuit(false); break;case 104: SetSuspendState(FALSE, FALSE, FALSE); break;- // como no Mac: alerta com o ícone do computador, Cancelar | Reiniciar/Desligar (antes era a caixa do Windows)- case 105: alertas::Confirm(Tr(L"Tem certeza de que deseja reiniciar o computador agora?"), L"", Tr(L"Reiniciar"), [] { Shutdown(EWX_REBOOT); }, L"pack:macstudio"); break;- case 106: alertas::Confirm(Tr(L"Tem certeza de que deseja desligar o computador agora?"), L"", Tr(L"Desligar"), [] { Shutdown(EWX_POWEROFF); }, L"pack:macstudio"); break;+ // como no Mac: alerta com o ícone do computador, Cancelar | Reiniciar/Desligar (antes era a caixa do Windows). O ícone é+ // o mesmo do Sobre Este Mac: o computador em alumínio (modo "este PC", o padrão) ou o Mac Studio+ case 105: alertas::Confirm(Tr(L"Tem certeza de que deseja reiniciar o computador agora?"), L"", Tr(L"Reiniciar"), [] { Shutdown(EWX_REBOOT); }, IconePC()); break;+ case 106: alertas::Confirm(Tr(L"Tem certeza de que deseja desligar o computador agora?"), L"", Tr(L"Desligar"), [] { Shutdown(EWX_POWEROFF); }, IconePC()); break;case 107: bloqueio::Lock(); break; // a nossa tela de bloqueio (o LockWorkStation fica desligado pela política enquanto o Shell roda: não fazia nada, issue #8)- case 108: alertas::Confirm(Tr(L"Tem certeza de que deseja encerrar todos os aplicativos e sair agora?"), L"", Tr(L"Encerrar Sessão"), [] { ExitWindowsEx(EWX_LOGOFF, 0); }, L"pack:macstudio"); break;+ case 108: alertas::Confirm(Tr(L"Tem certeza de que deseja encerrar todos os aplicativos e sair agora?"), L"", Tr(L"Encerrar Sessão"), [] { ExitWindowsEx(EWX_LOGOFF, 0); }, IconePC()); break;case 109: shell::Quit(L"menu do logo"); break;case 200: if (app && !app->exe.empty()) ShellExecuteW(nullptr, L"properties", app->exe.c_str(), nullptr, nullptr, SW_SHOWNORMAL); break;case 201: if (app) apps::Hide(*app); break;diff --git a/src/shell/notificacoes.cpp b/src/shell/notificacoes.cppindex ac4ca0d..d24a8f6 100644--- a/src/shell/notificacoes.cpp+++ b/src/shell/notificacoes.cpp@@ -429,6 +429,37 @@ IDWriteTextFormat* Fmt(float size, DWRITE_FONT_WEIGHT w, const wchar_t* family =return tf;}+// O título "Central de Notificações" e os avisos soltos ("Sem Notificações", "N mais antigas") ficam direto sobre o que está+// atrás, sem cartão: brancos, sumiam em cima de uma janela clara (navegador, issue #8, carlosjrrr, 22/11/2026). A Central+// olha o fundo do topo da coluna ao abrir (antes de aparecer) e, se for claro, escreve escuro.+bool g_fundoClaro;+void MedeFundo(HWND wnd) {+ g_fundoClaro = false;+ RECT wr; if (!GetWindowRect(wnd, &wr)) return;+ int w = wr.right - wr.left, h = std::min<int>(wr.bottom - wr.top, MulDiv(160, GetDpiForWindow(wnd) ? GetDpiForWindow(wnd) : 96, 96));+ if (w <= 0 || h <= 0) return;+ const int BW = 24, BH = 12;+ HDC s = GetDC(nullptr); HDC m = CreateCompatibleDC(s);+ BITMAPINFO bi{}; bi.bmiHeader = { sizeof(BITMAPINFOHEADER), BW, -BH, 1, 32, BI_RGB };+ void* bits = nullptr;+ HBITMAP b = CreateDIBSection(s, &bi, DIB_RGB_COLORS, &bits, nullptr, 0);+ if (b && bits) {+ HGDIOBJ o = SelectObject(m, b);+ SetStretchBltMode(m, HALFTONE);+ StretchBlt(m, 0, 0, BW, BH, s, wr.left, wr.top, w, h, SRCCOPY);+ GdiFlush();+ double soma = 0;+ auto* px = (const BYTE*)bits;+ for (int i = 0; i < BW * BH; i++) soma += (0.0722 * px[i * 4] + 0.7152 * px[i * 4 + 1] + 0.2126 * px[i * 4 + 2]) / 255.0;+ g_fundoClaro = soma / (BW * BH) > 0.62;+ Log(L"central de notificações: fundo %ls atrás do título (%.2f)", g_fundoClaro ? L"claro: texto escuro" : L"escuro: texto branco", soma / (BW * BH));+ SelectObject(m, o);+ }+ if (b) DeleteObject(b);+ DeleteDC(m); ReleaseDC(nullptr, s);+}+D2D1_COLOR_F CorSolta() { return g_fundoClaro ? D2D1::ColorF(0, 0, 0, 0.85f) : D2D1::ColorF(1, 1, 1, 0.97f); }+void Text(ID2D1DeviceContext* dc, ID2D1SolidColorBrush* br, const std::wstring& s, IDWriteTextFormat* tf, D2D1_RECT_F r, D2D1_COLOR_F c,DWRITE_TEXT_ALIGNMENT al = DWRITE_TEXT_ALIGNMENT_LEADING, bool shadow = false) {if (!tf || s.empty()) return;@@ -1062,7 +1093,7 @@ void Paint() {case K_HEADER: {static IDWriteTextFormat* tfBig = Fmt(17, DWRITE_FONT_WEIGHT_BOLD, L"SF Pro Display");IDWriteTextFormat* tf = e.layer == 7 && tfBig ? tfBig : g_tfHeader;- Text(dc, br, e.text, tf, D2D1::RectF(r.left + 2, r.top, r.right - 150, r.bottom), D2D1::ColorF(1, 1, 1, 0.97f), DWRITE_TEXT_ALIGNMENT_LEADING, true);+ Text(dc, br, e.text, tf, D2D1::RectF(r.left + 2, r.top, r.right - 150, r.bottom), CorSolta(), DWRITE_TEXT_ALIGNMENT_LEADING, !g_fundoClaro);break;}case K_PILL: {@@ -1108,7 +1139,7 @@ void Paint() {break;}case K_LABEL:- Text(dc, br, e.text, g_tfEmpty, r, D2D1::ColorF(1, 1, 1, 0.92f), DWRITE_TEXT_ALIGNMENT_CENTER, true);+ Text(dc, br, e.text, g_tfEmpty, r, CorSolta(), DWRITE_TEXT_ALIGNMENT_CENTER, !g_fundoClaro);break;case K_EMPTY: {if (leo) smoke(r, 8, 0.75f);@@ -1921,6 +1952,7 @@ void notificacoes::Toggle() {Rebuild();Wake(); // relê já (e a cada 2 s enquanto aberto)Place();+ MedeFundo(g_wnd); // ainda escondida: a foto é só do que está atrásPaint();ShowWindow(g_wnd, SW_SHOWNOACTIVATE);SetForegroundWindow(g_wnd);diff --git a/src/shell/quicklook.cpp b/src/shell/quicklook.cppindex d60a44a..ab72b0a 100644--- a/src/shell/quicklook.cpp+++ b/src/shell/quicklook.cpp@@ -57,6 +57,44 @@ float g_zoom = 1, g_panX, g_panY;bool g_panning; POINT g_panFrom; float g_panX0, g_panY0;D2D1_RECT_F g_bodyR; // onde a foto foi desenhada por último (DIP da janela)bool g_bodyFill; // a foto preenche a moldura (Golden Gate fora da tela cheia) ou cabe nela+// Texto com rolagem (issue #8, carlosjrrr, 22/11/2026: antes só a primeira tela do arquivo aparecia e a roda não+// fazia nada): a roda, as setas e Page Up/Down rolam, com a barrinha fina do Mac à direita enquanto há mais texto.+float g_textY; // quanto o texto subiu (DIP)+IDWriteTextLayout* g_textLay; float g_textLayW, g_textH;+void TextoSolta() { if (g_textLay) { g_textLay->Release(); g_textLay = nullptr; } g_textY = 0; g_textH = 0; }+void DrawTexto(ID2D1RenderTarget* rt, ID2D1SolidColorBrush* br, D2D1_RECT_F body, float px, float py, bool dark) {+ float w = std::max(10.f, body.right - body.left - 2 * px), vis = body.bottom - body.top;+ if (!g_textLay || std::fabs(g_textLayW - w) > 0.5f) {+ if (g_textLay) { g_textLay->Release(); g_textLay = nullptr; }+ ui::dw->CreateTextLayout(g_text.c_str(), (UINT32)std::min<size_t>(g_text.size(), 300000), g_tfText, w, 1e7f, &g_textLay);+ g_textLayW = w; g_textH = 0;+ if (g_textLay) { // o formato pode vir centrado: aqui é do topo, à esquerda, quebrando nas palavras+ g_textLay->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_NEAR);+ g_textLay->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_LEADING);+ g_textLay->SetWordWrapping(DWRITE_WORD_WRAPPING_WRAP);+ }+ DWRITE_TEXT_METRICS tm{};+ if (g_textLay && SUCCEEDED(g_textLay->GetMetrics(&tm))) g_textH = tm.height;+ }+ if (!g_textLay) return;+ float maxY = std::max(0.f, g_textH + 2 * py - vis);+ g_textY = std::clamp(g_textY, 0.f, maxY);+ rt->DrawTextLayout({ body.left + px, body.top + py - g_textY }, g_textLay, br, D2D1_DRAW_TEXT_OPTIONS_CLIP);+ if (maxY > 0) { // a barrinha de rolagem+ float tot = g_textH + 2 * py, th = std::max(28.f, vis * vis / tot), ty = body.top + 3 + (vis - 6 - th) * (g_textY / maxY);+ D2D1_COLOR_F old = br->GetColor();+ br->SetColor(dark ? D2D1::ColorF(1, 1, 1, 0.35f) : D2D1::ColorF(0, 0, 0, 0.30f));+ rt->FillRoundedRectangle(D2D1::RoundedRect(D2D1::RectF(body.right - 8, ty, body.right - 3.5f, ty + th), 2.25f, 2.25f), br);+ br->SetColor(old);+ }+}+bool TextoRola(float dy) { // true se andou+ if (g_text.empty()) return false;+ float y0 = g_textY;+ g_textY = std::max(0.f, g_textY + dy); // o teto é preso no desenho (depende do tamanho do painel)+ return g_textY != y0 || dy > 0;+}+// o retângulo da foto no corpo, com o zoom e o deslocamento (que fica preso: a foto não sai da moldura)D2D1_RECT_F PhotoRect(D2D1_RECT_F body, UINT iw, UINT ih, bool fill) {float bw = body.right - body.left, bh = body.bottom - body.top;@@ -202,9 +240,10 @@ bool IsTextFile(const std::wstring& p) {std::wstring ReadText(const std::wstring& p) {HANDLE f = CreateFileW(p.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, 0, nullptr);if (f == INVALID_HANDLE_VALUE) return L"";- std::vector<char> b(64 * 1024);+ std::vector<char> b(1024 * 1024); // com rolagem dá para ver o arquivo inteiro (até 1 MB)DWORD n = 0; ReadFile(f, b.data(), (DWORD)b.size(), &n, nullptr);CloseHandle(f);+ if (n == b.size()) { int k = 0; while (n > 0 && k < 4 && ((BYTE)b[n - 1] & 0x80)) { n--; k++; } } // cortado no meio de uma letra UTF-8b.resize(n);if (n >= 2 && (BYTE)b[0] == 0xFF && (BYTE)b[1] == 0xFE) return std::wstring((wchar_t*)(b.data() + 2), (n - 2) / 2);int off = n >= 3 && (BYTE)b[0] == 0xEF && (BYTE)b[1] == 0xBB && (BYTE)b[2] == 0xBF ? 3 : 0;@@ -641,7 +680,7 @@ void DrawGolden(ID2D1RenderTarget* rt, float W, float H, bool dark, bool glass)br->SetColor(dark ? D2D1::ColorF(0.1f, 0.1f, 0.1f) : D2D1::ColorF(1, 1, 1));rt->FillRectangle(body, br);br->SetColor(text);- rt->DrawTextW(g_text.c_str(), (UINT32)std::min<size_t>(g_text.size(), 20000), g_tfText, D2D1::RectF(body.left + 18, body.top + 14, body.right - 18, body.bottom), br, D2D1_DRAW_TEXT_OPTIONS_CLIP);+ DrawTexto(rt, br, body, 18, 14, dark);} else if (g_bmp) { // a foto preenche a moldura// tela cheia: a foto inteira (o vidro aparece nas sobras); normal: o painel já tem a proporção da foto.// Com zoom, amplia em volta do ponteiro e o arrasto move (PhotoRect)@@ -837,7 +876,7 @@ void Paint() {br->SetColor(D2D1::ColorF(1, 1, 1, 1));rt->FillRectangle(body, br);br->SetColor(D2D1::ColorF(0, 0, 0, 0.9f));- rt->DrawTextW(g_text.c_str(), (UINT32)std::min<size_t>(g_text.size(), 20000), g_tfText, D2D1::RectF(body.left + 14, body.top + 10, body.right - 14, body.bottom), br, D2D1_DRAW_TEXT_OPTIONS_CLIP);+ DrawTexto(rt, br, body, 14, 10, false);} else {if (g_bmpRt != rt && g_bmp) { g_bmp->Release(); g_bmp = nullptr; }if (!g_bmp && !g_px.empty()) { g_bmp = ui::Bitmap(rt, g_iw, g_ih, g_px); g_bmpRt = rt; }@@ -886,7 +925,7 @@ void Paint() {rt->PushAxisAlignedClip(body, D2D1_ANTIALIAS_MODE_ALIASED);if (!g_text.empty()) {br->SetColor(dark ? D2D1::ColorF(1, 1, 1, 0.88f) : D2D1::ColorF(0, 0, 0, 0.88f));- rt->DrawTextW(g_text.c_str(), (UINT32)std::min<size_t>(g_text.size(), 20000), g_tfText, D2D1::RectF(body.left + 18, body.top + 14, body.right - 18, body.bottom), br, D2D1_DRAW_TEXT_OPTIONS_CLIP);+ DrawTexto(rt, br, body, 18, 14, dark);} else {if (g_bmpRt != rt && g_bmp) { g_bmp->Release(); g_bmp = nullptr; }if (!g_bmp && !g_px.empty()) { g_bmp = ui::Bitmap(rt, g_iw, g_ih, g_px); g_bmpRt = rt; }@@ -938,6 +977,7 @@ void Load(const std::wstring& path) {g_name = path.substr(path.find_last_of(L"\\/") + 1);g_app = DefaultAppName(path);g_text.clear(); g_px.clear(); g_iw = g_ih = 0;+ TextoSolta();if (g_bmp) { g_bmp->Release(); g_bmp = nullptr; }int gen = ++g_gen;LoadInfo(path);@@ -1171,6 +1211,7 @@ LRESULT CALLBACK Proc(HWND h, UINT m, WPARAM w, LPARAM l) {return HTCLIENT;}case WM_MOUSEWHEEL: { // zoom da foto em volta do ponteiro (issue #8)+ if (!g_text.empty()) { TextoRola(-GET_WHEEL_DELTA_WPARAM(w) * 0.6f); dica::Esconde(); Paint(); return 0; } // texto: rolaif (!Zoomable()) return 0;POINT p{ (short)LOWORD(l), (short)HIWORD(l) }; ScreenToClient(h, &p);float sc = Sc(), x = p.x / sc, y = p.y / sc;@@ -1272,6 +1313,12 @@ LRESULT CALLBACK Proc(HWND h, UINT m, WPARAM w, LPARAM l) {if (w == VK_ESCAPE && g_full) { g_full = false; ZoomReset(); Place(); Paint(); SyncBack(); return 0; }if (w == VK_ESCAPE || w == VK_SPACE) { quicklook::Close(); return 0; }if (w == VK_RETURN) { std::wstring p = g_path; quicklook::Close(); OpenPath(p); return 0; }+ if (!g_text.empty()) { // texto: setas, Page Up/Down, Home/End rolam+ RECT cr; GetClientRect(h, &cr);+ float pg = std::max(60.f, cr.bottom / Sc() - BAR - 40);+ float dy = w == VK_DOWN ? 40.f : w == VK_UP ? -40.f : w == VK_NEXT ? pg : w == VK_PRIOR ? -pg : w == VK_END ? 1e7f : w == VK_HOME ? -1e7f : 0.f;+ if (dy != 0) { TextoRola(dy); Paint(); }+ }return 0;case WM_MOVE: Paint(); return 0;case WM_WINDOWPOSCHANGED: SyncBack(); break;