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

Issues #173 #174 #160 #172; PRs #177 #168 #167 #175 #178

Eternity070628d5f9516015d4
diff --git a/docs/registro-mudancas.txt b/docs/registro-mudancas.txt
index 64ca5a4..90bb6df 100644
--- a/docs/registro-mudancas.txt
+++ b/docs/registro-mudancas.txt
@@ -1973,3 +1973,22 @@ Compilado (tudo), instalado, Shell e reserva do Finder reiniciados às 23:07 sem
desliga a cor avançada do Windows nas telas que aceitam; sem tela HDR, abre os Ajustes de Tela) e "Ajustes de Tela".
Compilado e instalado (o Shell roda). Não testado: o HDR (esta tela não foi trocada) nem o atalho na tela.
DESFAZER: reverter o commit e compilar.
+[2026-11-27 14:15] Issues #173, #174, #160, #172 e PRs #177, #168, #167, #175, #178 (aplicados à mão, com crédito):
+ - #173 (main.cpp KeyHook): Win+A abre a nossa Central de Controle e Win+N a Central de Notificações (ShellAbrirPainel
+ 9 e 10), no lugar das do Windows 11. Fora do modo nativo.
+ - #174 (paginas.cpp): Aparência avisa quando a Economia de energia do Windows está ligada (ela desliga a transparência
+ do Windows e o vidro fica sólido). launchpad.cpp: os nossos apps entram no Launchpad pelo exe da pasta do Shell
+ quando não há atalho no Menu Iniciar (rodando direto do zip, sem o WacOSSetup); abrem pelo exe (LApp::proprio).
+ - #160 (jogo.cpp): o modo jogo só tira o vidro real enquanto o jogo está NA FRENTE (jogo::VidroPausado); com o jogo
+ aberto e outro app ou a mesa na frente, o vidro real volta (o vidro comum ficava cinza no Dock e nos widgets).
+ - #172 (som.cpp): o volume mudado fora do Shell (botões/roda do fone, teclado que fala direto com o driver) mostra o
+ aviso de volume do Mac (IAudioEndpointVolumeCallback; as mudanças do Shell levam o contexto CTX_SHELL e não contam;
+ troca de saída registra de novo). Ajuste aviso_volume_fora=0 desliga. O aviso do Windows pode aparecer junto.
+ - PR #177 (KongGithubDev, issue #126): a barra de menus continua escondida no monitor do app em tela cheia quando
+ outro monitor tem o foco.
+ - PR #168 (404-Page-Found, issue #161): nome dos ícones da mesa escuro sobre papel de parede claro.
+ - PR #167 (404-Page-Found, issue #159): Experimental > "Ocultar menções ao Windows" (Sobre); traduzido nos 11 idiomas.
+ - PR #175 (eagle-233): miniaturas das janelas minimizadas no Dock não piscam na ampliação.
+ - PR #178 (Jop3r): bateria dos dispositivos Bluetooth na barra de menus (desligado por padrão).
+ Compilado (Shell e Ajustes). NÃO instalado nem testado na tela: o Shell em Rust estava rodando (teste da sessão do Rust).
+ DESFAZER: reverter o commit e compilar.
diff --git a/src/ajustes/paginas.cpp b/src/ajustes/paginas.cpp
index e5f829a..9ace5ba 100644
--- a/src/ajustes/paginas.cpp
+++ b/src/ajustes/paginas.cpp
@@ -363,7 +363,9 @@ Page Sobre() {
};
p.groups.push_back(Plain(head));
p.groups.push_back(G({ Value(L"Nome", i.computer), Value(L"Processador", i.cpu), Value(L"Memória", i.ram), Value(L"Gráficos", i.gpu) }));
- p.groups.push_back(G({ Value(L"Windows", i.windows), Value(L"Compilação", i.build) }, L"Sistema"));
+ // Experimental > "Ocultar menções ao Windows" (issue #159): sem a linha do Windows e da compilação
+ if (Setting(L"ocultar_windows", L"0") != L"1")
+ p.groups.push_back(G({ Value(L"Windows", i.windows), Value(L"Compilação", i.build) }, L"Sistema"));
auto mode = sys::CurrentResolution();
p.groups.push_back(G({ Button(L"Tela", L"Ajustes de Telas…", [] { int k = SidebarIndexFor(L"telas"); if (k >= 0) { HWND w = Window(); COPYDATASTRUCT cd{ 0x414A5354, 10, (void*)L"telas" }; SendMessageW(w, WM_COPYDATA, 0, (LPARAM)&cd); } },
Fmt(L"%d × %d", mode.w, mode.h)) }, L"Telas"));
@@ -1493,6 +1495,11 @@ Page TransparenciaEfeitos() {
});
p.groups.push_back(G({ liga }, L"Transparência do Windows"));
}
+ // issue #174: a Economia de energia do Windows também desliga o desfoque do Windows (sem mexer no ajuste acima)
+ SYSTEM_POWER_STATUS ps{};
+ if (!semTransp && !reduce && GetSystemPowerStatus(&ps) && ps.SystemStatusFlag == 1)
+ p.groups.push_back(G({ Note(L"A Economia de energia do Windows está ligada e desliga a transparência do Windows: o vidro fosco fica sólido até ela desligar (Configurações do Windows > Sistema > Energia e bateria).") },
+ L"Transparência do Windows"));
}
if (liquid && !reduce && leveOn)
p.groups.push_back(G({ mat, lg, real, Note(L"O Modo leve está ligado e deixa o vidro fosco. Para usar o vidro real, mude o Modo leve para Desligado, em Desempenho, mais abaixo."), refr, redo },
@@ -2660,7 +2667,11 @@ Page Experimental() {
p.groups.push_back(G({ tit, propria }, L"Janelas"));
Row shellWin = Toggle(L"Abrir no lugar da área de trabalho do Windows", [] { return ShellDoWindows(); }, [](bool on) { SetShellDoWindows(on); Rebuild(); },
L"O WacOS abre já no login, sem a área de trabalho do Windows piscar antes. Vale no próximo login.");
- p.groups.push_back(G({ shellWin }, L"Sistema"));
+ // Issue #159: esconde o nome do Windows no Sobre deste Mac (Ajustes e a janela "Sobre Este Mac")
+ Row semWin = Toggle(L"Ocultar menções ao Windows", [] { return Setting(L"ocultar_windows", L"0") == L"1"; },
+ [](bool v) { SetSetting(L"ocultar_windows", v ? L"1" : L"0"); Rebuild(); },
+ L"Tira a versão e a compilação do Windows do Sobre. Reabra a janela \"Sobre Este Mac\" para ver a mudança.");
+ p.groups.push_back(G({ shellWin, semWin }, L"Sistema"));
return p;
}
diff --git a/src/comum/idioma_de.inc b/src/comum/idioma_de.inc
index 9479f5e..6aa2cf9 100644
--- a/src/comum/idioma_de.inc
+++ b/src/comum/idioma_de.inc
@@ -1777,3 +1777,6 @@
{ L"Logo da barra de menus", L"Logo der Menüleiste" },
{ L"Maçã", L"Apfel" },
{ L"Ajustes de Tela", L"Displayeinstellungen" },
+{ L"A Economia de energia do Windows está ligada e desliga a transparência do Windows: o vidro fosco fica sólido até ela desligar (Configurações do Windows > Sistema > Energia e bateria).", L"Der Windows-Energiesparmodus ist aktiv und schaltet die Windows-Transparenz aus: Das Milchglas bleibt undurchsichtig, bis er aus ist (Windows-Einstellungen > System > Netzbetrieb und Akku)." },
+{ L"Ocultar menções ao Windows", L"Windows-Erwähnungen ausblenden" },
+{ L"Tira a versão e a compilação do Windows do Sobre. Reabra a janela \"Sobre Este Mac\" para ver a mudança.", L"Entfernt die Windows-Version und den Build aus „Über“. Öffne das Fenster „Über diesen Mac“ erneut, um die Änderung zu sehen." },
diff --git a/src/comum/idioma_en.inc b/src/comum/idioma_en.inc
index b1e820c..c9cc3e5 100644
--- a/src/comum/idioma_en.inc
+++ b/src/comum/idioma_en.inc
@@ -1651,6 +1651,8 @@
{ L"O Modo leve está ligado e deixa o vidro fosco. Para usar o vidro real, mude o Modo leve para Desligado, em Desempenho, mais abaixo.", L"Lite mode is on and keeps the glass frosted. To use real glass, set Lite mode to Off, under Performance below." },
{ L"Copiar Também para a Área de Transferência", L"Also Copy to Clipboard" },
{ L"Abrir no lugar da área de trabalho do Windows", L"Open instead of the Windows desktop" },
+{ L"Ocultar menções ao Windows", L"Hide mentions of Windows" },
+{ L"Tira a versão e a compilação do Windows do Sobre. Reabra a janela \"Sobre Este Mac\" para ver a mudança.", L"Removes the Windows version and build from About. Reopen the \"About This Mac\" window to see the change." },
{ L"Experimental. O WacOS abre já no login, sem a área de trabalho do Windows piscar antes. Vale no próximo login.", L"Experimental. WacOS opens right at sign-in, without the Windows desktop flashing first. Takes effect at the next sign-in." },
{ L"No próximo login, o WacOS abre no lugar da área de trabalho do Windows, antes do Explorador, sem a tela do Windows aparecer antes. O Explorador continua rodando no fundo.\n\nSe algo der errado, aperte Ctrl+Alt+Shift+F11 para voltar ao Explorador, ou desligue esta opção. Desinstalar o WacOS também desfaz isso.", L"At the next sign-in, WacOS opens instead of the Windows desktop, before File Explorer, so the Windows screen doesn't show first. File Explorer keeps running in the background.\n\nIf something goes wrong, press Ctrl+Alt+Shift+F11 to go back to File Explorer, or turn this option off. Uninstalling WacOS also undoes it." },
{ L"Abrir no lugar da área de trabalho do Windows?", L"Open instead of the Windows desktop?" },
@@ -1780,3 +1782,4 @@
{ L"Logo da barra de menus", L"Menu bar logo" },
{ L"Maçã", L"Apple" },
{ L"Ajustes de Tela", L"Display Settings" },
+{ L"A Economia de energia do Windows está ligada e desliga a transparência do Windows: o vidro fosco fica sólido até ela desligar (Configurações do Windows > Sistema > Energia e bateria).", L"Windows Energy saver is on and turns off Windows transparency: the frosted glass stays solid until it turns off (Windows Settings > System > Power & battery)." },
diff --git a/src/comum/idioma_es.inc b/src/comum/idioma_es.inc
index 2fa0611..3ea6a06 100644
--- a/src/comum/idioma_es.inc
+++ b/src/comum/idioma_es.inc
@@ -1777,3 +1777,6 @@
{ L"Logo da barra de menus", L"Logotipo de la barra de menús" },
{ L"Maçã", L"Manzana" },
{ L"Ajustes de Tela", L"Ajustes de pantalla" },
+{ L"A Economia de energia do Windows está ligada e desliga a transparência do Windows: o vidro fosco fica sólido até ela desligar (Configurações do Windows > Sistema > Energia e bateria).", L"El Ahorro de energía de Windows está activado y desactiva la transparencia de Windows: el cristal esmerilado queda sólido hasta que se desactive (Configuración de Windows > Sistema > Energía y batería)." },
+{ L"Ocultar menções ao Windows", L"Ocultar menciones de Windows" },
+{ L"Tira a versão e a compilação do Windows do Sobre. Reabra a janela \"Sobre Este Mac\" para ver a mudança.", L"Quita la versión y la compilación de Windows de Acerca de. Vuelve a abrir la ventana \"Acerca de este Mac\" para ver el cambio." },
diff --git a/src/comum/idioma_fr.inc b/src/comum/idioma_fr.inc
index d1b03f9..f165eca 100644
--- a/src/comum/idioma_fr.inc
+++ b/src/comum/idioma_fr.inc
@@ -1777,3 +1777,6 @@
{ L"Logo da barra de menus", L"Logo de la barre des menus" },
{ L"Maçã", L"Pomme" },
{ L"Ajustes de Tela", L"Réglages de l’écran" },
+{ L"A Economia de energia do Windows está ligada e desliga a transparência do Windows: o vidro fosco fica sólido até ela desligar (Configurações do Windows > Sistema > Energia e bateria).", L"L’économiseur d’énergie de Windows est activé et désactive la transparence de Windows : le verre dépoli reste opaque jusqu’à sa désactivation (Paramètres Windows > Système > Alimentation et batterie)." },
+{ L"Ocultar menções ao Windows", L"Masquer les mentions de Windows" },
+{ L"Tira a versão e a compilação do Windows do Sobre. Reabra a janela \"Sobre Este Mac\" para ver a mudança.", L"Retire la version et la build de Windows de « À propos ». Rouvrez la fenêtre « À propos de ce Mac » pour voir le changement." },
diff --git a/src/comum/idioma_it.inc b/src/comum/idioma_it.inc
index edf121b..5825002 100644
--- a/src/comum/idioma_it.inc
+++ b/src/comum/idioma_it.inc
@@ -1777,3 +1777,6 @@
{ L"Logo da barra de menus", L"Logo della barra dei menu" },
{ L"Maçã", L"Mela" },
{ L"Ajustes de Tela", L"Impostazioni schermo" },
+{ L"A Economia de energia do Windows está ligada e desliga a transparência do Windows: o vidro fosco fica sólido até ela desligar (Configurações do Windows > Sistema > Energia e bateria).", L"Il Risparmio energia di Windows è attivo e disattiva la trasparenza di Windows: il vetro smerigliato resta pieno finché non si spegne (Impostazioni di Windows > Sistema > Alimentazione e batteria)." },
+{ L"Ocultar menções ao Windows", L"Nascondi i riferimenti a Windows" },
+{ L"Tira a versão e a compilação do Windows do Sobre. Reabra a janela \"Sobre Este Mac\" para ver a mudança.", L"Toglie la versione e la build di Windows da Info. Riapri la finestra \"Informazioni su questo Mac\" per vedere la modifica." },
diff --git a/src/comum/idioma_ja.inc b/src/comum/idioma_ja.inc
index 2b8dbd6..60837e3 100644
--- a/src/comum/idioma_ja.inc
+++ b/src/comum/idioma_ja.inc
@@ -1777,3 +1777,6 @@
{ L"Logo da barra de menus", L"メニューバーのロゴ" },
{ L"Maçã", L"リンゴ" },
{ L"Ajustes de Tela", L"ディスプレイ設定" },
+{ L"A Economia de energia do Windows está ligada e desliga a transparência do Windows: o vidro fosco fica sólido até ela desligar (Configurações do Windows > Sistema > Energia e bateria).", L"Windows の省エネ機能がオンのため、Windows の透明効果がオフになっています。オフになるまで、すりガラスは不透明のままです (Windows の設定 > システム > 電源とバッテリー)。" },
+{ L"Ocultar menções ao Windows", L"Windows の表記を隠す" },
+{ L"Tira a versão e a compilação do Windows do Sobre. Reabra a janela \"Sobre Este Mac\" para ver a mudança.", L"「情報」から Windows のバージョンとビルドを外します。変更を見るには「この Mac について」を開き直してください。" },
diff --git a/src/comum/idioma_ko.inc b/src/comum/idioma_ko.inc
index eaf8fdd..cbb8532 100644
--- a/src/comum/idioma_ko.inc
+++ b/src/comum/idioma_ko.inc
@@ -1777,3 +1777,6 @@
{ L"Logo da barra de menus", L"메뉴 막대 로고" },
{ L"Maçã", L"사과" },
{ L"Ajustes de Tela", L"디스플레이 설정" },
+{ L"A Economia de energia do Windows está ligada e desliga a transparência do Windows: o vidro fosco fica sólido até ela desligar (Configurações do Windows > Sistema > Energia e bateria).", L"Windows 에너지 절약이 켜져 있어 Windows 투명도가 꺼집니다. 꺼질 때까지 반투명 유리가 불투명하게 유지됩니다(Windows 설정 > 시스템 > 전원 및 배터리)." },
+{ L"Ocultar menções ao Windows", L"Windows 언급 숨기기" },
+{ L"Tira a versão e a compilação do Windows do Sobre. Reabra a janela \"Sobre Este Mac\" para ver a mudança.", L"정보에서 Windows 버전과 빌드를 뺍니다. 변경 사항을 보려면 \"이 Mac에 관하여\" 창을 다시 여세요." },
diff --git a/src/comum/idioma_pl.inc b/src/comum/idioma_pl.inc
index 2a8d461..7a2039c 100644
--- a/src/comum/idioma_pl.inc
+++ b/src/comum/idioma_pl.inc
@@ -1777,3 +1777,6 @@
{ L"Logo da barra de menus", L"Logo paska menu" },
{ L"Maçã", L"Jabłko" },
{ L"Ajustes de Tela", L"Ustawienia ekranu" },
+{ L"A Economia de energia do Windows está ligada e desliga a transparência do Windows: o vidro fosco fica sólido até ela desligar (Configurações do Windows > Sistema > Energia e bateria).", L"Oszczędzanie energii w systemie Windows jest włączone i wyłącza przezroczystość: matowe szkło pozostaje pełne, dopóki się nie wyłączy (Ustawienia systemu Windows > System > Zasilanie i bateria)." },
+{ L"Ocultar menções ao Windows", L"Ukryj wzmianki o systemie Windows" },
+{ L"Tira a versão e a compilação do Windows do Sobre. Reabra a janela \"Sobre Este Mac\" para ver a mudança.", L"Usuwa wersję i kompilację systemu Windows z sekcji Informacje. Otwórz ponownie okno \"Ten Mac\", aby zobaczyć zmianę." },
diff --git a/src/comum/idioma_ru.inc b/src/comum/idioma_ru.inc
index 9aed614..9a69fb4 100644
--- a/src/comum/idioma_ru.inc
+++ b/src/comum/idioma_ru.inc
@@ -1777,3 +1777,6 @@
{ L"Logo da barra de menus", L"Логотип строки меню" },
{ L"Maçã", L"Яблоко" },
{ L"Ajustes de Tela", L"Настройки дисплея" },
+{ L"A Economia de energia do Windows está ligada e desliga a transparência do Windows: o vidro fosco fica sólido até ela desligar (Configurações do Windows > Sistema > Energia e bateria).", L"Включена экономия энергии Windows, и она отключает прозрачность Windows: матовое стекло остаётся сплошным, пока она не выключится (Параметры Windows > Система > Питание и батарея)." },
+{ L"Ocultar menções ao Windows", L"Скрыть упоминания Windows" },
+{ L"Tira a versão e a compilação do Windows do Sobre. Reabra a janela \"Sobre Este Mac\" para ver a mudança.", L"Убирает версию и сборку Windows из раздела «Об этом». Откройте окно «Об этом Mac» заново, чтобы увидеть изменение." },
diff --git a/src/comum/idioma_tr.inc b/src/comum/idioma_tr.inc
index a8da687..82696db 100644
--- a/src/comum/idioma_tr.inc
+++ b/src/comum/idioma_tr.inc
@@ -1777,3 +1777,6 @@
{ L"Logo da barra de menus", L"Menü çubuğu logosu" },
{ L"Maçã", L"Elma" },
{ L"Ajustes de Tela", L"Ekran Ayarları" },
+{ L"A Economia de energia do Windows está ligada e desliga a transparência do Windows: o vidro fosco fica sólido até ela desligar (Configurações do Windows > Sistema > Energia e bateria).", L"Windows Enerji tasarrufu açık ve Windows saydamlığını kapatıyor: kapanana kadar buzlu cam düz renkte kalır (Windows Ayarları > Sistem > Güç ve pil)." },
+{ L"Ocultar menções ao Windows", L"Windows ifadelerini gizle" },
+{ L"Tira a versão e a compilação do Windows do Sobre. Reabra a janela \"Sobre Este Mac\" para ver a mudança.", L"Windows sürümünü ve derlemesini Hakkında bölümünden kaldırır. Değişikliği görmek için \"Bu Mac Hakkında\" penceresini yeniden açın." },
diff --git a/src/comum/idioma_zh.inc b/src/comum/idioma_zh.inc
index d2e7ad3..8c8e20f 100644
--- a/src/comum/idioma_zh.inc
+++ b/src/comum/idioma_zh.inc
@@ -1777,3 +1777,6 @@
{ L"Logo da barra de menus", L"菜单栏标志" },
{ L"Maçã", L"苹果" },
{ L"Ajustes de Tela", L"显示器设置" },
+{ L"A Economia de energia do Windows está ligada e desliga a transparência do Windows: o vidro fosco fica sólido até ela desligar (Configurações do Windows > Sistema > Energia e bateria).", L"Windows 节能模式已开启,会关闭 Windows 透明效果:在它关闭之前,磨砂玻璃会保持纯色(Windows 设置 > 系统 > 电源和电池)。" },
+{ L"Ocultar menções ao Windows", L"隐藏 Windows 字样" },
+{ L"Tira a versão e a compilação do Windows do Sobre. Reabra a janela \"Sobre Este Mac\" para ver a mudança.", L"从“关于”中移除 Windows 版本和内部版本号。重新打开“关于本机”窗口即可看到变化。" },
diff --git a/src/shell/backdrop.cpp b/src/shell/backdrop.cpp
index fcb821d..108b349 100644
--- a/src/shell/backdrop.cpp
+++ b/src/shell/backdrop.cpp
@@ -1615,7 +1615,7 @@ void backdrop::Reload() {
s.tintK = std::clamp(s.tintK, 0.f, 1.f);
s.real = s.liquid && !s.reduce && shell::Setting(L"vidro_real", L"1") == L"1" && !rg::semCaptura; // aparece nas gravações (montado pelas janelas)
// modo jogo (jogo.cpp): o vidro real remontava o fundo a cada quadro do jogo atrás das peças; fica o vidro comum
- if (jogo::Ativo()) s.real = false;
+ if (jogo::VidroPausado()) s.real = false;
rg::g_semRitmo = shell::Setting(L"vidro_ritmo", L"1") == L"0";
// modo leve (leve.cpp: PC fraco ou na bateria): também sem o vidro real, e o fosco sem o desfoque extra (MakeFrost)
leve::Atualizar();
@@ -1626,7 +1626,7 @@ void backdrop::Reload() {
{
bool pedido = s.liquid && !s.reduce && shell::Setting(L"vidro_real", L"1") == L"1";
static int ultimo = -1;
- int motivo = !pedido || s.real ? 0 : rg::semCaptura ? 1 : jogo::Ativo() ? 2 : 3;
+ int motivo = !pedido || s.real ? 0 : rg::semCaptura ? 1 : jogo::VidroPausado() ? 2 : 3;
if (motivo != ultimo && motivo)
Log(L"vidro real: ligado nos ajustes, mas fica fosco (%ls)",
motivo == 1 ? L"a captura de janelas falhou nesta sessão" : motivo == 2 ? L"modo jogo" : L"modo leve ligado");
diff --git a/src/shell/central.cpp b/src/shell/central.cpp
index cc8ea6f..add0c45 100644
--- a/src/shell/central.cpp
+++ b/src/shell/central.cpp
@@ -16,9 +16,13 @@
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.Devices.Radios.h>
+#include <winrt/Windows.Devices.Bluetooth.h>
+#include <winrt/Windows.Devices.Bluetooth.GenericAttributeProfile.h>
+#include <winrt/Windows.Devices.Enumeration.h>
#include <winrt/Windows.Media.Control.h>
#include <winrt/Windows.Storage.Streams.h>
#include <atomic>
+#include <chrono>
#include <mutex>
#include <thread>
#include <algorithm>
@@ -37,6 +41,9 @@
#include <intrin.h>
#include "../comum/vidro.h"
#include <bluetoothapis.h>
+#include <cfgmgr32.h>
+#include <cfg.h>
+#pragma comment(lib, "cfgmgr32.lib")
#pragma comment(lib, "bthprops.lib")
#pragma comment(lib, "windowsapp.lib")
@@ -1141,9 +1148,17 @@ int g_detail = D_NONE;
double g_detailAt;
D2D1_RECT_F g_detailFrom{};
std::vector<std::wstring> g_nets; // Wi-Fi: outras redes, da mais forte para a mais fraca (g_mx)
-std::vector<std::pair<std::wstring, bool>> g_bts; // Bluetooth: (nome, conectado) (g_mx)
+struct BtDevice {
+ ULONGLONG address;
+ std::wstring name;
+ bool connected;
+ int battery = -1;
+};
+std::vector<BtDevice> g_bts; // g_mx
+std::atomic<bool> g_btLoading{ false };
+ULONGLONG g_btReadAt; // thread da interface
std::vector<Out> g_detOuts; // Som: as saídas
-bool g_detLoading;
+std::atomic<bool> g_detLoading{ false };
const wchar_t* FOCO_MODOS[4] = { L"Não Perturbe", L"Trabalho", L"Sono", L"Reduzir Interrupções" };
const float DET_TOP = 44, DET_ROW = 32, DET_SEP = 11, DET_LINK = 22, DET_HEAD = 16;
@@ -1161,8 +1176,126 @@ float DetailH() {
return h + DET_SEP + DET_LINK + 10;
}
+// O Windows publica o nível no nó do dispositivo BLE ou no perfil Hands-Free clássico.
+void ReadWindowsBluetoothBatteries(std::vector<BtDevice>& devices) {
+ constexpr DEVPROPKEY batteryKey{ { 0x104ea319, 0x6ee2, 0x4701, { 0xbd, 0x47, 0x8d, 0xdb, 0xf4, 0x25, 0xbb, 0xe5 } }, 2 };
+ constexpr DEVPROPKEY addressKey{ { 0x2bd67d8b, 0x8beb, 0x48d5, { 0x87, 0xe0, 0x6c, 0xda, 0x34, 0x28, 0x04, 0x0a } }, 1 };
+ constexpr DEVPROPKEY nameKey{ { 0xb725f130, 0x47ef, 0x101a, { 0xa5, 0xf1, 0x02, 0x60, 0x8c, 0x9e, 0xeb, 0xac } }, 10 };
+ constexpr ULONG flags = CM_GETIDLIST_FILTER_ENUMERATOR | CM_GETIDLIST_FILTER_PRESENT;
+ for (const wchar_t* enumerator : { L"BTHENUM", L"BTHLE" }) {
+ const bool le = wcscmp(enumerator, L"BTHLE") == 0;
+ ULONG count = 0;
+ if (CM_Get_Device_ID_List_SizeW(&count, enumerator, flags) != CR_SUCCESS || count <= 1) continue;
+ std::vector<wchar_t> ids(count);
+ if (CM_Get_Device_ID_ListW(enumerator, ids.data(), count, flags) != CR_SUCCESS) continue;
+ for (wchar_t* id = ids.data(); *id; id += wcslen(id) + 1) {
+ DEVINST node;
+ if (CM_Locate_DevNodeW(&node, id, CM_LOCATE_DEVNODE_NORMAL) != CR_SUCCESS) continue;
+ ULONG status, problem;
+ if (CM_Get_DevNode_Status(&status, &problem, node, 0) != CR_SUCCESS ||
+ !(status & DN_STARTED) || (status & DN_DEVICE_DISCONNECTED)) continue;
+
+ BYTE level;
+ DEVPROPTYPE type;
+ ULONG size = sizeof(level);
+ if (CM_Get_DevNode_PropertyW(node, &batteryKey, &type, &level, &size, 0) != CR_SUCCESS ||
+ type != DEVPROP_TYPE_BYTE || size != sizeof(level) || level > 100) continue;
+
+ wchar_t text[32]{};
+ size = sizeof(text);
+ if (CM_Get_DevNode_PropertyW(node, &addressKey, &type, reinterpret_cast<PBYTE>(text), &size, 0) != CR_SUCCESS ||
+ type != DEVPROP_TYPE_STRING || wcslen(text) != 12) continue;
+ wchar_t* end;
+ auto address = wcstoull(text, &end, 16);
+ if (*end || !address) continue;
+ auto found = std::find_if(devices.begin(), devices.end(), [address](auto const& device) { return device.address == address; });
+ if (found != devices.end()) {
+ if (le || found->connected) {
+ found->connected = true;
+ found->battery = level;
+ }
+ } else if (le) {
+ wchar_t name[256]{};
+ size = sizeof(name);
+ if (CM_Get_DevNode_PropertyW(node, &nameKey, &type, reinterpret_cast<PBYTE>(name), &size, 0) == CR_SUCCESS &&
+ type == DEVPROP_TYPE_STRING && *name) devices.push_back({ address, name, true, level });
+ }
+ }
+ }
+}
+
+int ReadBtBattery(const winrt::Windows::Devices::Bluetooth::BluetoothLEDevice& device) {
+ using namespace winrt::Windows::Devices::Bluetooth;
+ using namespace GenericAttributeProfile;
+ using winrt::Windows::Storage::Streams::DataReader;
+
+ auto services = device.GetGattServicesForUuidAsync(GattServiceUuids::Battery(), BluetoothCacheMode::Cached).get();
+ if (services.Status() != GattCommunicationStatus::Success) return -1;
+ for (auto const& service : services.Services()) {
+ auto chars = service.GetCharacteristicsForUuidAsync(GattCharacteristicUuids::BatteryLevel(), BluetoothCacheMode::Cached).get();
+ if (chars.Status() != GattCommunicationStatus::Success) continue;
+ for (auto const& characteristic : chars.Characteristics()) {
+ auto read = characteristic.ReadValueAsync(BluetoothCacheMode::Uncached);
+ if (read.wait_for(std::chrono::seconds(2)) != winrt::Windows::Foundation::AsyncStatus::Completed) {
+ read.Cancel();
+ continue;
+ }
+ auto value = read.GetResults();
+ if (value.Status() != GattCommunicationStatus::Success || value.Value().Length() != 1) continue;
+ int level = DataReader::FromBuffer(value.Value()).ReadByte();
+ if (level <= 100) return level;
+ }
+ }
+ return -1;
+}
+
+void AddBluetoothDevices(std::vector<BtDevice>& devices) {
+ using namespace winrt::Windows::Devices::Bluetooth;
+ using namespace winrt::Windows::Devices::Enumeration;
+ try {
+ winrt::init_apartment(winrt::apartment_type::multi_threaded);
+ } catch (winrt::hresult_error const&) {
+ return;
+ }
+ constexpr wchar_t batteryKey[] = L"System.Devices.BatteryLife";
+ try {
+ auto selector = BluetoothLEDevice::GetDeviceSelectorFromConnectionStatus(BluetoothConnectionStatus::Connected);
+ for (auto const& info : DeviceInformation::FindAllAsync(selector, { winrt::hstring(batteryKey) }, DeviceInformationKind::AssociationEndpoint).get()) {
+ try {
+ auto device = BluetoothLEDevice::FromIdAsync(info.Id()).get();
+ if (!device || device.ConnectionStatus() != BluetoothConnectionStatus::Connected) continue;
+ auto address = device.BluetoothAddress();
+ auto found = std::find_if(devices.begin(), devices.end(), [address](auto const& existing) {
+ return existing.address == address;
+ });
+ if (found == devices.end()) {
+ auto name = info.Name();
+ if (name.empty()) continue;
+ devices.push_back({ address, std::wstring(name.c_str()), true });
+ found = devices.end() - 1;
+ }
+ found->connected = true;
+ if (found->battery < 0) {
+ int level = winrt::unbox_value_or<uint8_t>(info.Properties().TryLookup(batteryKey), 255);
+ found->battery = level <= 100 ? level : ReadBtBattery(device);
+ }
+ } catch (winrt::hresult_error const&) {
+ // O dispositivo pode desconectar enquanto a lista está sendo lida.
+ }
+ }
+ } catch (winrt::hresult_error const&) {
+ // Mantém a lista do Win32 quando a enumeração BLE não está disponível.
+ }
+ winrt::uninit_apartment();
+}
+
void LoadDetail(int kind) {
- g_detLoading = true;
+ if (kind == D_BT) {
+ if (g_btLoading.exchange(true)) return;
+ g_btReadAt = GetTickCount64();
+ } else {
+ g_detLoading = true;
+ }
std::thread([kind] {
if (kind == D_WIFI) {
std::vector<std::pair<std::wstring, ULONG>> v;
@@ -1193,22 +1326,25 @@ void LoadDetail(int kind) {
g_nets.clear();
for (auto& e : v) if (e.first != g_st.ssid) g_nets.push_back(e.first);
} else if (kind == D_BT) {
- std::vector<std::pair<std::wstring, bool>> r;
+ std::vector<BtDevice> r;
BLUETOOTH_DEVICE_SEARCH_PARAMS sp{ sizeof(sp) };
sp.fReturnAuthenticated = TRUE; sp.fReturnRemembered = TRUE; sp.fReturnConnected = TRUE;
BLUETOOTH_DEVICE_INFO di{ sizeof(di) };
if (HBLUETOOTH_DEVICE_FIND f = BluetoothFindFirstDevice(&sp, &di)) {
do {
- if (di.fRemembered || di.fAuthenticated) r.push_back({ di.szName, di.fConnected != FALSE });
+ if (di.fRemembered || di.fAuthenticated) r.push_back({ di.Address.ullLong, di.szName, di.fConnected != FALSE });
di.dwSize = sizeof(di);
} while (BluetoothFindNextDevice(f, &di));
BluetoothFindDeviceClose(f);
}
- std::stable_sort(r.begin(), r.end(), [](auto& a, auto& b) { return a.second > b.second; });
+ ReadWindowsBluetoothBatteries(r);
+ AddBluetoothDevices(r);
+ std::stable_sort(r.begin(), r.end(), [](auto& a, auto& b) { return a.connected > b.connected; });
std::lock_guard<std::mutex> l(g_mx);
- g_bts = r;
+ g_bts = std::move(r);
}
- g_detLoading = false;
+ if (kind == D_BT) g_btLoading = false;
+ else g_detLoading = false;
if (g_wnd) PostMessageW(g_wnd, WM_CC_UPDATE, 1, 0);
}).detach();
}
@@ -1476,7 +1612,7 @@ void PaintTahoe() {
Text(dc, br, link, D2D1::RectF(L, y, R, y + DET_LINK), g_tfTile, white);
g_hits.push_back({ H_DET_SET, D2D1::RectF(full.left + 4, y, full.right - 4, y + DET_LINK) });
};
- std::vector<std::wstring> nets; std::vector<std::pair<std::wstring, bool>> bts;
+ std::vector<std::wstring> nets; std::vector<BtDevice> bts;
{ std::lock_guard<std::mutex> l(g_mx); nets = g_nets; bts = g_bts; }
// a faixa de volume / brilho (o mesmo trilho dos blocos: #E8E8E8 / #232323 e a parte cheia branca)
auto slider = [&](HitId track, float v, const wchar_t* sl, wchar_t fl, const wchar_t* sr, wchar_t fr) {
@@ -1505,8 +1641,14 @@ void PaintTahoe() {
case D_BT:
sw(st.radio[1] == 1);
head(Tr(L"Dispositivos"));
- if (bts.empty()) { Text(dc, br, g_detLoading ? Tr(L"Procurando…") : Tr(L"Nenhum dispositivo"), D2D1::RectF(L, y, R, y + DET_ROW), g_tfTile, white2); y += DET_ROW; }
- for (size_t i = 0; i < bts.size() && i < 6; i++) row(bts[i].first, L"headphones", 0xE702, bts[i].second, blue, (int)i);
+ if (bts.empty()) { Text(dc, br, g_btLoading ? Tr(L"Procurando…") : Tr(L"Nenhum dispositivo"), D2D1::RectF(L, y, R, y + DET_ROW), g_tfTile, white2); y += DET_ROW; }
+ for (size_t i = 0; i < bts.size() && i < 6; i++) {
+ const auto& device = bts[i];
+ std::wstring label = device.name;
+ if (st.radio[1] == 1 && device.connected && device.battery >= 0)
+ label = std::to_wstring(device.battery) + L"% " + label;
+ row(label, L"headphones", 0xE702, device.connected && st.radio[1] == 1, blue, (int)i);
+ }
tail(Tr(L"Ajustes de Bluetooth…"));
break;
case D_FOCO: {
@@ -2232,7 +2374,10 @@ LRESULT CALLBACK Proc(HWND h, UINT m, WPARAM w, LPARAM l) {
case WM_CC_UPDATE: if (w == 1 && g_detail >= 0) Place(); Paint(); return 0; // w 1: a lista do módulo expandido chegou
case veil::WM_VEIL_CLICK: Close(); return 0;
case WM_TIMER:
- if (w == T_POLL && g_open && g_drag < 0) { ReadFast(); ReadMedia(); Paint(); }
+ if (w == T_POLL && g_open && g_drag < 0) {
+ if (g_detail == D_BT && GetTickCount64() - g_btReadAt >= 30000) LoadDetail(D_BT);
+ ReadFast(); ReadMedia(); Paint();
+ }
return 0;
case WM_MOUSELEAVE: g_ccHover = { -1, -1 }; if (Tahoe()) { Paint(); ui::FrameClock(h, WM_CC_FRAME, true); } return 0; // o botão de Tela/Som some com fade
case WM_LBUTTONDOWN:
@@ -2398,3 +2543,15 @@ void central::Toggle() {
SetTimer(g_wnd, T_POLL, 1000, nullptr);
ui::FrameClock(g_wnd, WM_CC_FRAME, true);
}
+
+void central::RefreshBluetoothBatteries() {
+ if (GetTickCount64() - g_btReadAt >= 10000 || !g_btReadAt) LoadDetail(D_BT);
+}
+
+std::vector<central::BluetoothBattery> central::BluetoothBatteries() {
+ std::vector<BluetoothBattery> result;
+ std::lock_guard<std::mutex> l(g_mx);
+ for (const auto& device : g_bts)
+ if (device.connected && device.battery >= 0) result.push_back({ device.address, device.name, device.battery });
+ return result;
+}
diff --git a/src/shell/dock.cpp b/src/shell/dock.cpp
index d21a177..f096229 100644
--- a/src/shell/dock.cpp
+++ b/src/shell/dock.cpp
@@ -882,7 +882,7 @@ void PaintBack() {
float rad = DOCK_RADIUS;
bool dark = ui::Dark();
if (g_glass) { // vidro da Composição: recorte com a mesma curva do Dock
- SetWindowPos(g_back, g_icons, x, y, w, h, SWP_NOACTIVATE | SWP_SHOWWINDOW);
+ SetWindowPos(g_back, g_thumbWnd ? g_thumbWnd : g_icons, x, y, w, h, SWP_NOACTIVATE | SWP_SHOWWINDOW);
D2D1_COLOR_F tint = dark ? D2D1::ColorF(0.13f, 0.14f, 0.15f, 0.50f) : D2D1::ColorF(0.98f, 0.98f, 0.99f, 0.38f);
// Tahoe: cor do vidro medida na tela (guia macOS26-Theme-Reference, seções 52 e 60): saída ≈ 0,61 × fundo + 0,11
// no escuro (39 % de um cinza 0,28 por cima do fundo desfocado); no claro a média sobe ~0,11 (cinza 0,56)
@@ -899,7 +899,7 @@ void PaintBack() {
// Sem a Composição: acrílico com o canto de 8 do DWM, encolhido para caber dentro da curva.
int in = rad > 8 ? (int)std::ceil((rad - 8) * sc * 0.293f) + 1 : 0;
x += in; y += in; w -= 2 * in; h -= 2 * in;
- SetWindowPos(g_back, g_icons, x, y, w, h, SWP_NOACTIVATE | SWP_SHOWWINDOW);
+ SetWindowPos(g_back, g_thumbWnd ? g_thumbWnd : g_icons, x, y, w, h, SWP_NOACTIVATE | SWP_SHOWWINDOW);
auto* rt = ui::Begin(g_sb, w, h, sc);
if (!rt) return;
ID2D1SolidColorBrush* br = nullptr;
@@ -934,7 +934,6 @@ void UpdateThumbs(float baseline) {
if (!g_thumbWnd) return;
float sc = 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;
for (auto& it : g_items) {
@@ -948,17 +947,23 @@ void UpdateThumbs(float baseline) {
D2D1_RECT_F r = MinThumbRect(it, baseline);
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);
}
if (rects.empty() || !show) { ShowWindow(g_thumbWnd, SW_HIDE); return; }
- // a janela cobre só as miniaturas (o resto da faixa continua clicável) e fica logo abaixo da dos ícones
- SetWindowPos(g_thumbWnd, g_icons, box.left, box.top, box.right - box.left, box.bottom - box.top, SWP_NOACTIVATE | SWP_SHOWWINDOW);
+ // A janela fica sempre com a faixa inteira, como a dos ícones (cuja imagem nunca é recriada, então nada pisca).
+ // Antes ela era redimensionada para a caixa das miniaturas a cada quadro da ampliação e as miniaturas DWM
+ // piscavam quando o mouse deslizava sobre elas (o resize da janela hospedeira faz o DWM redesenhar em branco
+ // por um quadro). Agora a janela é fixa e só o destino de cada miniatura muda dentro dela. O clique continua
+ // passando através (WM_NCHITTEST = HTTRANSPARENT), por isso cobrir a faixa toda não atrapalha.
+ RECT cur; GetWindowRect(g_thumbWnd, &cur);
+ if (!IsWindowVisible(g_thumbWnd) || cur.left != strip.left || cur.top != strip.top || cur.right != strip.right || cur.bottom != strip.bottom) {
+ SetWindowPos(g_thumbWnd, g_icons, strip.left, strip.top, strip.right - strip.left, strip.bottom - strip.top, SWP_NOACTIVATE | SWP_SHOWWINDOW);
+ }
for (auto& [it, px] : rects) {
auto f = g_thumbs.find(it->win);
if (f == g_thumbs.end()) continue;
DWM_THUMBNAIL_PROPERTIES tp{};
tp.dwFlags = DWM_TNP_RECTDESTINATION | DWM_TNP_VISIBLE | DWM_TNP_OPACITY | DWM_TNP_SOURCECLIENTAREAONLY;
- tp.rcDestination = { px.left - box.left, px.top - box.top, px.right - box.left, px.bottom - box.top };
+ tp.rcDestination = { px.left - strip.left, px.top - strip.top, px.right - strip.left, px.bottom - strip.top };
tp.fVisible = TRUE; tp.opacity = 255; tp.fSourceClientAreaOnly = FALSE;
DwmUpdateThumbnailProperties(f->second, &tp);
}
@@ -2255,6 +2260,7 @@ void dock::Raise() { // por cima de janelas de tela inteira nossas (Launchpad)
auto alheias = shell::AlheiasNoTopo();
SetWindowPos(g_back, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
SetWindowPos(g_icons, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+ if (g_thumbWnd) SetWindowPos(g_thumbWnd, g_icons, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); // miniaturas acima do vidro
MenusPorCima();
shell::DevolveAlheias(alheias);
}
diff --git a/src/shell/jogo.cpp b/src/shell/jogo.cpp
index bc47ab9..263244e 100644
--- a/src/shell/jogo.cpp
+++ b/src/shell/jogo.cpp
@@ -18,6 +18,7 @@
namespace {
std::atomic<bool> g_on{ false }; // lido também pela thread do índice
+bool g_frente = false; // o jogo está na frente (o vidro real só sai enquanto ele estiver)
bool g_enabled = true;
DWORD g_pid = 0;
int g_gone = 0; // verificações seguidas sem janela do jogo
@@ -153,6 +154,7 @@ void Eco(bool on) {
void Apply(bool on) {
g_on = on;
+ g_frente = on;
Log(on ? L"modo jogo: ligado (%ls, pid %lu)" : L"modo jogo: desligado (%ls fechou)", g_name.c_str(), g_pid);
backdrop::Reload(); // vidro real fora (backdrop.cpp confere jogo::Ativo)
ponteiro::Pausar(on); // sem Raw Input do mouse
@@ -166,6 +168,11 @@ void Apply(bool on) {
void Check(HWND fg) {
if (!g_enabled) return;
if (g_on) {
+ // issue #160: com o jogo aberto mas outro app (ou a mesa) na frente, o vidro real volta; o vidro comum ficava
+ // cinza no Dock e nos widgets com a mesa do WacOS no lugar da do Windows
+ DWORD fp = 0; GetWindowThreadProcessId(fg, &fp);
+ bool frente = fp == g_pid;
+ if (frente != g_frente) { g_frente = frente; backdrop::Reload(); }
if (HasWindow(g_pid)) { g_gone = 0; return; }
if (++g_gone < 2) return; // ~4 s sem janela nenhuma: o jogo fechou
Apply(false);
@@ -215,3 +222,4 @@ void jogo::SoltarPosicao(WINEVENTPROC fn) {
if (g_ganchos[i].fn == fn) { g_ganchos.erase(g_ganchos.begin() + i); Ganchos(!g_on); return; }
}
bool jogo::Ativo() { return g_on; }
+bool jogo::VidroPausado() { return g_on && g_frente; }
diff --git a/src/shell/launchpad.cpp b/src/shell/launchpad.cpp
index 4852222..1bf041f 100644
--- a/src/shell/launchpad.cpp
+++ b/src/shell/launchpad.cpp
@@ -42,6 +42,7 @@ struct LApp {
UINT w = 0, h = 0;
std::vector<BYTE> px;
bool mac = false; // ícone do pacote do Sequoia
+ bool proprio = false; // app nosso sem atalho no Menu Iniciar: parsing é o caminho do exe (issue #174)
ID2D1Bitmap* bmp = nullptr;
};
std::wstring NomeDe(const LApp& a) {
@@ -193,6 +194,33 @@ void Loader() {
}
folder->Release();
}
+ // issue #174: rodando direto do zip (sem o WacOSSetup) não há atalhos no Menu Iniciar e os nossos apps sumiam do
+ // Launchpad. Os que faltam entram pelo exe da pasta do Shell.
+ {
+ wchar_t me[MAX_PATH] = {};
+ GetModuleFileNameW(nullptr, me, MAX_PATH);
+ std::wstring dir = me;
+ dir = dir.substr(0, dir.find_last_of(L'\\') + 1);
+ static const wchar_t* nossos[][2] = {
+ { L"WacOSFinder", L"Finder" }, { L"WacOSSettings", L"System Settings" }, { L"WacOSActivityMonitor", L"Activity Monitor" },
+ { L"WacOSTerminal", L"Terminal" }, { L"WacOSCalculator", L"Calculator" }, { L"WacOSNotes", L"Notes" },
+ { L"WacOSScreenshot", L"Screenshot" }, { L"WacOSPreview", L"Preview" }, { L"WacOSReminders", L"Reminders" },
+ { L"WacOSCalendar", L"Calendar" }, { L"WacOSTextEdit", L"TextEdit" }, { L"WacOSClock", L"Clock" },
+ { L"WacOSWeather", L"Weather" }, { L"WacOSContacts", L"Contacts" }, { L"WacOSPhotos", L"Photos" },
+ { L"WacOSTimeMachine", L"Time Machine" }, { L"WacOSMusic", L"Music" }, { L"WacOSQuickTime", L"QuickTime Player" } };
+ for (auto& n : nossos) {
+ std::wstring exe = dir + n[0] + L".exe", low = std::wstring(n[0]) + L".exe";
+ for (auto& c : low) c = towlower(c);
+ if (GetFileAttributesW(exe.c_str()) == INVALID_FILE_ATTRIBUTES) continue;
+ bool tem = false;
+ for (auto& a : found) {
+ std::wstring p = a.parsing;
+ for (auto& c : p) c = towlower(c);
+ if (p.size() >= low.size() && !p.compare(p.size() - low.size(), low.size(), low)) { tem = true; break; }
+ }
+ if (!tem) { LApp a; a.name = n[1]; a.parsing = exe; a.proprio = true; found.push_back(std::move(a)); }
+ }
+ }
std::sort(found.begin(), found.end(), [](const LApp& a, const LApp& b) { return _wcsicmp(a.name.c_str(), b.name.c_str()) < 0; });
found.erase(std::unique(found.begin(), found.end(), [](const LApp& a, const LApp& b) { return !_wcsicmp(a.name.c_str(), b.name.c_str()); }), found.end());
int px = 256;
@@ -772,6 +800,12 @@ void Close() {
void Launch(int i) {
if (i < 0 || i >= (int)g_all.size()) return;
+ if (g_all[i].proprio) { // app nosso sem atalho: o exe direto
+ ShellExecuteW(nullptr, L"open", g_all[i].parsing.c_str(), nullptr, nullptr, SW_SHOWNORMAL);
+ Log(L"launchpad: abrindo %ls", g_all[i].name.c_str());
+ Close();
+ return;
+ }
std::wstring target = L"shell:AppsFolder\\" + g_all[i].parsing;
if (shell::OpenCalculator(target)) { Close(); return; } // a Calculadora do Windows: abre a nossa
if (apps::LaunchNoOcclusion(target)) { Close(); return; } // Chrome, Discord...: miniatura viva no Mission Control
diff --git a/src/shell/main.cpp b/src/shell/main.cpp
index d1d343d..32ce302 100644
--- a/src/shell/main.cpp
+++ b/src/shell/main.cpp
@@ -262,6 +262,14 @@ static LRESULT CALLBACK KeyHook(int code, WPARAM w, LPARAM l) {
g_winCombo = g_winEaten = true;
PostMessageW(g_msg, k->vkCode == VK_TAB ? WM_APP_MISSION : WM_APP_SETTINGS, 0, 0);
return 1;
+ } else if (!shell::nativo && g_winDown && down && !g_winCombo && (k->vkCode == 'A' || k->vkCode == 'N') &&
+ GetAsyncKeyState(VK_SHIFT) >= 0 && GetAsyncKeyState(VK_CONTROL) >= 0 && GetAsyncKeyState(VK_MENU) >= 0) {
+ // issue #173: Win+A abre a nossa Central de Controle e Win+N a Central de Notificações (no lugar das
+ // Configurações Rápidas e da central do Windows 11)
+ g_winCombo = g_winEaten = true;
+ static UINT openPanel2 = RegisterWindowMessageW(L"ShellAbrirPainel");
+ PostMessageW(g_msg, openPanel2, k->vkCode == 'A' ? 9 : 10, 0);
+ return 1;
} else if (!shell::nativo && g_winDown && down && (k->vkCode == VK_LEFT || k->vkCode == VK_RIGHT) && GetAsyncKeyState(VK_CONTROL) >= 0 &&
GetAsyncKeyState(VK_SHIFT) >= 0 && GetAsyncKeyState(VK_MENU) >= 0) {
// Win+←/→: metade da tela (o encaixe do Windows fica desligado enquanto o Shell roda: encaixe.cpp)
@@ -983,10 +991,20 @@ bool shell::NaoIncomodar(HMONITOR mon) {
// Com mais de um monitor, só some o que está no monitor do app em tela cheia (a barra daquele monitor; o Dock
// se ele estiver lá). Tela travada: tudo some.
+// Issue #126: the fullscreen window stays fullscreen when the user clicks an app on another monitor. It is no longer
+// the foreground window, but its monitor keeps its menu bar (and the Dock, if it is there) hidden until something on
+// that same monitor takes the foreground or the window leaves fullscreen.
+static HWND g_fsJanela;
static void CheckFullscreen() {
HWND fg = GetForegroundWindow();
bool locked = bloqueio::Active();
bool fs = !locked && IsFullscreen(fg);
+ if (fs) g_fsJanela = fg;
+ else if (!locked && g_fsJanela && fg != g_fsJanela && IsWindow(g_fsJanela) && IsFullscreen(g_fsJanela)
+ && (!fg || MonitorFromWindow(fg, MONITOR_DEFAULTTONEAREST) != MonitorFromWindow(g_fsJanela, MONITOR_DEFAULTTONEAREST))) {
+ fg = g_fsJanela; fs = true; // foreground is on another monitor: the fullscreen app is still there
+ }
+ else g_fsJanela = nullptr;
HMONITOR fm = fs ? MonitorFromWindow(fg, MONITOR_DEFAULTTONEAREST) : nullptr;
{ // registro: quem fez o Dock e a barra de menus sumirem (uma vez por janela)
static HWND visto;
@@ -998,14 +1016,14 @@ static void CheckFullscreen() {
visto = fs ? fg : nullptr;
}
dock::SetFullscreen(locked || (fs && fm == dock::MonitorHandle()));
- menubar::SetFullscreen(locked || fs, fm);
+ menubar::SetFullscreen(locked || fs, fm, fs ? fg : nullptr);
ilha::SetFullscreen(locked); // a ilha confere sozinha a tela cheia do monitor principal (jogo, vídeo, app)
}
static void CALLBACK OnWinEvent(HWINEVENTHOOK, DWORD ev, HWND h, LONG obj, LONG, DWORD, DWORD) {
// maximizada por cima da barra/do Dock (issue #24): qualquer janela de topo (a conferência é barata e sai cedo)
if (ev == EVENT_OBJECT_LOCATIONCHANGE && obj == OBJID_WINDOW && !shell::nativo && h && GetAncestor(h, GA_ROOT) == h) limites::Maximizada(h);
- if (ev == EVENT_OBJECT_LOCATIONCHANGE && (obj != OBJID_WINDOW || h != GetForegroundWindow())) return;
+ if (ev == EVENT_OBJECT_LOCATIONCHANGE && (obj != OBJID_WINDOW || (h != GetForegroundWindow() && h != g_fsJanela))) return;
if (ev == EVENT_SYSTEM_FOREGROUND) { revelar::Foreground(h); jogo::Foreground(h); }
CheckFullscreen();
}
diff --git a/src/shell/menubar.cpp b/src/shell/menubar.cpp
index fc4e81c..a5f9e1c 100644
--- a/src/shell/menubar.cpp
+++ b/src/shell/menubar.cpp
@@ -531,6 +531,8 @@ void PegaStatus() {
}
void RefreshStatus() {
+ if (shell::Setting(L"barra_bluetooth", L"0") == L"1" || !shell::Setting(L"barra_baterias_bt", L"").empty())
+ central::RefreshBluetoothBatteries();
PedeStatus();
PegaStatus();
}
@@ -951,11 +953,12 @@ void Render() {
// entrada, Wi-Fi, bateria, som, Bluetooth, ícones fixados dos apps e a setinha dos guardados.
// Cada item é o símbolo com 10 pt de cada lado (no Mac fica um a cada ~38 pt).
float r = W - 10;
- auto slot = [&](float iconW, Kind k, int i) { // reserva o espaço e devolve a caixa do símbolo
- float w = iconW + 2 * PAD;
+ auto slot = [&](float iconW, Kind k, int i, float rightInset = -1.f) { // reserva o espaço e devolve a caixa do símbolo
+ if (rightInset < 0) rightInset = PAD;
+ float w = iconW + PAD + rightInset;
if (r - w < limD) return D2D1::RectF(-1000, 0, -1000 + iconW, H); // o Dock ocupa o lugar: fica de fora (nem clique)
add(D2D1::RectF(r - w, 0, r, H), k, i);
- D2D1_RECT_F box = D2D1::RectF(r - w + PAD, 0, r - PAD, H);
+ D2D1_RECT_F box = D2D1::RectF(r - w + PAD, 0, r - rightInset, H);
r -= w;
br->SetColor(litNow ? D2D1::ColorF(1, 1, 1) : fgc);
return box;
@@ -1010,6 +1013,80 @@ void Render() {
br->SetColor(dark ? D2D1::ColorF(0.13f, 0.13f, 0.14f) : D2D1::ColorF(0.96f, 0.96f, 0.96f));
rt->DrawTextW(t.c_str(), (UINT32)t.size(), g_tfBadge, D2D1::RectF(k.left, k.top - 0.5f, k.right, k.bottom - 0.5f), br);
}
+ const bool showBluetooth = g_st.bt && shell::Setting(L"barra_bluetooth", L"0") == L"1";
+ struct BatteryIndicator {
+ const wchar_t* symbol;
+ const wchar_t* fallback;
+ std::wstring percent;
+ float width;
+ };
+ constexpr float iconWidth = 14, iconGap = 3, deviceGap = 7, bluetoothGap = 4;
+ std::vector<BatteryIndicator> batteries;
+ float btWidth = showBluetooth ? 9.f : 0.f;
+ const auto selected = shell::Setting(L"barra_baterias_bt", L"");
+ const float btRightInset = !g_hits.empty() && g_hits.back().kind == K_INPUT ? std::min(PAD, 2.f) : PAD;
+ if (!selected.empty()) {
+ for (const auto& device : central::BluetoothBatteries()) {
+ if (selected.find(L"|" + std::to_wstring(device.address) + L"|") == std::wstring::npos) continue;
+
+ const wchar_t* symbol = L"battery.100percent";
+ const wchar_t* fallback = L"\uE850";
+ auto name = device.name;
+ for (auto& ch : name) ch = towlower(ch);
+ if (name.find(L"headphone") != std::wstring::npos || name.find(L"headset") != std::wstring::npos ||
+ name.find(L"earbud") != std::wstring::npos || name.find(L"airpods") != std::wstring::npos) {
+ symbol = L"headphones";
+ fallback = L"\uE7F6";
+ } else if (name.find(L"controller") != std::wstring::npos || name.find(L"gamepad") != std::wstring::npos ||
+ name.find(L"xbox") != std::wstring::npos || name.find(L"dualsense") != std::wstring::npos) {
+ symbol = L"gamecontroller.fill";
+ fallback = L"\uE7FC";
+ } else if (name.find(L"phone") != std::wstring::npos || name.find(L"galaxy") != std::wstring::npos) {
+ symbol = nullptr;
+ fallback = L"\uE8EA";
+ } else if (name.find(L"keyboard") != std::wstring::npos) {
+ symbol = L"keyboard.fill";
+ } else if (name.find(L"mouse") != std::wstring::npos) {
+ symbol = L"computermouse.fill";
+ }
+ auto percent = std::to_wstring(device.percent) + L"%";
+ float width = iconWidth + iconGap + ui::TextWidth(tfN, percent) + 1;
+ float gap = batteries.empty() ? (showBluetooth ? bluetoothGap : 0.f) : deviceGap;
+ if (r - btWidth - gap - width - PAD - btRightInset < std::max(limD, leftEnd)) continue;
+ btWidth += gap + width;
+ batteries.push_back({ symbol, fallback, std::move(percent), width });
+ }
+ }
+ auto drawBluetooth = [&] {
+ // O rádio e as baterias abrem o mesmo menu e compartilham a mesma área de clique.
+ auto group = slot(btWidth, K_BT, 0, batteries.empty() ? PAD : btRightInset);
+ float cursor = group.left;
+ if (showBluetooth) {
+ auto bx = D2D1::RectF(cursor, 0, cursor + 9, H);
+ float cx = (bx.left + bx.right) / 2, cy = H / 2, hh = 7.2f, ww = 3.9f;
+ ID2D1PathGeometry* g = nullptr;
+ if (SUCCEEDED(ui::d2d->CreatePathGeometry(&g))) {
+ ID2D1GeometrySink* sk = nullptr; g->Open(&sk);
+ sk->BeginFigure({ cx - ww, cy - hh * 0.48f }, D2D1_FIGURE_BEGIN_HOLLOW);
+ D2D1_POINT_2F pts[] = { { cx + ww, cy + hh * 0.48f }, { cx, cy + hh }, { cx, cy - hh }, { cx + ww, cy - hh * 0.48f }, { cx - ww, cy + hh * 0.48f } };
+ sk->AddLines(pts, 5); sk->EndFigure(D2D1_FIGURE_END_OPEN); sk->Close(); sk->Release();
+ ID2D1StrokeStyle* st = nullptr;
+ ui::d2d->CreateStrokeStyle(D2D1::StrokeStyleProperties(D2D1_CAP_STYLE_ROUND, D2D1_CAP_STYLE_ROUND, D2D1_CAP_STYLE_ROUND, D2D1_LINE_JOIN_ROUND), nullptr, 0, &st);
+ rt->DrawGeometry(g, br, 1.5f, st);
+ if (st) st->Release();
+ g->Release();
+ }
+ cursor += 9 + bluetoothGap;
+ }
+ for (const auto& device : batteries) {
+ auto icon = D2D1::RectF(cursor, 0, cursor + iconWidth, H);
+ if (!device.symbol || !sym(device.symbol, icon, 12)) rt->DrawTextW(device.fallback, 1, g_tfIcon, icon, br);
+ auto text = D2D1::RectF(icon.right + iconGap, 0, cursor + device.width, H);
+ rt->DrawTextW(device.percent.c_str(), (UINT32)device.percent.size(), tfN, text, br);
+ cursor += device.width + deviceGap;
+ }
+ };
+ if (!batteries.empty()) drawBluetooth();
// como no Mac: só quem tem Wi-Fi; no cabo, o Wi-Fi desconectado não aparece
if (g_st.wlan && (g_st.wifiOn || !g_st.wired) && shell::Setting(L"barra_wifi", L"1") == L"1") {
auto bx = slot(18, K_NET, 0);
@@ -1056,22 +1133,7 @@ void Render() {
auto bx = slot(g_st.phones ? 16 : 21, K_SOUND, 0);
sym(name, bx, g_st.phones ? 16 : 14);
}
- if (g_st.bt && shell::Setting(L"barra_bluetooth", L"0") == L"1") { // o símbolo do Bluetooth do Mac (não está no SF Symbols público)
- auto bx = slot(9, K_BT, 0);
- float cx = (bx.left + bx.right) / 2, cy = H / 2, hh = 7.2f, ww = 3.9f;
- ID2D1PathGeometry* g = nullptr;
- if (SUCCEEDED(ui::d2d->CreatePathGeometry(&g))) {
- ID2D1GeometrySink* sk = nullptr; g->Open(&sk);
- sk->BeginFigure({ cx - ww, cy - hh * 0.48f }, D2D1_FIGURE_BEGIN_HOLLOW);
- D2D1_POINT_2F pts[] = { { cx + ww, cy + hh * 0.48f }, { cx, cy + hh }, { cx, cy - hh }, { cx + ww, cy - hh * 0.48f }, { cx - ww, cy + hh * 0.48f } };
- sk->AddLines(pts, 5); sk->EndFigure(D2D1_FIGURE_END_OPEN); sk->Close(); sk->Release();
- ID2D1StrokeStyle* st = nullptr;
- ui::d2d->CreateStrokeStyle(D2D1::StrokeStyleProperties(D2D1_CAP_STYLE_ROUND, D2D1_CAP_STYLE_ROUND, D2D1_CAP_STYLE_ROUND, D2D1_LINE_JOIN_ROUND), nullptr, 0, &st);
- rt->DrawGeometry(g, br, 1.5f, st);
- if (st) st->Release();
- g->Release();
- }
- }
+ if (batteries.empty() && showBluetooth) drawBluetooth();
// issue #44: uso do sistema, como os apps de monitor do Mac (Stats, iStat Menus): o nome pequeno em cima e a
// porcentagem embaixo, um ao lado do outro (CPU, GPU, memória, disco). Clique: Monitor de Atividade.
{
@@ -1528,7 +1590,36 @@ void Click(D2D1_POINT_2F p, bool right) {
som::Toggle(ir);
break;
}
- case K_BT: ShowAt(hit, { I(Tr(L"Bluetooth"), 0, true), Sep(), I(Tr(L"Ajustes de Bluetooth…"), 1) }, [](int) { shell::OpenSettings(L"bluetooth"); }); break;
+ case K_BT: {
+ central::RefreshBluetoothBatteries();
+ auto devices = central::BluetoothBatteries();
+ auto selected = shell::Setting(L"barra_baterias_bt", L"");
+ std::vector<ctxmenu::Item> items{ I(Tr(L"Bluetooth"), 0, true) };
+ if (!devices.empty()) {
+ items.push_back(Sep());
+ items.push_back(I(Tr(L"Mostrar na barra de menus"), 0, true));
+ for (size_t i = 0; i < devices.size(); ++i) {
+ const auto& device = devices[i];
+ auto key = L"|" + std::to_wstring(device.address) + L"|";
+ items.push_back(I(device.name + L" " + std::to_wstring(device.percent) + L"%",
+ (int)i + 3, false, selected.find(key) != std::wstring::npos));
+ }
+ }
+ if (!selected.empty()) items.push_back(I(Tr(L"Limpar"), 2));
+ items.push_back(Sep());
+ items.push_back(I(Tr(L"Ajustes de Bluetooth…"), 1));
+ ShowAt(hit, items, [&](int id) {
+ if (id == 1) shell::OpenSettings(L"bluetooth");
+ else if (id == 2) shell::SetSetting(L"barra_baterias_bt", L"");
+ else if (id >= 3 && (size_t)(id - 3) < devices.size()) {
+ auto key = L"|" + std::to_wstring(devices[id - 3].address) + L"|";
+ if (auto pos = selected.find(key); pos == std::wstring::npos) selected += key;
+ else selected.erase(pos, key.size());
+ shell::SetSetting(L"barra_baterias_bt", selected);
+ }
+ });
+ break;
+ }
case K_BATT: {
wchar_t b[64]; swprintf_s(b, Tr(L"Bateria: %d%%"), g_st.pct);
ShowAt(hit, { I(b, 0, true), I(g_st.charging ? Tr(L"Fonte de Energia: Carregador") : Tr(L"Fonte de Energia: Bateria"), 0, true), Sep(), I(Tr(L"Ajustes de Bateria…"), 1) },
@@ -1847,13 +1938,13 @@ static void TiqueOcultar() {
if (!fora) fora = agora;
if (agora - fora >= 400) { fora = 0; Revela(false); }
}
-void menubar::SetFullscreen(bool on, HMONITOR mon) {
+void menubar::SetFullscreen(bool on, HMONITOR mon, HWND janela) {
if (!g_bar) return;
bool revela = false;
if (on && mon && !bloqueio::Active() && shell::Setting(L"barra_tela_cheia", L"1") == L"1") {
QUERY_USER_NOTIFICATION_STATE q{};
bool d3d = SUCCEEDED(SHQueryUserNotificationState(&q)) && q == QUERY_USER_NOTIFICATION_STATE::QUNS_RUNNING_D3D_FULL_SCREEN;
- HWND fg = GetForegroundWindow();
+ HWND fg = janela ? janela : GetForegroundWindow(); // the fullscreen app, even when another monitor has the focus (issue #126)
wchar_t cls[64] = {}, path[MAX_PATH] = {};
GetClassNameW(fg, cls, 64);
DWORD pid = 0; GetWindowThreadProcessId(fg, &pid);
diff --git a/src/shell/mesa.cpp b/src/shell/mesa.cpp
index 26af731..8e6bbbb 100644
--- a/src/shell/mesa.cpp
+++ b/src/shell/mesa.cpp
@@ -755,6 +755,7 @@ void EnsureFormat() {
if (ell) ell->Release();
}
+bool LabelOnLight(const D2D1_RECT_F& lb); // abaixo (issue #161)
void DrawIcons(ID2D1RenderTarget* rt) {
EnsureFormat();
if (!g_br) rt->CreateSolidColorBrush(D2D1::ColorF(1, 1, 1, 1), &g_br);
@@ -805,18 +806,20 @@ void DrawIcons(ID2D1RenderTarget* rt) {
IDWriteTextLayout* lay = nullptr;
ui::dw->CreateTextLayout(it.name.c_str(), (UINT32)it.name.size(), g_tf, lb.right - lb.left, lb.bottom - lb.top, &lay);
if (!lay) continue;
+ const bool claro = !it.sel && LabelOnLight(lb);
if (it.sel) {
DWRITE_TEXT_METRICS tm{}; lay->GetMetrics(&tm);
float h = std::min(tm.height, lb.bottom - lb.top);
g_br->SetColor(D2D1::ColorF(0.04f, 0.38f, 0.88f, 1));
rt->FillRoundedRectangle(D2D1::RoundedRect(D2D1::RectF(lb.left + tm.left - 4 * s, lb.top - 1 * s, lb.left + tm.left + tm.width + 4 * s, lb.top + h + 1 * s), 4 * s, 4 * s), g_br);
- } else { // sombra do nome, como no Mac
+ } else if (!claro) { // sombra do nome, como no Mac
g_br->SetColor(D2D1::ColorF(0, 0, 0, 0.30f));
rt->DrawTextLayout(D2D1::Point2F(lb.left, lb.top + 1.5f * s), lay, g_br, D2D1_DRAW_TEXT_OPTIONS_CLIP);
g_br->SetColor(D2D1::ColorF(0, 0, 0, 0.55f));
rt->DrawTextLayout(D2D1::Point2F(lb.left, lb.top + 1 * s), lay, g_br, D2D1_DRAW_TEXT_OPTIONS_CLIP);
}
- g_br->SetColor(D2D1::ColorF(1, 1, 1, 1));
+ if (claro) g_br->SetColor(D2D1::ColorF(0.08f, 0.08f, 0.09f, 1)); // papel de parede claro: nome escuro (issue #161)
+ else g_br->SetColor(D2D1::ColorF(1, 1, 1, 1));
rt->DrawTextLayout(D2D1::Point2F(lb.left, lb.top), lay, g_br, D2D1_DRAW_TEXT_OPTIONS_CLIP);
lay->Release();
}
@@ -833,6 +836,30 @@ void DrawIcons(ID2D1RenderTarget* rt) {
// de outro programa ali dentro, a mesa vira transparente (janela em camadas, alfa por pixel): só os ícones, sobre
// um fundo de alfa 1/255 (invisível, mas ainda recebe os cliques da mesa: seleção, botão direito, arrastar).
bool g_live;
+// Papel de parede claro (branco, por exemplo): o nome branco do ícone sumia (issue #161). Mede o brilho médio do papel
+// de parede atrás do nome: se for claro, o nome sai escuro. No papel de parede animado a mesa é transparente e o
+// papel não está aqui; fica o nome branco.
+bool LabelOnLight(const D2D1_RECT_F& lb) {
+ Mon* p = Primary();
+ if (!p || !p->wallDC || !p->wall || g_live) return false;
+ static HDC dc = nullptr; static HBITMAP bmp = nullptr; static BYTE* bits = nullptr;
+ if (!dc) {
+ BITMAPINFO bi{}; bi.bmiHeader = { sizeof(BITMAPINFOHEADER), 1, -1, 1, 32, BI_RGB };
+ dc = CreateCompatibleDC(nullptr);
+ bmp = dc ? CreateDIBSection(dc, &bi, DIB_RGB_COLORS, (void**)&bits, nullptr, 0) : nullptr;
+ if (!dc || !bmp || !bits) return false;
+ SelectObject(dc, bmp);
+ SetStretchBltMode(dc, HALFTONE);
+ }
+ BITMAP bm{};
+ if (!GetObjectW(p->wall, sizeof(bm), &bm) || bm.bmWidth <= 0 || bm.bmHeight <= 0) return false;
+ int x = std::clamp((int)lb.left, 0, (int)bm.bmWidth - 1), y = std::clamp((int)lb.top, 0, (int)bm.bmHeight - 1);
+ int w = std::clamp((int)(lb.right - lb.left), 1, (int)bm.bmWidth - x), h = std::clamp((int)(lb.bottom - lb.top), 1, (int)bm.bmHeight - y);
+ if (!StretchBlt(dc, 0, 0, 1, 1, p->wallDC, x, y, w, h, SRCCOPY)) return false;
+ GdiFlush();
+ float lum = (0.2126f * bits[2] + 0.7152f * bits[1] + 0.0722f * bits[0]) / 255.f; // BGRA
+ return lum > 0.72f;
+}
bool LiveWallpaperNow() {
HWND pm = FindWindowW(L"Progman", nullptr);
DWORD exPid = 0; if (pm) GetWindowThreadProcessId(pm, &exPid);
diff --git a/src/shell/shell.h b/src/shell/shell.h
index 9cc6d0b..f8d98ef 100644
--- a/src/shell/shell.h
+++ b/src/shell/shell.h
@@ -245,7 +245,7 @@ bool Create(HINSTANCE hi);
void Update(); // app ativo mudou, relógio, ícones
HWND Hwnd();
int Height(); // px
-void SetFullscreen(bool on, HMONITOR mon = nullptr); // app em tela cheia na frente: some (só no monitor dele; nullptr = todos)
+void SetFullscreen(bool on, HMONITOR mon = nullptr, HWND janela = nullptr); // app em tela cheia na frente: some (só no monitor dele; nullptr = todos). janela: the fullscreen window (nullptr = the foreground one)
int HeightOn(HMONITOR mon); // px da barra naquele monitor (cada monitor tem a sua barra)
int ReservedOn(HMONITOR mon); // px que a barra ocupa no topo daquele monitor (0: secundário sem barra, barra_todos_monitores=0, ou barra embaixo)
bool Embaixo(); // barra_embaixo: a barra está na linha do Dock (Dock embaixo no monitor principal, fora do Leopard)
@@ -288,7 +288,14 @@ namespace sombras { // sombra do Mac nas janelas que a MacJanela.dll não trata
void Start();
void Stop();
}
-namespace central { // Central de Controle: painel embaixo do ícone da barra de menus (central.cpp)
+namespace central {
+struct BluetoothBattery {
+ ULONGLONG address;
+ std::wstring name;
+ int percent;
+};
+void RefreshBluetoothBatteries();
+std::vector<BluetoothBattery> BluetoothBatteries(); // Central de Controle: painel embaixo do ícone da barra de menus (central.cpp)
bool Create(HINSTANCE hi);
void BrilhoPasso(int dir); // teclas de brilho (F14/F15): -1/+1 de 16 passos, DDC/CI ou WMI, aviso na Ilha
bool SemBrilho(); // já se sabe que nenhuma tela aceita brilho (sem DDC/CI nem WMI): F14/F15 ficam para os outros programas
@@ -763,6 +770,7 @@ void Start();
void Reload(); // ajustes mudaram
void Foreground(HWND h); // a janela da frente mudou
bool Ativo();
+bool VidroPausado(); // jogo aberto E na frente: só então o vidro real sai (issue #160)
// gancho de EVENT_OBJECT_LOCATIONCHANGE que sai durante o modo jogo (cada movimento do cursor chegava ao Shell)
void GanchoPosicao(WINEVENTPROC fn, DWORD flags);
void SoltarPosicao(WINEVENTPROC fn);
diff --git a/src/shell/sobre.cpp b/src/shell/sobre.cpp
index 9092f6d..3f5ea8d 100644
--- a/src/shell/sobre.cpp
+++ b/src/shell/sobre.cpp
@@ -404,8 +404,11 @@ void Paint() {
rows[1][0] = Tr(L"Gráficos"); rows[1][1] = info.gpu;
rows[2][0] = Tr(L"Memória"); rows[2][1] = info.ram;
rows[3][0] = Tr(L"Nome"); rows[3][1] = info.nome;
- rows[4][0] = L"Windows"; rows[4][1] = info.windows.substr(info.windows.find(L"Windows ") == 0 ? 8 : 0);
- nrows = 5;
+ nrows = 4;
+ if (shell::Setting(L"ocultar_windows", L"0") != L"1") { // Experimental > "Ocultar menções ao Windows" (issue #159)
+ rows[4][0] = L"Windows"; rows[4][1] = info.windows.substr(info.windows.find(L"Windows ") == 0 ? 8 : 0);
+ nrows = 5;
+ }
}
float row0 = ROW0_CY + (pc && GG ? 6.f : 0.f); // macOS 27: abaixo da linha do fabricante
float split = pc ? 96.f : COL_SPLIT; // este PC: nomes de processador e placa de vídeo mais longos
diff --git a/src/shell/som.cpp b/src/shell/som.cpp
index 2e408cd..5bc0e1e 100644
--- a/src/shell/som.cpp
+++ b/src/shell/som.cpp
@@ -178,11 +178,48 @@ void SetAppVolume(size_t i, float v) {
g_apps[i].vol = v; g_apps[i].mute = v <= 0.001f;
}
+// issue #172: o volume mudado por fora (botões/roda do fone, teclado que manda direto ao driver) também mostra o aviso
+// de volume do Mac. As mudanças do próprio Shell levam este contexto e são ignoradas.
+const GUID CTX_SHELL = { 0x5f3c7a21, 0x9b4e, 0x4d6a, { 0x8e, 0x12, 0x6c, 0x0b, 0x77, 0x3a, 0x51, 0xd4 } };
+const UINT WM_VOL_FORA = WM_APP + 71;
+HWND g_volAviso; // a janela do aviso (recebe WM_VOL_FORA)
+struct VolCb : IAudioEndpointVolumeCallback, IMMNotificationClient {
+ LONG ref = 1;
+ ULONG STDMETHODCALLTYPE AddRef() override { return InterlockedIncrement(&ref); }
+ ULONG STDMETHODCALLTYPE Release() override { return InterlockedDecrement(&ref); } // estático: vive o Shell todo
+ HRESULT STDMETHODCALLTYPE QueryInterface(REFIID r, void** p) override {
+ if (r == __uuidof(IUnknown) || r == __uuidof(IAudioEndpointVolumeCallback)) *p = (IAudioEndpointVolumeCallback*)this;
+ else if (r == __uuidof(IMMNotificationClient)) *p = (IMMNotificationClient*)this;
+ else { *p = nullptr; return E_NOINTERFACE; }
+ AddRef(); return S_OK;
+ }
+ HRESULT STDMETHODCALLTYPE OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA d) override {
+ if (d && d->guidEventContext != CTX_SHELL && g_volAviso) PostMessageW(g_volAviso, WM_VOL_FORA, 0, 0);
+ return S_OK;
+ }
+ HRESULT STDMETHODCALLTYPE OnDefaultDeviceChanged(EDataFlow f, ERole r, LPCWSTR) override {
+ if (f == eRender && r == eConsole && g_volAviso) PostMessageW(g_volAviso, WM_VOL_FORA, 1, 0); // outra saída: registra de novo
+ return S_OK;
+ }
+ HRESULT STDMETHODCALLTYPE OnDeviceStateChanged(LPCWSTR, DWORD) override { return S_OK; }
+ HRESULT STDMETHODCALLTYPE OnDeviceAdded(LPCWSTR) override { return S_OK; }
+ HRESULT STDMETHODCALLTYPE OnDeviceRemoved(LPCWSTR) override { return S_OK; }
+ HRESULT STDMETHODCALLTYPE OnPropertyValueChanged(LPCWSTR, const PROPERTYKEY) override { return S_OK; }
+} g_volCb;
+IAudioEndpointVolume* g_volReg; // a saída em que o aviso está registrado
+DWORD g_volRegAt; // quando trocou de saída (o volume da nova saída não é "mudança")
+void RegistraVolume() {
+ if (g_volReg) { g_volReg->UnregisterControlChangeNotify(&g_volCb); g_volReg->Release(); g_volReg = nullptr; }
+ g_volReg = Endpoint();
+ if (g_volReg && FAILED(g_volReg->RegisterControlChangeNotify(&g_volCb))) { g_volReg->Release(); g_volReg = nullptr; }
+ g_volRegAt = GetTickCount();
+}
+
void SetVolume(float v) {
v = std::clamp(v, 0.f, 1.f);
if (IAudioEndpointVolume* e = Endpoint()) {
- e->SetMasterVolumeLevelScalar(v, nullptr);
- e->SetMute(v <= 0.001f, nullptr); // no zero, mudo (o ícone vira o alto-falante cortado, como no Mac)
+ e->SetMasterVolumeLevelScalar(v, &CTX_SHELL);
+ e->SetMute(v <= 0.001f, &CTX_SHELL); // no zero, mudo (o ícone vira o alto-falante cortado, como no Mac)
e->Release();
}
g_au.vol = v; g_au.mute = v <= 0.001f;
@@ -190,7 +227,7 @@ void SetVolume(float v) {
}
void SetMute(bool m) {
- if (IAudioEndpointVolume* e = Endpoint()) { e->SetMute(m, nullptr); e->Release(); }
+ if (IAudioEndpointVolume* e = Endpoint()) { e->SetMute(m, &CTX_SHELL); e->Release(); }
g_au.mute = m;
menubar::SoundChanged(false);
}
@@ -792,6 +829,20 @@ LRESULT CALLBACK HudProc(HWND h, UINT m, WPARAM w, LPARAM l) {
switch (m) {
case WM_PAINT: { PAINTSTRUCT ps; BeginPaint(h, &ps); EndPaint(h, &ps); PaintHud(); return 0; }
case WM_MOUSEACTIVATE: return MA_NOACTIVATE;
+ case WM_VOL_FORA: { // issue #172: volume mudado fora do Shell (fone, teclado externo)
+ if (w == 1) { RegistraVolume(); Read(false); return 0; }
+ float antes = g_au.vol; bool mudoAntes = g_au.mute;
+ Read(false);
+ if (!g_au.ok || GetTickCount() - g_volRegAt < 1500) return 0;
+ if (std::fabs(g_au.vol - antes) < 0.004f && g_au.mute == mudoAntes) return 0; // nada que se veja
+ menubar::SoundChanged(false);
+ if (g_open) { PaintMenu(); return 0; }
+ if (central::IsOpen()) return 0; // o controle de som da Central de Controle sendo arrastado
+ if (shell::Setting(L"aviso_volume_fora", L"1") == L"0") return 0;
+ if (ilha::Volume(g_au.mute ? 0 : g_au.vol, g_au.mute)) { HideHud(); return 0; }
+ ShowHud();
+ return 0;
+ }
case WM_TIMER:
if (w == T_FADE) { KillTimer(h, T_FADE); g_hudFadeAt = anim::Now(); ui::FrameClock(h, WM_HUD_FRAME, true); }
return 0;
@@ -812,6 +863,14 @@ LRESULT CALLBACK HudProc(HWND h, UINT m, WPARAM w, LPARAM l) {
bool som::Create(HINSTANCE hi) {
if (!MakeGlass(g_m, hi, L"ShellSomMenu", MenuProc, false, L"Som")) return false;
if (!MakeGlass(g_h, hi, L"ShellSomAviso", HudProc, true, L"Volume")) return false;
+ g_volAviso = g_h.wnd;
+ Read(false);
+ RegistraVolume();
+ { // troca da saída padrão: o aviso passa para a nova
+ IMMDeviceEnumerator* en = nullptr;
+ if (SUCCEEDED(CoCreateInstance(__uuidof(MMDeviceEnumerator), nullptr, CLSCTX_ALL, IID_PPV_ARGS(&en))))
+ en->RegisterEndpointNotificationCallback(&g_volCb); // o enumerador fica vivo com o registro
+ }
g_tfTitle = ui::Format(13, DWRITE_FONT_WEIGHT_BOLD);
g_tfHead = ui::Format(12, DWRITE_FONT_WEIGHT_SEMI_BOLD);
g_tfRow = ui::Format(13, DWRITE_FONT_WEIGHT_NORMAL);