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

Drag maximized Chromium apps out, smoother Quick Look video, genie fade, QuickTime volume

Eternity0706289c7a7c04a6f1
diff --git a/docs/registro-mudancas.txt b/docs/registro-mudancas.txt
index e432b8a..0579c5a 100644
--- a/docs/registro-mudancas.txt
+++ b/docs/registro-mudancas.txt
@@ -876,3 +876,12 @@ Compilado (tudo), instalado, Shell e reserva do Finder reiniciados às 23:07 sem
Compilada a DLL das janelas, instalada, Shell reiniciado (a versão nova assumiu Discord, Claude e Chrome). Conferido: faixa do Discord dentro da janela (433..2013, área do app 433+1580), sem região, DWM informa a parte visível; Chrome maximizado com o grupo de abas inteiro e os botões no lugar dos do Windows (fotos dos cantos, apagadas); Edge de teste (perfil próprio) normal com os botões à esquerda, maximizado com a faixa rente (0,30), verde restaurou, vermelho fechou, tela cheia (--start-fullscreen) sem faixa nem sombra. NÃO conferidos na tela: o Discord de perto (estava atrás do Chrome do usuário), arrastar abas, F11 entrando com a janela já pega (pelo código a faixa some: Fullscreen()), o menu do verde.
Obs. (PR #14, ainda não juntado): arrastar pela barra um Chrome/Discord MAXIMIZADO não desmaximiza. Quem faz isso é o Snap do Windows, que o Shell desliga (SPI_SETWINARRANGING em src\shell\encaixe.cpp); sem ele nem vem o EVENT_SYSTEM_MOVESIZESTART. Não é a faixa; o PR #14 traz a opção encaixe_windows.
Nada no registro do Windows. DESFAZER: reverter o commit (barra_mac_propria=0 desliga os botões nesses apps).
+
+[2026-11-21 14:05] Bugs apontados nos PRs do cooblg (#9, #12, #13, #14), com código nosso (o usuário preferiu não juntar os PRs).
+ 1) #9 (Salvar/Pasta em outros idiomas): já resolvido desde a build-23 (Salvar pela estrutura da janela; Pasta pela falta da lista de tipos). Nada a mudar.
+ 2) QuickTime (src\quicktime\main.cpp): o volume vai para quicktime_volume no ajustes.txt ao fechar (só se mudou) e é lido ao abrir. Antes cada vídeo abria em 100 %.
+ 3) Gênio (src\shell\genio.cpp): os níveis menores com menos faixas (n0 x 0,55^nível, no mínimo 10; eram n0/2 em todos): menos preparo antes de a janela se mexer. No fim a janela some de todo (opacidade 1 -> 0 nos últimos 25 %, nos dois motores); parava em 85 % e sumia num quadro (provável causa do issue #16).
+ 4) Quick Look do Finder (src\finder\main.cpp): os quadros do vídeo no ritmo da tela, por uma thread com timer de alta resolução no período do DWM (24 a 240 Hz) que manda WM_APP_QUADRO; era um SetTimer de 15 ms (engasgos). Sem WaitForVBlank (pode travar com a tela apagada): a espera nunca passa de 100 ms. T_MEDIA fica em 100 ms para o tempo e o fim.
+ 5) WacOSWindow.dll (src\janelas\macjanela.cpp, LeveProc): arrastar pela barra um app de barra própria maximizado (Chrome, Discord, Electron) desmaximiza e segue o ponteiro (DragDetect, SW_RESTORE no lugar proporcional, SC_MOVE). Só com o Snap do Windows desligado (o Shell desliga para o encaixe dele). Sem opção nova (o PR #14 devolvia o Snap ao Windows por uma opção).
+ Compilados DLL, Shell, Finder e apps; instalado; a DLL nova assumiu o Chrome (MacJanelaPropria). NÃO conferidos na tela: volume do QuickTime, gênio, vídeo no Quick Look, arrastar o Chrome maximizado (sem SendInput no PC real).
+ Nada no registro do Windows. DESFAZER: reverter o commit.
diff --git a/src/finder/main.cpp b/src/finder/main.cpp
index 9ca77aa..c732df1 100644
--- a/src/finder/main.cpp
+++ b/src/finder/main.cpp
@@ -84,7 +84,7 @@ static float CellMinW() { return std::max(96.f, g_icon + 38); }
static float CellH() { return g_icon + 56.5f; }
static float LabelW() { return std::max(98.f, g_icon + 34); }
-enum : UINT { WM_APP_THUMB = WM_APP + 1, WM_APP_CHANGE = WM_APP + 2, WM_APP_SEARCH = WM_APP + 3, WM_APP_MEDIA = WM_APP + 4, WM_APP_WARMUP = WM_APP + 5, WM_APP_INFO = WM_APP + 6 };
+enum : UINT { WM_APP_THUMB = WM_APP + 1, WM_APP_CHANGE = WM_APP + 2, WM_APP_SEARCH = WM_APP + 3, WM_APP_MEDIA = WM_APP + 4, WM_APP_WARMUP = WM_APP + 5, WM_APP_INFO = WM_APP + 6, WM_APP_QUADRO = WM_APP + 7 };
enum : UINT_PTR { T_SCROLL = 1, T_RELOAD = 2, T_CARET = 3, T_AUTOSCROLL = 4, T_SCROLLBAR = 5, T_SEARCH = 7, T_MEDIA = 8, T_WARMUP = 9, T_SLOWRENAME = 10, T_TAHOE = 11, T_FRENTE = 12, T_DRIVES = 13 };
// Logo depois de abrir, quem pediu às vezes toma a frente de volta (o painel de downloads do Chrome se fecha e
// reativa a janela dele): por 3 s, se o usuário não clicou nem apertou tecla, o Finder volta para a frente.
@@ -3661,11 +3661,46 @@ static D2D1_RECT_F QlPhotoRect(D2D1_RECT_F body, UINT iw, UINT ih, bool fill) {
return D2D1::RectF(x, y, x + w, y + h);
}
+// Ritmo dos quadros do vídeo no Quick Look: uma thread com um timer de alta resolução no período da tela (60, 120,
+// 144 Hz... pelo DWM) avisa a janela, que pergunta ao Media Foundation se já há quadro novo. Era um SetTimer de 15 ms:
+// os timers comuns andam em degraus de ~15,6 ms e são as mensagens de menor prioridade, então num vídeo de 30/60
+// quadros uns quadros saíam atrasados e outros repetidos (engasgos; PR #12 apontou, 21/11/2026). A espera nunca passa
+// de 100 ms (sem depender do monitor ligado): parar é rápido mesmo com a tela apagada.
+static std::atomic<bool> g_quadrosOn{ false }, g_quadroNaFila{ false };
+static std::thread g_quadros;
+static void QuadrosParar() {
+ g_quadrosOn = false;
+ if (g_quadros.joinable()) g_quadros.join();
+ g_quadroNaFila = false;
+}
+static void QuadrosComecar() {
+ QuadrosParar();
+ double hz = 60;
+ DWM_TIMING_INFO ti{ sizeof(ti) };
+ if (SUCCEEDED(DwmGetCompositionTimingInfo(nullptr, &ti)) && ti.rateRefresh.uiNumerator && ti.rateRefresh.uiDenominator)
+ hz = (double)ti.rateRefresh.uiNumerator / ti.rateRefresh.uiDenominator;
+ hz = std::clamp(hz, 24.0, 240.0);
+ g_quadrosOn = true;
+ HWND janela = g_hwnd;
+ g_quadros = std::thread([hz, janela] {
+ HANDLE tm = CreateWaitableTimerExW(nullptr, nullptr, 0x2 /*CREATE_WAITABLE_TIMER_HIGH_RESOLUTION*/, TIMER_ALL_ACCESS);
+ if (!tm) tm = CreateWaitableTimerExW(nullptr, nullptr, 0, TIMER_ALL_ACCESS);
+ LARGE_INTEGER passo; passo.QuadPart = -(LONGLONG)std::llround(1e7 / hz); // relativo, em 100 ns
+ while (g_quadrosOn) {
+ if (tm && SetWaitableTimer(tm, &passo, 0, nullptr, nullptr, FALSE)) WaitForSingleObject(tm, 100);
+ else Sleep(8);
+ if (g_quadrosOn && !g_quadroNaFila.exchange(true)) PostMessageW(janela, WM_APP_QUADRO, 0, 0);
+ }
+ if (tm) CloseHandle(tm);
+ });
+}
+
// Abre/fecha o player conforme o item do Quick Look (chamado antes de cada quadro).
static void QlSyncMedia() {
std::wstring want;
if (g_ql) { int i = QlItem(); if (i >= 0 && IsMediaFile(g_items[i])) want = g_items[i].path; }
if (want == g_qlMediaPath) return;
+ QuadrosParar();
media::Close();
KillTimer(g_hwnd, T_MEDIA);
g_qlSeekDrag = false;
@@ -3681,7 +3716,8 @@ static void QlSyncMedia() {
}
media::Open(want);
g_qlMouseAt = GetTickCount();
- SetTimer(g_hwnd, T_MEDIA, 15, nullptr);
+ SetTimer(g_hwnd, T_MEDIA, 100, nullptr); // o tempo e o fim; os quadros vêm pelo WM_APP_QUADRO
+ QuadrosComecar();
}
static bool QlMediaOn(const Entry& e) { return !g_qlMediaPath.empty() && g_qlMediaPath == e.path && media::Active() && !media::Failed(); }
@@ -6698,7 +6734,7 @@ static LRESULT CALLBACK WndProc(HWND h, UINT m, WPARAM w, LPARAM l) {
case T_MEDIA: { // quadros do vídeo; tempo da música ~5x por segundo
static DWORD last;
// sem player, ou o vídeo não abriu (sem codec): o timer para (antes seguia redesenhando a janela à toa)
- if (!media::Active() || media::Failed()) { KillTimer(h, T_MEDIA); Invalidate(); break; }
+ if (!media::Active() || media::Failed()) { KillTimer(h, T_MEDIA); QuadrosParar(); Invalidate(); break; }
bool fresh = media::UpdateFrame();
if (fresh || GetTickCount() - last > 200) { last = GetTickCount(); Render(); }
break;
@@ -6781,7 +6817,12 @@ static LRESULT CALLBACK WndProc(HWND h, UINT m, WPARAM w, LPARAM l) {
}
DestroyWindow(h);
return 0;
+ case WM_APP_QUADRO: // hora de um quadro (QuadrosComecar): só desenha se o vídeo tem quadro novo
+ g_quadroNaFila = false;
+ if (media::Active() && !media::Failed() && media::UpdateFrame()) Render();
+ return 0;
case WM_DESTROY:
+ QuadrosParar();
shadow::Destroy();
if (g_notifyId) SHChangeNotifyDeregister(g_notifyId);
RevokeDragDrop(h);
diff --git a/src/janelas/macjanela.cpp b/src/janelas/macjanela.cpp
index 42b5524..848b2a7 100644
--- a/src/janelas/macjanela.cpp
+++ b/src/janelas/macjanela.cpp
@@ -83,9 +83,10 @@ struct Info {
// por cima vão os botões do Mac à esquerda e uma faixa da cor da barra sobre os botões do app
bool custom = false;
// Barra própria: o canto de cima à esquerda quase sempre tem coisa do app (grupos de abas do Chrome, setas do
- // Discord, menu do Claude e do VS Code). Os botões do Mac só ficam lá com o canto vazio; senão vão para o lugar
- // dos botões do app, numa faixa da largura medida deles (MedirBarra), sem esconder nada.
- bool lightsRight = false;
+ // Discord, menu do Claude e do VS Code). Com o canto vazio os botões do Mac ficam ali, na linha do app; senão a
+ // área do app desce (WM_NCCALCSIZE) e ganha em cima uma faixa de título do Mac, com os botões à esquerda (como uma
+ // barra de título do Mac por cima): nada do app fica escondido. Fica ligada enquanto a janela existir (sem pular).
+ bool topStrip = false;
float patchR = 0; // largura dos botões do app (pt); 0 = ainda não medida (PATCH_R)
DWORD layoutAt = 0; // última medição (0 = medir na próxima volta do timer)
// janela de ferramenta com barra (plug-ins VST do Ableton e afins): barra escura compacta, como as janelas de
@@ -177,9 +178,14 @@ RECT FrameRect(HWND h) {
RECT cli{ c.x, c.y, c.x + cr.right, c.y + cr.bottom }, r;
bool aware = GetAwarenessFromDpiAwarenessContext(GetWindowDpiAwarenessContext(h)) != DPI_AWARENESS_UNAWARE;
if (!aware || FAILED(DwmGetWindowAttribute(h, DWMWA_EXTENDED_FRAME_BOUNDS, &r, sizeof(r)))) return cli;
- RECT x;
- return IntersectRect(&x, &r, &cli) ? x : cli;
+ // dos lados e embaixo, rente à área do app; em cima, o topo do DWM (com a faixa de título nossa a área do app
+ // começa mais abaixo, e a faixa faz parte da janela)
+ RECT x{ std::max(r.left, cli.left), std::min(r.top, cli.top), std::min(r.right, cli.right), std::min(r.bottom, cli.bottom) };
+ return x.right > x.left && x.bottom > x.top ? x : cli;
}
+// altura da faixa de título do Mac por cima do app (px); 0 sem ela. 28 pt (Leopard 22), como a barra só de título do Mac
+int StripPx(HWND h) { return (int)std::lround((leopard::On() ? 22 : 28) * GetDpiForWindow(h) / 96.f); }
+int AppTop(HWND h) { POINT c{ 0, 0 }; ClientToScreen(h, &c); return c.y; } // topo da área do app (tela)
bool TemaTahoe(bool force = false); // mais abaixo: tema Tahoe ligado no ajustes.txt do Shell
bool TemaGolden(); // mais abaixo: macOS 27 Golden Gate (liquid_glass=1 + golden_gate=1)
@@ -233,11 +239,12 @@ void LightsLayout(Info* in, float& lx0, float& lpitch, float& lr) {
if (int u = UnifiedBar(in->owner)) { lx0 = u > 40 ? 26.f : 16.f; lpitch = 23; lr = 7; } // macOS 27: com barra de ferramentas 26, 49, 72; só título 16, 39, 62
if (leopard::On() && !in->tool && !UnifiedBar(in->owner)) { lx0 = 14.5f; lpitch = 21; lr = 7; } // Leopard (medido: 14 px, 21 entre centros)
lx0 += WinAppInset(in);
- if (in->custom && in->lightsRight) { // no lugar dos botões do app: centrados na faixa deles
- RECT r = BarRect(in);
- float W = (r.right - r.left) / Scale(in->owner);
- lx0 = W - PatchR(in) / 2 - lpitch;
- }
+}
+// altura (pt) do centro dos botões: no meio da faixa de título nossa, ou da barra do app
+float LightsY(Info* in, float H) {
+ if (in->custom && in->topStrip) { RECT f = FrameRect(in->owner); return (AppTop(in->owner) - f.top) / Scale(in->owner) / 2; }
+ if (in->custom && in->barH) return in->barH / Scale(in->owner) / 2;
+ return H / 2;
}
void Insets(Info* in, int& l, int& t, int& rr, int& b);
@@ -262,7 +269,7 @@ RECT BarRect(Info* in) {
RECT f = FrameRect(in->owner);
float sc = Scale(in->owner);
int h = in->barH ? in->barH : (int)(32 * sc);
- return { f.left, f.top, f.right, f.top + h };
+ return { f.left, f.top, f.right, std::max<LONG>(f.top, AppTop(in->owner)) + h }; // a faixa de título (se houver) e a barra do app
}
// ---- desenho da faixa (janela em camadas, alfa por pixel)
@@ -314,8 +321,16 @@ void Paint(Info* in) {
rt->FillGeometry(g, b);
g->Release();
};
- if (!in->lightsRight) fill(in->leftColor, D2D1::RectF(0, 0, PATCH_L, H), true);
- fill(in->rightColor, D2D1::RectF(W - PatchR(in), 0, W, H), false);
+ float S = (AppTop(in->owner) - r.top) / sc; // faixa de título nossa (0 sem ela)
+ if (in->topStrip && S > 0) { // faixa inteira na cor da barra do app (parece a mesma barra, mais alta)
+ fill(in->rightColor, D2D1::RectF(0, 0, W / 2 + 1, S), true);
+ fill(in->rightColor, D2D1::RectF(W / 2, 0, W, S), false);
+ b->SetColor(D2D1::ColorF(GetRValue(in->rightColor) / 255.f, GetGValue(in->rightColor) / 255.f, GetBValue(in->rightColor) / 255.f, 1));
+ rt->FillRectangle(D2D1::RectF(W - PatchR(in), S - 1, W, H), b); // e os botões do app, na linha dele
+ } else {
+ fill(in->leftColor, D2D1::RectF(0, 0, PATCH_L, H), true);
+ fill(in->rightColor, D2D1::RectF(W - PatchR(in), 0, W, H), false);
+ }
}
// Leopard: a barra de título padrão vira o metal cinza do 10.5 de ponta a ponta (com os cantos de cima da
// janela); a barra própria dos apps (Chromium e afins) e as janelas de plug-in ficam como estão
@@ -328,7 +343,7 @@ void Paint(Info* in) {
float lx0, lpitch, lr;
LightsLayout(in, lx0, lpitch, lr);
for (int k = 0; k < 3; k++) {
- D2D1_POINT_2F c{ lx0 + k * lpitch, H / 2 };
+ D2D1_POINT_2F c{ lx0 + k * lpitch, LightsY(in, H) };
bool lit = (in->active || in->hoverLights) && can[k];
b->SetColor(lit ? on[k] : (in->dark ? D2D1::ColorF(1, 1, 1, 0.22f) : D2D1::ColorF(0, 0, 0, 0.18f)));
rt->FillEllipse(D2D1::Ellipse(c, lr, lr), b);
@@ -394,7 +409,7 @@ int HitLight(Info* in, POINT clientPt) {
float x = clientPt.x / sc, y = clientPt.y / sc;
float lx0, lpitch, lr;
LightsLayout(in, lx0, lpitch, lr); // mesmas posições do desenho
- for (int k = 0; k < 3; k++) if (std::fabs(x - (lx0 + k * lpitch)) <= 9 && std::fabs(y - H / 2) <= 8) return k;
+ for (int k = 0; k < 3; k++) if (std::fabs(x - (lx0 + k * lpitch)) <= 9 && std::fabs(y - LightsY(in, H)) <= 8) return k;
return -1;
}
@@ -423,6 +438,7 @@ void Insets(Info* in, int& l, int& t, int& rr, int& b) {
// rente à área do app nos lados e embaixo (sem sobrar nada da borda clássica); em cima, a barra
// inteira (barra padrão) ou nada (barra própria: a área do app é a janela visível inteira)
RECT wr; GetWindowRect(in->owner, &wr);
+ if (in->custom) { RECT f = FrameRect(in->owner); l = f.left - wr.left; t = f.top - wr.top; rr = wr.right - f.right; b = wr.bottom - f.bottom; return; }
POINT c{ 0, 0 }; ClientToScreen(in->owner, &c);
RECT cr; GetClientRect(in->owner, &cr);
l = c.x - wr.left; rr = wr.right - (c.x + cr.right); b = wr.bottom - (c.y + cr.bottom);
@@ -980,8 +996,9 @@ LRESULT CALLBACK OverlayProc(HWND h, UINT m, WPARAM w, LPARAM l) {
p.x -= r.left; p.y -= r.top;
float sc = Scale(in->owner);
if (in->custom) { // só as duas faixas pintadas; o resto deixa o clique passar para a barra do app (abas, arrastar)
- if (!in->lightsRight && p.x / sc < PATCH_L) return HTCLIENT;
- if (p.x / sc > (r.right - r.left) / sc - PatchR(in)) return HTCLIENT;
+ float S = (AppTop(in->owner) - r.top) / sc; // faixa de título nossa: os botões; o resto arrasta (barra da janela)
+ if (p.x / sc < PATCH_L && (in->topStrip ? p.y / sc < S : true)) return HTCLIENT;
+ if (p.x / sc > (r.right - r.left) / sc - PatchR(in) && (!in->topStrip || p.y / sc >= S)) return HTCLIENT;
return HTTRANSPARENT;
}
if (p.x / sc < (UnifiedBar(in->owner) > 40 ? 84 : 72) + WinAppInset(in)) return HTCLIENT;
@@ -1167,6 +1184,7 @@ void SampleCaption(Info* in) {
void SampleBar(Info* in) {
if (IsIconic(in->owner) || !IsWindowVisible(in->owner) || in->transit) return;
RECT f = FrameRect(in->owner);
+ f.top = std::max<LONG>(f.top, AppTop(in->owner)); // a barra do app (abaixo da faixa de título nossa)
float sc = Scale(in->owner);
// Inativa também: o Chrome clareia a barra ao perder o foco e a faixa ficava na cor de ativa. Só lê se os pontos
// lidos estão à mostra (nenhuma outra janela por cima deles).
@@ -1218,12 +1236,12 @@ void SampleBar(Info* in) {
}
SelectObject(mem, old); DeleteObject(bmp); DeleteDC(mem); ReleaseDC(nullptr, screen);
UINT32 left = count.empty() ? right : std::max_element(count.begin(), count.end(), [](auto& a, auto& b) { return a.second < b.second; })->first;
- barH = std::clamp(barH, (int)(20 * sc), (int)(48 * sc));
+ barH = std::clamp(barH, (int)(30 * sc), (int)(48 * sc)); // mínimo 30 pt: a barra preta do Discord media 20 e a faixa não cobria o pé dos botões dele
COLORREF L = col(left), R = col(right);
if (L == in->leftColor && R == in->rightColor && barH == in->barH) return;
if (barH != in->barH) in->layoutAt = 0; // outra altura de barra: mede de novo onde ficam os botões
in->leftColor = L; in->rightColor = R; in->barH = barH;
- COLORREF D = in->lightsRight ? R : L; // o fundo de onde estão os botões do Mac
+ COLORREF D = in->topStrip ? R : L; // o fundo de onde estão os botões do Mac (a faixa de título tem a cor da direita)
in->dark = (GetRValue(D) * 299 + GetGValue(D) * 587 + GetBValue(D) * 114) / 1000 < 128;
PlaceOverlay(in);
}
@@ -1241,7 +1259,7 @@ void MedirBarra(Info* in) {
RECT f = FrameRect(h);
float sc = Scale(h);
int bh = in->barH ? in->barH : (int)(32 * sc);
- int W = wr.right - wr.left, H = (f.top - wr.top) + bh;
+ int W = wr.right - wr.left, H = ((int)std::max<LONG>(f.top, AppTop(h)) - wr.top) + bh;
if (W < 200 || W > 16384 || H < 16 || H > 1024) return;
HDC mdc = CreateCompatibleDC(nullptr);
BITMAPINFO bi{}; bi.bmiHeader = { sizeof(BITMAPINFOHEADER), W, -H, 1, 32, BI_RGB };
@@ -1255,7 +1273,7 @@ void MedirBarra(Info* in) {
auto dist = [](UINT32 a, UINT32 b) {
return std::abs((int)(a & 255) - (int)(b & 255)) + std::abs((int)((a >> 8) & 255) - (int)((b >> 8) & 255)) + std::abs((int)((a >> 16) & 255) - (int)((b >> 16) & 255));
};
- int x0 = std::max(0, (int)(f.left - wr.left)), x1 = std::min(W, (int)(f.right - wr.left)), y0 = f.top - wr.top;
+ int x0 = std::max(0, (int)(f.left - wr.left)), x1 = std::min(W, (int)(f.right - wr.left)), y0 = (int)std::max<LONG>(f.top, AppTop(h)) - wr.top;
int ya = y0 + (int)(3 * sc), yb = std::min(H, y0 + bh - (int)(3 * sc));
bool done = false;
if (ok && yb > ya && x1 - x0 > 200) {
@@ -1268,7 +1286,11 @@ void MedirBarra(Info* in) {
if (it == cnt.end()) { if (cnt.size() < 256) cnt.push_back({ v, 1 }); } else it->second++;
}
UINT32 bg = cnt.empty() ? 0 : std::max_element(cnt.begin(), cnt.end(), [](auto& a, auto& b) { return a.second < b.second; })->first;
- if (bg != 0) { // preto puro: o app ainda não desenhou (tenta de novo na próxima volta)
+ // tudo preto: o app ainda não desenhou (tenta de novo na próxima volta). Só o fundo preto não basta: o Discord
+ // (tema escuro) tem a barra preto puro e nunca era medido
+ bool drawn = bg != 0;
+ for (int y = ya; y < yb && !drawn; y += 2) for (int x = x0; x < x1 && !drawn; x += 3) drawn = at(x, y) != 0;
+ if (drawn) {
done = true;
// (1) canto esquerdo, onde ficam os botões do Mac: alguns pixels soltos ainda contam como vazio
int busy = 0, lw = std::min(x1 - x0, (int)(PATCH_L * sc));
@@ -1291,8 +1313,11 @@ void MedirBarra(Info* in) {
float p1 = c0 - c1, p2 = c1 - c2;
if (std::fabs(p1 - p2) <= 4 * sc && p1 >= 24 * sc && p1 <= 64 * sc) pr = ((x1 - c2) + p1 / 2) / sc + 2;
}
- bool changed = right != in->lightsRight || (pr > 0 && std::fabs(pr - in->patchR) >= 1);
- in->lightsRight = right;
+ right = right || in->topStrip; // ligada fica ligada: a janela não pula de altura a cada grupo de abas
+ bool changed = right != in->topStrip || (pr > 0 && std::fabs(pr - in->patchR) >= 1);
+ bool strip = right && !in->topStrip;
+ in->topStrip = right;
+ if (strip) SetWindowPos(h, nullptr, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); // a área do app desce
if (pr > 0) in->patchR = pr;
g_ultimoLado = right ? 1 : 0; g_ultimoPatch = in->patchR;
if (changed) {
@@ -1353,6 +1378,46 @@ LRESULT CALLBACK OwnerProc(HWND h, UINT m, WPARAM w, LPARAM l, UINT_PTR, DWORD_P
if (p->rgrc[0].top > want) p->rgrc[0].top = want;
return r;
}
+ // Barra própria com a faixa de título do Mac: a área do app começa StripPx mais abaixo (o app inteiro desce; nada
+ // fica escondido atrás dos botões). Só com a moldura de janela (WS_THICKFRAME): em tela cheia (F11, vídeo) o
+ // Chromium tira a moldura e a faixa some sozinha.
+ if (m == WM_NCCALCSIZE && w && in->custom && in->topStrip && (GetWindowLongW(h, GWL_STYLE) & WS_THICKFRAME) && !IsIconic(h)) {
+ auto* p = (NCCALCSIZE_PARAMS*)l;
+ LRESULT r = DefSubclassProc(h, m, w, l);
+ p->rgrc[0].top += StripPx(h);
+ if (p->rgrc[0].bottom < p->rgrc[0].top) p->rgrc[0].bottom = p->rgrc[0].top;
+ return r;
+ }
+ if (m == WM_NCHITTEST && in->custom && in->topStrip) { // a faixa: arrasta a janela; a beirada de cima redimensiona
+ LRESULT r = DefSubclassProc(h, m, w, l);
+ POINT pt{ (short)LOWORD(l), (short)HIWORD(l) };
+ RECT f = FrameRect(h);
+ int top = AppTop(h);
+ if (pt.y >= top || pt.y < f.top - 8 || pt.x < f.left - 8 || pt.x >= f.right + 8) return r;
+ if (IsZoomed(h)) return HTCAPTION;
+ int e = (int)(5 * Scale(h)), c = (int)(16 * Scale(h));
+ if (pt.y < f.top + e) return pt.x < f.left + c ? HTTOPLEFT : pt.x >= f.right - c ? HTTOPRIGHT : HTTOP;
+ if (pt.x < f.left + e) return HTLEFT;
+ if (pt.x >= f.right - e) return HTRIGHT;
+ return HTCAPTION;
+ }
+ if (m == WM_NCLBUTTONDBLCLK && w == HTCAPTION && in->custom && in->topStrip && (short)HIWORD(l) < AppTop(h) && (in->style & WS_MAXIMIZEBOX)) {
+ ShowWindow(h, IsZoomed(h) ? SW_RESTORE : SW_MAXIMIZE); // duplo clique na faixa: maximiza, como na barra do app
+ return 0;
+ }
+ if (m == WM_NCPAINT && in->custom && in->topStrip) { // a faixa fica na cor da barra mesmo antes de a nossa camada chegar
+ LRESULT r = DefSubclassProc(h, m, w, l);
+ if (HDC dc = GetWindowDC(h)) {
+ RECT wr; GetWindowRect(h, &wr);
+ RECT f = FrameRect(h);
+ RECT s{ f.left - wr.left, f.top - wr.top, f.right - wr.left, AppTop(h) - wr.top };
+ HBRUSH b = CreateSolidBrush(in->rightColor);
+ FillRect(dc, &s, b);
+ DeleteObject(b);
+ ReleaseDC(h, dc);
+ }
+ return r;
+ }
static UINT msgShow = RegisterWindowMessageW(L"MacJanelaMostrar"); // o Shell terminou a animação do ampliar
if (m == msgShow && msgShow) { ZoomShow(h); return 1; }
static UINT msgMove = RegisterWindowMessageW(L"MacJanelaMover"); // o Shell: volta para a área (limites.cpp)
@@ -1632,7 +1697,8 @@ void Attach(HWND h, int mode) {
} else {
in->dark = Dark(); // barra própria: os botões do Mac e a faixa por cima dos botões do app (BarRect/Paint)
SetPropW(h, L"MacJanelaPropria", (HANDLE)1);
- if (g_ultimoLado >= 0) { in->lightsRight = g_ultimoLado == 1; in->patchR = g_ultimoPatch; }
+ if (g_ultimoLado >= 0) { in->topStrip = g_ultimoLado == 1; in->patchR = g_ultimoPatch; }
+ if (in->topStrip) SetWindowPos(h, nullptr, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); // a área do app desce
}
in->overlay = CreateWindowExW(WS_EX_LAYERED | WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE, L"MacJanelaBarra", L"", WS_POPUP, 0, 0, 1, 1, h, nullptr, g_mod, nullptr);
if (in->overlay) { SetWindowLongPtrW(in->overlay, GWLP_USERDATA, (LONG_PTR)in); in->fastUntil = GetTickCount() + 900; SetTimer(in->overlay, 1, 16, nullptr); }
@@ -1682,9 +1748,11 @@ void Detach(HWND h, Info* in) {
DwmSetWindowAttribute(h, DWMWA_NCRENDERING_POLICY, &on, sizeof(on));
}
if (in->custom) {
+ bool strip = in->topStrip;
RemovePropW(h, L"MacJanelaAmpliada"); RemovePropW(h, PROP); RemovePropW(h, L"MacJanelaPropria");
RemoveWindowSubclass(h, OwnerProc, SUBCLASS_ID);
delete in;
+ if (strip) SetWindowPos(h, nullptr, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); // o app volta ao topo
return;
}
COLORREF defc = 0xFFFFFFFF;
@@ -1816,6 +1884,32 @@ LRESULT CALLBACK LeveProc(HWND h, UINT m, WPARAM w, LPARAM l, UINT_PTR, DWORD_PT
}
if (m == msgShow && msgShow) { ZoomShow(h); return 1; }
if (m == WM_NCDESTROY) { RemovePropW(h, PROP_LEVE); RemoveWindowSubclass(h, LeveProc, LEVE_ID); }
+ // Arrastar pela barra um app de barra própria maximizado (Chrome, Discord, Electron): sai do maximizado e segue o
+ // ponteiro, como no Windows e no Mac. Quem fazia isso era o Snap do Windows, que o Shell desliga para usar o encaixe
+ // dele (SPI_SETWINARRANGING): com ele desligado o Windows nem começa a mover uma janela maximizada, e a janela não
+ // saía do lugar (PR #14 apontou, 21/11/2026). Só quando o Snap do Windows está desligado; ligado, ele mesmo faz.
+ if (m == WM_NCLBUTTONDOWN && w == HTCAPTION && IsZoomed(h)) {
+ BOOL arranjo = TRUE;
+ SystemParametersInfoW(SPI_GETWINARRANGING, 0, &arranjo, 0);
+ POINT pt{ (short)LOWORD(l), (short)HIWORD(l) };
+ if (!arranjo && DragDetect(h, pt)) {
+ RECT fb; if (FAILED(DwmGetWindowAttribute(h, DWMWA_EXTENDED_FRAME_BOUNDS, &fb, sizeof(fb)))) GetWindowRect(h, &fb);
+ float fx = (pt.x - fb.left) / (float)std::max<LONG>(1, fb.right - fb.left); // onde o ponteiro estava na largura
+ int dy = pt.y - fb.top; // e abaixo do topo
+ WINDOWPLACEMENT wp{ sizeof(wp) }; GetWindowPlacement(h, &wp);
+ int nw = wp.rcNormalPosition.right - wp.rcNormalPosition.left;
+ SetPropW(h, PROP_LEVE, (HANDLE)1); // sem a animação de ampliar no meio do arrasto
+ ShowWindow(h, SW_RESTORE);
+ POINT c; GetCursorPos(&c);
+ RECT wr, vis; GetWindowRect(h, &wr);
+ if (FAILED(DwmGetWindowAttribute(h, DWMWA_EXTENDED_FRAME_BOUNDS, &vis, sizeof(vis)))) vis = wr;
+ if (nw <= 0) nw = vis.right - vis.left;
+ int x = c.x - (int)std::lround(fx * (vis.right - vis.left)) - (vis.left - wr.left), y = c.y - dy - (vis.top - wr.top);
+ SetWindowPos(h, nullptr, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
+ SendMessageW(h, WM_SYSCOMMAND, SC_MOVE | HTCAPTION, MAKELPARAM(c.x, c.y)); // o arrasto continua daqui
+ return 0;
+ }
+ }
if (m == WM_MOVING && l && ClampTopDrag(h, (RECT*)l)) return TRUE; // não passa por cima da barra de menus
// só quando o tamanho mudou: o Chromium/Electron troca a moldura (SWP_FRAMECHANGED, sem tamanho) já marcado
// como maximizado e antes de crescer; guardar ali fazia o maximizar de verdade passar sem animação
diff --git a/src/quicktime/main.cpp b/src/quicktime/main.cpp
index ba10504..448a0ef 100644
--- a/src/quicktime/main.cpp
+++ b/src/quicktime/main.cpp
@@ -25,7 +25,7 @@ IMFPMediaPlayer* g_mp;
std::wstring g_path;
bool g_full = false, g_ended = false, g_ready = false, g_noVideo = false; // noVideo: só som (sem o codec da imagem)
WINDOWPLACEMENT g_place{ sizeof(g_place) };
-float g_volume = 1.0f;
+float g_volume = 1.0f, g_volumeInicial = 1.0f;
DWORD g_lastMove = 0;
bool g_barShown = false, g_scrubbing = false;
IDWriteTextFormat *g_tfTime, *g_tfIcon, *g_tfIconBig, *g_tfTitle;
@@ -468,6 +468,9 @@ LRESULT CALLBACK Proc(HWND h, UINT m, WPARAM w, LPARAM l) {
}
case WM_DROPFILES: { wchar_t p[MAX_PATH * 2] = {}; if (DragQueryFileW((HDROP)w, 0, p, MAX_PATH * 2)) Open(p); DragFinish((HDROP)w); return 0; }
case WM_DESTROY:
+ // o volume fica para a próxima vez (quicktime_volume no ajustes.txt; gravado só ao fechar e só se mudou: antes
+ // cada vídeo aberto voltava a 100 %)
+ if (std::fabs(g_volume - g_volumeInicial) > 0.004f) { wchar_t v[16]; swprintf_s(v, L"%.2f", g_volume); SetAppSetting(L"quicktime_volume", v); }
if (g_mp) { g_mp->Shutdown(); g_mp->Release(); g_mp = nullptr; }
if (g_bar) DestroyWindow(g_bar);
if (g_barBack) DestroyWindow(g_barBack);
@@ -483,6 +486,9 @@ LRESULT CALLBACK Proc(HWND h, UINT m, WPARAM w, LPARAM l) {
int WINAPI wWinMain(HINSTANCE hi, HINSTANCE, PWSTR, int show) {
if (!Init()) return 1;
+ for (auto& l : ReadLines(DataPath(L"ajustes.txt"))) // o volume da última vez (WM_DESTROY grava)
+ if (l.rfind(L"quicktime_volume=", 0) == 0) { float v = (float)_wtof(l.c_str() + 17); if (v >= 0 && v <= 1) g_volume = v; }
+ g_volumeInicial = g_volume;
MFStartup(MF_VERSION);
g_tfTime = Fmt(11, DWRITE_FONT_WEIGHT_MEDIUM, DWRITE_TEXT_ALIGNMENT_CENTER);
g_tfIcon = Fmt(16, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_TEXT_ALIGNMENT_CENTER, false, IconFamily());
diff --git a/src/shell/genio.cpp b/src/shell/genio.cpp
index efd952b..ea89f26 100644
--- a/src/shell/genio.cpp
+++ b/src/shell/genio.cpp
@@ -365,7 +365,10 @@ bool Start(HWND h) {
// janela por faixa bastam. Eram ~3 px (até 200 faixas, 700 no total): montar tudo levava ~30 ms antes de a janela
// se mexer, e numa GTX 1660 a "pausa antes de minimizar" aparecia (Reddit, 20/11/2026)
const int n0 = std::clamp((int)((g_a.win.bottom - g_a.win.top) / 6), 24, 110);
- auto stripsOf = [&](int lvl) { return lvl == 0 ? n0 : std::max(12, n0 / 2); }; // os níveis estreitos aparecem com a janela já fina
+ // Cada nível menor só aparece com a janela já estreita e baixa no funil (a escala dele na tela é ~0,55 da do anterior):
+ // as faixas acompanham essa altura. Com n0/2 em todos os níveis eram centenas de faixas e curvas montadas antes
+ // de a janela se mexer (uma pausa no começo de minimizar em PCs mais fracos; PR #12 apontou, 21/11/2026)
+ auto stripsOf = [&](int lvl) { return lvl == 0 ? n0 : std::max(10, (int)std::lround(n0 * std::pow(0.55f, (float)lvl))); };
for (g_levels = 0; g_levels < MAX_LEVELS; g_levels++) {
if (!Upload(lv, lw, lh, &g_surf[g_levels])) break;
{
@@ -476,7 +479,9 @@ bool Start(HWND h) {
std::vector<float> op(K);
for (int k = 0; k < K; k++) {
float t = (float)k / (K - 1), pp = g_a.restore ? 1 - anim::Ease(t) : anim::Ease(t);
- op[k] = 1 - 0.15f * Smooth(0.85f, 1.f, pp);
+ // some de todo ao entrar no Dock (e aparece do nada ao sair dele). Parava em 85 % e sumia num quadro: o corte
+ // no fim de minimizar (issue #16, PR #12)
+ op[k] = 1 - Smooth(0.75f, 1.f, pp);
}
if (IDCompositionAnimation* ao = Curve(op, D)) { g_fx->SetOpacity(ao); ao->Release(); }
}
@@ -529,7 +534,7 @@ void Frame() {
tp.rcSource = { g_a.src.left, g_a.src.top + (LONG)std::lround(v0 * sh), g_a.src.right, g_a.src.top + (LONG)std::lround(v1 * sh) };
tp.rcDestination = { (LONG)std::lround(L) - g_ovRect.left, (LONG)std::floor(ya) - g_ovRect.top, (LONG)std::lround(R) - g_ovRect.left, (LONG)std::ceil(yb) - g_ovRect.top };
tp.fVisible = yb - ya >= 0.2f && R - L >= 1;
- tp.opacity = (BYTE)std::lround(255 * (1 - 0.15f * Smooth(0.85f, 1.f, p))); // some de leve ao entrar no Dock
+ tp.opacity = (BYTE)std::lround(255 * (1 - Smooth(0.75f, 1.f, p))); // some de todo ao entrar no Dock (o mesmo do compositor)
tp.fSourceClientAreaOnly = FALSE;
if (i < (int)g_a.strips.size() && g_a.strips[i]) DwmUpdateThumbnailProperties(g_a.strips[i], &tp);
}