A new style desktop shell for Windows 11: menu bar, Dock, Finder, Spotlight, Control Center and Liquid Glass, in native C++.
Rust
//! sobre.cpp: "Sobre Este Mac" (menu da Apple): a janela do Sequoia (280 × 474, medida na referência) com os dados deste
//! PC (padrão) ou, com sobre_mac=macstudio, um Mac Studio M4 Max de enfeite; macOS 27 (280 × 487) e o About This Mac do
//! Mac OS X 10.5 no tema Leopard (cinza 232, barra de metal, maçã prateada, botões em pílula do Aqua).
#![allow(dead_code)]
use comum::windows::core::*;
use comum::windows::Win32::Foundation::*;
use comum::windows::Win32::Graphics::Direct2D::Common::*;
use comum::windows::Win32::Graphics::Direct2D::*;
use comum::windows::Win32::Graphics::DirectWrite::*;
use comum::windows::Win32::Graphics::Dwm::*;
use comum::windows::Win32::Graphics::Gdi::*;
use comum::windows::Win32::System::Registry::*;
use comum::windows::Win32::System::SystemInformation::*;
use comum::windows::Win32::UI::Input::KeyboardAndMouse::*;
use comum::windows::Win32::UI::WindowsAndMessaging::*;
use comum::*;
use crate::{anim, apps, backdrop, liquid, shell, ui};
const W: f32 = 280.0;
const LIGHT_PITCH: f32 = 23.0;
const LIGHT_R: f32 = 7.0;
const IMG_TOP: f32 = 90.0;
const IMG_W: f32 = 145.5;
const IMG_H: f32 = 70.7;
const YEAR_CY: f32 = 262.0;
const COL_SPLIT: f32 = 119.0;
const COL_GAP: f32 = 10.0;
const WM_SB_FRAME: u32 = WM_APP + 72;
fn gg() -> bool {
liquid::golden()
}
fn leo() -> bool {
liquid::leopard()
}
fn hh() -> f32 {
if leo() {
384.0
} else if gg() {
487.0
} else {
474.0
}
}
fn radius() -> f32 {
if liquid::on() {
16.0
} else if leo() {
6.0
} else {
10.0
}
}
fn light_x0() -> f32 {
if liquid::on() {
16.0
} else if leo() {
14.5
} else {
19.0
}
}
fn light_y() -> f32 {
if liquid::on() {
16.0
} else if leo() {
11.0
} else {
14.0
}
}
fn title_cy() -> f32 {
if gg() {
245.5
} else {
240.6
}
}
struct S {
wnd: HWND,
back: HWND,
glass: bool,
active: bool,
s: ui::GpuSurface,
hover: i32,
press: i32,
btn: RectF,
reg: RectF,
serial: String,
open_at: f64,
foto: Option<(f32, f32)>,
}
static SS: Global<Option<S>> = Global::new(None);
fn s() -> &'static mut S {
SS.get().get_or_insert_with(|| S { wnd: HWND::default(), back: HWND::default(), glass: false, active: false, s: ui::GpuSurface::default(), hover: -1, press: -1, btn: rf(0.0, 0.0, 0.0, 0.0), reg: rf(0.0, 0.0, 0.0, 0.0), serial: String::new(), open_at: 0.0, foto: None })
}
fn sc() -> f32 {
if s().foto.is_some() {
ui::foto_scale()
} else {
ui::scale(s().wnd)
}
}
fn reg(key: &str, val: &str) -> String {
let mut v = [0u16; 256];
let mut cb = 512u32;
let ok = unsafe { RegGetValueW(HKEY_LOCAL_MACHINE, pc(&wz(key)), pc(&wz(val)), RRF_RT_REG_SZ | RRF_SUBKEY_WOW6464KEY, None, Some(v.as_mut_ptr() as *mut _), Some(&mut cb)).is_ok() };
if ok {
from_w(&v).trim().to_string()
} else {
String::new()
}
}
fn memoria() -> String {
let mut m = MEMORYSTATUSEX { dwLength: std::mem::size_of::<MEMORYSTATUSEX>() as u32, ..Default::default() };
unsafe {
let _ = GlobalMemoryStatusEx(&mut m);
}
format!("{} GB", (m.ullTotalPhys + (1 << 29)) >> 30)
}
fn limpa_cpu(mut c: String) -> String {
for t in ["(R)", "(TM)", " CPU", " Processor"] {
c = c.replace(t, "");
}
while c.contains(" ") {
c = c.replace(" ", " ");
}
c.trim().to_string()
}
/// o Leopard mostra "3,6 GHz Intel Core i7"
fn processador() -> String {
let c = limpa_cpu(reg("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", "ProcessorNameString"));
match c.split_once(" @ ") {
Some((a, b)) => format!("{b} {a}"),
None if c.is_empty() => "Intel Core 2 Duo".into(),
None => c,
}
}
fn modo_pc() -> bool {
shell::setting("sobre_mac", "pc") != "macstudio"
}
#[derive(Clone, Default)]
struct PcInfo {
modelo: String,
fabricante: String,
cpu: String,
gpu: String,
ram: String,
nome: String,
windows: String,
}
/// os dados deste PC (Reddit, 21/11/2026: "o Sobre este PC mostra um Mac aleatório")
fn pc_info() -> PcInfo {
static INFO: std::sync::OnceLock<PcInfo> = std::sync::OnceLock::new();
INFO.get_or_init(|| {
let bios = "HARDWARE\\DESCRIPTION\\System\\BIOS";
let lixo = |t: &str| {
let l = t.to_lowercase();
l.is_empty() || l.contains("system product") || l.contains("to be filled") || l.contains("default string") || l.contains("system manufacturer") || l == "o.e.m."
};
let mut i = PcInfo { modelo: reg(bios, "SystemProductName"), fabricante: reg(bios, "SystemManufacturer"), ..Default::default() };
if lixo(&i.modelo) {
i.modelo = reg(bios, "BaseBoardProduct");
i.fabricante = reg(bios, "BaseBoardManufacturer");
}
if lixo(&i.fabricante) {
i.fabricante.clear();
}
if lixo(&i.modelo) {
i.modelo = "PC".into();
}
unsafe {
let mut b = [0u16; 256];
let mut n = 256u32;
if GetComputerNameExW(ComputerNameDnsHostname, PWSTR(b.as_mut_ptr()), &mut n).is_ok() {
i.nome = String::from_utf16_lossy(&b[..n as usize]);
}
let c = limpa_cpu(reg("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", "ProcessorNameString"));
i.cpu = c.split(" @ ").next().unwrap_or("").to_string();
let mut dd = DISPLAY_DEVICEW { cb: std::mem::size_of::<DISPLAY_DEVICEW>() as u32, ..Default::default() };
let mut k = 0;
while EnumDisplayDevicesW(PCWSTR::null(), k, &mut dd, 0).as_bool() {
if dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE != 0 {
i.gpu = from_w(&dd.DeviceString);
break;
}
k += 1;
}
let mut kb = 0u64;
i.ram = if GetPhysicallyInstalledSystemMemory(&mut kb).is_ok() { format!("{} GB", (kb + 512 * 1024) / (1024 * 1024)) } else { memoria() };
}
let cv = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";
let mut prod = reg(cv, "ProductName");
if reg(cv, "CurrentBuild").parse::<u32>().unwrap_or(0) >= 22000 && prod.starts_with("Windows 10") {
prod.replace_range(0..10, "Windows 11"); // o registro ainda diz 10
}
i.windows = format!("{prod} {}", reg(cv, "DisplayVersion"));
i
})
.clone()
}
/// número de série estável para esta máquina (10 caracteres, como os do Mac)
fn serial() -> String {
let guid = reg("SOFTWARE\\Microsoft\\Cryptography", "MachineGuid");
let mut h: u64 = 1469598103934665603;
for c in guid.encode_utf16() {
h ^= c as u64;
h = h.wrapping_mul(1099511628211);
}
let abc: Vec<char> = "0123456789ACDEFGHJKLMNPQRTUVWXYZ".chars().collect();
(0..10)
.map(|_| {
let c = abc[(h % 32) as usize];
h /= 32;
if h == 0 {
h = 0x9E37_79B9_7F4A_7C15;
}
c
})
.collect()
}
#[allow(clippy::too_many_arguments)]
unsafe fn text(dc: &ID2D1DeviceContext, br: &ID2D1SolidColorBrush, t: &str, size: f32, wgt: DWRITE_FONT_WEIGHT, al: DWRITE_TEXT_ALIGNMENT, r: RectF, c: Cor, underline: bool, display: bool) {
let tf = if display { cjk::format(ui::dw(), "SF Pro Display", wgt, DWRITE_FONT_STYLE_NORMAL, size, "pt-br") } else { None }.unwrap_or_else(|| ui::format(size, wgt, false, al));
let _ = tf.SetTextAlignment(al);
let _ = tf.SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
let _ = tf.SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);
// texto mais largo que o espaço (placa de vídeo, processador): corta com "…"
if let Ok(dots) = ui::dw().CreateEllipsisTrimmingSign(&tf) {
let tr_ = DWRITE_TRIMMING { granularity: DWRITE_TRIMMING_GRANULARITY_CHARACTER, delimiter: 0, delimiterCount: 0 };
let _ = tf.SetTrimming(&tr_, &dots);
}
let tw = w(t);
if let Ok(lay) = ui::dw().CreateTextLayout(&tw, &tf, r.right - r.left, r.bottom - r.top) {
if underline {
let _ = lay.SetUnderline(true, DWRITE_TEXT_RANGE { startPosition: 0, length: tw.len() as u32 });
}
br.SetColor(&c);
dc.DrawTextLayout(pt(r.left, r.top), &lay, br, D2D1_DRAW_TEXT_OPTIONS_NONE);
}
}
fn tw(size: f32, t: &str) -> f32 {
ui::text_width(&ui::fmt(size, DWRITE_FONT_WEIGHT_NORMAL), t)
}
unsafe fn grad(dc: &ID2D1DeviceContext, a: Ponto, b: Ponto, st: &[(f32, Cor)]) -> Option<ID2D1LinearGradientBrush> {
let rt: ID2D1RenderTarget = dc.cast().ok()?;
let stops: Vec<D2D1_GRADIENT_STOP> = st.iter().map(|(p, c)| D2D1_GRADIENT_STOP { position: *p, color: *c }).collect();
let gs = rt.CreateGradientStopCollection(&stops, D2D1_GAMMA_2_2, D2D1_EXTEND_MODE_CLAMP).ok()?;
rt.CreateLinearGradientBrush(&D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES { startPoint: a, endPoint: b }, None, &gs).ok()
}
/// botão em pílula do Aqua (perolado; apertado, azul)
unsafe fn aqua_pill(dc: &ID2D1DeviceContext, br: &ID2D1SolidColorBrush, r: RectF, down: bool) {
let rad = (r.bottom - r.top) / 2.0;
br.SetColor(&col(1.0, 1.0, 1.0, 0.6));
dc.FillRoundedRectangle(&comum::rr(rf(r.left, r.top + 1.0, r.right, r.bottom + 1.0), rad, rad), br);
let st = if down {
[(0.0, col(0.66, 0.80, 0.98, 1.0)), (0.5, col(0.38, 0.60, 0.93, 1.0)), (0.5, col(0.24, 0.47, 0.87, 1.0)), (1.0, col(0.58, 0.82, 1.0, 1.0))]
} else {
[(0.0, col(1.0, 1.0, 1.0, 1.0)), (0.5, col(0.95, 0.95, 0.95, 1.0)), (0.5, col(0.88, 0.88, 0.88, 1.0)), (1.0, col(0.98, 0.98, 0.98, 1.0))]
};
if let Some(lb) = grad(dc, pt(0.0, r.top), pt(0.0, r.bottom), &st) {
dc.FillRoundedRectangle(&comum::rr(r, rad, rad), &lb);
}
br.SetColor(&col(0.0, 0.0, 0.0, 0.40));
dc.DrawRoundedRectangle(&comum::rr(rf(r.left + 0.5, r.top + 0.5, r.right - 0.5, r.bottom - 0.5), rad - 0.5, rad - 0.5), br, 1.0, None);
}
/// Mac Studio de frente (desenho vetorial, sem o PNG do pacote)
unsafe fn draw_mac_studio(dc: &ID2D1DeviceContext, x: f32, y: f32) {
let (body_h, inset) = (63.5f32, 11.0f32);
let Ok(sb) = dc.CreateSolidColorBrush(&col(0.0, 0.0, 0.0, 0.10), None) else { return };
for i in 0..4 {
let e = 2.0 + i as f32 * 2.0;
dc.FillRoundedRectangle(&comum::rr(rf(x + inset - e, y + IMG_H - 3.0, x + IMG_W - inset + e, y + IMG_H + 1.5 + i as f32 * 0.6), 4.0, 4.0), &sb);
}
if let Some(b) = grad(dc, pt(0.0, y + body_h), pt(0.0, y + IMG_H), &[(0.0, col(0.62, 0.62, 0.64, 1.0)), (0.4, col(0.74, 0.74, 0.76, 1.0)), (1.0, col(0.56, 0.56, 0.58, 1.0))]) {
if let Ok(g) = ui::d2d().CreatePathGeometry() {
if let Ok(k) = g.Open() {
k.BeginFigure(pt(x + inset, y + body_h - 1.0), D2D1_FIGURE_BEGIN_FILLED);
k.AddLine(pt(x + IMG_W - inset, y + body_h - 1.0));
k.AddLine(pt(x + IMG_W - inset - 1.5, y + IMG_H));
k.AddLine(pt(x + inset + 1.5, y + IMG_H));
k.EndFigure(D2D1_FIGURE_END_CLOSED);
let _ = k.Close();
dc.FillGeometry(&g, &b, None);
}
}
sb.SetColor(&col(0.30, 0.30, 0.32, 0.45)); // furinhos da ventilação
let mut vx = x + inset + 3.0;
while vx < x + IMG_W - inset - 3.0 {
dc.FillEllipse(&ell(pt(vx, y + body_h + 3.6), 0.45, 0.45), &sb);
vx += 1.6;
}
}
let body = comum::rr(rf(x, y, x + IMG_W, y + body_h), 4.5, 4.5);
if let Some(b) = grad(dc, pt(0.0, y), pt(0.0, y + body_h), &[(0.0, col(0.93, 0.93, 0.94, 1.0)), (0.08, col(0.88, 0.88, 0.89, 1.0)), (0.85, col(0.84, 0.84, 0.85, 1.0)), (1.0, col(0.74, 0.74, 0.76, 1.0))]) {
dc.FillRoundedRectangle(&body, &b);
}
if let Some(b) = grad(dc, pt(x, 0.0), pt(x + IMG_W, 0.0), &[(0.0, col(0.0, 0.0, 0.0, 0.16)), (0.06, col(0.0, 0.0, 0.0, 0.0)), (0.94, col(0.0, 0.0, 0.0, 0.0)), (1.0, col(0.0, 0.0, 0.0, 0.18))]) {
dc.FillRoundedRectangle(&body, &b);
}
sb.SetColor(&col(1.0, 1.0, 1.0, 0.75));
dc.DrawLine(pt(x + 6.0, y + 0.6), pt(x + IMG_W - 6.0, y + 0.6), &sb, 0.8, None);
sb.SetColor(&col(0.0, 0.0, 0.0, 0.18));
dc.DrawLine(pt(x + 5.0, y + body_h - 0.4), pt(x + IMG_W - 5.0, y + body_h - 0.4), &sb, 0.8, None);
let py = y + 52.5;
sb.SetColor(&col(0.16, 0.16, 0.18, 1.0));
for px in [23.2f32, 33.0] {
dc.FillRoundedRectangle(&comum::rr(rf(x + px - 0.85, py - 2.8, x + px + 0.85, py + 2.8), 0.85, 0.85), &sb);
}
dc.FillRoundedRectangle(&comum::rr(rf(x + 45.2, py - 0.85, x + 63.8, py + 0.85), 0.85, 0.85), &sb);
sb.SetColor(&col(0.98, 0.98, 1.0, 1.0)); // luz de ligado
dc.FillEllipse(&ell(pt(x + 120.6, py), 0.9, 0.9), &sb);
}
unsafe fn paint_leopard(dc: &ID2D1DeviceContext, br: &ID2D1SolidColorBrush) {
let st = s();
let rt: ID2D1RenderTarget = dc.cast().unwrap();
let (h, r) = (hh(), radius());
br.SetColor(&col(232.0 / 255.0, 232.0 / 255.0, 232.0 / 255.0, 1.0));
dc.FillRoundedRectangle(&comum::rr(rf(0.0, 0.0, W, h), r, r), br);
leopard::metal(&rt, rf(0.0, 0.0, W, 22.0), st.active, false, true, r);
let c = DWRITE_TEXT_ALIGNMENT_CENTER;
text(dc, br, &tr("Sobre Este Mac"), 13.0, DWRITE_FONT_WEIGHT_NORMAL, c, rf(70.0, 1.0, W - 70.0, 22.0), col(1.0, 1.0, 1.0, 0.5), false, false);
text(dc, br, &tr("Sobre Este Mac"), 13.0, DWRITE_FONT_WEIGHT_NORMAL, c, rf(70.0, 0.0, W - 70.0, 21.0), col(0.0, 0.0, 0.0, if st.active { 0.80 } else { 0.45 }), false, false);
br.SetColor(&col(0.0, 0.0, 0.0, 0.45));
dc.DrawRoundedRectangle(&comum::rr(rf(0.5, 0.5, W - 0.5, h - 0.5), r - 0.5, r - 0.5), br, 1.0, None);
// só o fechar aceso (gel); minimizar e ampliar apagados
for k in 0..3 {
let cc = pt(light_x0() + k as f32 * 21.0, light_y());
br.SetColor(&if k == 0 && st.active { semaforo::close() } else { col(0.75, 0.75, 0.75, 1.0) });
dc.FillEllipse(&ell(cc, 7.0, 7.0), br);
semaforo::gloss(&rt, cc, 7.0, br);
if k == 0 && st.hover == 0 {
br.SetColor(&col(0.30, 0.0, 0.0, 0.75));
dc.DrawLine(pt(cc.x - 2.6, cc.y - 2.6), pt(cc.x + 2.6, cc.y + 2.6), br, 1.2, None);
dc.DrawLine(pt(cc.x - 2.6, cc.y + 2.6), pt(cc.x + 2.6, cc.y - 2.6), br, 1.2, None);
}
}
// a maçã prateada (degradê do branco para o cinza, com a sombra)
let ar = rf(W / 2.0 - 34.0, 40.0, W / 2.0 + 34.0, 118.0);
if let Some(lb) = grad(dc, pt(0.0, ar.top), pt(0.0, ar.bottom), &[(0.0, col(0.97, 0.97, 0.98, 1.0)), (0.55, col(0.80, 0.81, 0.83, 1.0)), (1.0, col(0.58, 0.59, 0.62, 1.0))]) {
br.SetColor(&col(0.0, 0.0, 0.0, 0.22));
simbolo::draw(&rt, "apple.logo", rf(ar.left, ar.top + 1.5, ar.right, ar.bottom + 1.5), &br.cast().unwrap());
simbolo::draw(&rt, "apple.logo", ar, &lb.cast().unwrap());
}
let (ink, gray) = (col(0.0, 0.0, 0.0, 0.88), col(0.0, 0.0, 0.0, 0.55));
text(dc, br, "Mac OS X", 27.0, DWRITE_FONT_WEIGHT_LIGHT, c, rf(0.0, 124.0, W, 158.0), col(0.25, 0.25, 0.26, 1.0), false, false);
text(dc, br, &tr("Versão 10.5.8"), 11.0, DWRITE_FONT_WEIGHT_NORMAL, c, rf(0.0, 158.0, W, 174.0), gray, false, false);
let pill = |t: &str, top: f32, id: i32| -> RectF {
let bw = (tw(11.0, t) + 30.0).ceil();
let out = rf((W - bw) / 2.0, top, (W + bw) / 2.0, top + 19.0);
aqua_pill(dc, br, out, st.press == id && st.hover == id);
text(dc, br, t, 11.0, DWRITE_FONT_WEIGHT_NORMAL, c, out, ink, false, false);
out
};
st.reg = pill(&tr("Atualização de Software…"), 184.0, 2);
let rows = [(tr("Processador"), processador()), (tr("Memória"), memoria()), (tr("Disco de Inicialização"), "Macintosh HD".to_string())];
for (i, (a, b)) in rows.iter().enumerate() {
let cy = 232.0 + i as f32 * 22.0;
text(dc, br, a, 11.0, DWRITE_FONT_WEIGHT_BOLD, DWRITE_TEXT_ALIGNMENT_TRAILING, rf(0.0, cy - 8.0, 112.0, cy + 8.0), ink, false, false);
text(dc, br, b, 11.0, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_TEXT_ALIGNMENT_LEADING, rf(120.0, cy - 8.0, W - 10.0, cy + 8.0), ink, false, false);
}
st.btn = pill(&tr("Mais Informações…"), 300.0, 1);
text(dc, br, &tr("™ e © 1983-2009 Apple Inc."), 10.0, DWRITE_FONT_WEIGHT_NORMAL, c, rf(0.0, 344.0, W, 358.0), gray, false, false);
text(dc, br, &tr("Todos os direitos reservados."), 10.0, DWRITE_FONT_WEIGHT_NORMAL, c, rf(0.0, 358.0, W, 372.0), gray, false, false);
}
unsafe fn paint_on(dc: &ID2D1DeviceContext) {
let st = s();
let Ok(br) = dc.CreateSolidColorBrush(&col(0.0, 0.0, 0.0, 1.0), None) else { return };
let rt: ID2D1RenderTarget = dc.cast().unwrap();
let (h, r) = (hh(), radius());
let dark = ui::dark();
if st.foto.is_some() {
backdrop::foto_vidro(dc, rf(0.0, 0.0, W, h), r, if leo() { col(232.0 / 255.0, 232.0 / 255.0, 232.0 / 255.0, 1.0) } else if dark { col(0.12, 0.12, 0.13, 0.72) } else { col(0.93, 0.93, 0.94, 0.55) });
}
if leo() {
paint_leopard(dc, &br);
return;
}
if !st.glass && st.foto.is_none() {
br.SetColor(&if dark { col(0.145, 0.145, 0.15, 1.0) } else { col(0.93, 0.93, 0.94, 1.0) });
dc.FillRoundedRectangle(&comum::rr(rf(0.0, 0.0, W, h), r, r), &br);
}
br.SetColor(&if dark { col(1.0, 1.0, 1.0, 0.17) } else { col(0.0, 0.0, 0.0, 0.14) });
dc.DrawRoundedRectangle(&comum::rr(rf(0.5, 0.5, W - 0.5, h - 0.5), r - 0.5, r - 0.5), &br, 1.0, None);
// bolinhas: só fechar fica ativa
for k in 0..3 {
let c = pt(light_x0() + k as f32 * LIGHT_PITCH, light_y());
let on = k == 0 && (st.active || st.hover == 0);
br.SetColor(&if on {
semaforo::close()
} else if dark {
col(1.0, 1.0, 1.0, 0.16)
} else {
col(0.0, 0.0, 0.0, 0.14)
});
dc.FillEllipse(&ell(c, LIGHT_R, LIGHT_R), &br);
if k == 0 && st.hover == 0 {
br.SetColor(&col(0.30, 0.0, 0.0, 0.75));
dc.DrawLine(pt(c.x - 2.6, c.y - 2.6), pt(c.x + 2.6, c.y + 2.6), &br, 1.2, None);
dc.DrawLine(pt(c.x - 2.6, c.y + 2.6), pt(c.x + 2.6, c.y - 2.6), &br, 1.2, None);
}
}
let pc_ = modo_pc();
if pc_ {
// este PC: o símbolo desktopcomputer em alumínio (degradê), na área da foto
let ar = rf(W / 2.0 - 54.0, IMG_TOP - 10.0, W / 2.0 + 54.0, IMG_TOP + 84.0);
let st_ = if dark { [(0.0, col(0.86, 0.86, 0.88, 1.0)), (1.0, col(0.58, 0.58, 0.61, 1.0))] } else { [(0.0, col(0.62, 0.62, 0.65, 1.0)), (1.0, col(0.36, 0.36, 0.39, 1.0))] };
let ok = grad(dc, pt(0.0, ar.top), pt(0.0, ar.bottom), &st_).is_some_and(|lb| simbolo::draw(&rt, "desktopcomputer", ar, &lb.cast().unwrap()));
if !ok {
draw_mac_studio(dc, (W - IMG_W) / 2.0, IMG_TOP);
}
} else {
let png = ui::pack_icon("macstudio");
match ui::load_png(&png).and_then(|i| ui::bitmap(&rt, i.w, i.h, &i.px).map(|b| (b, i.w, i.h))) {
Some((b, pw, ph)) => {
let ih = IMG_W * ph as f32 / pw as f32;
dc.DrawBitmap(&b, Some(&rf((W - IMG_W) / 2.0, IMG_TOP, (W + IMG_W) / 2.0, IMG_TOP + ih)), 1.0, D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC, None, None);
}
None => draw_mac_studio(dc, (W - IMG_W) / 2.0, IMG_TOP),
}
}
let text1 = if dark { col(1.0, 1.0, 1.0, 0.92) } else { col(0.0, 0.0, 0.0, 0.86) };
let text2 = if dark { col(1.0, 1.0, 1.0, 0.52) } else { col(0.0, 0.0, 0.0, 0.50) };
let c = DWRITE_TEXT_ALIGNMENT_CENTER;
let info = pc_info();
let tcy = title_cy();
if pc_ {
// o modelo no título, diminuindo até caber; o fabricante na linha do ano
let mut size = 21.5f32;
while size > 13.0 && ui::text_width(&ui::fmt(size, DWRITE_FONT_WEIGHT_BOLD), &info.modelo) > W - 28.0 {
size -= 0.5;
}
text(dc, &br, &info.modelo, size, DWRITE_FONT_WEIGHT_BOLD, c, rf(14.0, tcy - 16.0, W - 14.0, tcy + 16.0), text1, false, true);
if !info.fabricante.is_empty() {
let y = if gg() { tcy + 19.0 } else { YEAR_CY };
text(dc, &br, &info.fabricante, 11.0, DWRITE_FONT_WEIGHT_NORMAL, c, rf(14.0, y - 8.0, W - 14.0, y + 8.0), text2, false, false);
}
} else {
text(dc, &br, "Mac Studio", 21.5, DWRITE_FONT_WEIGHT_BOLD, c, rf(0.0, tcy - 16.0, W, tcy + 16.0), text1, false, true);
if !gg() {
text(dc, &br, "2025", 11.0, DWRITE_FONT_WEIGHT_NORMAL, c, rf(0.0, YEAR_CY - 8.0, W, YEAR_CY + 8.0), text2, false, false); // macOS 27: sem o ano
}
}
let rows: Vec<(String, String)> = if pc_ {
let win = info.windows.strip_prefix("Windows ").unwrap_or(&info.windows).to_string();
let mut v = vec![(tr("Processador"), info.cpu.clone()), (tr("Gráficos"), info.gpu.clone()), (tr("Memória"), info.ram.clone()), (tr("Nome"), info.nome.clone())];
if shell::setting("ocultar_windows", "0") != "1" {
v.push(("Windows".into(), win)); // Experimental > "Ocultar menções ao Windows" (issue #159)
}
v
} else {
let mac = if gg() {
"Golden Gate 27.2.1"
} else if liquid::on() {
"Tahoe 26.7.2"
} else {
"Sequoia 15.3"
};
vec![("Chip".into(), "Apple M4 Max".into()), (tr("Memória"), tr("128 GB")), (tr("Número de série"), st.serial.clone()), ("macOS".into(), mac.into())]
};
let (row0, pitch) = (if gg() { 285.5 } else { 295.7 } + if pc_ && gg() { 6.0 } else { 0.0 }, if gg() { 16.0 } else { 15.2 });
let split = if pc_ { 96.0 } else { COL_SPLIT };
for (i, (a, b)) in rows.iter().enumerate() {
let cy = row0 + i as f32 * pitch;
text(dc, &br, a, 11.0, DWRITE_FONT_WEIGHT_MEDIUM, DWRITE_TEXT_ALIGNMENT_TRAILING, rf(0.0, cy - 8.0, split, cy + 8.0), text1, false, false);
text(dc, &br, b, 11.0, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_TEXT_ALIGNMENT_LEADING, rf(split + COL_GAP, cy - 8.0, W - 8.0, cy + 8.0), if dark { col(1.0, 1.0, 1.0, 0.80) } else { col(0.0, 0.0, 0.0, 0.75) }, false, false);
}
// botão "Mais Informações…": cinza translúcido, largura do texto
let more = tr("Mais Informações…");
let bw = (tw(13.0, &more) + 24.0).ceil();
let (btop, bh) = (if gg() { 376.5 } else { 370.4 }, if gg() { 24.0 } else { 20.0 });
st.btn = rf((W - bw) / 2.0, btop, (W + bw) / 2.0, btop + bh);
let down = st.press == 1 && st.hover == 1;
br.SetColor(&if dark { col(1.0, 1.0, 1.0, if down { 0.36 } else { 0.24 }) } else { col(0.0, 0.0, 0.0, if down { 0.16 } else { 0.08 }) });
dc.FillRoundedRectangle(&comum::rr(st.btn, 6.0, 6.0), &br);
if !dark {
br.SetColor(&col(0.0, 0.0, 0.0, 0.10));
let b = st.btn;
dc.DrawRoundedRectangle(&comum::rr(rf(b.left + 0.5, b.top + 0.5, b.right - 0.5, b.bottom - 0.5), 5.5, 5.5), &br, 1.0, None);
}
text(dc, &br, &more, 13.0, DWRITE_FONT_WEIGHT_NORMAL, c, st.btn, text1, false, false);
// rodapé
let (reg_cy, tm_cy, rights_cy) = if gg() { (422.0, 437.0, 451.0) } else { (411.0, 425.0, 439.4) };
let regt = tr("Certificação Regulatória");
let rw = tw(11.0, ®t);
st.reg = rf((W - rw) / 2.0 - 2.0, reg_cy - 8.0, (W + rw) / 2.0 + 2.0, reg_cy + 8.0);
text(dc, &br, ®t, 11.0, DWRITE_FONT_WEIGHT_NORMAL, c, rf(0.0, reg_cy - 8.0, W, reg_cy + 8.0), if st.hover == 2 { text1 } else { text2 }, true, false);
text(dc, &br, &tr("™ e © 1983-2025 Apple Inc."), 11.0, DWRITE_FONT_WEIGHT_NORMAL, c, rf(0.0, tm_cy - 8.0, W, tm_cy + 8.0), text2, false, false);
text(dc, &br, &tr("Todos os direitos reservados."), 11.0, DWRITE_FONT_WEIGHT_NORMAL, c, rf(0.0, rights_cy - 8.0, W, rights_cy + 8.0), text2, false, false);
}
fn paint() {
let st = s();
if st.foto.is_none() && (st.wnd.0.is_null() || !unsafe { IsWindowVisible(st.wnd).as_bool() }) {
return;
}
let k = sc();
let (wpx, hpx) = ((W * k).round() as i32, (hh() * k).round() as i32);
if let Some(fp) = st.foto {
st.s.foto_pos = fp;
}
let Some(dc) = ui::gpu_begin(&mut st.s, wpx, hpx, k) else { return };
unsafe { paint_on(&dc) };
ui::gpu_end(&mut st.s);
if st.foto.is_some() {
return;
}
let dark = ui::dark();
if st.glass {
// vidro fosco de janela do Mac: bem desfocado; a cor do papel de parede passa, o desenho não
let tint = if leo() {
col(232.0 / 255.0, 232.0 / 255.0, 232.0 / 255.0, 1.0)
} else if dark {
col(0.12, 0.12, 0.13, 0.72)
} else {
col(0.93, 0.93, 0.94, 0.55)
};
backdrop::set_pieces(st.back, wpx as f32, hpx as f32, &[backdrop::Piece { r: rf(0.0, 0.0, wpx as f32, hpx as f32), radius: radius() * k, ..Default::default() }], tint, if leo() { 0.0 } else { 30.0 });
}
let mo = anim::panel_in(anim::now() - st.open_at); // aparece com a mola comum, em volta do centro
ui::gpu_motion(&st.s, mo.scale, wpx as f32 / 2.0, hpx as f32 / 2.0, mo.fade);
if st.glass {
backdrop::fade(st.back, mo.fade, mo.scale, wpx as f32 / 2.0, hpx as f32 / 2.0);
}
}
fn close() {
let st = s();
unsafe {
let _ = ShowWindow(st.wnd, SW_HIDE);
let _ = ShowWindow(st.back, SW_HIDE);
}
st.hover = -1;
st.press = -1;
}
fn hit(p: Ponto) -> i32 {
let st = s();
let (dx, dy) = (p.x - light_x0(), p.y - light_y());
if dx * dx + dy * dy <= (LIGHT_R + 2.0).powi(2) {
return 0;
}
let inside = |r: RectF| p.x >= r.left && p.x < r.right && p.y >= r.top && p.y < r.bottom;
if inside(st.btn) {
1
} else if inside(st.reg) {
2
} else {
-1
}
}
fn click(what: i32) {
match what {
0 => close(),
1 => shell::open_settings("geral"),
2 => shell::open_settings(if leo() { "atualizacao" } else { "geral" }), // Leopard: "Atualização de Software…"
_ => {}
}
}
unsafe extern "system" fn proc_(h: HWND, m: u32, w_: WPARAM, l: LPARAM) -> LRESULT {
let st = s();
match m {
WM_PAINT => {
let mut ps = PAINTSTRUCT::default();
BeginPaint(h, &mut ps);
let _ = EndPaint(h, &ps);
paint();
LRESULT(0)
}
WM_SB_FRAME => {
ui::frame_ack(h, WM_SB_FRAME);
paint();
if anim::panel_in(anim::now() - st.open_at).done {
ui::frame_clock(h, WM_SB_FRAME, false);
}
LRESULT(0)
}
WM_ACTIVATE => {
st.active = w_.0 & 0xFFFF != WA_INACTIVE as usize;
paint();
LRESULT(0)
}
WM_KEYDOWN => {
if w_.0 == VK_ESCAPE.0 as usize || (w_.0 == 'W' as usize && GetKeyState(VK_CONTROL.0 as i32) < 0) {
close();
}
LRESULT(0)
}
WM_MOUSEMOVE | WM_LBUTTONDOWN | WM_LBUTTONUP => {
let k = sc();
let p = pt(get_x_lparam(l) as f32 / k, get_y_lparam(l) as f32 / k);
let ht = hit(p);
if m == WM_LBUTTONDOWN {
if ht < 0 {
// arrasta por qualquer lugar
let _ = comum::windows::Win32::UI::Input::KeyboardAndMouse::ReleaseCapture();
SendMessageW(h, WM_NCLBUTTONDOWN, WPARAM(HTCAPTION as usize), LPARAM(0));
return LRESULT(0);
}
st.press = ht;
SetCapture(h);
} else if m == WM_LBUTTONUP {
let was = st.press;
st.press = -1;
let _ = ReleaseCapture();
if was >= 0 && was == ht {
click(ht);
if ht == 0 {
return LRESULT(0);
}
}
} else {
let mut t = TRACKMOUSEEVENT { cbSize: std::mem::size_of::<TRACKMOUSEEVENT>() as u32, dwFlags: TME_LEAVE, hwndTrack: h, dwHoverTime: 0 };
let _ = TrackMouseEvent(&mut t);
}
if ht != st.hover || m != WM_MOUSEMOVE {
st.hover = ht;
paint();
}
LRESULT(0)
}
WM_MOUSELEAVE => {
if st.hover >= 0 && st.press < 0 {
st.hover = -1;
paint();
}
LRESULT(0)
}
WM_MOVE => {
if IsWindowVisible(st.back).as_bool() {
let mut r = RECT::default();
let _ = GetWindowRect(h, &mut r);
let _ = SetWindowPos(st.back, None, r.left, r.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
}
LRESULT(0)
}
WM_CLOSE => {
close();
LRESULT(0)
}
_ => DefWindowProcW(h, m, w_, l),
}
}
unsafe extern "system" fn back_proc(h: HWND, m: u32, w_: WPARAM, l: LPARAM) -> LRESULT {
if m == WM_MOUSEACTIVATE {
return LRESULT(MA_NOACTIVATE as isize);
}
DefWindowProcW(h, m, w_, l)
}
use comum::windows::Win32::UI::Controls::WM_MOUSELEAVE;
pub fn create(hi: HINSTANCE) -> bool {
let st = s();
unsafe {
RegisterClassW(&WNDCLASSW { lpfnWndProc: Some(back_proc), hInstance: hi, lpszClassName: w!("ShellSobreFundo"), ..Default::default() });
RegisterClassW(&WNDCLASSW { lpfnWndProc: Some(proc_), hInstance: hi, lpszClassName: w!("ShellSobre"), hCursor: LoadCursorW(None, IDC_ARROW).unwrap_or_default(), ..Default::default() });
// o fundo de vidro é o dono da janela de cima: ela fica sempre logo acima dele
st.back = CreateWindowExW(WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE | WS_EX_NOREDIRECTIONBITMAP, w!("ShellSobreFundo"), w!(""), WS_POPUP, 0, 0, 10, 10, None, None, hi, None).unwrap_or_default();
if st.back.0.is_null() {
return false;
}
st.glass = backdrop::attach(st.back);
let corner: u32 = if st.glass { 1 } else { 2 };
if !st.glass {
let _ = DestroyWindow(st.back);
st.back = CreateWindowExW(WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE, w!("ShellSobreFundo"), w!(""), WS_POPUP, 0, 0, 10, 10, None, None, hi, None).unwrap_or_default();
ui::acrylic(st.back, if ui::dark() { 0xE020_1E1E } else { 0xE0F6_F6F6 });
}
let _ = DwmSetWindowAttribute(st.back, DWMWINDOWATTRIBUTE(33), &corner as *const _ as *const _, 4);
let none: u32 = 0xFFFF_FFFE;
let _ = DwmSetWindowAttribute(st.back, DWMWINDOWATTRIBUTE(34), &none as *const _ as *const _, 4);
st.wnd = CreateWindowExW(WS_EX_TOOLWINDOW | WS_EX_NOREDIRECTIONBITMAP, w!("ShellSobre"), w!("Sobre Este Mac"), WS_POPUP, 0, 0, 10, 10, st.back, None, hi, None).unwrap_or_default();
if st.wnd.0.is_null() {
return false;
}
}
apps::ours().push(st.wnd);
apps::ours().push(st.back);
st.s.hwnd = st.wnd;
true
}
pub fn show() {
let st = s();
if st.serial.is_empty() {
st.serial = serial();
}
unsafe {
if !IsWindowVisible(st.wnd).as_bool() {
let k = sc();
let (wpx, hpx) = ((W * k).round() as i32, (hh() * k).round() as i32);
let mut c = POINT::default();
let _ = GetCursorPos(&mut c);
let mut mi = MONITORINFO { cbSize: std::mem::size_of::<MONITORINFO>() as u32, ..Default::default() };
let _ = GetMonitorInfoW(MonitorFromPoint(c, MONITOR_DEFAULTTOPRIMARY), &mut mi);
let (x, y) = ((mi.rcWork.left + mi.rcWork.right - wpx) / 2, mi.rcWork.top + (mi.rcWork.bottom - mi.rcWork.top - hpx) / 4);
let _ = SetWindowPos(st.back, HWND_TOP, x, y, wpx, hpx, SWP_NOACTIVATE | SWP_SHOWWINDOW);
let _ = SetWindowPos(st.wnd, HWND_TOP, x, y, wpx, hpx, SWP_NOACTIVATE);
st.open_at = anim::now();
let _ = ShowWindow(st.wnd, SW_SHOW);
paint();
ui::frame_clock(st.wnd, WM_SB_FRAME, true);
}
st.hover = -1;
st.press = -1;
let fg = GetForegroundWindow();
let ft = if fg.0.is_null() { 0 } else { GetWindowThreadProcessId(fg, None) };
let me = comum::windows::Win32::System::Threading::GetCurrentThreadId();
let att = ft != 0 && ft != me && comum::windows::Win32::System::Threading::AttachThreadInput(me, ft, true).as_bool();
let _ = SetWindowPos(st.back, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
let _ = SetForegroundWindow(st.wnd);
let _ = SetFocus(st.wnd);
if att {
let _ = comum::windows::Win32::System::Threading::AttachThreadInput(me, ft, false);
}
}
st.active = true;
paint();
}
/// modo foto: a janela aberta no lugar dela (centro, um quarto da altura da área de trabalho)
pub fn foto(tela_w: f32, tela_h: f32) {
let st = s();
st.serial = serial();
st.active = true;
let k = ui::foto_scale();
let top = menubar_pt();
st.foto = Some(((tela_w - W) / 2.0 * k, (top + (tela_h - top - hh()) / 4.0) * k));
paint();
}
fn menubar_pt() -> f32 {
crate::menubar::bar_pt()
}