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

Add opt-in compatibility for covered PecoFence panels

Eternity07062853dee9e4c1b4
diff --git a/src/shell/mesa.cpp b/src/shell/mesa.cpp
index 0157162..5dd4368 100644
--- a/src/shell/mesa.cpp
+++ b/src/shell/mesa.cpp
@@ -1824,6 +1824,39 @@ void RefreshLiveLabels() {
if (mudou) Redraw();
}
+bool PecoFenceCoberto(DWORD pid) {
+ for (const auto& m : g_mons) {
+ if (!IsWindowVisible(m.h)) continue;
+ for (HWND h = GetWindow(m.h, GW_HWNDNEXT); h; h = GetWindow(h, GW_HWNDNEXT)) {
+ DWORD owner = 0;
+ GetWindowThreadProcessId(h, &owner);
+ if (owner != pid || !IsWindowVisible(h) || IsIconic(h)) continue;
+ wchar_t cls[32]{};
+ if (!GetClassNameW(h, cls, ARRAYSIZE(cls)) || wcscmp(cls, L"PecoFence.Fence")) continue;
+ RECT fence{}, overlap{};
+ if (!GetWindowRect(h, &fence) || !IntersectRect(&overlap, &fence, &m.r)) continue;
+ DWORD cloaked = 0;
+ if (FAILED(DwmGetWindowAttribute(h, DWMWA_CLOAKED, &cloaked, sizeof(cloaked))) || !cloaked)
+ return true;
+ }
+ }
+ return false;
+}
+
+bool PecoFencePrecisaExplorer(bool fundo, HWND explorer) {
+ static HWND active = nullptr;
+ HWND control = fundo && explorer && !shell::nativo ? FindWindowW(L"PecoFence.Control", nullptr) : nullptr;
+ if (active == control) return active != nullptr;
+ DWORD pid = 0;
+ if (control) GetWindowThreadProcessId(control, &pid);
+ // A cerca pode estar atrás da nossa mesa sem piscar. Mantém a compatibilidade enquanto
+ // a mesma instância estiver aberta, mesmo se o usuário esconder as cercas temporariamente.
+ HWND next = pid && PecoFenceCoberto(pid) ? control : nullptr;
+ if (next != active) Log(L"mesa: compatibilidade PecoFence %ls", next ? L"ligada (cerca coberta)" : L"desligada");
+ active = next;
+ return active != nullptr;
+}
+
// máquina de estados, a cada 500 ms
void Tick() {
{ // papel de parede animado entrou ou saiu (a cada ~2 s); com ele, a cor dos nomes acompanha o papel de parede
@@ -1839,12 +1872,15 @@ void Tick() {
bool want0 = opt == L"0";
// sem o ajuste: fundo (o padrão do instalador). Antes, vazio e sem o registro do Winlogon = a mesa do Explorador, e quem
// perdeu a linha do ajustes.txt ficava com os ícones e o menu de clique direito do Windows (23/11/2026)
- g_fundo = opt == L"fundo" || opt.empty();
// nativo: o Shell roda dentro do explorer.exe; a mesa do projeto fica por cima da dele (os ícones e o papel
// de parede do Windows ficam atrás, sem uso) e nunca se pede para o Explorador sair
- if (shell::nativo) { g_fundo = true; g_uwpWant = false; }
- if (g_fundo) want0 = false;
+ bool fundo = shell::nativo || opt == L"fundo" || opt.empty();
+ if (shell::nativo) g_uwpWant = false;
+ if (fundo) want0 = false;
HWND ex = ExplorerProgman();
+ const bool pecoCompat = fundo && shell::Setting(L"pecofence_compat", L"0") == L"1";
+ const bool peco = PecoFencePrecisaExplorer(pecoCompat, ex);
+ g_fundo = fundo && !peco;
DWORD now = GetTickCount();
{ // Papel de parede trocado sem aviso: com o Explorador aberto, o Ajustes troca por ele (IDesktopWallpaper) e
// ninguém manda o WM_SETTINGCHANGE para a nossa mesa (ela continuava com o antigo). Confere o registro.