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

Win+D handled by the Shell, no topmost leaks, Settings comes to the front

Eternity070628928816a377ba
diff --git a/src/ajustes/main.cpp b/src/ajustes/main.cpp
index f100922..1502866 100644
--- a/src/ajustes/main.cpp
+++ b/src/ajustes/main.cpp
@@ -33,7 +33,7 @@ const float SEARCH_H = 28, ACCOUNT_H = 50;
const float PAD = 20, GROUP_R = 8, GROUP_GAP = 11;
float ROW_H = 38;
const UINT WM_APP_REBUILD = WM_APP + 1, WM_APP_BITMAP = WM_APP + 2;
-const UINT_PTR T_REFRESH = 1, T_ANIM = 2, T_CARET = 3;
+const UINT_PTR T_REFRESH = 1, T_ANIM = 2, T_CARET = 3, T_FRENTE = 4; // T_FRENTE: vem para a frente depois de aparecer
HWND g_hwnd;
HINSTANCE g_inst;
@@ -1509,6 +1509,12 @@ LRESULT CALLBACK WndProc(HWND h, UINT m, WPARAM w, LPARAM l) {
return 0;
}
case WM_TIMER:
+ if (w == T_FRENTE) { // já à mostra (o Shell terminou a animação de abrir): para a frente de verdade
+ KillTimer(h, T_FRENTE);
+ if (GetForegroundWindow() != h) { keybd_event(VK_MENU, 0, 0, 0); SetForegroundWindow(h); keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0); }
+ BringWindowToTop(h);
+ return 0;
+ }
if (w == T_REFRESH) {
if (tahoe::Reload()) { g_tahoe = tahoe::On(); ApplyWindowTheme(); shadow::Update(); Invalidate(); }
if (!g_sheet.open && g_drag.g < 0 && !ctxmenu::IsOpen()) {
@@ -1576,7 +1582,8 @@ LRESULT CALLBACK WndProc(HWND h, UINT m, WPARAM w, LPARAM l) {
else if (id == L"atualizacao") { int g = SidebarIndexFor(L"geral"); if (g >= 0) SelectSide(g); OpenUpdatePage(); }
}
if (IsIconic(h)) ShowWindow(h, SW_RESTORE);
- SetForegroundWindow(h);
+ keybd_event(VK_MENU, 0, 0, 0); SetForegroundWindow(h); keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0); // já aberta: para a frente mesmo atrás de outro app
+ BringWindowToTop(h);
return TRUE;
}
case WM_APP_REBUILD:
@@ -1724,6 +1731,9 @@ int WINAPI wWinMain(HINSTANCE hi, HINSTANCE, LPWSTR, int) {
DwmFlush();
ampliacao::Revelar(g_hwnd); // abrir animado (o Shell mostra no fim) ou já
SetTimer(g_hwnd, T_REFRESH, 2500, nullptr);
+ // aberta pelo Dock (o Shell não está na frente para passar a vez): o SetForegroundWindow lá em cima, com a
+ // janela ainda escondida, não pegava e os Ajustes abriam atrás do app da frente
+ SetTimer(g_hwnd, T_FRENTE, 350, nullptr);
MSG msg;
while (GetMessageW(&msg, nullptr, 0, 0)) { TranslateMessage(&msg); DispatchMessageW(&msg); }
diff --git a/src/shell/barras.cpp b/src/shell/barras.cpp
index f21ca93..01c68b9 100644
--- a/src/shell/barras.cpp
+++ b/src/shell/barras.cpp
@@ -735,10 +735,18 @@ void Ordem(Info& in) {
SetWindowPos(in.faixa, (GetWindowLongW(in.alvo, GWL_EXSTYLE) & WS_EX_TOPMOST) ? HWND_TOPMOST : HWND_TOP, 0, 0, 0, 0, F);
return;
}
+ // A faixa fica na mesma camada da janela. Antes ela ia para logo abaixo da janela de cima, que podia ser "sempre no
+ // topo" (Dock, barra de menus): a faixa virava "sempre no topo" e, no passo de baixo, a janela do app também
+ // (Chrome, Claude, Finder ficavam por cima de tudo e os outros apps não vinham mais para a frente; Win+D repetido)
+ const bool alvoTop = (GetWindowLongW(in.alvo, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0;
+ if (((GetWindowLongW(in.faixa, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0) != alvoTop)
+ SetWindowPos(in.faixa, alvoTop ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, F);
HWND prev = GetWindow(in.alvo, GW_HWNDPREV);
+ if (prev && !alvoTop && (GetWindowLongW(prev, GWL_EXSTYLE) & WS_EX_TOPMOST)) prev = nullptr; // a 1ª da camada comum
SetWindowPos(in.faixa, prev ? prev : HWND_TOP, 0, 0, 0, 0, F);
if (GetWindow(in.alvo, GW_HWNDPREV) == in.faixa) return;
// não ficou colada: põe a faixa embaixo da janela e a janela embaixo da faixa (sem esperar o programa)
+ if (((GetWindowLongW(in.faixa, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0) != alvoTop) return; // camadas diferentes: não arrasta o app
SetWindowPos(in.faixa, in.alvo, 0, 0, 0, 0, F);
SetWindowPos(in.alvo, in.faixa, 0, 0, 0, 0, F | SWP_ASYNCWINDOWPOS);
}
diff --git a/src/shell/genio.cpp b/src/shell/genio.cpp
index e0c6b9c..008d4a1 100644
--- a/src/shell/genio.cpp
+++ b/src/shell/genio.cpp
@@ -505,9 +505,11 @@ bool Wanted(HWND h) {
return true;
}
+DWORD g_pauseUntil; // Win+D: sem gênio até esta hora (genio::Pause)
void CALLBACK OnMinimize(HWINEVENTHOOK, DWORD ev, HWND h, LONG obj, LONG, DWORD, DWORD) {
if (obj != OBJID_WINDOW || ev != EVENT_SYSTEM_MINIMIZESTART || !Wanted(h)) return;
if (revelar::Owns(h) || apps::IsHidden(h)) return; // Ocultar: some sem o gênio
+ if ((int)(g_pauseUntil - GetTickCount()) > 0) return; // Win+D: sem o gênio
if (g_running && g_a.target == h) { Log(L"gênio: aviso de minimizou %.1f ms depois do começo", anim::Now() - g_a.t0); return; } // já começou pela pergunta do Windows
RECT slot = dock::MinimizeTarget();
Start(h, slot, false);
@@ -546,11 +548,12 @@ void genio::Stop() {
}
bool genio::Busy(HWND h) { return g_running && g_a.target == h; }
+void genio::Pause(DWORD ms) { g_pauseUntil = GetTickCount() + ms; }
// HSHELL_GETMINRECT: o Windows vai minimizar `h` (ela ainda está na tela). Começa o gênio agora e responde
// com o lugar no Dock. false: não é uma janela nossa de animar (ou é a volta de uma restauração).
bool genio::OnMinRect(HWND h, RECT* out) {
- if (!g_ov || !Wanted(h) || revelar::Owns(h) || IsIconic(h) || apps::IsHidden(h)) return false;
+ if (!g_ov || !Wanted(h) || revelar::Owns(h) || IsIconic(h) || apps::IsHidden(h) || (int)(g_pauseUntil - GetTickCount()) > 0) return false;
if (g_running && g_a.target == h) { *out = g_a.slot; return true; }
RECT slot = dock::MinimizeTarget();
if (slot.right <= slot.left) return false;
diff --git a/src/shell/main.cpp b/src/shell/main.cpp
index 66b1b50..de9c29c 100644
--- a/src/shell/main.cpp
+++ b/src/shell/main.cpp
@@ -238,6 +238,12 @@ static LRESULT CALLBACK KeyHook(int code, WPARAM w, LPARAM l) {
g_winCombo = g_winEaten = true;
PostMessageW(g_msg, WM_APP_WINKEY, 'E', 0);
return 1;
+ } else if (g_winDown && down && !g_winCombo && !shell::nativo && k->vkCode == 'D') {
+ // Win+D é sempre nosso: com o Explorador de fundo, o "mostrar a área de trabalho" dele punha a mesa
+ // DELE na frente e a nossa voltava por cima em seguida (piscava, os widgets sumiam e voltavam)
+ g_winCombo = g_winEaten = true;
+ PostMessageW(g_msg, WM_APP_WINKEY, 'D', 0);
+ return 1;
} else if (g_winDown && down && !g_winCombo && mesa::Standalone() && (k->vkCode == 'E' || k->vkCode == 'R' || k->vkCode == 'D')) {
// sem o Explorador ninguém trata Win+E/R/D: fazemos nós (Finder, Executar, mostrar a mesa)
g_winCombo = g_winEaten = true;
diff --git a/src/shell/mesa.cpp b/src/shell/mesa.cpp
index 4056d6c..bc49c54 100644
--- a/src/shell/mesa.cpp
+++ b/src/shell/mesa.cpp
@@ -1729,7 +1729,13 @@ LRESULT CALLBACK CtlProc(HWND h, UINT m, WPARAM w, LPARAM l) {
// Win+D sem o Explorador: minimiza as janelas dos apps; de novo, devolve
std::vector<HWND> g_shown;
void ShowDesktopToggle() {
+ // já voltaram por outro caminho (Dock, Alt+Tab)? Então este Win+D esconde de novo, em vez de "devolver" nada
+ bool anyHidden = false;
+ for (HWND h : g_shown) if (IsWindow(h) && IsIconic(h)) { anyHidden = true; break; }
+ if (!anyHidden) g_shown.clear();
if (!g_shown.empty()) {
+ // devolve de trás para a frente: a que estava na frente termina na frente
+ // (SW_RESTORE: a maximizada volta maximizada; a de cima é a última, e fica com o foco)
for (auto it = g_shown.rbegin(); it != g_shown.rend(); ++it) if (IsWindow(*it) && IsIconic(*it)) ShowWindowAsync(*it, SW_RESTORE);
g_shown.clear();
return;
@@ -1743,6 +1749,7 @@ void ShowDesktopToggle() {
wchar_t c[64]; GetClassNameW(h, c, 64);
if (mesa::IsDeskClass(c) || !wcscmp(c, L"Shell_TrayWnd")) return TRUE;
g_shown.push_back(h);
+ genio::Pause(1200); // todas de uma vez, sem o gênio (várias animações juntas travavam com Win+D repetido)
ShowWindowAsync(h, SW_MINIMIZE);
return TRUE;
}, 0);
diff --git a/src/shell/shell.h b/src/shell/shell.h
index e5a8c50..46dceff 100644
--- a/src/shell/shell.h
+++ b/src/shell/shell.h
@@ -328,6 +328,7 @@ bool Busy(HWND h); // a janela está no meio do gênio (o Dock a
int Phase(HWND h); // 0 parada, 1 minimizando (indo para o Dock), 2 restaurando (saindo dele)
bool Restore(HWND h, RECT fromSlot);
bool OnMinRect(HWND h, RECT* out); // HSHELL_GETMINRECT: começa o gênio antes da janela sumir
+void Pause(DWORD ms); // Win+D: minimiza tudo de uma vez, sem o gênio (pesado em várias janelas)
}
namespace seletor { // Alt+Tab: o seletor de apps do Mac (seletor.cpp)
bool Create(HINSTANCE hi);