Skip to content

armgit / WacOS

Public Imported from GitHub
0

A new style desktop shell for Windows 11: menu bar, Dock, Finder, Spotlight, Control Center and Liquid Glass, in native C++.

Rust

Bug sweep: settings file, thread races, leaks, settings that did nothing, missing translations

Eternity0706280c0115d531b5
diff --git a/docs/registro-mudancas.txt b/docs/registro-mudancas.txt
index b6fdab2..8b53e4b 100644
--- a/docs/registro-mudancas.txt
+++ b/docs/registro-mudancas.txt
@@ -1322,3 +1322,22 @@ Compilado (tudo), instalado, Shell e reserva do Finder reiniciados às 23:07 sem
- src/shell/dock.cpp (dock::Raise), menubar.cpp (volta da tela cheia e Displays) e revelar.cpp (ShowOverlay): pegam antes de subir as nossas e devolvem depois.
Testado: janela Tk descartável "sempre por cima" no meio do topo continuou acima do Dock e da barra com o Launchpad abrindo e fechando por mensagem. Não testado: o clique na mesa (sem cliques simulados) e o Vibrance (não instalado).
DESFAZER: reverter o commit.
+
+[2026-11-23 03:15, hora do PC] Caça a bugs no código inteiro (sessão caca-bugs, branch claude/caca-bugs-4d948f). Nada mudou no sistema: só código.
+ - src/comum/ajustes_arquivo.h (novo), src/shell/main.cpp, src/ajustes/main.cpp: o ajustes.txt era lido em pedaços de 512 caracteres. apps_ordem e launchpad_ocultos (nomes de apps com "|") passam disso: a linha era cortada e a gravação seguinte salvava a lista cortada (ordem do Launchpad/Apps perdida). Agora lê linhas de qualquer tamanho e grava num .tmp trocado de uma vez (quem lê no meio não vê o arquivo vazio; o Ajustes relia vazio e regravava só a chave dele). Testado: linha de 7.090 caracteres com acentos, ida e volta igual, BOM mantido.
+ - src/shell/main.cpp: shell::Setting/SetSetting/LoadSettings com trava (SRWLOCK). O mapa g_settings era lido de várias threads enquanto a interface o trocava inteiro.
+ - src/shell/menus.cpp e src/menu/context_menu.cpp: GoldenIcon sempre devolvia false (o "if" tinha ficado dentro do comentário da linha do "for"): no Golden Gate nenhum item de menu ganhava símbolo.
+ - src/janelas/controles.cpp (DLL das janelas, dentro dos apps): o ícone grande de cada caixa de mensagem no visual do Mac nunca era destruído (um objeto USER perdido por alerta, no processo do app).
+ - src/shell/memoria.cpp: app em soneca (App Nap) que fechava a janela e ficava na bandeja (Discord, Spotify) saía da lista ainda com o modo de eficiência ligado e seguia lento ao ser reaberto. Agora acorda antes de sair da lista.
+ - src/shell/notificacoes.cpp: com "Banners do Mac" desligado os alarmes do Relógio e os avisos de Lembretes/Calendário não apareciam nem tocavam (não têm aviso do Windows para cair no lugar). Eles seguem saindo no banner.
+ - src/shell/spotlight.cpp: SaveLearned abria e zerava o arquivo antes de pegar a trava; duas gravações de threads diferentes se misturavam (as linhas absurdas que o LoadLearned conserta). Agora trava antes e grava em .tmp.
+ - src/shell/ilha.cpp: histórico de cópias: duas gravações quase juntas, a mais nova falhava ao abrir o .tmp e o arquivo ficava com a lista anterior (agora uma por vez, só a mais nova). Tamanho de arquivo inválido virava um vetor de 4 GB.
+ - src/shell/atalhos.cpp e apps.cpp: o mesmo do tamanho inválido (GetFileSize falhando) ao ler o arquivo do Ableton e o AppxManifest.
+ - src/shell/dialogs.cpp: as leituras do combo de tipos da janela de Abrir/Salvar de outro programa iam sem tempo-limite (programa ocupado segurava o Shell).
+ - src/shell/atualizacao.cpp: com "Avisar quando houver atualização" desligado o Shell não roda mais o PowerShell a cada 6 h; script que passa de 60 s é encerrado (antes ficava rodando escondido). src/ajustes/paginas.cpp: o mesmo encerramento na conferência da página Atualização.
+ - src/ajustes/paginas.cpp: "Abrir pastas no Finder" rodava o Finder e esperava até 15 s na thread da interface do Ajustes; agora numa thread. Tirado o bloco lockbg (fundo da tela de bloqueio), sem uso desde que a página saiu em 21/11.
+ - src/shell/revelar.cpp + main.cpp: "Clicar no papel de parede para mostrar a mesa": com o Shell aberto em "Nunca", trocar a opção não fazia nada até reiniciar. Agora liga na hora.
+ - src/shell/progresso.cpp: a lista de posições das janelas de cópia do Windows não apagava as que já fecharam.
+ - Tradução: filtros das janelas de abrir/salvar (Ajustes, Pré-Visualização, QuickTime, TextEdit), "Escolher" (ícone próprio), repetição dos alarmes do Relógio e o erro do Direct2D no Ajustes passavam sem Tr() ou sem par no dicionário; os 8 textos novos estão nos 11 dicionários.
+ Compilado (shell, ajustes, apps, preview, janelas 32/64). NÃO instalado nem conferido na tela: só os testes acima.
+ DESFAZER: reverter o commit.
diff --git a/src/ajustes/main.cpp b/src/ajustes/main.cpp
index 79a2bb1..ce7ebca 100644
--- a/src/ajustes/main.cpp
+++ b/src/ajustes/main.cpp
@@ -17,6 +17,7 @@
#include <cstdarg>
#include "../comum/ampliacao.h" // botão verde com a animação do ampliar do Shell
#include "../comum/semaforo.h"
+#include "../comum/ajustes_arquivo.h"
#include "../comum/leopard.h" // tema Mac OS X Leopard: barra metálica de ponta a ponta
// Libera o SetForegroundWindow (a última entrada foi nossa). Alt com uma tecla sem função (vkE8) no meio: Alt sozinho,
@@ -160,17 +161,11 @@ bool ReadDark() {
}
void LoadSettings() {
- g_settings.clear();
- FILE* fp = nullptr;
- if (_wfopen_s(&fp, g_settingsPath.c_str(), L"r, ccs=UTF-8") || !fp) return;
- wchar_t line[512];
- while (fgetws(line, 512, fp)) {
- std::wstring s = line;
- while (!s.empty() && (s.back() == L'\n' || s.back() == L'\r' || s.back() == L' ')) s.pop_back();
- size_t eq = s.find(L'=');
- if (eq != std::wstring::npos && !s.empty() && s[0] != L'#') g_settings[s.substr(0, eq)] = s.substr(eq + 1);
- }
- fclose(fp);
+ // linhas de qualquer tamanho: com fgetws(512) a apps_ordem do Launchpad era cortada e a próxima gravação salvava
+ // a lista cortada. Sem conseguir abrir (arquivo trocado naquele instante), fica o que já estava lido: zerar aqui
+ // fazia o SetSetting regravar o arquivo só com a chave nova.
+ std::map<std::wstring, std::wstring> novo;
+ if (ajarq::Ler(g_settingsPath, novo)) g_settings.swap(novo);
}
} // namespace
@@ -218,11 +213,7 @@ void aj::SetSetting(const wchar_t* key, const std::wstring& v) {
if (g_pendKey == key) { g_pendKey.clear(); if (g_hwnd) KillTimer(g_hwnd, T_SLIDE); }
LoadSettings(); // o Shell também grava aqui: parte do arquivo atual
g_settings[key] = v;
- FILE* fp = nullptr;
- if (!_wfopen_s(&fp, g_settingsPath.c_str(), L"w, ccs=UTF-8") && fp) {
- for (auto& [k, val] : g_settings) fwprintf(fp, L"%ls=%ls\n", k.c_str(), val.c_str());
- fclose(fp);
- }
+ ajarq::Gravar(g_settingsPath, g_settings); // atômico: o Shell nunca lê o arquivo pela metade
// avisa o Shell (Dock, barra de menus) para reler os ajustes
static UINT msg = RegisterWindowMessageW(L"ShellAjustesMudaram");
HWND sh = FindWindowExW(HWND_MESSAGE, nullptr, L"ShellMensagens", nullptr);
@@ -2323,7 +2314,7 @@ int WINAPI wWinMain(HINSTANCE hi, HINSTANCE, LPWSTR, int) {
g_tahoe = tahoe::On();
ApplyWindowTheme();
SetWindowPos(g_hwnd, nullptr, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
- if (!gfx::Init(g_hwnd)) { MessageBoxW(nullptr, L"Não foi possível iniciar o Direct2D.", L"Ajustes do Sistema", MB_ICONERROR); return 1; }
+ if (!gfx::Init(g_hwnd)) { MessageBoxW(nullptr, Tr(L"Não foi possível iniciar o Direct2D."), Tr(L"Ajustes do Sistema"), MB_ICONERROR); return 1; }
CreateFormats();
shadow::Create(g_hwnd);
diff --git a/src/ajustes/paginas.cpp b/src/ajustes/paginas.cpp
index 6e2c9b5..1354a35 100644
--- a/src/ajustes/paginas.cpp
+++ b/src/ajustes/paginas.cpp
@@ -425,7 +425,8 @@ static void UpdCheck() {
std::wstring cmd = L"powershell.exe -NoProfile -ExecutionPolicy Bypass -File \"" + UpdScript() + L"\" -Verificar -Saida \"" + f + L"\" -Bin \"" + BinDir() + L"\"";
STARTUPINFOW si{ sizeof(si) }; PROCESS_INFORMATION pi{};
if (CreateProcessW(nullptr, cmd.data(), nullptr, nullptr, FALSE, CREATE_NO_WINDOW, nullptr, nullptr, &si, &pi)) {
- WaitForSingleObject(pi.hProcess, 45000);
+ // rede parada: encerra o script (antes ele seguia rodando escondido depois de o Ajustes desistir)
+ if (WaitForSingleObject(pi.hProcess, 45000) == WAIT_TIMEOUT) TerminateProcess(pi.hProcess, 1);
CloseHandle(pi.hThread); CloseHandle(pi.hProcess);
}
FILE* fp = nullptr;
@@ -653,7 +654,8 @@ Page Geral() {
Toggle(L"Abrir pastas no Finder", [] { return Setting(L"finder_padrao", L"1") == L"1"; },
[](bool on) {
SetSetting(L"finder_padrao", on ? L"1" : L"0");
- RunHidden(L"\"" + BinDir() + L"\\WacOSFinder.exe\" --quieto --padrao " + (on ? L"on" : L"off"));
+ // numa thread: o Finder grava no Registro e o Ajustes esperava até 15 s parado
+ std::thread([on] { RunHidden(L"\"" + BinDir() + L"\\WacOSFinder.exe\" --quieto --padrao " + (on ? L"on" : L"off")); }).detach();
}, L"Downloads do navegador, \"Mostrar na pasta\" e o Win+E também"),
// Só o Dock e a barra de menus (modo=dock, shell::SoDock): o resto fica com o Windows. Pastas voltam ao
// Explorador (o "Abrir pastas no Finder" de antes é guardado e volta no modo completo). Reinicia o Shell.
@@ -1838,7 +1840,7 @@ static bool g_allPhotos; // Imagem de Fundo: "Mostrar Todas"
void AddPhoto() {
IFileOpenDialog* d = nullptr;
if (FAILED(CoCreateInstance(CLSID_FileOpenDialog, nullptr, CLSCTX_ALL, IID_PPV_ARGS(&d)))) return;
- COMDLG_FILTERSPEC spec[] = { { L"Imagens", L"*.jpg;*.jpeg;*.png;*.bmp" } };
+ COMDLG_FILTERSPEC spec[] = { { Tr(L"Imagens"), L"*.jpg;*.jpeg;*.png;*.bmp" } };
d->SetFileTypes(1, spec);
if (SUCCEEDED(d->Show(Window()))) {
IShellItem* it = nullptr;
@@ -2139,162 +2141,6 @@ Page TempoUso() {
}
// ================= Tela Bloqueada
-// ---- Fundo da tela de bloqueio: imagem ou vídeo escolhido aqui.
-// Guardado em %APPDATA%\Shell\bloqueio\fundo.jpg (+ fundo.mp4 no vídeo; o .jpg é o 1º quadro, usado no vidro do
-// relógio e enquanto o vídeo carrega). Ajustes bloqueio_fundo / bloqueio_video. Quando a tela de logon do Windows
-// é a do projeto (AuthUX, pasta C:\Windows\Web\Screen\macOS), os dois vão também para lá como
-// personalizado.jpg / personalizado.mp4: a pasta é só de administradores, então o Windows pede a confirmação.
-namespace lockbg {
-const wchar_t* AUTHUX = L"C:\\Windows\\Web\\Screen\\macOS";
-std::wstring Dir() {
- PWSTR p = nullptr; std::wstring d;
- if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, nullptr, &p))) { d = std::wstring(p) + L"\\Shell\\bloqueio"; CoTaskMemFree(p); }
- SHCreateDirectoryExW(nullptr, d.c_str(), nullptr);
- return d;
-}
-bool Exists(const std::wstring& f) { return !f.empty() && GetFileAttributesW(f.c_str()) != INVALID_FILE_ATTRIBUTES; }
-
-// grava um HBITMAP ou um arquivo de imagem como JPEG (WIC)
-bool SaveJpeg(IWICImagingFactory* wic, IWICBitmapSource* src, const std::wstring& out) {
- IWICStream* st = nullptr; IWICBitmapEncoder* enc = nullptr; IWICBitmapFrameEncode* fr = nullptr; IPropertyBag2* bag = nullptr;
- IWICFormatConverter* cv = nullptr;
- bool ok = false;
- if (SUCCEEDED(wic->CreateStream(&st)) && SUCCEEDED(st->InitializeFromFilename(out.c_str(), GENERIC_WRITE)) &&
- SUCCEEDED(wic->CreateEncoder(GUID_ContainerFormatJpeg, nullptr, &enc)) && SUCCEEDED(enc->Initialize(st, WICBitmapEncoderNoCache)) &&
- SUCCEEDED(enc->CreateNewFrame(&fr, &bag))) {
- PROPBAG2 opt{}; wchar_t nome[] = L"ImageQuality"; opt.pstrName = nome;
- VARIANT v; VariantInit(&v); v.vt = VT_R4; v.fltVal = 0.92f;
- bag->Write(1, &opt, &v);
- if (SUCCEEDED(fr->Initialize(bag)) && SUCCEEDED(wic->CreateFormatConverter(&cv)) &&
- SUCCEEDED(cv->Initialize(src, GUID_WICPixelFormat24bppBGR, WICBitmapDitherTypeNone, nullptr, 0, WICBitmapPaletteTypeCustom))) {
- UINT w = 0, h = 0; cv->GetSize(&w, &h);
- WICPixelFormatGUID pf = GUID_WICPixelFormat24bppBGR;
- ok = SUCCEEDED(fr->SetSize(w, h)) && SUCCEEDED(fr->SetPixelFormat(&pf)) && SUCCEEDED(fr->WriteSource(cv, nullptr)) &&
- SUCCEEDED(fr->Commit()) && SUCCEEDED(enc->Commit());
- }
- }
- for (IUnknown* u : { (IUnknown*)cv, (IUnknown*)bag, (IUnknown*)fr, (IUnknown*)enc, (IUnknown*)st }) if (u) u->Release();
- if (!ok) DeleteFileW(out.c_str());
- return ok;
-}
-bool ImageToJpeg(const std::wstring& in, const std::wstring& out) {
- IWICImagingFactory* wic = nullptr; IWICBitmapDecoder* dec = nullptr; IWICBitmapFrameDecode* fr = nullptr;
- bool ok = SUCCEEDED(CoCreateInstance(CLSID_WICImagingFactory, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&wic))) &&
- SUCCEEDED(wic->CreateDecoderFromFilename(in.c_str(), nullptr, GENERIC_READ, WICDecodeMetadataCacheOnDemand, &dec)) &&
- SUCCEEDED(dec->GetFrame(0, &fr)) && SaveJpeg(wic, fr, out);
- for (IUnknown* u : { (IUnknown*)fr, (IUnknown*)dec, (IUnknown*)wic }) if (u) u->Release();
- return ok;
-}
-// Um quadro do vídeo (a 1 s do começo), decodificado do MESMO jeito que a tela de logon toca o vídeo
-// (Media Foundation, SourceReader convertendo para RGB32). Se aqui não decodifica (HEVC sem a extensão, AV1, arquivo
-// quebrado...), lá a tela ficaria preta: o vídeo é recusado. A miniatura do Windows não serve para isso (ela existe
-// mesmo quando o vídeo não toca, e o primeiro quadro costuma ser preto).
-bool VideoFrameToJpeg(const std::wstring& in, const std::wstring& out) {
- if (FAILED(MFStartup(MF_VERSION, MFSTARTUP_LITE))) return false;
- IMFAttributes* at = nullptr; IMFSourceReader* rd = nullptr; IMFMediaType* mt = nullptr; IMFMediaType* cur = nullptr;
- IMFSample* smp = nullptr; IMFMediaBuffer* buf = nullptr; IMF2DBuffer* b2 = nullptr;
- IWICImagingFactory* wic = nullptr; IWICBitmap* bmp = nullptr;
- bool ok = false;
- const DWORD V = (DWORD)MF_SOURCE_READER_FIRST_VIDEO_STREAM;
- do {
- if (FAILED(MFCreateAttributes(&at, 1)) || FAILED(at->SetUINT32(MF_SOURCE_READER_ENABLE_VIDEO_PROCESSING, TRUE))) break;
- if (FAILED(MFCreateSourceReaderFromURL(in.c_str(), at, &rd))) break;
- if (FAILED(MFCreateMediaType(&mt)) || FAILED(mt->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video)) || FAILED(mt->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_RGB32))) break;
- if (FAILED(rd->SetCurrentMediaType(V, nullptr, mt))) break; // sem decodificador para este vídeo
- UINT32 w = 0, h = 0;
- if (FAILED(rd->GetCurrentMediaType(V, &cur)) || FAILED(MFGetAttributeSize(cur, MF_MT_FRAME_SIZE, &w, &h)) || !w || !h) break;
- PROPVARIANT pos; PropVariantInit(&pos); pos.vt = VT_I8; pos.hVal.QuadPart = 10000000; // 1 s
- rd->SetCurrentPosition(GUID_NULL, pos);
- for (int n = 0; n < 60 && !smp; n++) {
- DWORD flags = 0; LONGLONG ts = 0;
- if (FAILED(rd->ReadSample(V, 0, nullptr, &flags, &ts, &smp))) break;
- if (flags & MF_SOURCE_READERF_ENDOFSTREAM) { // vídeo com menos de 1 s: do começo
- if (smp) break;
- pos.hVal.QuadPart = 0; rd->SetCurrentPosition(GUID_NULL, pos);
- }
- }
- if (!smp || FAILED(smp->ConvertToContiguousBuffer(&buf))) break;
- std::vector<BYTE> px((size_t)w * h * 4);
- BYTE* scan = nullptr; LONG pitch = 0;
- if (SUCCEEDED(buf->QueryInterface(IID_PPV_ARGS(&b2))) && SUCCEEDED(b2->Lock2D(&scan, &pitch))) {
- for (UINT32 y = 0; y < h; y++) memcpy(&px[(size_t)y * w * 4], scan + (LONG_PTR)y * pitch, (size_t)w * 4);
- b2->Unlock2D();
- } else {
- BYTE* d = nullptr; DWORD len = 0;
- if (FAILED(buf->Lock(&d, nullptr, &len)) || len < px.size()) break;
- memcpy(px.data(), d, px.size());
- buf->Unlock();
- }
- bool algo = false; // quadro todo preto = não decodificou de verdade
- for (size_t k = 0; k < px.size() && !algo; k += 4 * 97) algo = px[k] > 12 || px[k + 1] > 12 || px[k + 2] > 12;
- if (!algo) break;
- if (FAILED(CoCreateInstance(CLSID_WICImagingFactory, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&wic)))) break;
- if (FAILED(wic->CreateBitmapFromMemory(w, h, GUID_WICPixelFormat32bppBGR, w * 4, (UINT)px.size(), px.data(), &bmp))) break;
- ok = SaveJpeg(wic, bmp, out);
- } while (false);
- for (IUnknown* u : { (IUnknown*)bmp, (IUnknown*)wic, (IUnknown*)b2, (IUnknown*)buf, (IUnknown*)smp, (IUnknown*)cur, (IUnknown*)mt, (IUnknown*)rd, (IUnknown*)at }) if (u) u->Release();
- MFShutdown();
- return ok;
-}
-// leva (ou tira) o fundo personalizado da pasta da tela de logon do projeto; pede administrador (UAC)
-void Publish(const std::wstring& jpg, const std::wstring& mp4) {
- if (!Exists(AUTHUX)) return;
- std::wstring d = AUTHUX, cmd = L"/c ";
- if (jpg.empty()) cmd += L"del /q \"" + d + L"\\personalizado.jpg\" \"" + d + L"\\personalizado.mp4\"";
- else {
- cmd += L"copy /y \"" + jpg + L"\" \"" + d + L"\\personalizado.jpg\"";
- if (mp4.empty()) cmd += L" & del /q \"" + d + L"\\personalizado.mp4\"";
- else cmd += L" & copy /y \"" + mp4 + L"\" \"" + d + L"\\personalizado.mp4\"";
- }
- ShellExecuteW(Window(), L"runas", L"cmd.exe", cmd.c_str(), nullptr, SW_HIDE);
-}
-void Default() {
- SetSetting(L"bloqueio_fundo", L"");
- SetSetting(L"bloqueio_video", L"");
- Publish(L"", L"");
- Rebuild();
-}
-void Pick(bool video) {
- IFileOpenDialog* d = nullptr;
- if (FAILED(CoCreateInstance(CLSID_FileOpenDialog, nullptr, CLSCTX_ALL, IID_PPV_ARGS(&d)))) return;
- COMDLG_FILTERSPEC img[] = { { L"Imagens", L"*.jpg;*.jpeg;*.png;*.bmp;*.heic;*.webp" } };
- COMDLG_FILTERSPEC vid[] = { { L"Vídeos", L"*.mp4;*.mov;*.m4v" } };
- d->SetFileTypes(1, video ? vid : img);
- std::wstring in;
- if (SUCCEEDED(d->Show(Window()))) {
- IShellItem* it = nullptr;
- if (SUCCEEDED(d->GetResult(&it))) {
- PWSTR path = nullptr;
- if (SUCCEEDED(it->GetDisplayName(SIGDN_FILESYSPATH, &path))) { in = path; CoTaskMemFree(path); }
- it->Release();
- }
- }
- d->Release();
- if (in.empty()) return;
- // nome novo a cada escolha (a miniatura da página é guardada pelo caminho); as antigas saem
- std::wstring dir = Dir(), jpg = dir + L"\\fundo-" + std::to_wstring(GetTickCount64()) + L".jpg", mp4 = dir + L"\\fundo.mp4";
-
- bool ok;
- // o vídeo só é aceito se decodifica aqui (senão a tela de bloqueio ficaria preta); nada é trocado em caso de erro
- if (video) ok = VideoFrameToJpeg(in, jpg) && CopyFileW(in.c_str(), mp4.c_str(), FALSE);
- else { ok = ImageToJpeg(in, jpg); if (ok) DeleteFileW(mp4.c_str()); }
- if (!ok) {
- DeleteFileW(jpg.c_str());
- MessageBoxW(Window(), video ? Tr(L"Este vídeo não pode ser usado: o Windows não consegue reproduzir o formato dele. Use um vídeo MP4 em H.264.") : Tr(L"Não foi possível usar esta imagem."), Tr(L"Tela Bloqueada"), MB_ICONWARNING);
- return;
- }
- { // as imagens antigas saem (menos a nova)
- WIN32_FIND_DATAW fd; HANDLE h = FindFirstFileW((dir + L"\\fundo-*.jpg").c_str(), &fd);
- if (h != INVALID_HANDLE_VALUE) { do { std::wstring f = dir + L"\\" + fd.cFileName; if (_wcsicmp(f.c_str(), jpg.c_str())) DeleteFileW(f.c_str()); } while (FindNextFileW(h, &fd)); FindClose(h); }
- }
- SetSetting(L"bloqueio_fundo", jpg);
- SetSetting(L"bloqueio_video", video ? mp4 : L"");
- SetSetting(L"bloqueio_fundo_nome", PathFindFileNameW(in.c_str()));
- Publish(jpg, video ? mp4 : L"");
- Rebuild();
-}
-} // namespace lockbg
-
Page TelaBloqueada() {
Page p;
// a imagem de fundo da tela de bloqueio do WacOS saiu junto com ela (21/11/2026); fica o que é do Windows
diff --git a/src/comum/ajustes_arquivo.h b/src/comum/ajustes_arquivo.h
new file mode 100644
index 0000000..5575f3c
--- /dev/null
+++ b/src/comum/ajustes_arquivo.h
@@ -0,0 +1,67 @@
+#pragma once
+// Leitura e gravação do %APPDATA%\Shell\ajustes.txt pelo Shell e pelo Ajustes do Sistema (os dois regravam o arquivo
+// inteiro). Duas armadilhas que este arquivo resolve:
+// - linha de qualquer tamanho: apps_ordem e launchpad_ocultos guardam nomes de apps separados por "|" e passam
+// fácil de 512 caracteres; lidas com fgetws(512) viravam dois pedaços, o primeiro cortado, e a regravação
+// seguinte salvava a lista cortada (ordem do Launchpad perdida);
+// - gravação atômica: com "w" direto, quem lesse no meio da gravação via o arquivo vazio (o Ajustes relê antes de
+// gravar e regravava só a chave dele, apagando o resto). Agora grava em .tmp e troca de uma vez.
+#include <windows.h>
+#include <cstdio>
+#include <map>
+#include <string>
+
+namespace ajarq {
+
+// uma linha inteira, sem \r\n no fim; false no fim do arquivo
+inline bool LerLinha(FILE* f, std::wstring& s) {
+ s.clear();
+ wchar_t buf[1024];
+ bool leu = false;
+ while (fgetws(buf, (int)(sizeof(buf) / sizeof(buf[0])), f)) {
+ leu = true;
+ s += buf;
+ if (!s.empty() && s.back() == L'\n') break;
+ }
+ while (!s.empty() && (s.back() == L'\n' || s.back() == L'\r')) s.pop_back();
+ return leu;
+}
+
+// chave=valor (linhas com # ou sem = ficam de fora); false se o arquivo não abriu
+inline bool Ler(const std::wstring& path, std::map<std::wstring, std::wstring>& out) {
+ FILE* fp = nullptr;
+ if (_wfopen_s(&fp, path.c_str(), L"r, ccs=UTF-8") || !fp) return false;
+ std::wstring s;
+ while (LerLinha(fp, s)) {
+ while (!s.empty() && s.back() == L' ') s.pop_back();
+ size_t eq = s.find(L'=');
+ if (eq != std::wstring::npos && !s.empty() && s[0] != L'#') out[s.substr(0, eq)] = s.substr(eq + 1);
+ }
+ fclose(fp);
+ return true;
+}
+
+inline bool Gravar(const std::wstring& path, const std::map<std::wstring, std::wstring>& m) {
+ std::wstring tmp = path + L".tmp";
+ FILE* fp = nullptr;
+ if (_wfopen_s(&fp, tmp.c_str(), L"w, ccs=UTF-8") || !fp) return false;
+ for (auto& [k, v] : m) fwprintf(fp, L"%ls=%ls\n", k.c_str(), v.c_str());
+ bool ok = fflush(fp) == 0;
+ fclose(fp);
+ if (!ok) { DeleteFileW(tmp.c_str()); return false; }
+ // outro app pode estar com o arquivo aberto para ler (fopen não divide a exclusão): tenta de novo e, em último
+ // caso, grava direto como antes
+ for (int i = 0; i < 5; i++) {
+ // sem MOVEFILE_WRITE_THROUGH: o Shell grava na thread da interface, e esperar o disco (ocupado, issue #32)
+ // a travaria; a troca já é atômica para quem lê
+ if (MoveFileExW(tmp.c_str(), path.c_str(), MOVEFILE_REPLACE_EXISTING)) return true;
+ Sleep(10);
+ }
+ DeleteFileW(tmp.c_str());
+ if (_wfopen_s(&fp, path.c_str(), L"w, ccs=UTF-8") || !fp) return false;
+ for (auto& [k, v] : m) fwprintf(fp, L"%ls=%ls\n", k.c_str(), v.c_str());
+ fclose(fp);
+ return true;
+}
+
+} // namespace ajarq
diff --git a/src/comum/idioma_de.inc b/src/comum/idioma_de.inc
index bee5fce..f0dee80 100644
--- a/src/comum/idioma_de.inc
+++ b/src/comum/idioma_de.inc
@@ -1629,3 +1629,11 @@
{ L"Digite a cidade do Meu Local", L"Stadt für „Mein Standort“ eingeben" },
{ L"Botões do Mac nos apps com barra própria", L"Mac-Tasten in Apps mit eigener Titelleiste" },
{ L"Experimental. Edge, Chrome, Figma, Discord, VS Code e outros apps que desenham a própria barra ganham os botões do Mac no lugar dos do Windows. Vale para as janelas abertas depois de mudar.", L"Experimentell. Edge, Chrome, Figma, Discord, VS Code und andere Apps mit eigener Titelleiste erhalten die Mac-Tasten statt der Windows-Tasten. Gilt für Fenster, die danach geöffnet werden." },
+{ L"Imagens e PDF", L"Bilder und PDF" },
+{ L"Texto Formatado (RTF)", L"Formatierter Text (RTF)" },
+{ L"Texto Simples", L"Reiner Text" },
+{ L"Documentos de texto", L"Textdokumente" },
+{ L"Escolher", L"Auswählen" },
+{ L"Todos os Dias", L"Täglich" },
+{ L"Dias de Semana", L"Wochentags" },
+{ L"Fins de Semana", L"Wochenenden" },
diff --git a/src/comum/idioma_en.inc b/src/comum/idioma_en.inc
index 275c5ad..0168de2 100644
--- a/src/comum/idioma_en.inc
+++ b/src/comum/idioma_en.inc
@@ -1629,3 +1629,11 @@
{ L"Digite a cidade do Meu Local", L"Type the city for My Location" },
{ L"Botões do Mac nos apps com barra própria", L"Mac buttons in apps with their own title bar" },
{ L"Experimental. Edge, Chrome, Figma, Discord, VS Code e outros apps que desenham a própria barra ganham os botões do Mac no lugar dos do Windows. Vale para as janelas abertas depois de mudar.", L"Experimental. Edge, Chrome, Figma, Discord, VS Code and other apps that draw their own title bar get the Mac buttons instead of the Windows ones. Applies to windows opened after the change." },
+{ L"Imagens e PDF", L"Images and PDF" },
+{ L"Texto Formatado (RTF)", L"Rich Text (RTF)" },
+{ L"Texto Simples", L"Plain Text" },
+{ L"Documentos de texto", L"Text Documents" },
+{ L"Escolher", L"Choose" },
+{ L"Todos os Dias", L"Every Day" },
+{ L"Dias de Semana", L"Weekdays" },
+{ L"Fins de Semana", L"Weekends" },
diff --git a/src/comum/idioma_es.inc b/src/comum/idioma_es.inc
index 3512422..0af754c 100644
--- a/src/comum/idioma_es.inc
+++ b/src/comum/idioma_es.inc
@@ -1629,3 +1629,11 @@
{ L"Digite a cidade do Meu Local", L"Escribe la ciudad de Mi ubicación" },
{ L"Botões do Mac nos apps com barra própria", L"Botones del Mac en apps con barra propia" },
{ L"Experimental. Edge, Chrome, Figma, Discord, VS Code e outros apps que desenham a própria barra ganham os botões do Mac no lugar dos do Windows. Vale para as janelas abertas depois de mudar.", L"Experimental. Edge, Chrome, Figma, Discord, VS Code y otras apps que dibujan su propia barra reciben los botones del Mac en lugar de los de Windows. Se aplica a las ventanas abiertas después del cambio." },
+{ L"Imagens e PDF", L"Imágenes y PDF" },
+{ L"Texto Formatado (RTF)", L"Texto enriquecido (RTF)" },
+{ L"Texto Simples", L"Texto sin formato" },
+{ L"Documentos de texto", L"Documentos de texto" },
+{ L"Escolher", L"Elegir" },
+{ L"Todos os Dias", L"Todos los días" },
+{ L"Dias de Semana", L"Días laborables" },
+{ L"Fins de Semana", L"Fines de semana" },
diff --git a/src/comum/idioma_fr.inc b/src/comum/idioma_fr.inc
index afc8ce0..e4ce1be 100644
--- a/src/comum/idioma_fr.inc
+++ b/src/comum/idioma_fr.inc
@@ -1629,3 +1629,11 @@
{ L"Digite a cidade do Meu Local", L"Saisissez la ville de Ma position" },
{ L"Botões do Mac nos apps com barra própria", L"Boutons du Mac dans les apps à barre propre" },
{ L"Experimental. Edge, Chrome, Figma, Discord, VS Code e outros apps que desenham a própria barra ganham os botões do Mac no lugar dos do Windows. Vale para as janelas abertas depois de mudar.", L"Expérimental. Edge, Chrome, Figma, Discord, VS Code et les autres apps qui dessinent leur propre barre reçoivent les boutons du Mac à la place de ceux de Windows. S’applique aux fenêtres ouvertes après le changement." },
+{ L"Imagens e PDF", L"Images et PDF" },
+{ L"Texto Formatado (RTF)", L"Texte enrichi (RTF)" },
+{ L"Texto Simples", L"Texte brut" },
+{ L"Documentos de texto", L"Documents texte" },
+{ L"Escolher", L"Choisir" },
+{ L"Todos os Dias", L"Tous les jours" },
+{ L"Dias de Semana", L"Jours de semaine" },
+{ L"Fins de Semana", L"Week-ends" },
diff --git a/src/comum/idioma_it.inc b/src/comum/idioma_it.inc
index 97ae411..e4440a9 100644
--- a/src/comum/idioma_it.inc
+++ b/src/comum/idioma_it.inc
@@ -1629,3 +1629,11 @@
{ L"Digite a cidade do Meu Local", L"Digita la città della Mia posizione" },
{ L"Botões do Mac nos apps com barra própria", L"Pulsanti del Mac nelle app con barra propria" },
{ L"Experimental. Edge, Chrome, Figma, Discord, VS Code e outros apps que desenham a própria barra ganham os botões do Mac no lugar dos do Windows. Vale para as janelas abertas depois de mudar.", L"Sperimentale. Edge, Chrome, Figma, Discord, VS Code e le altre app che disegnano la propria barra ricevono i pulsanti del Mac al posto di quelli di Windows. Vale per le finestre aperte dopo la modifica." },
+{ L"Imagens e PDF", L"Immagini e PDF" },
+{ L"Texto Formatado (RTF)", L"Testo formattato (RTF)" },
+{ L"Texto Simples", L"Testo semplice" },
+{ L"Documentos de texto", L"Documenti di testo" },
+{ L"Escolher", L"Scegli" },
+{ L"Todos os Dias", L"Ogni giorno" },
+{ L"Dias de Semana", L"Giorni feriali" },
+{ L"Fins de Semana", L"Fine settimana" },
diff --git a/src/comum/idioma_ja.inc b/src/comum/idioma_ja.inc
index efe6906..1b3f6a7 100644
--- a/src/comum/idioma_ja.inc
+++ b/src/comum/idioma_ja.inc
@@ -1629,3 +1629,11 @@
{ L"Digite a cidade do Meu Local", L"現在地にする都市を入力" },
{ L"Botões do Mac nos apps com barra própria", L"独自のタイトルバーを持つアプリにMacのボタン" },
{ L"Experimental. Edge, Chrome, Figma, Discord, VS Code e outros apps que desenham a própria barra ganham os botões do Mac no lugar dos do Windows. Vale para as janelas abertas depois de mudar.", L"実験的機能。Edge、Chrome、Figma、Discord、VS Code など独自のタイトルバーを描くアプリで、Windows のボタンの代わりに Mac のボタンを使います。変更後に開いたウインドウに適用されます。" },
+{ L"Imagens e PDF", L"画像とPDF" },
+{ L"Texto Formatado (RTF)", L"リッチテキスト (RTF)" },
+{ L"Texto Simples", L"標準テキスト" },
+{ L"Documentos de texto", L"テキスト書類" },
+{ L"Escolher", L"選択" },
+{ L"Todos os Dias", L"毎日" },
+{ L"Dias de Semana", L"平日" },
+{ L"Fins de Semana", L"週末" },
diff --git a/src/comum/idioma_ko.inc b/src/comum/idioma_ko.inc
index a527cbe..19fb111 100644
--- a/src/comum/idioma_ko.inc
+++ b/src/comum/idioma_ko.inc
@@ -1629,3 +1629,11 @@
{ L"Digite a cidade do Meu Local", L"나의 위치로 쓸 도시를 입력하세요" },
{ L"Botões do Mac nos apps com barra própria", L"자체 제목 막대가 있는 앱에 Mac 버튼" },
{ L"Experimental. Edge, Chrome, Figma, Discord, VS Code e outros apps que desenham a própria barra ganham os botões do Mac no lugar dos do Windows. Vale para as janelas abertas depois de mudar.", L"실험적 기능. Edge, Chrome, Figma, Discord, VS Code 등 자체 제목 막대를 그리는 앱에 Windows 버튼 대신 Mac 버튼을 씁니다. 변경 후 연 윈도우에 적용됩니다." },
+{ L"Imagens e PDF", L"이미지 및 PDF" },
+{ L"Texto Formatado (RTF)", L"서식 있는 텍스트(RTF)" },
+{ L"Texto Simples", L"일반 텍스트" },
+{ L"Documentos de texto", L"텍스트 문서" },
+{ L"Escolher", L"선택" },
+{ L"Todos os Dias", L"매일" },
+{ L"Dias de Semana", L"주중" },
+{ L"Fins de Semana", L"주말" },
diff --git a/src/comum/idioma_pl.inc b/src/comum/idioma_pl.inc
index 79c3e2e..3e356b7 100644
--- a/src/comum/idioma_pl.inc
+++ b/src/comum/idioma_pl.inc
@@ -1629,3 +1629,11 @@
{ L"Digite a cidade do Meu Local", L"Wpisz miasto dla Mojej lokalizacji" },
{ L"Botões do Mac nos apps com barra própria", L"Przyciski Maca w aplikacjach z własnym paskiem" },
{ L"Experimental. Edge, Chrome, Figma, Discord, VS Code e outros apps que desenham a própria barra ganham os botões do Mac no lugar dos do Windows. Vale para as janelas abertas depois de mudar.", L"Eksperymentalne. Edge, Chrome, Figma, Discord, VS Code i inne aplikacje z własnym paskiem dostają przyciski Maca zamiast przycisków Windows. Dotyczy okien otwartych po zmianie." },
+{ L"Imagens e PDF", L"Obrazy i PDF" },
+{ L"Texto Formatado (RTF)", L"Tekst sformatowany (RTF)" },
+{ L"Texto Simples", L"Zwykły tekst" },
+{ L"Documentos de texto", L"Dokumenty tekstowe" },
+{ L"Escolher", L"Wybierz" },
+{ L"Todos os Dias", L"Codziennie" },
+{ L"Dias de Semana", L"Dni robocze" },
+{ L"Fins de Semana", L"Weekendy" },
diff --git a/src/comum/idioma_ru.inc b/src/comum/idioma_ru.inc
index cfccb29..6c31c07 100644
--- a/src/comum/idioma_ru.inc
+++ b/src/comum/idioma_ru.inc
@@ -1629,3 +1629,11 @@
{ L"Digite a cidade do Meu Local", L"Введите город для «Моё место»" },
{ L"Botões do Mac nos apps com barra própria", L"Кнопки Mac в приложениях со своей панелью" },
{ L"Experimental. Edge, Chrome, Figma, Discord, VS Code e outros apps que desenham a própria barra ganham os botões do Mac no lugar dos do Windows. Vale para as janelas abertas depois de mudar.", L"Экспериментальная функция. Edge, Chrome, Figma, Discord, VS Code и другие приложения со своей панелью получают кнопки Mac вместо кнопок Windows. Действует для окон, открытых после изменения." },
+{ L"Imagens e PDF", L"Изображения и PDF" },
+{ L"Texto Formatado (RTF)", L"Форматированный текст (RTF)" },
+{ L"Texto Simples", L"Простой текст" },
+{ L"Documentos de texto", L"Текстовые документы" },
+{ L"Escolher", L"Выбрать" },
+{ L"Todos os Dias", L"Каждый день" },
+{ L"Dias de Semana", L"По будням" },
+{ L"Fins de Semana", L"По выходным" },
diff --git a/src/comum/idioma_tr.inc b/src/comum/idioma_tr.inc
index 0ec36c4..7d72abe 100644
--- a/src/comum/idioma_tr.inc
+++ b/src/comum/idioma_tr.inc
@@ -1629,3 +1629,11 @@
{ L"Digite a cidade do Meu Local", L"Konumum için şehri yazın" },
{ L"Botões do Mac nos apps com barra própria", L"Kendi başlık çubuğu olan uygulamalarda Mac düğmeleri" },
{ L"Experimental. Edge, Chrome, Figma, Discord, VS Code e outros apps que desenham a própria barra ganham os botões do Mac no lugar dos do Windows. Vale para as janelas abertas depois de mudar.", L"Deneysel. Edge, Chrome, Figma, Discord, VS Code ve kendi başlık çubuğunu çizen diğer uygulamalar Windows düğmeleri yerine Mac düğmelerini alır. Değişiklikten sonra açılan pencerelerde geçerlidir." },
+{ L"Imagens e PDF", L"Görüntüler ve PDF" },
+{ L"Texto Formatado (RTF)", L"Zengin Metin (RTF)" },
+{ L"Texto Simples", L"Düz Metin" },
+{ L"Documentos de texto", L"Metin Belgeleri" },
+{ L"Escolher", L"Seç" },
+{ L"Todos os Dias", L"Her Gün" },
+{ L"Dias de Semana", L"Hafta İçi" },
+{ L"Fins de Semana", L"Hafta Sonları" },
diff --git a/src/comum/idioma_zh.inc b/src/comum/idioma_zh.inc
index d02f093..029de71 100644
--- a/src/comum/idioma_zh.inc
+++ b/src/comum/idioma_zh.inc
@@ -1629,3 +1629,11 @@
{ L"Digite a cidade do Meu Local", L"输入“我的位置”的城市" },
{ L"Botões do Mac nos apps com barra própria", L"在自带标题栏的应用中使用 Mac 按钮" },
{ L"Experimental. Edge, Chrome, Figma, Discord, VS Code e outros apps que desenham a própria barra ganham os botões do Mac no lugar dos do Windows. Vale para as janelas abertas depois de mudar.", L"实验性功能。Edge、Chrome、Figma、Discord、VS Code 等自带标题栏的应用将使用 Mac 按钮代替 Windows 按钮。对更改后打开的窗口生效。" },
+{ L"Imagens e PDF", L"图像和 PDF" },
+{ L"Texto Formatado (RTF)", L"多信息文本 (RTF)" },
+{ L"Texto Simples", L"纯文本" },
+{ L"Documentos de texto", L"文本文稿" },
+{ L"Escolher", L"选取" },
+{ L"Todos os Dias", L"每天" },
+{ L"Dias de Semana", L"工作日" },
+{ L"Fins de Semana", L"周末" },
diff --git a/src/janelas/controles.cpp b/src/janelas/controles.cpp
index 86adb48..6c0da60 100644
--- a/src/janelas/controles.cpp
+++ b/src/janelas/controles.cpp
@@ -584,6 +584,15 @@ struct Alert {
SIZE before{}; // tamanho do cliente original (para desfazer)
};
std::map<HWND, Alert> g_alerts;
+// Tira o alerta da lista e solta o ícone grande do app (SHDefExtractIcon/ExtractIconEx criam um ícone novo a cada
+// caixa de mensagem; sem o DestroyIcon, cada alerta deixava um objeto USER para trás dentro do programa)
+bool EraseAlert(HWND h) {
+ auto it = g_alerts.find(h);
+ if (it == g_alerts.end()) return false;
+ if (it->second.app) DestroyIcon(it->second.app);
+ g_alerts.erase(it);
+ return true;
+}
const float AW = 260, APAD = 20, AICON = 64, ABTN = 28, AGAP = 8;
// Leopard (alerta do 10.5): 420 de largura, ícone de 64 em (24, 15), o texto a 104 da borda (negrito 13 e 11 embaixo),
@@ -703,6 +712,7 @@ void MakeAlert(HWND dlg) {
AdjustWindowRectExForDpi(&want, GetWindowLongW(dlg, GWL_STYLE), FALSE, GetWindowLongW(dlg, GWL_EXSTYLE), GetDpiForWindow(dlg));
int ww = want.right - want.left, wh = want.bottom - want.top;
int cx = (wr.left + wr.right) / 2, cy = (wr.top + wr.bottom) / 2;
+ EraseAlert(dlg); // montado de novo: o ícone anterior sai
g_alerts[dlg] = a;
SetWindowPos(dlg, nullptr, cx - ww / 2, cy - wh / 2, ww, wh, SWP_NOZORDER | SWP_NOACTIVATE);
}
@@ -776,7 +786,7 @@ LRESULT CALLBACK CtlProc(HWND h, UINT m, WPARAM w, LPARAM l, UINT_PTR, DWORD_PTR
int type = (int)ref;
switch (m) {
case WM_SETFONT: return DefSubclassProc(h, m, (WPARAM)MacFont((HFONT)w), l); // o diálogo põe a fonte depois de criar
- case WM_NCDESTROY: RemoveWindowSubclass(h, CtlProc, SUB_ID); g_segments.erase(h); g_alerts.erase(h); break;
+ case WM_NCDESTROY: RemoveWindowSubclass(h, CtlProc, SUB_ID); g_segments.erase(h); EraseAlert(h); break;
}
if (type == 0) return DefSubclassProc(h, m, w, l); // texto fixo, controle deslizante...: só a fonte
if (type == T_DIALOG) {
@@ -914,7 +924,7 @@ void controles::Unstyle(HWND top) {
SetWindowPos(c, nullptr, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
};
RemovePropW(top, L"MacCtl");
- if (g_alerts.erase(top)) { // alerta: os textos do Windows voltam (o tamanho fica)
+ if (EraseAlert(top)) { // alerta: os textos do Windows voltam (o tamanho fica)
if (HWND t = GetDlgItem(top, 0xFFFF)) ShowWindow(t, SW_SHOW);
if (HWND i = GetDlgItem(top, 20)) ShowWindow(i, SW_SHOW);
}
diff --git a/src/menu/context_menu.cpp b/src/menu/context_menu.cpp
index 9fe5a5a..ae89973 100644
--- a/src/menu/context_menu.cpp
+++ b/src/menu/context_menu.cpp
@@ -464,7 +464,10 @@ static bool Golden() { bool t = Tahoe(); return t && (g_glassSet ? g_glass.golde
// vai de uma borda à outra, sem cantos (como no 10.5)
static bool Leopard() { bool t = Tahoe(); return !t && (g_glassSet ? g_glass.leopard : g_fileLeopard); }
static bool GoldenIcon(const std::wstring& l) {
- for (const wchar_t* k : { L"Ajustes", L"Settings", L"System Settings", L"Preferências", L"Preferences", L"Sobre Este", L"About This", L"App Store", L"Microsoft Store" }) // macOS 27: o menu da Apple tem símbolo nestes if (l.rfind(k, 0) == 0) return true;
+ // macOS 27: o menu da Apple tem símbolo nestes. (O if estava no fim do comentário da linha do for: o laço
+ // devolvia false no 1º item e nenhum item ganhava símbolo no Golden Gate.)
+ for (const wchar_t* k : { L"Ajustes", L"Settings", L"System Settings", L"Preferências", L"Preferences", L"Sobre Este", L"About This", L"App Store", L"Microsoft Store" })
+ if (l.rfind(k, 0) == 0) return true;
return false;
}
diff --git a/src/preview/main.cpp b/src/preview/main.cpp
index caa5131..0ceb36c 100644
--- a/src/preview/main.cpp
+++ b/src/preview/main.cpp
@@ -814,7 +814,7 @@ void GoPage(int i) {
void OpenDialog() {
IFileOpenDialog* d = nullptr;
if (FAILED(CoCreateInstance(CLSID_FileOpenDialog, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&d)))) return;
- COMDLG_FILTERSPEC f[] = { { L"Imagens e PDF", L"*.pdf;*.png;*.jpg;*.jpeg;*.gif;*.bmp;*.tif;*.tiff;*.webp;*.heic;*.ico" }, { L"Todos", L"*.*" } };
+ COMDLG_FILTERSPEC f[] = { { Tr(L"Imagens e PDF"), L"*.pdf;*.png;*.jpg;*.jpeg;*.gif;*.bmp;*.tif;*.tiff;*.webp;*.heic;*.ico" }, { Tr(L"Todos"), L"*.*" } };
d->SetFileTypes(2, f);
if (SUCCEEDED(d->Show(g_wnd))) {
IShellItem* it = nullptr;
diff --git a/src/quicktime/main.cpp b/src/quicktime/main.cpp
index 448a0ef..b463969 100644
--- a/src/quicktime/main.cpp
+++ b/src/quicktime/main.cpp
@@ -321,7 +321,7 @@ void Open(const std::wstring& path) {
void OpenDialog() {
IFileOpenDialog* d = nullptr;
if (FAILED(CoCreateInstance(CLSID_FileOpenDialog, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&d)))) return;
- COMDLG_FILTERSPEC f[] = { { L"Filmes", L"*.mp4;*.mov;*.m4v;*.mkv;*.avi;*.wmv;*.webm;*.mp3;*.m4a;*.wav" }, { L"Todos", L"*.*" } };
+ COMDLG_FILTERSPEC f[] = { { Tr(L"Filmes"), L"*.mp4;*.mov;*.m4v;*.mkv;*.avi;*.wmv;*.webm;*.mp3;*.m4a;*.wav" }, { Tr(L"Todos"), L"*.*" } };
d->SetFileTypes(2, f);
if (SUCCEEDED(d->Show(wnd))) { IShellItem* it = nullptr; if (SUCCEEDED(d->GetResult(&it))) { PWSTR p = nullptr; if (SUCCEEDED(it->GetDisplayName(SIGDN_FILESYSPATH, &p))) {
if (g_path.empty()) Open(p); else { wchar_t me[MAX_PATH]; GetModuleFileNameW(nullptr, me, MAX_PATH); ShellExecuteW(nullptr, L"open", me, (L"\"" + std::wstring(p) + L"\"").c_str(), nullptr, SW_SHOWNORMAL); }
diff --git a/src/shell/apps.cpp b/src/shell/apps.cpp
index beb157e..9cd9cc5 100644
--- a/src/shell/apps.cpp
+++ b/src/shell/apps.cpp
@@ -876,8 +876,10 @@ static std::wstring PackagedAumid(const std::wstring& path) {
HANDLE fh = CreateFileW((path.substr(0, f1) + L"\\AppxManifest.xml").c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr);
if (fh != INVALID_HANDLE_VALUE) {
DWORD size = GetFileSize(fh, nullptr), rd = 0;
+ if (size == INVALID_FILE_SIZE || size > 16 * 1024 * 1024) size = 0; // não lido: nada de string de 4 GB
std::string x(size, 0);
- ReadFile(fh, x.data(), size, &rd, nullptr);
+ if (!ReadFile(fh, x.data(), size, &rd, nullptr)) rd = 0;
+ x.resize(rd);
CloseHandle(fh);
std::string lx = x; for (auto& c : lx) c = (char)tolower((unsigned char)c);
std::string want(exe.begin(), exe.end());
diff --git a/src/shell/atalhos.cpp b/src/shell/atalhos.cpp
index 2386c48..5d9ee7b 100644
--- a/src/shell/atalhos.cpp
+++ b/src/shell/atalhos.cpp
@@ -215,8 +215,11 @@ std::vector<atalhos::Item> CubaseRecent(int max) {
HANDLE f = xml.empty() ? INVALID_HANDLE_VALUE : CreateFileW(xml.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr);
if (f == INVALID_HANDLE_VALUE) return out;
DWORD size = GetFileSize(f, nullptr), rd = 0;
+ // tamanho que não deu para ler (INVALID_FILE_SIZE = 4 GB) virava um std::string gigante e derrubava o Shell
+ if (size == INVALID_FILE_SIZE || size > 16 * 1024 * 1024) { CloseHandle(f); return out; }
std::string t(size, 0);
- ReadFile(f, t.data(), size, &rd, nullptr);
+ if (!ReadFile(f, t.data(), size, &rd, nullptr)) rd = 0;
+ t.resize(rd);
CloseHandle(f);
size_t at = t.find("GRecentDocumentPaths");
if (at == std::string::npos) return out;
diff --git a/src/shell/atualizacao.cpp b/src/shell/atualizacao.cpp
index defe6f8..f0e142a 100644
--- a/src/shell/atualizacao.cpp
+++ b/src/shell/atualizacao.cpp
@@ -29,6 +29,8 @@ std::wstring Root() { return shell::dir.substr(0, shell::dir.find_last_of(L'\\')
// Uma checagem (≈ 2 a 10 s, rede): atual= e novo= do script
void Checar() {
+ // aviso desligado: nem confere (antes rodava o PowerShell e ia à rede a cada 6 h só para não mostrar nada)
+ if (shell::Setting(L"avisar_atualizacao", L"1") == L"0") return;
std::wstring script = Root() + L"\\tools\\atualizar-github.ps1";
if (GetFileAttributesW(script.c_str()) == INVALID_FILE_ATTRIBUTES) return;
wchar_t tmp[MAX_PATH], f[MAX_PATH];
@@ -37,7 +39,11 @@ void Checar() {
std::wstring cmd = L"powershell.exe -NoProfile -ExecutionPolicy Bypass -File \"" + script + L"\" -Verificar -Saida \"" + f + L"\" -Bin \"" + shell::dir + L"\"";
STARTUPINFOW si{ sizeof(si) }; PROCESS_INFORMATION pi{};
if (!CreateProcessW(nullptr, cmd.data(), nullptr, nullptr, FALSE, CREATE_NO_WINDOW | BELOW_NORMAL_PRIORITY_CLASS, nullptr, nullptr, &si, &pi)) { DeleteFileW(f); return; }
- WaitForSingleObject(pi.hProcess, 60000);
+ if (WaitForSingleObject(pi.hProcess, 60000) == WAIT_TIMEOUT) {
+ // rede parada: o script não termina; sem encerrar, ele ficava rodando e um a mais a cada 6 h
+ TerminateProcess(pi.hProcess, 1);
+ Log(L"atualização: a conferência passou de 60 s e foi encerrada");
+ }
CloseHandle(pi.hThread); CloseHandle(pi.hProcess);
std::wstring atual, novo, erro;
int n = 0;
diff --git a/src/shell/dialogs.cpp b/src/shell/dialogs.cpp
index d786119..f2f91bf 100644
--- a/src/shell/dialogs.cpp
+++ b/src/shell/dialogs.cpp
@@ -289,11 +289,17 @@ Request Read(HWND dlg) {
if (ok.find(L"salv") != std::wstring::npos || ok.find(L"save") != std::wstring::npos) r.mode = 1;
else if (ok.find(L"pasta") != std::wstring::npos || ok.find(L"folder") != std::wstring::npos || !combo) r.mode = 2;
if (combo) { // "Imagens (*.png;*.jpg)" → descrição + padrões
- int n = (int)SendMessageW(combo, CB_GETCOUNT, 0, 0);
+ // com tempo-limite, como o Text(): o combo é do programa que pediu a janela; ocupado, ele segurava o Shell
+ auto cb = [&](UINT m, WPARAM w, LPARAM l) -> LRESULT {
+ DWORD_PTR res = 0;
+ return SendMessageTimeoutW(combo, m, w, l, SMTO_ABORTIFHUNG, g_textMs, &res) ? (LRESULT)res : CB_ERR;
+ };
+ int n = (int)cb(CB_GETCOUNT, 0, 0);
for (int i = 0; i < n && i < 64; i++) {
wchar_t buf[512] = {};
- if (SendMessageW(combo, CB_GETLBTEXTLEN, i, 0) >= 511) continue;
- SendMessageW(combo, CB_GETLBTEXT, i, (LPARAM)buf);
+ LRESULT len = cb(CB_GETLBTEXTLEN, i, 0);
+ if (len < 0 || len >= 511) continue;
+ cb(CB_GETLBTEXT, i, (LPARAM)buf);
std::wstring t = buf, desc = t, spec = L"*.*";
size_t o = t.rfind(L'('), c = t.rfind(L')');
if (o != std::wstring::npos && c != std::wstring::npos && c > o) {
@@ -304,7 +310,7 @@ Request Read(HWND dlg) {
for (auto& ch : spec) if (ch == L',' ) ch = L';';
r.types.push_back({ desc.empty() ? t : desc, spec });
}
- r.type = std::max(0, (int)SendMessageW(combo, CB_GETCURSEL, 0, 0));
+ r.type = std::max(0, (int)cb(CB_GETCURSEL, 0, 0));
}
// Salvar pela estrutura, não só pelo texto do botão: a janela de Abrir do Windows sempre tem o campo do nome 1148
// (ComboBoxEx32); a de Salvar não tem, o nome fica num Edit 1001 dentro de FloatNotifySink. O botão nasce com o
diff --git a/src/shell/ilha.cpp b/src/shell/ilha.cpp
index 2ddfd3b..a7b031d 100644
--- a/src/shell/ilha.cpp
+++ b/src/shell/ilha.cpp
@@ -39,6 +39,7 @@
#include <winrt/Windows.Media.Control.h>
#include <winrt/Windows.Storage.Streams.h>
#include <algorithm>
+#include <atomic>
#include <cmath>
#include <condition_variable>
#include <deque>
@@ -704,7 +705,14 @@ void SaveClips() {
for (auto& c : g_clips) { all += c; all.push_back(L'\0'); }
std::wstring path = ClipsPath();
if (path.empty()) return;
- std::thread([all = std::move(all), path] {
+ // Uma gravação por vez e só a mais nova: duas cópias seguidas abriam duas threads; a segunda não conseguia abrir o
+ // .tmp (a primeira o segurava sem compartilhar) e o arquivo ficava com a lista de antes da última cópia
+ static std::mutex gravando;
+ static std::atomic<unsigned> geracao{ 0 };
+ unsigned minha = ++geracao;
+ std::thread([all = std::move(all), path, minha] {
+ std::lock_guard<std::mutex> lk(gravando);
+ if (minha != geracao) return; // já há uma lista mais nova esperando para gravar
if (all.empty()) { DeleteFileW(path.c_str()); return; }
DATA_BLOB in{ (DWORD)(all.size() * sizeof(wchar_t)), (BYTE*)all.data() }, out{};
if (!CryptProtectData(&in, L"WacOS", nullptr, nullptr, nullptr, CRYPTPROTECT_UI_FORBIDDEN, &out)) return;
@@ -721,7 +729,8 @@ void LoadClips() {
std::wstring path = ClipsPath();
HANDLE f = path.empty() ? INVALID_HANDLE_VALUE : CreateFileW(path.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr);
if (f == INVALID_HANDLE_VALUE) return;
- std::vector<BYTE> buf(GetFileSize(f, nullptr));
+ DWORD tam = GetFileSize(f, nullptr); // INVALID_FILE_SIZE (4 GB) virava um vetor gigante e derrubava o Shell
+ std::vector<BYTE> buf(tam == INVALID_FILE_SIZE || tam >= 8 * 1024 * 1024 ? 0 : tam);
DWORD r = 0; BOOL ok = !buf.empty() && buf.size() < 8 * 1024 * 1024 && ReadFile(f, buf.data(), (DWORD)buf.size(), &r, nullptr);
CloseHandle(f);
if (!ok) return;
diff --git a/src/shell/main.cpp b/src/shell/main.cpp
index 48574af..4efee4a 100644
--- a/src/shell/main.cpp
+++ b/src/shell/main.cpp
@@ -3,6 +3,7 @@
// (menu do logo → Sair do Shell, Ctrl+Alt+Shift+F12, ou erro), devolve tudo como estava.
#include "shell.h"
#include "../comum/simbolos.h"
+#include "../comum/ajustes_arquivo.h"
#include "../menu/context_menu.h"
#include <shlobj.h>
#include <dwmapi.h>
@@ -325,9 +326,15 @@ void Log(const wchar_t* fmt, ...) {
g_logCv.notify_one();
}
+// g_settings é lido de várias threads (vidro, índice, ilha, widgets...) enquanto a interface relê o arquivo
+// (LoadSettings troca o mapa inteiro): sem trava, a leitura podia pegar o mapa no meio da troca e derrubar o Shell
+static SRWLOCK g_settingsLock = SRWLOCK_INIT;
std::wstring shell::Setting(const wchar_t* key, const wchar_t* def) {
+ AcquireSRWLockShared(&g_settingsLock);
auto it = g_settings.find(key);
- return it != g_settings.end() ? it->second : def;
+ std::wstring r = it != g_settings.end() ? it->second : (def ? def : L"");
+ ReleaseSRWLockShared(&g_settingsLock);
+ return r;
}
static std::wstring SettingsPath() {
@@ -339,11 +346,12 @@ static std::wstring SettingsPath() {
}
void shell::SetSetting(const wchar_t* key, const std::wstring& value) {
+ std::map<std::wstring, std::wstring> copia;
+ AcquireSRWLockExclusive(&g_settingsLock);
g_settings[key] = value;
- FILE* fp = nullptr;
- if (_wfopen_s(&fp, SettingsPath().c_str(), L"w, ccs=UTF-8") || !fp) return;
- for (auto& [k, v] : g_settings) fwprintf(fp, L"%ls=%ls\n", k.c_str(), v.c_str());
- fclose(fp);
+ copia = g_settings;
+ ReleaseSRWLockExclusive(&g_settingsLock);
+ ajarq::Gravar(SettingsPath(), copia); // atômico (.tmp + troca): quem lê no meio não vê o arquivo vazio
}
// Calculadora (Calculadora.exe) no lugar da Calculadora do Windows: Launchpad, Spotlight e Dock passam
@@ -419,20 +427,14 @@ static void LoadSettings() {
if (FAILED(SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, nullptr, &p))) return;
std::wstring f = std::wstring(p) + L"\\Shell\\ajustes.txt";
CoTaskMemFree(p);
- FILE* fp = nullptr;
- if (_wfopen_s(&fp, f.c_str(), L"r, ccs=UTF-8") || !fp) return;
// Do zero a cada leitura: uma linha tirada do arquivo (ajuste de volta ao padrão) continuava valendo com o valor
// antigo até reiniciar o Shell (23/11/2026: ocultar=1 apagado deixava o Dock sem reserva na área de trabalho).
+ // Linhas de qualquer tamanho (apps_ordem passava de 512 caracteres e era cortada).
std::map<std::wstring, std::wstring> novo;
- wchar_t line[512];
- while (fgetws(line, 512, fp)) {
- std::wstring s = line;
- while (!s.empty() && (s.back() == L'\n' || s.back() == L'\r' || s.back() == L' ')) s.pop_back();
- size_t eq = s.find(L'=');
- if (eq != std::wstring::npos && s[0] != L'#') novo[s.substr(0, eq)] = s.substr(eq + 1);
- }
- fclose(fp);
- g_settings = std::move(novo);
+ if (!ajarq::Ler(f, novo)) return;
+ AcquireSRWLockExclusive(&g_settingsLock);
+ g_settings.swap(novo);
+ ReleaseSRWLockExclusive(&g_settingsLock);
backdrop::Reload(); // Transparência e Efeitos (Liquid Glass, reduzir transparência, tinta)
anim::reduceMotion = shell::Setting(L"reduzir_movimento", L"0") == L"1";
}
@@ -981,6 +983,9 @@ static LRESULT CALLBACK MsgProc(HWND h, UINT m, WPARAM w, LPARAM l) {
widgets::SettingsChanged(); // Personalizar a Mesa: widgets ligados/desligados
jogo::Reload(); // modo_jogo e jogos.txt
palco::Sync();
+ // "Clicar no papel de parede para mostrar a mesa" saiu de "Nunca": com o Shell aberto em "Nunca" o gancho do mouse
+ // nunca era criado e a opção nova só valia depois de reiniciar (Start não faz nada se já estiver ligado)
+ if (!shell::SoDock() && !jogo::Ativo()) revelar::Start();
return 0;
}
if (m == WM_SHELLHOOK && WM_SHELLHOOK) {
diff --git a/src/shell/memoria.cpp b/src/shell/memoria.cpp
index a568d6a..d3e2860 100644
--- a/src/shell/memoria.cpp
+++ b/src/shell/memoria.cpp
@@ -232,8 +232,14 @@ void NapTick(DWORD now) {
DWORD fgPid = 0; GetWindowThreadProcessId(GetForegroundWindow(), &fgPid);
std::set<DWORD> audio = AudioPids();
- // processos que sumiram
- for (auto it = g_procs.begin(); it != g_procs.end();) it = s.any.count(it->first) ? std::next(it) : g_procs.erase(it);
+ // processos que sumiram (ou ficaram sem janela: Discord e Spotify fechados para a bandeja continuam rodando).
+ // Em soneca, acordam antes de sair da lista: sem isso o modo de eficiência ficava ligado para sempre e o app
+ // reaberto pela bandeja seguia lento (o Wake da frente não o achava mais na lista)
+ for (auto it = g_procs.begin(); it != g_procs.end();) {
+ if (s.any.count(it->first)) { ++it; continue; }
+ if (it->second.napped && SetThrottle(it->first, false, it->second)) Log(L"memoria: %ls acordou (sem janela)", it->second.exe.c_str());
+ it = g_procs.erase(it);
+ }
// por programa, não por processo: o Chrome (Edge, Discord, Spotify...) toca o som num processo de áudio à parte e
// desenha o vídeo em outro; só o da janela entrava em soneca e o YouTube tocando atrás de outra janela travava
diff --git a/src/shell/menus.cpp b/src/shell/menus.cpp
index c7657c4..6a8e363 100644
--- a/src/shell/menus.cpp
+++ b/src/shell/menus.cpp
@@ -141,7 +141,10 @@ const float ARROW = 18; // faixa com a setinha em cima/embaixo de um menu q
bool GoldenMenus() { return backdrop::Liquid() && backdrop::Current().golden; }
#define MENU_R (GoldenMenus() ? 11.f : MENU_R_TAHOE) // Golden Gate: canto de 11 (medido)
bool GoldenIcon(const std::wstring& label) {
- for (const wchar_t* k : { L"Ajustes", L"Settings", L"System Settings", L"Preferências", L"Preferences", L"Sobre Este", L"About This", L"App Store", L"Microsoft Store" }) // macOS 27: o menu da Apple tem símbolo nestes if (label.rfind(k, 0) == 0) return true;
+ // macOS 27: o menu da Apple tem símbolo nestes. (O if estava no fim do comentário da linha do for: o laço
+ // devolvia false no 1º item e nenhum menu ganhava símbolo.)
+ for (const wchar_t* k : { L"Ajustes", L"Settings", L"System Settings", L"Preferências", L"Preferences", L"Sobre Este", L"About This", L"App Store", L"Microsoft Store" })
+ if (label.rfind(k, 0) == 0) return true;
return false;
}
diff --git a/src/shell/notificacoes.cpp b/src/shell/notificacoes.cpp
index 3809a49..918bd70 100644
--- a/src/shell/notificacoes.cpp
+++ b/src/shell/notificacoes.cpp
@@ -1668,7 +1668,8 @@ std::vector<std::vector<std::wstring>> ReadTsv(const std::wstring& path) {
return out;
}
void ChecarAvisos() {
- if (!BannersOn()) return;
+ // Sem o "Banners do Mac" os avisos dos apps do Windows saem no aviso do Windows; os do Relógio, Lembretes e
+ // Calendário não têm outro caminho. Antes daqui saía sem conferir: com os banners desligados o alarme não tocava.
std::wstring done = ShellData(L"avisos-feitos.txt");
if (!g_avisadosLidos) { g_avisadosLidos = true; for (auto& v : ReadTsv(done)) if (!v.empty()) g_avisados.insert(v[0]); }
long long now = (long long)time(nullptr) / 60;
@@ -1740,7 +1741,9 @@ void BannerShowNote(const Note& n) {
[gr](ID2D1DeviceContext* dc, ID2D1SolidColorBrush* br, D2D1_RECT_F r) { DrawIcon(dc, br, gr, r); },
[nn] { OpenApp(nn); })) { Log(L"notificação na ilha: %ls", n.app.c_str()); return; }
}
- if (g_open || g_closing || !BannersOn() || !g_bwnd) return;
+ // avisos dos nossos apps (ChecarAvisos: aumid na pasta do WacOS) aparecem mesmo sem os banners do Mac
+ bool nosso = !n.aumid.empty() && n.aumid.rfind(shell::dir + L"\\", 0) == 0;
+ if (g_open || g_closing || (!BannersOn() && !nosso) || !g_bwnd) return;
bool first = g_bans.empty();
Ban b;
b.n = n; b.at = anim::Now(); b.until = GetTickCount64() + BannerMs(); b.y = TOP;
diff --git a/src/shell/progresso.cpp b/src/shell/progresso.cpp
index 5d3a10a..8d7d7b3 100644
--- a/src/shell/progresso.cpp
+++ b/src/shell/progresso.cpp
@@ -261,6 +261,9 @@ void HideOriginal(HWND h) {
{
std::lock_guard<std::mutex> l(g_mx);
if (!OffScreen(r)) {
+ // janelas de cópia que já fecharam saem da lista (uma por cópia: crescia sem fim, e um HWND reaproveitado
+ // por outra janela herdava a posição velha)
+ for (auto it = g_saved.begin(); it != g_saved.end();) it = IsWindow(it->first) ? std::next(it) : g_saved.erase(it);
g_saved[h] = r;
if (g_anchor.x == INT_MIN && IsWindowVisible(h)) g_anchor = { (r.left + r.right) / 2, (r.top + r.bottom) / 2 };
int x = GetSystemMetrics(SM_XVIRTUALSCREEN) - (r.right - r.left) - 4000;
diff --git a/src/shell/revelar.cpp b/src/shell/revelar.cpp
index 1054922..e844cfd 100644
--- a/src/shell/revelar.cpp
+++ b/src/shell/revelar.cpp
@@ -501,6 +501,7 @@ void HookThread() {
} // namespace
void revelar::Start() {
+ if (g_wnd) return; // já ligado (o main.cpp chama de novo quando o ajuste sai de "Nunca")
if (shell::Setting(L"clique_mostra_mesa", L"palco") == L"0") return; // "Nunca": nem o gancho do mouse
WNDCLASSW wc{}; wc.lpfnWndProc = Proc; wc.hInstance = shell::inst; wc.lpszClassName = L"ShellRevelar";
RegisterClassW(&wc);
diff --git a/src/shell/spotlight.cpp b/src/shell/spotlight.cpp
index 90a3d7d..9c10219 100644
--- a/src/shell/spotlight.cpp
+++ b/src/shell/spotlight.cpp
@@ -387,15 +387,24 @@ void LoadLearned() {
}
}
void SaveLearned() {
+ // A trava vem ANTES de abrir: o arquivo era aberto (e zerado) fora dela, e duas gravações seguidas (cada Learn
+ // roda numa thread) escreviam por cima uma da outra no mesmo arquivo; daí as linhas absurdas que o LoadLearned
+ // conserta. Grava num .tmp e troca, para quem lê nunca ver o arquivo pela metade.
+ static std::mutex gravando;
+ std::lock_guard<std::mutex> g(gravando);
+ std::wstring file = LearnFile(), tmp = file + L".tmp";
FILE* f = nullptr;
- if (_wfopen_s(&f, LearnFile().c_str(), L"w, ccs=UTF-8") || !f) return;
- std::lock_guard<std::mutex> l(g_learnMu);
- for (auto& [t, L] : g_learn) {
- fwprintf(f, L"%ls\t%d\t%lld", t.c_str(), L.opens, L.last);
- for (size_t i = 0; i < L.queries.size() && i < MAX_QUERIES; i++) fwprintf(f, L"\t%ls", L.queries[i].c_str());
- fputwc(L'\n', f);
+ if (_wfopen_s(&f, tmp.c_str(), L"w, ccs=UTF-8") || !f) return;
+ {
+ std::lock_guard<std::mutex> l(g_learnMu);
+ for (auto& [t, L] : g_learn) {
+ fwprintf(f, L"%ls\t%d\t%lld", t.c_str(), L.opens, L.last);
+ for (size_t i = 0; i < L.queries.size() && i < MAX_QUERIES; i++) fwprintf(f, L"\t%ls", L.queries[i].c_str());
+ fputwc(L'\n', f);
+ }
}
fclose(f);
+ if (!MoveFileExW(tmp.c_str(), file.c_str(), MOVEFILE_REPLACE_EXISTING)) DeleteFileW(tmp.c_str());
}
// abriu `target` depois de digitar `q` (já em minúsculas sem acento)
void Learn(const std::wstring& target, const std::wstring& q) {
diff --git a/src/textedit/main.cpp b/src/textedit/main.cpp
index 29f89f2..b82faf3 100644
--- a/src/textedit/main.cpp
+++ b/src/textedit/main.cpp
@@ -118,8 +118,8 @@ bool Save() { return g_path.empty() ? SaveAs() : SaveTo(g_path); }
bool SaveAs() {
IFileSaveDialog* d = nullptr;
if (FAILED(CoCreateInstance(CLSID_FileSaveDialog, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&d)))) return false;
- COMDLG_FILTERSPEC rtf[] = { { L"Texto Formatado (RTF)", L"*.rtf" }, { L"Texto Simples", L"*.txt" } };
- COMDLG_FILTERSPEC txt[] = { { L"Texto Simples", L"*.txt" }, { L"Texto Formatado (RTF)", L"*.rtf" } };
+ COMDLG_FILTERSPEC rtf[] = { { Tr(L"Texto Formatado (RTF)"), L"*.rtf" }, { Tr(L"Texto Simples"), L"*.txt" } };
+ COMDLG_FILTERSPEC txt[] = { { Tr(L"Texto Simples"), L"*.txt" }, { Tr(L"Texto Formatado (RTF)"), L"*.rtf" } };
d->SetFileTypes(2, g_plain ? txt : rtf);
d->SetDefaultExtension(g_plain ? L"txt" : L"rtf");
d->SetFileName(g_path.empty() ? Tr(L"Sem Título") : PathFindFileNameW(g_path.c_str()));
@@ -131,7 +131,7 @@ bool SaveAs() {
void OpenDialog() {
IFileOpenDialog* d = nullptr;
if (FAILED(CoCreateInstance(CLSID_FileOpenDialog, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&d)))) return;
- COMDLG_FILTERSPEC f[] = { { L"Documentos de texto", L"*.rtf;*.txt;*.md;*.log;*.csv;*.ini;*.json" }, { L"Todos", L"*.*" } };
+ COMDLG_FILTERSPEC f[] = { { Tr(L"Documentos de texto"), L"*.rtf;*.txt;*.md;*.log;*.csv;*.ini;*.json" }, { Tr(L"Todos"), L"*.*" } };
d->SetFileTypes(2, f);
if (SUCCEEDED(d->Show(wnd))) {
IShellItem* it = nullptr;