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

Green button keeps zoomed custom-title-bar windows below the menu bar; index growth no longer doubles name memory; Wi-Fi/Bluetooth detail rows left-aligned (found in the Rust live test)

Eternity0706284aa8ad45c9c8
diff --git a/docs/registro-mudancas.txt b/docs/registro-mudancas.txt
index e978281..88ff4ec 100644
--- a/docs/registro-mudancas.txt
+++ b/docs/registro-mudancas.txt
@@ -2008,3 +2008,14 @@ Compilado (tudo), instalado, Shell e reserva do Finder reiniciados às 23:07 sem
abria junto).
Compilado; não testado na tela (o Shell em Rust estava no ar).
DESFAZER: reverter o commit e compilar.
+[2026-11-27 15:34] Mais achados do teste ao vivo do Rust (dd6aee0), trazidos para o C++:
+ - macjanela.cpp ToggleZoom (botão verde): numa janela de barra própria maximizada (Claude, Electron), logo depois do
+ SW_RESTORE o DWM ainda devolvia a moldura da maximizada e o topo da ampliada caía em y=0, atrás da barra de menus; o
+ Windows gravava isso como posição normal. Agora as bordas são lidas antes do SW_RESTORE e o topo é o da área útil;
+ ao desfazer, o tamanho de antes nunca começa acima da área útil.
+ - indice.cpp: a primeira atualização depois da carga dobrava a capacidade dos nomes (shrink_to_fit seguido de +=);
+ agora reserva só o que falta, com ~1,5% de folga.
+ - central.cpp: as linhas do detalhe Wi-Fi/Bluetooth usam g_tfDet (à esquerda e no meio da altura) em vez do g_tfTile
+ (centrado e no alto).
+ Compilado (Shell e DLLs das janelas). Não testado na tela.
+ DESFAZER: reverter o commit e compilar.
diff --git a/src/janelas/macjanela.cpp b/src/janelas/macjanela.cpp
index b8a4d80..5e5c7ac 100644
--- a/src/janelas/macjanela.cpp
+++ b/src/janelas/macjanela.cpp
@@ -1510,10 +1510,20 @@ void ToggleZoom(Info* in) {
if (in->zoomed) {
in->zoomed = false;
RemovePropW(h, L"MacJanelaAmpliada");
+ // o tamanho de antes não pode começar atrás da barra de menus (achado no teste do Rust: o Windows tinha gravado
+ // como posição normal o topo em y=0)
+ MONITORINFO mi{ sizeof(mi) };
+ if (GetMonitorInfoW(MonitorFromWindow(h, MONITOR_DEFAULTTONEAREST), &mi) && in->before.top < mi.rcWork.top)
+ OffsetRect(&in->before, 0, mi.rcWork.top - in->before.top);
MoveAnimated(in, in->before);
return;
}
+ // Barra própria (Claude, apps Electron) maximizada: logo depois do SW_RESTORE o DWM ainda devolve a moldura da
+ // maximizada, e a borda de cima medida saía igual à altura da barra de menus; o ZoomRect punha o topo em y=0, atrás
+ // dela, e o Windows gravava isso como posição normal (achado no teste do Rust, 27/11/2026). As bordas são lidas antes.
+ bool preIns = false; int pl = 0, pt = 0, pr = 0, pb = 0;
if (IsZoomed(h)) { // maximizada pelo Windows/pelo app: vira "ampliada" (o tamanho normal guardado é o de antes)
+ if (in->custom) { Insets(in, pl, pt, pr, pb); preIns = true; }
WINDOWPLACEMENT wp{ sizeof(wp) };
GetWindowPlacement(h, &wp);
in->before = wp.rcNormalPosition;
@@ -1523,6 +1533,11 @@ void ToggleZoom(Info* in) {
ShowWindow(h, SW_RESTORE);
} else GetWindowRect(h, &in->before);
RECT z = ZoomRect(in);
+ if (preIns) {
+ MONITORINFO mi{ sizeof(mi) };
+ if (GetMonitorInfoW(MonitorFromWindow(h, MONITOR_DEFAULTTONEAREST), &mi))
+ z = { mi.rcWork.left - pl, mi.rcWork.top, mi.rcWork.right + pr, mi.rcWork.bottom + pb };
+ }
in->zoomed = true;
SetPropW(h, L"MacJanelaAmpliada", (HANDLE)1); // o Shell sabe que Win+↓ deve desfazer
MoveAnimated(in, z);
diff --git a/src/shell/central.cpp b/src/shell/central.cpp
index add0c45..b9b919a 100644
--- a/src/shell/central.cpp
+++ b/src/shell/central.cpp
@@ -67,7 +67,7 @@ ui::GpuSurface g_s;
bool g_open, g_glass, g_menu;
double g_openAt; // ms de anim::Now
DWORD g_closedAt;
-IDWriteTextFormat *g_tfBold, *g_tfSmall, *g_tfTile;
+IDWriteTextFormat *g_tfBold, *g_tfSmall, *g_tfTile, *g_tfDet; // g_tfDet: linhas do detalhe Wi-Fi/Bluetooth (à esquerda, no meio da altura)
// ---- estado (lido em threads; a janela só desenha)
std::mutex g_mx;
@@ -1600,7 +1600,7 @@ void PaintTahoe() {
br->SetColor(on ? onColor : D2D1::ColorF(1, 1, 1, 0.18f));
dc->FillEllipse(D2D1::Ellipse(c, 13, 13), br);
Sym(dc, br, sym, fb, D2D1::RectF(c.x - 7, cy - 7, c.x + 7, cy + 7), white);
- Text(dc, br, name, D2D1::RectF(L + 34, y, R - (lock ? 22 : 0), y + DET_ROW), g_tfTile, white);
+ Text(dc, br, name, D2D1::RectF(L + 34, y, R - (lock ? 22 : 0), y + DET_ROW), g_tfDet, white);
if (lock) Sym(dc, br, L"lock.fill", 0xE72E, D2D1::RectF(R - 14, cy - 6, R - 2, cy + 6), white2);
g_hits.push_back({ H_DET_ROW, D2D1::RectF(full.left + 4, y, full.right - 4, y + DET_ROW), arg });
y += DET_ROW;
@@ -1609,7 +1609,7 @@ void PaintTahoe() {
br->SetColor(D2D1::ColorF(1, 1, 1, 0.14f));
dc->FillRectangle(D2D1::RectF(L, y + 5, R, y + 5 + 1 / sc), br);
y += DET_SEP;
- Text(dc, br, link, D2D1::RectF(L, y, R, y + DET_LINK), g_tfTile, white);
+ Text(dc, br, link, D2D1::RectF(L, y, R, y + DET_LINK), g_tfDet, white);
g_hits.push_back({ H_DET_SET, D2D1::RectF(full.left + 4, y, full.right - 4, y + DET_LINK) });
};
std::vector<std::wstring> nets; std::vector<BtDevice> bts;
@@ -1634,14 +1634,14 @@ void PaintTahoe() {
sw(st.radio[0] == 1);
if (!st.ssid.empty()) { head(Tr(L"Rede Conhecida")); row(st.ssid, L"wifi", 0xE701, true, blue, -1, true); }
Text(dc, br, Tr(L"Outras Redes"), D2D1::RectF(L, y, R, y + 22), g_tfBold, white2); y += 22;
- if (nets.empty()) { Text(dc, br, g_detLoading ? Tr(L"Procurando…") : Tr(L"Nenhuma rede encontrada"), D2D1::RectF(L, y, R, y + DET_ROW), g_tfTile, white2); y += DET_ROW; }
+ if (nets.empty()) { Text(dc, br, g_detLoading ? Tr(L"Procurando…") : Tr(L"Nenhuma rede encontrada"), D2D1::RectF(L, y, R, y + DET_ROW), g_tfDet, white2); y += DET_ROW; }
for (size_t i = 0; i < nets.size() && i < 6; i++) row(nets[i], L"wifi", 0xE701, false, blue, (int)i, true);
tail(Tr(L"Ajustes de Wi‑Fi…"));
break;
case D_BT:
sw(st.radio[1] == 1);
head(Tr(L"Dispositivos"));
- if (bts.empty()) { Text(dc, br, g_btLoading ? Tr(L"Procurando…") : Tr(L"Nenhum dispositivo"), D2D1::RectF(L, y, R, y + DET_ROW), g_tfTile, white2); y += DET_ROW; }
+ if (bts.empty()) { Text(dc, br, g_btLoading ? Tr(L"Procurando…") : Tr(L"Nenhum dispositivo"), D2D1::RectF(L, y, R, y + DET_ROW), g_tfDet, white2); y += DET_ROW; }
for (size_t i = 0; i < bts.size() && i < 6; i++) {
const auto& device = bts[i];
std::wstring label = device.name;
@@ -2465,10 +2465,13 @@ bool central::Create(HINSTANCE hi) {
g_tfBold = ui::Format(13, DWRITE_FONT_WEIGHT_SEMI_BOLD);
g_tfSmall = ui::Format(11, DWRITE_FONT_WEIGHT_NORMAL);
g_tfTile = ui::Format(11, DWRITE_FONT_WEIGHT_MEDIUM, false, DWRITE_TEXT_ALIGNMENT_CENTER);
- for (auto* tf : { g_tfBold, g_tfSmall }) if (tf) { tf->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER); tf->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP); }
+ // linhas do detalhe Wi-Fi/Bluetooth: usavam o g_tfTile (centrado e no alto), o nome não ficava ao lado do ícone
+ // nem no meio da linha (achado no teste do Rust, 27/11/2026)
+ g_tfDet = ui::Format(11, DWRITE_FONT_WEIGHT_MEDIUM);
+ for (auto* tf : { g_tfBold, g_tfSmall, g_tfDet }) if (tf) { tf->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER); tf->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP); }
if (g_tfTile) g_tfTile->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_NEAR);
DWRITE_TRIMMING tr{ DWRITE_TRIMMING_GRANULARITY_CHARACTER, 0, 0 };
- for (auto* tf : { g_tfBold, g_tfSmall }) if (tf) { // texto que não cabe termina em "…" (como no Mac), não cortado no meio
+ for (auto* tf : { g_tfBold, g_tfSmall, g_tfDet }) if (tf) { // texto que não cabe termina em "…" (como no Mac), não cortado no meio
IDWriteInlineObject* dots = nullptr;
if (ui::dw) ui::dw->CreateEllipsisTrimmingSign(tf, &dots);
tf->SetTrimming(&tr, dots);
diff --git a/src/shell/indice.cpp b/src/shell/indice.cpp
index 8df65cb..a7e201e 100644
--- a/src/shell/indice.cpp
+++ b/src/shell/indice.cpp
@@ -321,6 +321,12 @@ bool Incremental(const std::vector<std::wstring>& dirs) {
}
for (auto& [id, mt] : touch) if (id < N) ix.nodes[id].mtime = mt;
uint32_t base = N, nameBase = (uint32_t)ix.names.size();
+ // depois do shrink_to_fit da carga, o primeiro acréscimo dobrava a capacidade (achado no teste do Rust: 74 → 147
+ // MB): cresce só o que falta, com ~1,5% de folga para as próximas atualizações
+ if (ix.names.size() + add.names.size() > ix.names.capacity())
+ ix.names.reserve(ix.names.size() + add.names.size() + (ix.names.size() + add.names.size()) / 64);
+ if (ix.nodes.size() + add.nodes.size() > ix.nodes.capacity())
+ ix.nodes.reserve(ix.nodes.size() + add.nodes.size() + (ix.nodes.size() + add.nodes.size()) / 64);
for (auto n : add.nodes) {
if (n.parent != UINT32_MAX && (n.parent & LOCAL)) n.parent = (n.parent & ~LOCAL) + base;
n.name += nameBase;