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

Dock on the left or right of the screen (dock_posicao=baixo|esquerda|direita)

Eternity07062874433aff4185
diff --git a/docs/BRIEFING.md b/docs/BRIEFING.md
index cc0977d..eccbea7 100644
--- a/docs/BRIEFING.md
+++ b/docs/BRIEFING.md
@@ -221,7 +221,7 @@ Chaves (padrão): `ajustes_pagina=geral` `ampliacao=0` `ampliacao_tamanho=128` `
`spotlight_google=1` `tamanho=48` `tecla_windows_launchpad=1` `tema=auto` `vidro_real=1` `vidro_tinta=0.5`
`volume_mac=1` `cc_layout` (ordem da Central) e `widget.*`.
Personalização (vazio = padrão do Mac): `dock_espaco` `dock_margem` `dock_raio` (0-100) `dock_cor` (auto/clara/escura/destaque)
-`dock_opacidade` (0-100) `dock_launchpad=1` `dock_separador=1` `dock_rotulos=1` `dock_indicador=ponto` (ou traco)
+`dock_opacidade` (0-100) `dock_posicao=baixo` (esquerda/direita; Leopard sempre embaixo) `dock_launchpad=1` `dock_separador=1` `dock_rotulos=1` `dock_indicador=ponto` (ou traco)
`mesa_icone_tamanho=64` `mesa_espaco=0` `mesa_texto=12` `notif_duracao=5`; ícones próprios do Dock em `%APPDATA%\Shell\icones-dock`
(PNG com o nome do .exe ou do app). Quem recebe a DLL das janelas (e quem nunca recebe: jogos/anti-cheat): `src/comum/jogos.h`.
Outros arquivos em `%APPDATA%\Shell`: `dock.txt`, `mesa.txt` (posições), `dialogo.txt` (programas que usam o
diff --git a/docs/registro-mudancas.txt b/docs/registro-mudancas.txt
index 46bf9f3..fb2bf50 100644
--- a/docs/registro-mudancas.txt
+++ b/docs/registro-mudancas.txt
@@ -671,3 +671,5 @@ Compilado (tudo), instalado, Shell e reserva do Finder reiniciados às 23:07 sem
banner com as chaves novas e a DLL nova no Shell instalado (a tabela de 32 DLLs de gancho está cheia neste PC, erro 126: a DLL nova só
carrega depois de sair e entrar na sessão; e a sessão principal testava o gênio no Shell instalado).
DESFAZER: apagar as chaves dock_*/mesa_icone_tamanho/mesa_espaco/mesa_texto/notif_duracao (ou "Restaurar o Padrão").
+
+[2026-11-20 16:45 PC] DOCK À ESQUERDA E À DIREITA (pedido do Reddit, "como o MyDockFinder"). Ajustes > Mesa e Dock > Posição na tela: Esquerda / Embaixo / Direita, grava dock_posicao=baixo|esquerda|direita no %APPDATA%\Shelljustes.txt (sem a chave = embaixo). O Leopard fica sempre embaixo (a prateleira em perspectiva só existe deitada). src\shell\dock.cpp: o layout continua "ao longo do Dock" (x pelos ícones, y até a borda) e só o mapeamento para a tela muda (Strip/ToWin/ToLocal/Up): dos lados, a coluna da borda abaixo da barra de menus, ícones/números/miniaturas em pé, ponto do app aberto do lado da borda, etiqueta ao lado do ícone com a setinha (título longo ganha "…"), ampliação, pulo, separador (arrasta na horizontal), ocultação pela borda lateral, menus ao lado do ícone, alvo do gênio (dock::MinimizeTarget; genio.cpp não mudou: o funil anda até o lugar do lado). Área de trabalho (shell::WorkAreaFor) reserva a borda do Dock (dock::Posicao + dock::ReservedHeight); limites.cpp empurra as janelas para fora do Dock lateral (deslizando pela thread; a DLL só desliza na vertical); Mission Control tira o espaço do lado certo; Pilhas: com o Dock do lado a Grade abre ao lado do ícone (sem o Leque e sem a setinha) e os menus de Downloads também. Trocar de lado cancela um arrasto em andamento (no teste o separador estava sendo arrastado durante a troca e o tamanho foi gravado como 74; antes 69 — deixado como está). Frases: Esquerda/Embaixo/Direita já existiam nos 12 idiomas (idioma-conferir: 0 faltando). Testado no PC (Shell instalado): esquerda e direita no Tahoe, esquerda no Sequoia, embaixo de novo; área de trabalho 97,30-3440,1440 / 0,30-3343,1440; janela minimizada (Bloco de Notas de teste) com a miniatura entre Downloads e a Lixeira e o gênio rodando. NÃO testado: etiqueta ao passar o mouse, ampliação, arrastar ícones e as Pilhas no Dock lateral (precisa de mouse de verdade); com dois monitores, o lado que encosta em outro monitor não segura o ponteiro para mostrar o Dock oculto. Nada no registro do Windows. DESFAZER: dock_posicao=baixo (ou apagar a chave).
diff --git a/src/ajustes/paginas.cpp b/src/ajustes/paginas.cpp
index df4914c..081ef70 100644
--- a/src/ajustes/paginas.cpp
+++ b/src/ajustes/paginas.cpp
@@ -1536,7 +1536,11 @@ Page MesaDock() {
magSize.enabled = Setting(L"ampliacao", L"0") == L"1";
size.hasDef = true; size.def = 48;
magSize.hasDef = true; magSize.def = 128;
- Row pos = Popup(L"Posição na tela", { L"!Esquerda", L"Embaixo", L"!Direita" }, [] { return 1; }, [](int) {});
+ // dock_posicao = baixo | esquerda | direita (o Dock do Leopard, a prateleira em perspectiva, fica sempre embaixo)
+ Row pos = Popup(L"Posição na tela", { L"Esquerda", L"Embaixo", L"Direita" }, [] {
+ std::wstring v = Setting(L"dock_posicao", L"baixo");
+ return v == L"esquerda" ? 0 : v == L"direita" ? 2 : 1;
+ }, [](int i) { SetSetting(L"dock_posicao", i == 0 ? L"esquerda" : i == 2 ? L"direita" : L"baixo"); });
// Monitor do Dock (dock_monitor = nome do monitor, ex. \\.\DISPLAY2; vazio = o principal). A barra de
// menus fica em todos; o Dock só neste.
std::vector<std::wstring> monDev{ L"" }, monName{ L"Tela principal" };
diff --git a/src/shell/dock.cpp b/src/shell/dock.cpp
index 5fcd1b9..6504592 100644
--- a/src/shell/dock.cpp
+++ b/src/shell/dock.cpp
@@ -141,7 +141,15 @@ int g_dropHit = -1;
void LeftClick(int i);
float Sc() { return ui::Scale(g_icons); }
-float WinH() { return g_large + PAD_TOP + PAD_BOTTOM + MARGIN + 52; } // espaço para ampliar e para a etiqueta
+// Posição na tela (Ajustes > Mesa e Dock > Posição na tela: dock_posicao=baixo|esquerda|direita). Todo o layout é feito
+// "ao longo do Dock": x corre pelos ícones e y vai de dentro da tela (0) até a borda onde o Dock encosta (WinH). Embaixo
+// isso é a própria janela; dos lados, a mesma conta girada (ToWin/ToLocal). Os ícones, os números e as etiquetas são
+// desenhados sempre em pé (Up). O Leopard fica sempre embaixo (a prateleira em perspectiva só existe deitada).
+int g_pos = 0; // 0 embaixo, 1 esquerda, 2 direita
+int Pos() { return LEO_DOCK ? 0 : g_pos; }
+bool Vert() { return Pos() != 0; }
+// espaço para ampliar e para a etiqueta (dos lados a etiqueta fica ao lado do ícone: precisa de mais largura)
+float WinH() { return g_large + PAD_TOP + PAD_BOTTOM + MARGIN + (Vert() ? 280 : 52); }
// O monitor do Dock (Ajustes > Mesa e Dock > Monitor do Dock: dock_monitor = nome do monitor, ex. \\.\DISPLAY2;
// vazio = o principal). Antes era o monitor onde a janela estava, e com dois monitores o Dock passava de um
@@ -174,6 +182,64 @@ RECT Monitor() {
return mi.rcMonitor;
}
+// A janela dos ícones na tela (px): embaixo, a faixa de baixo do monitor; dos lados, a coluna da borda, da barra de
+// menus para baixo (como no Mac, o Dock lateral fica centralizado no espaço abaixo da barra).
+RECT Strip() {
+ MONITORINFO mi{ sizeof(mi) };
+ HMONITOR hm = DockMon();
+ GetMonitorInfoW(hm, &mi);
+ RECT m = mi.rcMonitor;
+ int H = (int)std::lround(WinH() * Sc());
+ int top = m.top + ((mi.dwFlags & MONITORINFOF_PRIMARY) ? menubar::Height() : menubar::HeightOn(hm));
+ if (Pos() == 1) return { m.left, top, m.left + H, m.bottom };
+ if (Pos() == 2) return { m.right - H, top, m.right, m.bottom };
+ return { m.left, m.bottom - H, m.right, m.bottom };
+}
+// comprimento disponível ao longo do Dock (pt)
+float AxisLen() { RECT s = Strip(); return (Vert() ? s.bottom - s.top : s.right - s.left) / Sc(); }
+// do sistema do Dock (x ao longo, y até a borda) para a janela dos ícones (pt) e de volta
+D2D1_POINT_2F ToWin(float x, float y) {
+ if (Pos() == 1) return { WinH() - y, x }; // esquerda: a borda (y = WinH) fica em X = 0
+ if (Pos() == 2) return { y, x }; // direita: a borda fica em X = WinH
+ return { x, y };
+}
+D2D1_POINT_2F ToLocal(float X, float Y) {
+ if (Pos() == 1) return { Y, WinH() - X };
+ if (Pos() == 2) return { Y, X };
+ return { X, Y };
+}
+D2D1_MATRIX_3X2_F DockMatrix() { // a mesma conta de ToWin, para o Direct2D
+ if (Pos() == 1) return D2D1::Matrix3x2F(0, 1, -1, 0, WinH(), 0);
+ if (Pos() == 2) return D2D1::Matrix3x2F(0, 1, 1, 0, 0, 0);
+ return D2D1::Matrix3x2F::Identity();
+}
+D2D1_RECT_F RectToWin(D2D1_RECT_F r) {
+ D2D1_POINT_2F a = ToWin(r.left, r.top), b = ToWin(r.right, r.bottom);
+ return { std::min(a.x, b.x), std::min(a.y, b.y), std::max(a.x, b.x), std::max(a.y, b.y) };
+}
+// um quadrado do sistema do Dock em pé na janela: o mesmo tamanho, centrado no mesmo ponto (ícones não giram)
+D2D1_RECT_F Up(D2D1_RECT_F r) {
+ D2D1_POINT_2F c = ToWin((r.left + r.right) / 2, (r.top + r.bottom) / 2);
+ float w = (r.right - r.left) / 2, h = (r.bottom - r.top) / 2;
+ return { c.x - w, c.y - h, c.x + w, c.y + h };
+}
+POINT ToScreen(float x, float y) {
+ RECT s = Strip(); float sc = Sc();
+ D2D1_POINT_2F p = ToWin(x, y);
+ return { s.left + (LONG)std::lround(p.x * sc), s.top + (LONG)std::lround(p.y * sc) };
+}
+RECT ToScreenRect(D2D1_RECT_F local) {
+ RECT s = Strip(); float sc = Sc();
+ D2D1_RECT_F r = RectToWin(local);
+ return { s.left + (LONG)std::lround(r.left * sc), s.top + (LONG)std::lround(r.top * sc), s.left + (LONG)std::lround(r.right * sc), s.top + (LONG)std::lround(r.bottom * sc) };
+}
+D2D1_POINT_2F ScreenToLocal(POINT p) {
+ RECT s = Strip(); float sc = Sc();
+ return ToLocal((p.x - s.left) / sc, (p.y - s.top) / sc);
+}
+// coordenada de tela que cresce para dentro da tela, perpendicular ao Dock (arrastar o separador muda o tamanho)
+LONG Inward(POINT c) { return Pos() == 1 ? c.x : Pos() == 2 ? -c.x : -c.y; }
+
// Muitos apps abertos: o Dock encolhe para caber na tela (como no Mac), em vez de passar da borda (e entrar
// no outro monitor). g_tileWant é o tamanho escolhido; g_tile, o usado agora.
float g_tileWant = 48;
@@ -181,8 +247,7 @@ void FitTile() {
g_tile = g_tileWant;
float sc = ui::Scale(g_icons);
if (sc <= 0) sc = 1;
- RECT m = Monitor();
- float W = (m.right - m.left) / sc - 16; // um respiro de cada lado
+ float W = AxisLen() - 16; // um respiro de cada lado
float units = 0; // largura em múltiplos de g_tile
for (auto& it : g_items) units += it.kind == I_SEP ? SEP_W / g_tile : SLOT / g_tile;
units += 2 * PAD_X / g_tile;
@@ -272,7 +337,7 @@ void BuildItems() {
// Posições e tamanhos (com ampliação), centralizado na tela.
void Layout() {
- float W = (Monitor().right - Monitor().left) / Sc();
+ float W = AxisLen(); // ao longo do Dock (dos lados, a altura abaixo da barra de menus)
float slot = SLOT;
// largura base para achar os centros sem ampliação
float base = PAD_X;
@@ -571,10 +636,7 @@ float BounceOffset(const App& a) {
// Ocultação inteligente: alguma janela de app (não minimizada, nesta mesa) cobre a área do Dock à mostra?
// Como a "ocultação inteligente" dos docks do Windows: janela maximizada ou arrastada até embaixo esconde o Dock.
bool WindowOverDock() {
- float sc = Sc();
- RECT mon = Monitor();
- RECT dk{ mon.left + (LONG)(g_bg.left * sc), mon.bottom - (LONG)std::lround((g_tile + PAD_TOP + PAD_BOTTOM + MARGIN) * sc),
- mon.left + (LONG)(g_bg.right * sc), mon.bottom };
+ RECT dk = ToScreenRect({ g_bg.left, WinH() - (g_tile + PAD_TOP + PAD_BOTTOM + MARGIN), g_bg.right, WinH() });
if (dk.right <= dk.left) return false;
struct C { RECT dk; bool hit; } c{ dk, false };
EnumWindows([](HWND h, LPARAM p) -> BOOL {
@@ -597,8 +659,10 @@ bool WantHidden() {
POINT c; GetCursorPos(&c);
RECT mon = Monitor();
float sc = Sc();
- bool nearEdge = c.x >= mon.left && c.x < mon.right &&
- (c.y >= mon.bottom - 2 || (g_reveal > 0.5f && c.y >= mon.bottom - (LONG)((g_bg.bottom - g_bg.top + 30) * sc)));
+ // distância do ponteiro até a borda do Dock (embaixo, a de baixo; dos lados, a esquerda ou a direita)
+ bool along = Vert() ? c.y >= mon.top && c.y < mon.bottom : c.x >= mon.left && c.x < mon.right;
+ LONG dist = Pos() == 1 ? c.x - mon.left : Pos() == 2 ? mon.right - 1 - c.x : mon.bottom - 1 - c.y;
+ bool nearEdge = along && dist >= 0 && (dist <= 1 || (g_reveal > 0.5f && dist < (LONG)((g_bg.bottom - g_bg.top + 30) * sc)));
if (g_smart && GetTickCount() - g_coverAt >= 100) { g_coverAt = GetTickCount(); g_covered = WindowOverDock(); }
return (!g_smart || g_covered) && !nearEdge && g_press < 0;
}
@@ -626,9 +690,8 @@ std::wstring Label(const Item& it) {
void PaintBack() {
float sc = Sc();
- RECT mon = Monitor();
- int x = mon.left + (int)std::lround(g_bg.left * sc), y = mon.bottom - (int)std::lround((WinH() - g_bg.top) * sc);
- int w = (int)std::lround((g_bg.right - g_bg.left) * sc), h = (int)std::lround((g_bg.bottom - g_bg.top) * sc);
+ RECT bgs = ToScreenRect(g_bg); // dos lados o fundo fica em pé (mais alto que largo)
+ int x = bgs.left, y = bgs.top, w = bgs.right - bgs.left, h = bgs.bottom - bgs.top;
if (g_reveal <= 0.01f || LEO_DOCK) { ShowWindow(g_back, SW_HIDE); g_lastBg = {}; return; } // Leopard: sem vidro atrás (a prateleira é desenhada com os ícones)
if (!memcmp(&g_bg, &g_lastBg, sizeof(g_bg)) && IsWindowVisible(g_back)) return; // nada mudou
g_lastBg = g_bg;
@@ -667,7 +730,7 @@ void PaintBack() {
ui::End(g_sb, false);
}
-// onde fica a miniatura de uma janela minimizada (pt, coordenadas da janela dos ícones): cabe num
+// onde fica a miniatura de uma janela minimizada (pt, na janela dos ícones, já em pé): cabe num
// quadrado de 92% do ícone, com a proporção da janela, assentada no pé dos ícones
D2D1_RECT_F MinThumbRect(const Item& it, float baseline) {
float box = it.size * 0.92f;
@@ -678,16 +741,15 @@ D2D1_RECT_F MinThumbRect(const Item& it, float baseline) {
else { RECT r{}; WINDOWPLACEMENT wp{ sizeof(wp) }; if (GetWindowPlacement(it.win, &wp)) r = wp.rcNormalPosition; if (r.right > r.left) { ww = (float)(r.right - r.left); wh = (float)(r.bottom - r.top); } }
float k = std::min(box / ww, box / wh);
float w = ww * k, h = wh * k;
- float cy = baseline - it.size / 2;
- return { it.cx - w / 2, cy - h / 2, it.cx + w / 2, cy + h / 2 };
+ D2D1_POINT_2F c = ToWin(it.cx, baseline - it.size / 2);
+ return { c.x - w / 2, c.y - h / 2, c.x + w / 2, c.y + h / 2 };
}
// miniaturas do DWM das minimizadas, na janela própria entre o fundo e a dos ícones
void UpdateThumbs(float baseline) {
if (!g_thumbWnd) return;
float sc = Sc();
- RECT mon = Monitor();
- int H = (int)std::lround(WinH() * sc);
+ RECT strip = Strip();
RECT box{ LONG_MAX, LONG_MAX, LONG_MIN, LONG_MIN };
std::vector<std::pair<const Item*, RECT>> rects;
bool show = !g_fullscreen && g_reveal > 0.5f;
@@ -700,7 +762,7 @@ void UpdateThumbs(float baseline) {
}
if (!g_thumbs.count(it.win)) { HTHUMBNAIL th = nullptr; if (SUCCEEDED(DwmRegisterThumbnail(g_thumbWnd, it.win, &th))) g_thumbs[it.win] = th; }
D2D1_RECT_F r = MinThumbRect(it, baseline);
- RECT px{ mon.left + (LONG)std::lround(r.left * sc), mon.bottom - H + (LONG)std::lround(r.top * sc), mon.left + (LONG)std::lround(r.right * sc), mon.bottom - H + (LONG)std::lround(r.bottom * sc) };
+ RECT px{ strip.left + (LONG)std::lround(r.left * sc), strip.top + (LONG)std::lround(r.top * sc), strip.left + (LONG)std::lround(r.right * sc), strip.top + (LONG)std::lround(r.bottom * sc) };
rects.push_back({ &it, px });
box.left = std::min(box.left, px.left); box.top = std::min(box.top, px.top); box.right = std::max(box.right, px.right); box.bottom = std::max(box.bottom, px.bottom);
}
@@ -799,24 +861,74 @@ void CALLBACK FgEvent(HWINEVENTHOOK, DWORD, HWND h, LONG obj, LONG, DWORD, DWORD
}
}
+// A etiqueta com o nome (pt, na janela dos ícones, sempre em pé): embaixo, acima do ícone com a setinha para baixo;
+// dos lados, ao lado do ícone com a setinha apontando para ele (como no Mac com o Dock à esquerda ou à direita).
+struct LabelBox { D2D1_RECT_F r{}; D2D1_POINT_2F tri[3]{}; D2D1_POINT_2F in{}; std::wstring t; }; // in: da base da setinha para a ponta
+bool LabelGeom(int lab, LabelBox& L) {
+ if (!g_rotulos || lab < 0 || lab >= (int)g_items.size() || g_items[lab].kind == I_SEP || g_reveal <= 0.9f) return false;
+ auto& it = g_items[lab];
+ L.t = Label(it);
+ float tw = ui::TextWidth(g_tfLabel, L.t) + 22, th = 26;
+ float baseline = g_bg.top + PAD_TOP + g_tile;
+ if (!Vert()) {
+ float top = baseline - it.size - 14 - th;
+ L.r = { it.cx - tw / 2, top, it.cx + tw / 2, top + th };
+ float cx = it.cx, ab = L.r.bottom - 0.5f;
+ L.tri[0] = { cx - 7, ab }; L.tri[1] = { cx, ab + 7 }; L.tri[2] = { cx + 7, ab };
+ L.in = { 0, 1 };
+ return true;
+ }
+ const float MAXW = 250; // a janela lateral tem ~280 pt para a etiqueta: título comprido ganha "…"
+ if (tw > MAXW) {
+ while (L.t.size() > 1 && ui::TextWidth(g_tfLabel, L.t + L"…") + 22 > MAXW) L.t.pop_back();
+ L.t += L"…";
+ tw = ui::TextWidth(g_tfLabel, L.t) + 22;
+ }
+ D2D1_POINT_2F tip = ToWin(it.cx, baseline - it.size - 7.5f);
+ float s = Pos() == 1 ? 1.f : -1.f; // para dentro da tela
+ float ab = tip.x + s * 7;
+ L.r = s > 0 ? D2D1::RectF(ab - 0.5f, tip.y - th / 2, ab - 0.5f + tw, tip.y + th / 2) : D2D1::RectF(ab + 0.5f - tw, tip.y - th / 2, ab + 0.5f, tip.y + th / 2);
+ L.tri[0] = { ab, tip.y - 7 }; L.tri[1] = tip; L.tri[2] = { ab, tip.y + 7 };
+ L.in = { -s, 0 };
+ return true;
+}
+
void JumpIds(const App& a, std::wstring& exe, std::wstring& aumid);
void Paint() {
if (!g_icons || g_fullscreen) { if (g_thumbWnd) ShowWindow(g_thumbWnd, SW_HIDE); return; }
Layout();
float sc = Sc();
- RECT mon = Monitor();
- int W = mon.right - mon.left, H = (int)std::lround(WinH() * sc);
+ RECT strip = Strip();
+ int W = strip.right - strip.left, H = strip.bottom - strip.top;
// Janela justa no Dock; inteira (espaço para a etiqueta e a ampliação) só com o mouse em cima ou
// animando, assim o resto da faixa de baixo da tela continua clicável.
bool active = g_mouseX >= 0 || g_dragging || g_resizing || g_press >= 0 || g_dropHit >= 0 || Animating();
- RECT want = active ? RECT{ 0, 0, W, H }
- : RECT{ (LONG)std::floor(g_bg.left * sc) - 2, (LONG)std::floor(g_bg.top * sc) - 2, (LONG)std::ceil(g_bg.right * sc) + 2, (LONG)std::ceil(g_bg.bottom * sc) + 2 };
+ LabelBox lbox;
+ bool hasLabel = LabelGeom(g_dragging ? -1 : g_hover, lbox);
+ D2D1_RECT_F bgw = RectToWin(g_bg);
+ RECT want{ (LONG)std::floor(bgw.left * sc) - 2, (LONG)std::floor(bgw.top * sc) - 2, (LONG)std::ceil(bgw.right * sc) + 2, (LONG)std::ceil(bgw.bottom * sc) + 2 };
+ bool poofing = g_poof.t0 > 0 && anim::Now() - g_poof.t0 < POOF_MS;
+ if (active && (!Vert() || g_dragging || g_resizing || poofing)) want = RECT{ 0, 0, W, H };
+ else if (active) {
+ // dos lados a janela é larga (cabe a etiqueta): só a coluna dos ícones (com a ampliação e o pulo) e a
+ // etiqueta recebem o mouse; o resto continua clicável para as janelas atrás
+ float head = std::max(g_magnify ? g_large - g_tile : 0.f, g_tile * 0.7f) + 8;
+ D2D1_RECT_F a = RectToWin({ 0, g_bg.top - head, AxisLen(), WinH() });
+ if (hasLabel) { a.left = std::min(a.left, lbox.r.left - 2); a.right = std::max(a.right, lbox.r.right + 2); }
+ want = { (LONG)std::floor(a.left * sc), (LONG)std::floor(a.top * sc), (LONG)std::ceil(a.right * sc), (LONG)std::ceil(a.bottom * sc) };
+ }
+ want.left = std::max<LONG>(want.left, 0); want.right = std::min<LONG>(want.right, W);
want.top = std::max<LONG>(want.top, 0); want.bottom = std::min<LONG>(want.bottom, H);
if (want.bottom <= want.top) want.bottom = want.top + 1;
+ if (want.right <= want.left) want.right = want.left + 1;
// A imagem tem sempre o tamanho da faixa inteira (nunca é recriada, então nada pisca); só a
// janela muda de tamanho e o conteúdo é deslocado para casar.
auto* rt = ui::GpuBegin(g_gi, W, H, sc);
if (!rt) return;
+ // desenho do Dock no sistema dele (dockT: dos lados, girado); ícones, números e etiquetas em pé (base)
+ D2D1_MATRIX_3X2_F base; rt->GetTransform(&base);
+ D2D1_MATRIX_3X2_F dockT = DockMatrix() * base;
+ rt->SetTransform(dockT);
bool moved = !EqualRect(&want, &g_win);
bool dark = ui::Dark();
ID2D1SolidColorBrush* br = nullptr;
@@ -941,12 +1053,14 @@ void Paint() {
App& a = apps::list[it.app];
float bs = s2 * 0.40f; // ícone do app, no canto de baixo à direita
D2D1_RECT_F br2{ tr.right - bs * 0.78f, tr.bottom - bs * 0.78f, tr.right + bs * 0.22f, tr.bottom + bs * 0.22f };
+ rt->SetTransform(base); // a miniatura e o ícone do app ficam em pé
if (a.finder) ui::DrawFolder(rt, br2, 0xE8B7);
else if (ID2D1Bitmap* b = IconBitmap(rt, a)) {
float art2 = (br2.right - br2.left) * (a.mac ? ART_PACK : ART_WIN);
float cx2 = (br2.left + br2.right) / 2, cy2 = (br2.top + br2.bottom) / 2;
rt->DrawBitmap(b, D2D1::RectF(cx2 - art2 / 2, cy2 - art2 / 2, cx2 + art2 / 2, cy2 + art2 / 2), 1, D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC);
}
+ rt->SetTransform(dockT);
continue;
}
float s = it.size * AppFactor(it);
@@ -956,7 +1070,9 @@ void Paint() {
auto f = g_bmps.find(gh.id);
float art = s * (gh.mac ? ART_PACK : ART_WIN);
D2D1_RECT_F ir{ it.cx - art / 2, baseline - (s + art) / 2, it.cx + art / 2, baseline - (s - art) / 2 };
- if (f != g_bmps.end() && f->second) rt->DrawBitmap(f->second, ir, 1, D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC);
+ rt->SetTransform(base);
+ if (f != g_bmps.end() && f->second) rt->DrawBitmap(f->second, Up(ir), 1, D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC);
+ rt->SetTransform(dockT);
continue;
}
float dy = it.kind == I_APP ? BounceOffset(apps::list[it.app]) : 0;
@@ -968,7 +1084,10 @@ void Paint() {
float art = s * ART_WIN;
D2D1_RECT_F sr{ it.cx - art / 2, baseline - (s + art) / 2, it.cx + art / 2, baseline - (s - art) / 2 };
reflect(sr.bottom, [&] { DrawStack(rt, sr); }); // Leopard: a pilha também se reflete na prateleira
- if (DrawStack(rt, sr)) continue;
+ rt->SetTransform(base);
+ bool drew = DrawStack(rt, Up(sr));
+ rt->SetTransform(dockT);
+ if (drew) continue;
b = PackBitmap(rt, L"folder downloads"); mac = b != nullptr;
}
else { b = PackBitmap(rt, it.kind == I_LAUNCHPAD ? L"Launchpad" : it.kind == I_DOWNLOADS ? L"folder downloads" : g_trashFull ? L"trashfull@2x" : L"trashempty@2x"); mac = b != nullptr; }
@@ -977,13 +1096,22 @@ void Paint() {
D2D1_RECT_F ir{ it.cx - art / 2, baseline - (s + art) / 2 + dy, it.cx + art / 2, baseline - (s - art) / 2 + dy };
if (b) reflect(baseline + dy, [&] { // espelha no pé do desenho (o PNG do pacote tem margem embaixo)
rt->DrawBitmap(b, ir, 1, D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC); });
- if (b) rt->DrawBitmap(b, ir, 1, D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC); // reduz 256 px sem serrilhar
- else if (it.kind == I_APP) { if (apps::list[it.app].finder) ui::DrawFolder(rt, ir, 0xE8B7); }
- else if (it.kind == I_DOWNLOADS) ui::DrawFolder(rt, ir, 0xE896);
- else if (it.kind == I_TRASH) ui::DrawTrash(rt, ir, g_trashFull);
- if (it.kind == I_APP) if (int n = BadgeCount(apps::list[it.app])) {
- float m = mac ? (ir.right - ir.left) * 0.10f : 0; // PNG do pacote: corpo = 80% do desenho
- DrawBadge(rt, br, D2D1::RectF(ir.left + m, ir.top + m, ir.right - m, ir.bottom - m), n);
+ { // o ícone, o número e o escurecido do clique em pé (dos lados o Dock gira, os ícones não)
+ D2D1_RECT_F iw = Up(ir);
+ rt->SetTransform(base);
+ if (b) rt->DrawBitmap(b, iw, 1, D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC); // reduz 256 px sem serrilhar
+ else if (it.kind == I_APP) { if (apps::list[it.app].finder) ui::DrawFolder(rt, iw, 0xE8B7); }
+ else if (it.kind == I_DOWNLOADS) ui::DrawFolder(rt, iw, 0xE896);
+ else if (it.kind == I_TRASH) ui::DrawTrash(rt, iw, g_trashFull);
+ if (it.kind == I_APP) if (int n = BadgeCount(apps::list[it.app])) {
+ float m = mac ? (iw.right - iw.left) * 0.10f : 0; // PNG do pacote: corpo = 80% do desenho
+ DrawBadge(rt, br, D2D1::RectF(iw.left + m, iw.top + m, iw.right - m, iw.bottom - m), n);
+ }
+ if ((i == g_press && !g_dragging && GetKeyState(VK_LBUTTON) < 0) || i == g_dropHit) { // pressionado: escurece
+ br->SetColor(D2D1::ColorF(0, 0, 0, i == g_dropHit ? 0.25f : 0.35f));
+ rt->FillRoundedRectangle(D2D1::RoundedRect(iw, art * 0.22f, art * 0.22f), br);
+ }
+ rt->SetTransform(dockT);
}
// ponto de app aberto; o Finder, como no Mac, está sempre aberto
if (it.kind == I_APP && (!apps::list[it.app].wins.empty() || apps::list[it.app].finder) && shell::Setting(L"indicadores", L"1") == L"1") {
@@ -1012,10 +1140,6 @@ void Paint() {
} else rt->FillEllipse(D2D1::Ellipse({ it.cx, dy }, dr, dr), br);
}
}
- if ((i == g_press && !g_dragging && GetKeyState(VK_LBUTTON) < 0) || i == g_dropHit) { // pressionado: escurece
- br->SetColor(D2D1::ColorF(0, 0, 0, i == g_dropHit ? 0.25f : 0.35f));
- rt->FillRoundedRectangle(D2D1::RoundedRect(ir, art * 0.22f, art * 0.22f), br);
- }
}
if (g_poof.t0 > 0 && anim::Now() - g_poof.t0 < POOF_MS) { // o "puf": bolinhas de fumaça que se abrem e somem
@@ -1035,13 +1159,12 @@ void Paint() {
rt->FillEllipse(D2D1::Ellipse({ g_poof.x, g_poof.y }, R * 0.55f, R * 0.5f), br);
}
- // etiqueta com o nome, acima do ícone
- int lab = g_dragging ? -1 : g_hover;
- if (g_rotulos && lab >= 0 && lab < (int)g_items.size() && g_items[lab].kind != I_SEP && g_reveal > 0.9f) {
- std::wstring t = Label(g_items[lab]);
- float tw = ui::TextWidth(g_tfLabel, t) + 22, th = 26;
- float top = baseline - g_items[lab].size - 14 - th;
- D2D1_RECT_F r{ g_items[lab].cx - tw / 2, top, g_items[lab].cx + tw / 2, top + th };
+ // etiqueta com o nome, acima do ícone (dos lados, ao lado dele); em pé, nas coordenadas da janela
+ rt->SetTransform(base);
+ if (hasLabel) {
+ const std::wstring& t = lbox.t;
+ float th = 26;
+ D2D1_RECT_F r = lbox.r;
if (leo) { // Leopard: o nome numa pílula preta translúcida com texto branco, sem setinha
float rr2 = th / 2 - 2;
D2D1_RECT_F q{ r.left, r.top + 2, r.right, r.bottom - 2 };
@@ -1054,18 +1177,20 @@ void Paint() {
} else {
br->SetColor(dark ? D2D1::ColorF(0.17f, 0.17f, 0.18f, 0.92f) : D2D1::ColorF(0.94f, 0.94f, 0.95f, 0.95f));
rt->FillRoundedRectangle(D2D1::RoundedRect(r, 6, 6), br);
- float cx = g_items[lab].cx, ab = r.bottom - 0.5f; // setinha apontando para o ícone, como no Mac
+ // setinha apontando para o ícone, como no Mac (embaixo para baixo; dos lados para a borda do Dock)
+ const D2D1_POINT_2F* tp = lbox.tri;
+ D2D1_POINT_2F n{ lbox.in.x * 0.5f, lbox.in.y * 0.5f };
ID2D1Factory* f = nullptr; rt->GetFactory(&f);
ID2D1PathGeometry* tri = nullptr; f->CreatePathGeometry(&tri);
ID2D1GeometrySink* sk = nullptr; tri->Open(&sk);
- sk->BeginFigure({ cx - 7, ab }, D2D1_FIGURE_BEGIN_FILLED);
- sk->AddLine({ cx, ab + 7 }); sk->AddLine({ cx + 7, ab });
+ sk->BeginFigure(tp[0], D2D1_FIGURE_BEGIN_FILLED);
+ sk->AddLine(tp[1]); sk->AddLine(tp[2]);
sk->EndFigure(D2D1_FIGURE_END_CLOSED); sk->Close(); sk->Release();
rt->FillGeometry(tri, br);
br->SetColor(dark ? D2D1::ColorF(1, 1, 1, 0.14f) : D2D1::ColorF(0, 0, 0, 0.10f));
rt->DrawRoundedRectangle(D2D1::RoundedRect(r, 6, 6), br, 0.8f);
- rt->DrawLine({ cx - 7, ab + 0.5f }, { cx, ab + 7 }, br, 0.8f);
- rt->DrawLine({ cx, ab + 7 }, { cx + 7, ab + 0.5f }, br, 0.8f);
+ rt->DrawLine({ tp[0].x + n.x, tp[0].y + n.y }, tp[1], br, 0.8f);
+ rt->DrawLine(tp[1], { tp[2].x + n.x, tp[2].y + n.y }, br, 0.8f);
tri->Release(); f->Release();
br->SetColor(dark ? D2D1::ColorF(1, 1, 1, 0.92f) : D2D1::ColorF(0, 0, 0, 0.85f));
rt->DrawTextW(t.c_str(), (UINT32)t.size(), g_tfLabel, r, br);
@@ -1075,7 +1200,7 @@ void Paint() {
if (g_dragging && g_press >= 0 && g_items[g_press].kind == I_APP) {
App& a = apps::list[g_items[g_press].app];
POINT c; GetCursorPos(&c);
- float mx = (c.x - mon.left) / sc, my = (c.y - (mon.bottom - H)) / sc;
+ float mx = (c.x - strip.left) / sc, my = (c.y - strip.top) / sc; // na janela (em pé)
float art = g_tile * (a.mac ? ART_PACK : ART_WIN);
D2D1_RECT_F ir{ mx - art / 2, my - art / 2, mx + art / 2, my + art / 2 };
if (a.finder) ui::DrawFolder(rt, ir, L'');
@@ -1101,9 +1226,9 @@ void Paint() {
g_win = want;
SetWindowRgn(g_icons, CreateRectRgn(want.left, want.top, want.right, want.bottom), TRUE);
RECT cur; GetWindowRect(g_icons, &cur);
- if (first || cur.left != mon.left || cur.top != mon.bottom - H || cur.right - cur.left != W || cur.bottom - cur.top != H || !IsWindowVisible(g_icons)) {
+ if (first || !EqualRect(&cur, &strip) || !IsWindowVisible(g_icons)) {
ui::GpuOffset(g_gi, 0.f, 0.f);
- SetWindowPos(g_icons, HWND_TOPMOST, mon.left, mon.bottom - H, W, H, SWP_NOACTIVATE | SWP_SHOWWINDOW);
+ SetWindowPos(g_icons, HWND_TOPMOST, strip.left, strip.top, W, H, SWP_NOACTIVATE | SWP_SHOWWINDOW);
}
}
PaintBack();
@@ -1139,11 +1264,13 @@ ctxmenu::Item MSep() { ctxmenu::Item i; i.separator = true; return i; }
int ShowMenu(int itemIndex, const std::vector<ctxmenu::Item>& items) {
ctxmenu::PlainNext(); // o menu do Dock no Mac não tem ícones (nem no Tahoe)
float sc = Sc();
- RECT mon = Monitor();
- int H = (int)std::lround(WinH() * sc);
- POINT pt{ mon.left + (LONG)std::lround(g_items[itemIndex].cx * sc) - 60, mon.bottom - H + (LONG)std::lround((g_bg.top - 8) * sc) };
- // o menu abre para cima: ajusta pela altura aproximada
- pt.y -= (LONG)std::lround(items.size() * 22 * sc + 12 * sc);
+ POINT pt = ToScreen(g_items[itemIndex].cx, g_bg.top - 8);
+ if (!Vert()) {
+ pt.x -= (LONG)std::lround(60 * sc);
+ // o menu abre para cima: ajusta pela altura aproximada
+ pt.y -= (LONG)std::lround(items.size() * 22 * sc + 12 * sc);
+ } else // dos lados: ao lado do ícone, centrado nele (à direita o menu vira para a esquerda sozinho: não cabe)
+ pt.y -= (LONG)std::lround((items.size() * 22 * sc + 12 * sc) / 2);
SetForegroundWindow(g_owner);
return ctxmenu::ShowItems(g_owner, pt, items);
}
@@ -1191,8 +1318,7 @@ void JumpIds(const App& a, std::wstring& exe, std::wstring& aumid) {
void ContextMenu(int i) {
auto& it = g_items[i];
if (it.kind == I_DOWNLOADS) { // como no Mac: ordenar, ver como (Leque, Grade, Lista) e abrir a pasta
- float sc = Sc(); RECT mon = Monitor(); int H = (int)std::lround(WinH() * sc);
- pilhas::Menu(POINT{ mon.left + (LONG)std::lround(it.cx * sc), mon.bottom - H + (LONG)std::lround((g_bg.top - 4) * sc) });
+ pilhas::Menu(ToScreen(it.cx, g_bg.top - 4));
g_stackAt = 0; g_stackPaths.clear(); // ordem ou "Exibir como" podem ter mudado
Paint();
return;
@@ -1290,7 +1416,7 @@ void ContextMenu(int i) {
void BackgroundMenu() {
POINT c; GetCursorPos(&c);
SetForegroundWindow(g_owner);
- c.y -= 120;
+ if (!Vert()) c.y -= 120;
std::wstring tema = shell::Setting(L"tema", L"auto");
int id = ctxmenu::ShowItems(g_owner, c, { MI(Tr(L"Ativar Ocultação"), 1, g_autohide && !g_smart), MI(Tr(L"Ocultação Inteligente"), 7, g_smart),
MI(Tr(L"Ativar Ampliação"), 2, g_magnify), MSep(),
@@ -1318,10 +1444,8 @@ void LeftClick(int i) {
auto& it = g_items[i];
if (it.kind == I_MINWIN) { // volta para a tela pelo funil (gênio ao contrário) e sai do Dock
HWND h = it.win;
- float sc = Sc(); RECT mon = Monitor(); int H = (int)std::lround(WinH() * sc);
float s = it.size, top = g_bg.top + PAD_TOP + g_tile - s;
- RECT from{ mon.left + (LONG)std::lround((it.cx - s / 2) * sc), mon.bottom - H + (LONG)std::lround(top * sc),
- mon.left + (LONG)std::lround((it.cx + s / 2) * sc), mon.bottom - H + (LONG)std::lround((top + s) * sc) };
+ RECT from = ToScreenRect({ it.cx - s / 2, top, it.cx + s / 2, top + s });
if (genio::Restore(h, from)) { apps::Refresh(); BuildItems(); Paint(); return; }
shell::Restaurar(h);
keybd_event(VK_MENU, 0, 0, 0); SetForegroundWindow(h); keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
@@ -1341,9 +1465,7 @@ void LeftClick(int i) {
if (it.kind == I_LAUNCHPAD && LEO_DOCK) { dock::OpenAppsStack(); return; } // Leopard: a pasta Aplicativos como Pilha em Grade (10.5)
if (it.kind == I_LAUNCHPAD) { launchpad::Toggle(); return; }
if (it.kind == I_DOWNLOADS && shell::Setting(L"pilhas", L"1") == L"1") { // Pilha em grade, como no Mac
- float sc = Sc(); RECT mon = Monitor(); int H = (int)std::lround(WinH() * sc);
- POINT a{ mon.left + (LONG)std::lround(it.cx * sc), mon.bottom - H + (LONG)std::lround((g_bg.top - 4) * sc) };
- pilhas::Show(a);
+ pilhas::Show(ToScreen(it.cx, g_bg.top - 4));
return;
}
if (it.kind == I_DOWNLOADS) {
@@ -1369,9 +1491,8 @@ struct DockDrop : IDropTarget {
STDMETHODIMP_(ULONG) AddRef() override { return ++ref; }
STDMETHODIMP_(ULONG) Release() override { return --ref; }
int At(POINTL p) {
- RECT mon = Monitor(); float sc = Sc();
- int H = (int)std::lround(WinH() * sc);
- return HitTest((p.x - mon.left) / sc, (p.y - (mon.bottom - H)) / sc);
+ D2D1_POINT_2F q = ScreenToLocal(POINT{ p.x, p.y });
+ return HitTest(q.x, q.y);
}
DWORD Effect(int i) {
if (i < 0) return DROPEFFECT_NONE;
@@ -1423,13 +1544,14 @@ LRESULT CALLBACK IconsProc(HWND h, UINT m, WPARAM w, LPARAM l) {
switch (m) {
case WM_MOUSEACTIVATE: return MA_NOACTIVATE;
case WM_SETCURSOR:
- if (g_sepHover || g_resizing) { SetCursor(LoadCursorW(nullptr, IDC_SIZENS)); return TRUE; } // setinha ↕ no separador
+ if (g_sepHover || g_resizing) { SetCursor(LoadCursorW(nullptr, Vert() ? IDC_SIZEWE : IDC_SIZENS)); return TRUE; } // setinha ↕ no separador (↔ dos lados)
break;
case WM_MOUSEMOVE: {
- float x = (GET_X_LPARAM(l)) / sc, y = (GET_Y_LPARAM(l)) / sc;
+ D2D1_POINT_2F lp = ToLocal(GET_X_LPARAM(l) / sc, GET_Y_LPARAM(l) / sc); // no sistema do Dock
+ float x = lp.x, y = lp.y;
if (g_resizing) { // arrastando o separador: para cima aumenta, para baixo diminui
POINT c; GetCursorPos(&c);
- g_tile = g_tileWant = std::clamp(g_resizeTile + (g_resizeY - c.y) / sc, 16.f, 128.f);
+ g_tile = g_tileWant = std::clamp(g_resizeTile + (Inward(c) - g_resizeY) / sc, 16.f, 128.f);
g_large = std::max(g_large, g_tile);
Paint();
return 0;
@@ -1467,13 +1589,14 @@ LRESULT CALLBACK IconsProc(HWND h, UINT m, WPARAM w, LPARAM l) {
if (!g_dragging) { g_mouseX = -1; g_hover = -1; if (Animating()) ui::FrameClock(g_icons, WM_DOCKFRAME, true); Paint(); }
return 0;
case WM_LBUTTONDOWN: {
- if (HitSep((GET_X_LPARAM(l)) / sc, (GET_Y_LPARAM(l)) / sc)) {
+ D2D1_POINT_2F lp = ToLocal(GET_X_LPARAM(l) / sc, GET_Y_LPARAM(l) / sc);
+ if (HitSep(lp.x, lp.y)) {
POINT c; GetCursorPos(&c);
- g_resizing = true; g_resizeY = c.y; g_resizeTile = g_tile;
+ g_resizing = true; g_resizeY = Inward(c); g_resizeTile = g_tile;
SetCapture(h);
return 0;
}
- g_press = HitTest((GET_X_LPARAM(l)) / sc, (GET_Y_LPARAM(l)) / sc);
+ g_press = HitTest(lp.x, lp.y);
GetCursorPos(&g_pressPt);
SetCapture(h);
Paint();
@@ -1498,8 +1621,8 @@ LRESULT CALLBACK IconsProc(HWND h, UINT m, WPARAM w, LPARAM l) {
if (g_dragOut) { // o "puf" do Mac
if (a.pinned) {
POINT c; GetCursorPos(&c);
- RECT mon = Monitor(); float sc = Sc(), H = WinH() * sc;
- g_poof = { (c.x - mon.left) / sc, (c.y - (mon.bottom - H)) / sc, anim::Now() };
+ D2D1_POINT_2F q = ScreenToLocal(c);
+ g_poof = { q.x, q.y, anim::Now() };
apps::SetPinned(a, false); shell::Sound(L"poof_item_off_dock");
ui::FrameClock(g_icons, WM_DOCKFRAME, true);
}
@@ -1512,13 +1635,15 @@ LRESULT CALLBACK IconsProc(HWND h, UINT m, WPARAM w, LPARAM l) {
Paint();
return 0;
}
- int i = HitTest((GET_X_LPARAM(l)) / sc, (GET_Y_LPARAM(l)) / sc);
+ D2D1_POINT_2F lp = ToLocal(GET_X_LPARAM(l) / sc, GET_Y_LPARAM(l) / sc);
+ int i = HitTest(lp.x, lp.y);
Paint();
if (i >= 0 && i == p) LeftClick(i);
return 0;
}
case WM_MBUTTONUP: { // botão do meio: uma janela nova do app (como na barra do Windows)
- int i = HitTest((GET_X_LPARAM(l)) / sc, (GET_Y_LPARAM(l)) / sc);
+ D2D1_POINT_2F lp = ToLocal(GET_X_LPARAM(l) / sc, GET_Y_LPARAM(l) / sc);
+ int i = HitTest(lp.x, lp.y);
if (i < 0) return 0;
auto& it = g_items[i];
if (it.kind == I_APP) {
@@ -1536,10 +1661,11 @@ LRESULT CALLBACK IconsProc(HWND h, UINT m, WPARAM w, LPARAM l) {
return 0;
}
case WM_RBUTTONUP: {
- int i = HitTest((GET_X_LPARAM(l)) / sc, (GET_Y_LPARAM(l)) / sc);
+ D2D1_POINT_2F lp = ToLocal(GET_X_LPARAM(l) / sc, GET_Y_LPARAM(l) / sc);
+ int i = HitTest(lp.x, lp.y);
g_hover = -1;
if (i >= 0) ContextMenu(i);
- else if ((GET_Y_LPARAM(l)) / sc >= g_bg.top) BackgroundMenu();
+ else if (lp.y >= g_bg.top) BackgroundMenu();
Paint();
return 0;
}
@@ -1591,7 +1717,9 @@ HWND dock::Hwnd() { return g_icons; }
HWND dock::Fundo() { return g_back; }
HMONITOR dock::MonitorHandle() { return DockMon(); }
-int dock::ReservedHeight() {
+int dock::Posicao() { return Pos(); }
+
+int dock::ReservedHeight() { // a espessura do Dock na borda dele (embaixo, à esquerda ou à direita: dock::Posicao)
if (!g_icons || g_autohide) return 0;
return (int)std::lround((g_tile + PAD_TOP + PAD_BOTTOM + MARGIN) * Sc());
}
@@ -1617,6 +1745,8 @@ static void ReadSettings() {
g_mostraLaunchpad = shell::Setting(L"dock_launchpad", L"1") != L"0";
g_indicador = shell::Setting(L"dock_indicador", L"ponto") == L"traco" ? 1 : 0;
g_rotulos = shell::Setting(L"dock_rotulos", L"1") != L"0";
+ std::wstring pos = shell::Setting(L"dock_posicao", L"baixo");
+ g_pos = pos == L"esquerda" ? 1 : pos == L"direita" ? 2 : 0;
g_customIcon.clear(); // a pasta de ícones próprios pode ter mudado
FitTile();
}
@@ -1641,14 +1771,24 @@ void dock::IconsChanged() {
void dock::ReloadSettings() {
bool hide = g_autohide, smart = g_smart;
+ int pos = g_pos;
ReadSettings();
if (!g_icons) return;
+ if (pos != g_pos) { // mudou de lado: a área de trabalho reserva a borda nova (e as janelas maximizadas se ajeitam)
+ Log(L"Dock: posição %ls", g_pos == 1 ? L"esquerda" : g_pos == 2 ? L"direita" : L"embaixo");
+ g_mouseX = g_lastMouseX = -1; g_hover = -1; g_magAmt = 0;
+ // arrasto em andamento (ícone ou separador) é cancelado: a referência era do lado antigo (20/11/2026, o
+ // separador arrastado durante a troca levou o tamanho a 128, depois a 16, e gravou um valor qualquer)
+ if (g_resizing || g_dragging || g_press >= 0) { g_resizing = g_dragging = g_dragOut = false; g_press = -1; ReleaseCapture(); }
+ for (auto& it : g_items) it.cx = 0;
+ }
if (hide != g_autohide || smart != g_smart) { g_hidden = false; g_covered = false; g_coverAt = 0; ui::FrameClock(g_icons, WM_DOCKFRAME, true); }
g_win = {}; g_lastBg = {};
for (auto& [k, b] : g_bmps) if (b) b->Release(); // ícones próprios novos ou tirados
g_bmps.clear();
BuildItems(); // a pasta Downloads, a divisória ou o Launchpad podem ter entrado ou saído
Paint();
+ if (pos != g_pos) shell::ApplyWorkArea();
}
bool dock::Create(HINSTANCE hi) {
@@ -1703,13 +1843,10 @@ bool dock::Create(HINSTANCE hi) {
}
RECT dock::MinimizeTarget() {
- float sc = Sc();
- RECT mon = Monitor();
- int H = (int)std::lround(WinH() * sc);
for (auto& it : g_items) if (it.kind == I_TRASH) {
+ // o lugar logo antes da Lixeira (dos lados, o mesmo quadrado girado com o Dock)
float cx = it.cx - SLOT / 2, s = g_tile, top = g_bg.top + PAD_TOP;
- return { mon.left + (LONG)std::lround((cx - s / 2) * sc), mon.bottom - H + (LONG)std::lround(top * sc),
- mon.left + (LONG)std::lround((cx + s / 2) * sc), mon.bottom - H + (LONG)std::lround((top + s) * sc) };
+ return ToScreenRect({ cx - s / 2, top, cx + s / 2, top + s });
}
return { 0, 0, 0, 0 };
}
@@ -1741,8 +1878,7 @@ void dock::ApplyTheme() {
void dock::OpenAppsStack() {
for (auto& it : g_items) {
if (it.kind != I_LAUNCHPAD) continue;
- float sc = Sc(); RECT mon = Monitor(); int H = (int)std::lround(WinH() * sc);
- POINT a{ mon.left + (LONG)std::lround(it.cx * sc), mon.bottom - H + (LONG)std::lround((g_bg.top - 4) * sc) };
+ POINT a = ToScreen(it.cx, g_bg.top - 4);
pilhas::ShowApps(a);
return;
}
@@ -1751,8 +1887,7 @@ void dock::OpenAppsStack() {
void dock::OpenDownloadsStack() {
for (auto& it : g_items) {
if (it.kind != I_DOWNLOADS) continue;
- float sc = Sc(); RECT mon = Monitor(); int H = (int)std::lround(WinH() * sc);
- POINT a{ mon.left + (LONG)std::lround(it.cx * sc), mon.bottom - H + (LONG)std::lround((g_bg.top - 4) * sc) };
+ POINT a = ToScreen(it.cx, g_bg.top - 4);
pilhas::Show(a);
return;
}
diff --git a/src/shell/limites.cpp b/src/shell/limites.cpp
index 7beb82d..893da59 100644
--- a/src/shell/limites.cpp
+++ b/src/shell/limites.cpp
@@ -79,17 +79,27 @@ void Clamp(HWND h) {
// de verdade, mas continua redimensionável (Ableton); diálogos de tamanho fixo só mudam de lugar
bool resizable = (GetWindowLongW(h, GWL_STYLE) & WS_THICKFRAME) || GetPropW(h, L"MacJanela");
if (vis.top + dy + newH > wa.bottom && resizable) newH = wa.bottom - (vis.top + dy);
- if (!dy && newH == hh) return;
+ // Dock à esquerda ou à direita (Ajustes > Posição na tela): a mesma conta na horizontal, só do lado dele
+ int dx = 0, newW = w;
+ if (dock::Posicao() != 0 && hm == dock::MonitorHandle()) {
+ if (dock::Posicao() == 1 && vis.left < wa.left) dx = wa.left - vis.left;
+ else if (dock::Posicao() == 2 && vis.right > wa.right) dx = -std::min((int)(vis.right - wa.right), std::max(0, (int)(vis.left - wa.left)));
+ // à direita, mais larga que a área: encolhe até o Dock (à esquerda, empurrar para dentro já basta)
+ if (dock::Posicao() == 2 && vis.left + dx + newW > wa.right && resizable) newW = std::max(120, (int)(wa.right - (vis.left + dx)));
+ }
+ if (!dy && newH == hh && !dx && newW == w) return;
{
std::lock_guard<std::mutex> k(g_slideMx);
if (std::find(g_sliding.begin(), g_sliding.end(), h) != g_sliding.end()) return; // já deslizando
g_sliding.push_back(h);
}
int bt = vis.top - wr.top, bb = wr.bottom - vis.bottom; // borda invisível de redimensionar
- RECT to{ wr.left, wr.top + dy, wr.right, wr.top + dy + newH + bt + bb };
+ int bl = vis.left - wr.left, brr = wr.right - vis.right;
+ RECT to{ wr.left + dx, wr.top + dy, wr.left + dx + newW + bl + brr, wr.top + dy + newH + bt + bb };
static UINT msgMove = RegisterWindowMessageW(L"MacJanelaMover");
DWORD_PTR ok = 0;
- if (GetPropW(h, L"MacJanela") &&
+ // a DLL das janelas só sabe deslizar na vertical: na horizontal (Dock do lado) a janela anda pela thread
+ if (!dx && newW == w && GetPropW(h, L"MacJanela") &&
SendMessageTimeoutW(h, msgMove, (WPARAM)(INT_PTR)dy, (LPARAM)(to.bottom - to.top), SMTO_ABORTIFHUNG, 300, &ok) && ok) {
std::lock_guard<std::mutex> k(g_slideMx);
g_sliding.erase(std::remove(g_sliding.begin(), g_sliding.end(), h), g_sliding.end());
@@ -97,7 +107,7 @@ void Clamp(HWND h) {
std::thread(SlideThread, h, wr, to).detach();
}
wchar_t cls[64] = {}; GetClassNameW(h, cls, 64);
- Log(L"limites: %ls voltando para a área (dy %d, altura %d -> %d)", cls, dy, hh, newH);
+ Log(L"limites: %ls voltando para a área (dx %d, dy %d, altura %d -> %d, largura %d -> %d)", cls, dx, dy, hh, newH, w, newW);
}
void CALLBACK OnMoveEnd(HWINEVENTHOOK, DWORD, HWND h, LONG obj, LONG child, DWORD, DWORD) {
diff --git a/src/shell/main.cpp b/src/shell/main.cpp
index 16f8cb6..60c6756 100644
--- a/src/shell/main.cpp
+++ b/src/shell/main.cpp
@@ -434,7 +434,12 @@ RECT shell::WorkAreaFor(HMONITOR hm) {
if (!GetMonitorInfoW(hm, &mi)) return {};
RECT want = mi.rcMonitor;
want.top += (mi.dwFlags & MONITORINFOF_PRIMARY) ? menubar::Height() : menubar::HeightOn(hm);
- if (hm == dock::MonitorHandle()) want.bottom -= dock::ReservedHeight();
+ if (hm == dock::MonitorHandle()) { // o Dock na borda escolhida (Ajustes > Posição na tela)
+ int r = dock::ReservedHeight();
+ if (dock::Posicao() == 1) want.left += r;
+ else if (dock::Posicao() == 2) want.right -= r;
+ else want.bottom -= r;
+ }
return want;
}
diff --git a/src/shell/missioncontrol.cpp b/src/shell/missioncontrol.cpp
index 99aca61..d4616ea 100644
--- a/src/shell/missioncontrol.cpp
+++ b/src/shell/missioncontrol.cpp
@@ -204,12 +204,15 @@ void Layout(float bar) {
size_t n = g_wins.size();
if (!n) return;
float top = BarHeightPx(bar) + 14 * Sc();
- float bottom = H() - dock::ReservedHeight() - 18 * Sc();
- D2D1_RECT_F area = { 28 * Sc(), top, W() - 28 * Sc(), bottom };
+ // o Dock embaixo tira espaço de baixo; à esquerda ou à direita, daquele lado (Ajustes > Posição na tela)
+ int dpos = dock::Posicao();
+ float dockB = dpos == 0 ? (float)dock::ReservedHeight() : 0.f, dockL = dpos == 1 ? (float)dock::ReservedHeight() : 0.f, dockR = dpos == 2 ? (float)dock::ReservedHeight() : 0.f;
+ float bottom = H() - dockB - 18 * Sc();
+ D2D1_RECT_F area = { dockL + 28 * Sc(), top, W() - dockR - 28 * Sc(), bottom };
if (liquid::On()) { // Tahoe (guia, seção 38, medido): 20 dos lados, de y 80 até ~104 da borda de baixo
- area.left = 20 * Sc(); area.right = W() - 20 * Sc();
+ area.left = dockL + 20 * Sc(); area.right = W() - dockR - 20 * Sc();
area.top = std::max(top, 80 * Sc());
- area.bottom = H() - 104 * Sc();
+ area.bottom = H() - (dpos == 0 ? 104 * Sc() : 24 * Sc());
}
float aw = area.right - area.left, ah = area.bottom - area.top, gap = 34 * Sc();
std::vector<size_t> order(n);
@@ -480,7 +483,7 @@ windows:
float tw = std::min(ui::TextWidth(g_tfTitle, t2) + 24, d.right - d.left + 80);
float cx = (d.left + d.right) / 2;
D2D1_RECT_F tr = { cx - tw / 2, d.bottom + 10, cx + tw / 2, d.bottom + 36 };
- if (tr.bottom > Hd - dock::ReservedHeight() / sc) { tr.top = d.bottom - 34; tr.bottom = d.bottom - 8; }
+ if (tr.bottom > Hd - (dock::Posicao() == 0 ? dock::ReservedHeight() : 0) / sc) { tr.top = d.bottom - 34; tr.bottom = d.bottom - 8; }
br->SetColor(D2D1::ColorF(0.12f, 0.12f, 0.13f, 0.82f));
dc->FillRoundedRectangle(D2D1::RoundedRect(tr, 8, 8), br);
br->SetColor(D2D1::ColorF(1, 1, 1, 0.95f));
diff --git a/src/shell/pilhas.cpp b/src/shell/pilhas.cpp
index 9c50e62..19cb986 100644
--- a/src/shell/pilhas.cpp
+++ b/src/shell/pilhas.cpp
@@ -43,6 +43,10 @@ float PH() { return HEAD + Rows() * CELL_H + FOOT + ARROW; } // com a setinha e
D2D1_RECT_F CellRect(int i) { float x = PAD + (i % COLS) * CELL_W, y = HEAD + (i / COLS) * CELL_H; return { x, y, x + CELL_W, y + CELL_H }; }
D2D1_RECT_F BtnRect() { return { PW() / 2 - 70, HEAD + Rows() * CELL_H + 2, PW() / 2 + 70, HEAD + Rows() * CELL_H + 26 }; }
float g_arrowX; // DIP, dentro do painel: onde a setinha aponta (o ícone no Dock)
+int g_side; // Dock à esquerda (1) ou à direita (2): a Grade abre ao lado, sem setinha, crescendo do lado do Dock
+// o ponto (px no painel) de onde o painel cresce e para onde volta: o ícone no Dock
+float GrowX(int wpx, float sc) { return g_side == 1 ? 0.f : g_side == 2 ? (float)wpx : g_arrowX * sc; }
+float GrowY(int hpx) { return g_side ? hpx / 2.f : (float)hpx; }
// ---- Leque
bool g_fan; // aberta em Leque (sem vidro: cada item com a etiqueta dele)
const int FAN_MAX = 10;
@@ -86,7 +90,7 @@ void Motion() {
float sc = Sc();
int wpx = (int)std::lround(PW() * sc), hpx = (int)std::lround(PH() * sc);
anim::Panel mo = g_closing ? anim::PanelOut(anim::Now() - g_closeAt) : anim::PanelIn(anim::Now() - g_openAt);
- float cx = g_arrowX * sc, cy = (float)hpx; // cresce e volta para o ícone
+ float cx = GrowX(wpx, sc), cy = GrowY(hpx); // cresce e volta para o ícone
if (g_inGlass) backdrop::Fade(g_back, mo.fade, mo.scale, cx, cy); // o desenho está dentro do vidro: vão juntos
else { ui::GpuMotion(g_s, mo.scale, cx, cy, mo.fade); if (g_glass) backdrop::Fade(g_back, mo.fade, mo.scale, cx, cy); }
}
@@ -196,7 +200,7 @@ void Paint() {
br->SetColor(dark ? D2D1::ColorF(1, 1, 1, 0.14f) : D2D1::ColorF(0, 0, 0, 0.12f));
dc->DrawRoundedRectangle(D2D1::RoundedRect(D2D1::RectF(0.5f, 0.5f, PW() - 0.5f, BODY - 0.5f), R, R), br, 1);
}
- { // setinha apontando para o ícone no Dock (na cor do vidro)
+ if (!g_side) { // setinha apontando para o ícone no Dock (na cor do vidro); com o Dock do lado não há
ID2D1Factory* fac = nullptr; dc->GetFactory(&fac);
ID2D1PathGeometry* tri = nullptr; if (fac) fac->CreatePathGeometry(&tri);
if (tri) {
@@ -503,6 +507,13 @@ std::vector<std::wstring> List(int max) {
return out;
}
+// Onde abrir um menu que sai do ícone no Dock (anchor: o lado de dentro do ícone): embaixo, para cima dele; com o
+// Dock à esquerda ou à direita, ao lado, centrado na altura do ícone (o menu vira para a esquerda sozinho se não couber)
+POINT MenuPt(POINT anchor, int hpx) {
+ if (dock::Posicao() == 0) return { anchor.x - (LONG)std::lround(60 * Sc()), anchor.y - hpx };
+ return { anchor.x, anchor.y - hpx / 2 };
+}
+
// Lista: um menu com os nomes, como antes (e como o "Lista" do Mac)
void ShowList(POINT anchor) {
auto files = List(14);
@@ -513,7 +524,7 @@ void ShowList(POINT anchor) {
ctxmenu::Item op; op.label = Tr(L"Abrir no Finder"); op.id = 30; m.push_back(op);
ctxmenu::PlainNext();
SetForegroundWindow(g_wnd);
- POINT pt{ anchor.x - 60, anchor.y - (LONG)std::lround((m.size() * 22 + 14) * Sc()) };
+ POINT pt = MenuPt(anchor, (int)std::lround((m.size() * 22 + 14) * Sc()));
int id = ctxmenu::ShowItems(g_wnd, pt, m);
if (id == 30) OpenDownloadsInFinder();
else if (id >= 5000 && id - 5000 < (int)files.size() && !AbrirNoAppMac(files[id - 5000])) ShellExecuteW(nullptr, L"open", files[id - 5000].c_str(), nullptr, nullptr, SW_SHOWNORMAL);
@@ -542,7 +553,7 @@ void pilhas::Menu(POINT anchor) {
std::vector<ctxmenu::Item> m = { sortBy, show, view, sep, MI(Tr(L"Abrir \u201cDownloads\u201d"), 300) };
ctxmenu::PlainNext();
SetForegroundWindow(g_wnd);
- POINT pt{ anchor.x - 60, anchor.y - (LONG)std::lround(120 * Sc()) };
+ POINT pt = MenuPt(anchor, (int)std::lround(120 * Sc()));
int id = ctxmenu::ShowItems(g_wnd, pt, m);
if (id >= 100 && id < 105) shell::SetSetting(L"pilha_ordem", ordK[id - 100]);
else if (id >= 200 && id < 204) shell::SetSetting(L"pilha_ver", verK[id - 200]);
@@ -567,6 +578,7 @@ void ShowStack(POINT anchor, bool apps) {
std::wstring ver = apps ? std::wstring(L"grade") : shell::Setting(L"pilha_ver", L"auto"); // Aplicativos: sempre a Grade
if (ver == L"lista") { ShowList(anchor); return; }
g_fan = ver != L"grade"; // Automático: o Leque, como o Mac faz com Downloads
+ if (dock::Posicao() != 0) g_fan = false; // Dock do lado: o Leque só existe embaixo (no Mac também vira Grade)
std::vector<std::wstring> files = List(g_fan ? FAN_MAX : MAXN);
{ // quem estava na frente (não o Shell): volta para ela ao fechar sem abrir nada
HWND fg = GetForegroundWindow(); DWORD pid = 0;
@@ -622,10 +634,17 @@ void ShowStack(POINT anchor, bool apps) {
MONITORINFO mi{ sizeof(mi) };
GetMonitorInfoW(MonitorFromPoint(anchor, MONITOR_DEFAULTTOPRIMARY), &mi);
int x, y;
+ g_side = 0;
if (g_fan) { // o arco sai do ícone: o ícone fica embaixo, perto da borda direita da janela
x = anchor.x - (int)std::lround((FAN_W - 70) * sc);
y = anchor.y - hpx;
g_arrowX = FAN_W - 70;
+ } else if (dock::Posicao() != 0) {
+ // Dock à esquerda ou à direita: a Grade abre ao lado do ícone, na altura dele (sem a setinha de baixo)
+ int pos = dock::Posicao();
+ x = pos == 1 ? anchor.x + (int)std::lround(4 * sc) : anchor.x - wpx - (int)std::lround(4 * sc);
+ y = std::clamp((int)anchor.y - hpx / 2, (int)mi.rcWork.top + 8, std::max((int)mi.rcWork.top + 8, (int)mi.rcWork.bottom - hpx - 8));
+ g_arrowX = 0; g_side = pos;
} else {
x = std::clamp((int)anchor.x - wpx / 2, (int)mi.rcWork.left + 8, (int)mi.rcWork.right - wpx - 8);
y = anchor.y - hpx - (int)std::lround(2 * sc);
@@ -635,8 +654,8 @@ void ShowStack(POINT anchor, bool apps) {
SetWindowPos(g_back, g_wnd, x, y, wpx, hpx, SWP_NOACTIVATE);
g_open = true; g_hover = -2;
g_openAt = anim::Now();
- if (g_glass) backdrop::Fade(g_back, 0, 0.96f, g_arrowX * sc, (float)hpx); // a última abertura deixou em 100%: piscava
- ui::GpuMotion(g_s, g_fan ? 1.f : 0.96f, g_arrowX * sc, (float)hpx, g_fan ? 1.f : 0.f); // o Leque se anima item a item
+ if (g_glass) backdrop::Fade(g_back, 0, 0.96f, GrowX(wpx, sc), GrowY(hpx)); // a última abertura deixou em 100%: piscava
+ ui::GpuMotion(g_s, g_fan ? 1.f : 0.96f, GrowX(wpx, sc), GrowY(hpx), g_fan ? 1.f : 0.f); // o Leque se anima item a item
Paint(); // vidro e conteúdo prontos (e invisíveis: a mola começa em 0) antes de mostrar
if (!g_fan) ShowWindow(g_back, SW_SHOWNOACTIVATE);
else ShowWindow(g_back, SW_HIDE);
diff --git a/src/shell/shell.h b/src/shell/shell.h
index 5354d76..8d33aa5 100644
--- a/src/shell/shell.h
+++ b/src/shell/shell.h
@@ -509,7 +509,8 @@ bool Create(HINSTANCE hi);
void Update(); // apps mudaram
HWND Hwnd();
HWND Fundo(); // o vidro, a janela mais de baixo do Dock
-int ReservedHeight(); // px reservados embaixo (área de trabalho)
+int ReservedHeight(); // px reservados na borda do Dock (área de trabalho): embaixo ou do lado (Posicao)
+int Posicao(); // 0 embaixo, 1 esquerda, 2 direita (dock_posicao; o Leopard fica sempre embaixo)
HMONITOR MonitorHandle(); // o monitor do Dock (ajuste dock_monitor; vazio = o principal)
void Raise(); // traz o Dock para cima (ex.: por cima do Launchpad)
void OpenAppsStack(); // Leopard: a pasta Aplicativos como Pilha em Grade