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

Launchpad: add an installed applications panel

Eternity070628a278efff730c
diff --git a/src/menu/context_menu.cpp b/src/menu/context_menu.cpp
index 4323cb9..83f0d58 100644
--- a/src/menu/context_menu.cpp
+++ b/src/menu/context_menu.cpp
@@ -1561,6 +1561,11 @@ void ctxmenu::WarmupAsync(const std::wstring& folder, const std::wstring& file)
ctxmenu::Result ctxmenu::Show(HWND owner, POINT pt, const std::wstring& folder,
const std::vector<std::wstring>& paths, bool full) {
+ return Show(owner, pt, folder, paths, full, false);
+}
+
+ctxmenu::Result ctxmenu::Show(HWND owner, POINT pt, const std::wstring& folder,
+ const std::vector<std::wstring>& paths, bool full, bool interceptUninstall) {
Result res;
bool bg = paths.empty();
ShellMenu sm;
@@ -1599,12 +1604,12 @@ ctxmenu::Result ctxmenu::Show(HWND owner, POINT pt, const std::wstring& folder,
res.chosen = true;
res.verb = VerbOf(sm, r->cmd);
if (res.verb == L"rename" && !bg) res.rename = true;
- else res.hr = InvokeCmd(owner, sm, r->cmd, pt, folder);
+ else if (!interceptUninstall || res.verb != L"uninstall") res.hr = InvokeCmd(owner, sm, r->cmd, pt, folder);
Log(L"Executado: %ls (id %u) → %ls 0x%08X", res.verb.empty() ? L"(sem verbo)" : res.verb.c_str(), r->cmd,
SUCCEEDED(res.hr) ? L"OK" : L"erro", (unsigned)res.hr);
}
g_active = nullptr;
- if (showAll) return Show(owner, pt, folder, paths, true); // menu novo: há extensões que só preenchem submenus uma vez
+ if (showAll) return Show(owner, pt, folder, paths, true, interceptUninstall); // menu novo: há extensões que só preenchem submenus uma vez
return res;
}
diff --git a/src/menu/context_menu.h b/src/menu/context_menu.h
index 746edde..6b5a366 100644
--- a/src/menu/context_menu.h
+++ b/src/menu/context_menu.h
@@ -57,6 +57,8 @@ struct Result {
// full = todas as opções na ordem do Windows (Shift+clique direito).
Result Show(HWND owner, POINT screenPt, const std::wstring& folder,
const std::vector<std::wstring>& paths, bool full);
+Result Show(HWND owner, POINT screenPt, const std::wstring& folder,
+ const std::vector<std::wstring>& paths, bool full, bool interceptUninstall);
// Menu com itens do próprio app (Agrupar por, Ações...), no mesmo visual. Devolve o id
// escolhido ou 0. Submenus de um nível.
diff --git a/src/shell/alertas.cpp b/src/shell/alertas.cpp
index 43492e0..a572574 100644
--- a/src/shell/alertas.cpp
+++ b/src/shell/alertas.cpp
@@ -40,6 +40,7 @@ IUIAutomation* g_uia;
struct State {
HWND target = nullptr; // a janela do Explorer
+ HWND owner = nullptr; // parent of an in-shell modal alert
std::function<void()> onYes; // pergunta do próprio Shell (sem janela original)
std::wstring title, info, yes, no;
float titleH = 0, infoH = 0;
@@ -476,6 +477,11 @@ void Close() {
ShowWindow(g_back, SW_HIDE);
KillTimer(g_wnd, 1);
g.target = nullptr;
+ if (g.owner && IsWindow(g.owner)) {
+ EnableWindow(g.owner, TRUE);
+ SetForegroundWindow(g.owner);
+ }
+ g.owner = nullptr;
g.onYes = nullptr;
g.idYes = g.idNo = g.idThird = 0;
g.taskDlg = false;
@@ -567,7 +573,7 @@ void GuardaLugar(HWND dlg, const RECT& wr) {
// textos da janela original (pergunta, nome do arquivo) e o alerta do Mac no lugar
void Take(HWND dlg) {
- if (g.target) return;
+ if (Aberto()) return;
// Os textos direto dos Static da janela (caixas de mensagem como a "Confirm Save As" do Ableton). A UI
// Automation voltava vazia nelas e a caixa ficava a do Windows (16/11/2026); ela segue para as do Explorer.
std::vector<std::wstring> texts;
@@ -714,7 +720,7 @@ std::wstring Rotulo(const std::wstring& s) { // botões do Windows em inglês
return s;
}
void TakeMessage(HWND dlg) {
- if (g.target || !IsWindowVisible(dlg)) return;
+ if (Aberto() || !IsWindowVisible(dlg)) return;
struct F { HWND text = nullptr; HWND btn[4]{}; int ids[4]{}; int n = 0; bool outro = false; } f;
EnumChildWindows(dlg, [](HWND c, LPARAM l) -> BOOL {
auto* f = (F*)l;
@@ -777,7 +783,7 @@ void Show(int cx, int cy) {
g.titleH = TextH(g.title, 13, GoldenWide() ? DWRITE_FONT_WEIGHT_NORMAL : DWRITE_FONT_WEIGHT_BOLD, inner);
g.infoH = TextH(g.info, GoldenAlert() ? 13.f : 11.f, DWRITE_FONT_WEIGHT_NORMAL, inner);
g.hover = g.press = -1;
- g.focus = 1;
+ g.focus = g.owner && !g.single ? 0 : 1;
if (g.px.empty()) SetIcon(g.iconOf);
float sc = Sc();
int wpx = (int)std::lround(AW * sc), hpx = (int)std::lround(PanelH() * sc);
@@ -827,6 +833,25 @@ bool alertas::Confirm(const std::wstring& title, const std::wstring& info, const
return true;
}
+bool alertas::Prompt(HWND owner, const std::wstring& title, const std::wstring& info, const std::wstring& yes,
+ std::function<void()> onYes, const std::wstring& icon, const std::wstring& cancel) {
+ if (!g_wnd || !owner || Aberto()) return false;
+ RECT bounds{};
+ if (!GetWindowRect(owner, &bounds)) return false;
+ g.owner = owner;
+ g.title = title;
+ g.info = info;
+ g.yes = yes;
+ g.no = cancel;
+ g.single = cancel.empty();
+ g.onYes = std::move(onYes);
+ SetIcon(icon);
+ EnableWindow(owner, FALSE);
+ Show((bounds.left + bounds.right) / 2, (bounds.top + bounds.bottom) / 2);
+ SetTimer(g_wnd, 1, 300, nullptr);
+ return true;
+}
+
namespace {
bool IsDeleteDialog(HWND h) {
@@ -866,11 +891,12 @@ LRESULT CALLBACK Proc(HWND h, UINT m, WPARAM w, LPARAM l) {
g_pendente = nullptr;
return 0;
}
- if (g.target && !IsWindow(g.target)) Close();
+ if ((g.target && !IsWindow(g.target)) || (g.owner && !IsWindow(g.owner))) Close();
return 0;
+ case WM_CLOSE: Answer(false); return 0;
case WM_KEYDOWN:
if (w == VK_ESCAPE) Answer(false);
- else if (w == VK_RETURN) Answer(true);
+ else if (w == VK_RETURN) Answer(!g.owner || g.focus == 1);
else if (w == VK_SPACE) { if (g.focus == 2) Answer(false, true); else Answer(g.focus == 1); }
else if ((w == VK_TAB || w == VK_LEFT || w == VK_RIGHT || w == VK_DOWN || w == VK_UP) && !g.single) {
if (g.idThird) g.focus = g.focus == 1 ? 2 : g.focus == 2 ? 0 : 1;
diff --git a/src/shell/installed_apps.cpp b/src/shell/installed_apps.cpp
new file mode 100644
index 0000000..ae7fe56
--- /dev/null
+++ b/src/shell/installed_apps.cpp
@@ -0,0 +1,840 @@
+#include "shell.h"
+#include "installed_apps.h"
+#include "installed_apps_text.h"
+#include "../comum/semaforo.h"
+#include <commctrl.h>
+#include <dwmapi.h>
+#include <shellapi.h>
+#include <shlobj.h>
+#include <shlwapi.h>
+#include <uxtheme.h>
+#include <algorithm>
+#include <cstring>
+#include <cwctype>
+#include <map>
+
+#pragma comment(lib, "comctl32.lib")
+#pragma comment(lib, "shlwapi.lib")
+#pragma comment(lib, "uxtheme.lib")
+#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
+
+namespace {
+namespace words = installed_apps_text;
+using words::Get;
+
+struct App {
+ std::wstring name, publisher, version, command, productCode;
+ std::wstring directory, iconFile;
+ int iconIndex = 0;
+ HICON icon = nullptr;
+ bool triedIcon = false;
+ DWORD sizeKiB = 0;
+ FILETIME lastLaunch{};
+};
+
+enum : int { ID_LIST = 101, ID_REMOVE, ID_OPEN_APPS, ID_EXPLORER, ID_DONE, ID_CLOSE, ID_MINIMIZE, ID_ZOOM };
+HWND window, list, removeButton, openAppsButton, explorerButton, doneButton, closeButton;
+HWND minimizeButton, zoomButton, hoveredButton;
+RECT normalBounds{};
+bool zoomed, darkTheme;
+unsigned windowGeneration;
+HFONT font, headingFont;
+HIMAGELIST rowMetrics;
+HANDLE uninstallProcess;
+std::vector<App> appsList;
+std::wstring preferred;
+HICON headerIcon;
+std::wstring totalSize;
+
+bool LocalPath(const std::wstring& path) {
+ return path.size() > 2 && iswalpha(path[0]) && path[1] == L':' && path[2] == L'\\';
+}
+
+std::wstring ReadText(HKEY key, const wchar_t* name) {
+ DWORD size = 0;
+ constexpr DWORD flags = RRF_RT_REG_SZ | RRF_RT_REG_EXPAND_SZ;
+ if (RegGetValueW(key, nullptr, name, flags, nullptr, nullptr, &size) != ERROR_SUCCESS ||
+ size < sizeof(wchar_t) || size > 128 * 1024) return {};
+ std::wstring value(size / sizeof(wchar_t), L'\0');
+ if (RegGetValueW(key, nullptr, name, flags, nullptr, value.data(), &size) != ERROR_SUCCESS) return {};
+ value.resize(wcslen(value.c_str()));
+ return value;
+}
+
+DWORD ReadNumber(HKEY key, const wchar_t* name) {
+ DWORD value = 0, size = sizeof(value);
+ if (RegGetValueW(key, nullptr, name, RRF_RT_REG_DWORD, nullptr, &value, &size) != ERROR_SUCCESS) return 0;
+ return value;
+}
+
+void ReadRegistry(HKEY root, REGSAM view) {
+ HKEY entries;
+ if (RegOpenKeyExW(root, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", 0,
+ KEY_READ | view, &entries) != ERROR_SUCCESS) return;
+ for (DWORD i = 0; ; ++i) {
+ wchar_t id[256];
+ DWORD length = ARRAYSIZE(id);
+ LONG status = RegEnumKeyExW(entries, i, id, &length, nullptr, nullptr, nullptr, nullptr);
+ if (status == ERROR_NO_MORE_ITEMS) break;
+ if (status == ERROR_MORE_DATA) continue;
+ if (status != ERROR_SUCCESS) break;
+ HKEY entry;
+ if (RegOpenKeyExW(entries, id, 0, KEY_READ | view, &entry) != ERROR_SUCCESS) continue;
+ if (!ReadNumber(entry, L"SystemComponent") && !ReadNumber(entry, L"NoRemove") &&
+ ReadText(entry, L"ParentKeyName").empty()) {
+ App app;
+ app.name = ReadText(entry, L"DisplayName");
+ app.publisher = ReadText(entry, L"Publisher");
+ app.version = ReadText(entry, L"DisplayVersion");
+ app.command = ReadText(entry, L"UninstallString");
+ app.directory = ReadText(entry, L"InstallLocation");
+ app.iconFile = ReadText(entry, L"DisplayIcon");
+ auto comma = app.iconFile.find_last_of(L',');
+ if (comma != std::wstring::npos) {
+ wchar_t* end = nullptr;
+ auto suffix = app.iconFile.c_str() + comma + 1;
+ long index = wcstol(suffix, &end, 10);
+ if (end != suffix && !*end) {
+ app.iconIndex = index;
+ app.iconFile.resize(comma);
+ }
+ }
+ if (app.iconFile.size() >= 2 && app.iconFile.front() == 34 && app.iconFile.back() == 34)
+ app.iconFile = app.iconFile.substr(1, app.iconFile.size()-2);
+ if (!LocalPath(app.directory) && LocalPath(app.iconFile))
+ app.directory = app.iconFile.substr(0, app.iconFile.find_last_of(wchar_t(92)));
+ app.sizeKiB = ReadNumber(entry, L"EstimatedSize");
+ GUID product;
+ if (ReadNumber(entry, L"WindowsInstaller") && length == 38 && SUCCEEDED(CLSIDFromString(id, &product)))
+ app.productCode = id;
+ if (!app.name.empty() && (!app.command.empty() || !app.productCode.empty())) {
+ auto same = [&](const App& other) {
+ return app.name == other.name && app.version == other.version &&
+ app.publisher == other.publisher && app.command == other.command &&
+ app.productCode == other.productCode;
+ };
+ if (std::none_of(appsList.begin(), appsList.end(), same)) appsList.push_back(std::move(app));
+ }
+ }
+ RegCloseKey(entry);
+ }
+ RegCloseKey(entries);
+}
+
+struct PathLess {
+ bool operator()(const std::wstring& a, const std::wstring& b) const {
+ return CompareStringOrdinal(a.c_str(), -1, b.c_str(), -1, TRUE) == CSTR_LESS_THAN;
+ }
+};
+
+using LaunchHistory = std::map<std::wstring, FILETIME, PathLess>;
+
+std::wstring KnownFolder(REFKNOWNFOLDERID id) {
+ PWSTR path = nullptr;
+ std::wstring folder;
+ if (SUCCEEDED(SHGetKnownFolderPath(id, KF_FLAG_DONT_VERIFY, nullptr, &path))) folder = path;
+ CoTaskMemFree(path);
+ return folder;
+}
+
+using KnownFolders = std::map<std::wstring, std::wstring, PathLess>;
+
+std::wstring DecodeHistoryPath(std::wstring value, KnownFolders& folders) {
+ for (auto& ch : value) {
+ if (ch >= L'A' && ch <= L'Z') ch = L'A' + (ch - L'A' + 13) % 26;
+ else if (ch >= L'a' && ch <= L'z') ch = L'a' + (ch - L'a' + 13) % 26;
+ }
+ if (value.size() > 38 && value.front() == L'{' && value[38] == L'\\') {
+ auto id = value.substr(0, 38);
+ auto [entry, inserted] = folders.try_emplace(id);
+ if (inserted) {
+ GUID guid;
+ if (SUCCEEDED(CLSIDFromString(id.c_str(), &guid))) entry->second = KnownFolder(guid);
+ }
+ if (!entry->second.empty()) value.replace(0, 38, entry->second);
+ }
+ return value;
+}
+
+std::wstring ShortcutTarget(const std::wstring& path) {
+ IShellLinkW* link = nullptr;
+ if (FAILED(CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&link)))) return {};
+ wchar_t target[MAX_PATH]{};
+ IPersistFile* file = nullptr;
+ if (SUCCEEDED(link->QueryInterface(IID_PPV_ARGS(&file)))) {
+ if (SUCCEEDED(file->Load(path.c_str(), STGM_READ)))
+ link->GetPath(target, ARRAYSIZE(target), nullptr, SLGP_RAWPATH);
+ file->Release();
+ }
+ link->Release();
+ wchar_t expanded[MAX_PATH]{};
+ const DWORD length = ExpandEnvironmentStringsW(target, expanded, ARRAYSIZE(expanded));
+ if (length && length <= ARRAYSIZE(expanded)) return expanded;
+ return target;
+}
+
+bool IsUnderDirectory(std::wstring_view path, std::wstring_view directory) {
+ while (!directory.empty() && directory.back() == L'\\') directory.remove_suffix(1);
+ return !directory.empty() && path.size() > directory.size() && path[directory.size()] == L'\\' &&
+ CompareStringOrdinal(path.data(), int(directory.size()), directory.data(), int(directory.size()), TRUE) == CSTR_EQUAL;
+}
+
+void AddLaunch(LaunchHistory& history, std::wstring executable, FILETIME time) {
+ if (!LocalPath(executable) || _wcsicmp(PathFindExtensionW(executable.c_str()), L".exe")) return;
+ auto& previous = history[std::move(executable)];
+ if (CompareFileTime(&time, &previous) > 0) previous = time;
+}
+
+bool ReadLaunchTime(const BYTE* data, DWORD length, FILETIME now, FILETIME& time) {
+ // Windows 7+ UserAssist layout. Restrict reads to this known record version.
+ if (length != 72) return false;
+ DWORD focusTime = 0;
+ std::memcpy(&focusTime, data + 12, sizeof(focusTime));
+ std::memcpy(&time, data + 60, sizeof(time));
+ return focusTime && (time.dwHighDateTime || time.dwLowDateTime) && CompareFileTime(&time, &now) <= 0;
+}
+
+void CollectLaunches(HKEY key, bool shortcuts, LaunchHistory& history, KnownFolders& folders) {
+ FILETIME now{};
+ GetSystemTimeAsFileTime(&now);
+ const std::wstring programs = shortcuts ? KnownFolder(FOLDERID_Programs) : L"";
+ const std::wstring common = shortcuts ? KnownFolder(FOLDERID_CommonPrograms) : L"";
+ const std::wstring desktop = shortcuts ? KnownFolder(FOLDERID_Desktop) : L"";
+ const std::wstring publicDesktop = shortcuts ? KnownFolder(FOLDERID_PublicDesktop) : L"";
+ std::vector<wchar_t> name(16384);
+ for (DWORD i = 0; ; ++i) {
+ BYTE data[72]{};
+ DWORD nameLength = DWORD(name.size()), size = sizeof(data), type = 0;
+ const LSTATUS status = RegEnumValueW(key, i, name.data(), &nameLength, nullptr, &type, data, &size);
+ if (status == ERROR_MORE_DATA) continue;
+ if (status != ERROR_SUCCESS) break;
+ FILETIME time{};
+ if (type != REG_BINARY || !ReadLaunchTime(data, size, now, time)) continue;
+ auto path = DecodeHistoryPath(std::wstring(name.data(), nameLength), folders);
+ if (shortcuts) {
+ if (!LocalPath(path) || _wcsicmp(PathFindExtensionW(path.c_str()), L".lnk")) continue;
+ if (!IsUnderDirectory(path, programs) && !IsUnderDirectory(path, common) &&
+ !IsUnderDirectory(path, desktop) && !IsUnderDirectory(path, publicDesktop)) continue;
+ path = ShortcutTarget(path);
+ }
+ AddLaunch(history, std::move(path), time);
+ }
+}
+
+LaunchHistory ReadLaunchHistory() {
+ constexpr wchar_t userAssist[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\UserAssist\\";
+ const wchar_t* buckets[] = {
+ L"{CEBFF5CD-ACE2-4F4F-9178-9926F41749EA}\\Count",
+ L"{F4E57C4B-2036-45F0-A9AB-443BCFE33D9F}\\Count",
+ };
+ LaunchHistory history;
+ KnownFolders folders;
+ for (int i = 0; i < ARRAYSIZE(buckets); ++i) {
+ HKEY key;
+ if (RegOpenKeyExW(HKEY_CURRENT_USER, (std::wstring(userAssist) + buckets[i]).c_str(),
+ 0, KEY_QUERY_VALUE, &key) != ERROR_SUCCESS) continue;
+ CollectLaunches(key, i == 1, history, folders);
+ RegCloseKey(key);
+ }
+ return history;
+}
+
+FILETIME LastLaunch(const App& app, const LaunchHistory& history) {
+ FILETIME latest{};
+ auto icon = history.find(app.iconFile);
+ if (icon != history.end()) latest = icon->second;
+ if (!LocalPath(app.directory)) return latest;
+ // Avoid assigning launch times of other programs in a shared installation directory.
+ for (const auto& [path, time] : history) {
+ if (!IsUnderDirectory(path, app.directory)) continue;
+ std::wstring executable = PathFindFileNameW(path.c_str());
+ executable.resize(executable.size() - 4);
+ if (CompareStringOrdinal(app.name.c_str(), -1, executable.c_str(), -1, TRUE) == CSTR_EQUAL &&
+ CompareFileTime(&time, &latest) > 0) latest = time;
+ }
+ return latest;
+}
+
+std::wstring FormatLaunch(FILETIME stamp) {
+ SYSTEMTIME utc{}, local{};
+ if ((!stamp.dwHighDateTime && !stamp.dwLowDateTime) || !FileTimeToSystemTime(&stamp, &utc) ||
+ !SystemTimeToTzSpecificLocalTimeEx(nullptr, &utc, &local)) return L"—";
+ wchar_t date[64]{}, clock[32]{};
+ const auto locale = idioma::Locale();
+ if (!GetDateFormatEx(locale, DATE_SHORTDATE, &local, nullptr, date, ARRAYSIZE(date), nullptr) ||
+ !GetTimeFormatEx(locale, TIME_NOSECONDS, &local, nullptr, clock, ARRAYSIZE(clock))) return L"—";
+ return std::wstring(date) + L" " + clock;
+}
+
+std::wstring Lower(std::wstring text) {
+ for (auto& ch : text) ch = towlower(ch);
+ return text;
+}
+
+int Selected() {
+ int row = ListView_GetNextItem(list, -1, LVNI_SELECTED);
+ if (row < 0) return -1;
+ LVITEMW item{};
+ item.mask = LVIF_PARAM;
+ item.iItem = row;
+ return ListView_GetItem(list, &item) ? (int)item.lParam : -1;
+}
+
+void UpdateButtons() {
+ const int index = Selected();
+ EnableWindow(explorerButton, index >= 0 && size_t(index) < appsList.size() &&
+ LocalPath(appsList[index].directory) && PathIsDirectoryW(appsList[index].directory.c_str()));
+ if (window) InvalidateRect(window, nullptr, FALSE);
+ EnableWindow(removeButton, !uninstallProcess && index >= 0);
+}
+
+void FillList() {
+ int exactRow = -1, exactCount = 0, row = 0;
+ SendMessageW(list, WM_SETREDRAW, FALSE, 0);
+ ListView_DeleteAllItems(list);
+ for (size_t i = 0; i < appsList.size(); ++i) {
+ auto& app = appsList[i];
+ LVITEMW item{};
+ item.mask = LVIF_TEXT | LVIF_PARAM;
+ item.iItem = row;
+ item.pszText = app.name.data();
+ item.lParam = (LPARAM)i;
+ ListView_InsertItem(list, &item);
+ ListView_SetItemText(list, row, 1, const_cast<wchar_t*>(app.productCode.empty() ? L"Windows" : L"Windows Installer"));
+ auto lastLaunch = FormatLaunch(app.lastLaunch);
+ ListView_SetItemText(list, row, 2, lastLaunch.data());
+ wchar_t size[64] = L"—";
+ if (app.sizeKiB) StrFormatByteSizeW((LONGLONG)app.sizeKiB * 1024, size, ARRAYSIZE(size));
+ ListView_SetItemText(list, row, 3, size);
+ if (!preferred.empty() && !_wcsicmp(app.name.c_str(), preferred.c_str())) {
+ exactRow = row;
+ ++exactCount;
+ }
+ ++row;
+ }
+ if (exactCount == 1) {
+ ListView_SetItemState(list, exactRow, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
+ ListView_EnsureVisible(list, exactRow, FALSE);
+ }
+ SendMessageW(list, WM_SETREDRAW, TRUE, 0);
+ InvalidateRect(list, nullptr, TRUE);
+ UpdateButtons();
+}
+
+void ReleaseIcons() {
+ for (auto& app : appsList) if (app.icon) DestroyIcon(app.icon);
+}
+
+void Layout(HWND h);
+
+void Reload() {
+ ReleaseIcons();
+ appsList.clear();
+ for (auto view : { KEY_WOW64_64KEY, KEY_WOW64_32KEY }) {
+ ReadRegistry(HKEY_LOCAL_MACHINE, view);
+ ReadRegistry(HKEY_CURRENT_USER, view);
+ }
+ const auto history = ReadLaunchHistory();
+ for (auto& app : appsList) app.lastLaunch = LastLaunch(app, history);
+ std::stable_sort(appsList.begin(), appsList.end(), [](const App& a, const App& b) {
+ if (a.sizeKiB != b.sizeKiB) return a.sizeKiB > b.sizeKiB;
+ return _wcsicmp(a.name.c_str(), b.name.c_str()) < 0;
+ });
+ LONGLONG bytes = 0;
+ for (const auto& app : appsList) bytes += LONGLONG(app.sizeKiB) * 1024;
+ wchar_t size[64]{};
+ StrFormatByteSizeW(bytes, size, ARRAYSIZE(size));
+ totalSize = size;
+ FillList();
+ Layout(window);
+}
+
+bool CommandParts(const std::wstring& command, std::wstring& file, std::wstring& args) {
+ const auto start = command.find_first_not_of(L" \t");
+ if (start == std::wstring::npos) return false;
+ size_t end;
+ if (command[start] == L'"') {
+ end = command.find(L'"', start + 1);
+ if (end == std::wstring::npos) return false;
+ file = command.substr(start + 1, end++ - start - 1);
+ } else {
+ auto lower = Lower(command);
+ end = lower.find(L".exe", start);
+ while (end != std::wstring::npos && end + 4 < command.size() && !iswspace(command[end + 4]))
+ end = lower.find(L".exe", end + 4);
+ if (end == std::wstring::npos) return false;
+ end += 4;
+ file = command.substr(start, end - start);
+ }
+ if (file.size() < 7 || !iswalpha(file[0]) || file[1] != L':' || file[2] != L'\\' ||
+ _wcsicmp(file.c_str() + file.size() - 4, L".exe") || (end < command.size() && !iswspace(command[end]))) return false;
+ const DWORD attrs = GetFileAttributesW(file.c_str());
+ if (attrs == INVALID_FILE_ATTRIBUTES || (attrs & FILE_ATTRIBUTE_DIRECTORY)) return false;
+ args = command.substr(end);
+ return true;
+}
+
+void RunUninstaller(const std::wstring& file, const std::wstring& args, const std::wstring& icon) {
+ SHELLEXECUTEINFOW run{ sizeof(run) };
+ run.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI;
+ run.hwnd = window;
+ run.lpFile = file.c_str();
+ run.lpParameters = args.c_str();
+ run.nShow = SW_SHOWNORMAL;
+ if (!ShellExecuteExW(&run)) {
+ if (GetLastError() != ERROR_CANCELLED)
+ alertas::Prompt(window, Get(words::UninstallError), L"", Get(words::Ok), [] {}, icon, L"");
+ return;
+ }
+ uninstallProcess = run.hProcess;
+ if (uninstallProcess) SetTimer(window, 1, 400, nullptr);
+ else Reload();
+ UpdateButtons();
+}
+
+void RemoveSelected() {
+ const int index = Selected();
+ if (uninstallProcess || index < 0 || (size_t)index >= appsList.size()) return;
+ const auto app = appsList[index];
+ std::wstring file, args;
+ if (!app.productCode.empty()) {
+ wchar_t system[MAX_PATH];
+ UINT size = GetSystemDirectoryW(system, ARRAYSIZE(system));
+ if (size && size < ARRAYSIZE(system)) {
+ file = std::wstring(system) + L"\\msiexec.exe";
+ args = L"/x " + app.productCode;
+ }
+ } else if (!CommandParts(app.command, file, args)) {
+ file.clear();
+ }
+ const auto icon = LocalPath(app.iconFile) ? app.iconFile : L"pack:App Store";
+ const auto generation = windowGeneration;
+ if (file.empty()) {
+ alertas::Prompt(window, app.name, Get(words::WindowsFallback), Get(words::OpenSettings),
+ [generation] {
+ if (window && generation == windowGeneration)
+ ShellExecuteW(window, L"open", L"ms-settings:appsfeatures", nullptr, nullptr, SW_SHOWNORMAL);
+ }, icon, Get(words::Cancel));
+ return;
+ }
+ std::wstring question = Get(words::ConfirmUninstall);
+ question.replace(question.find(L"%ls"), 3, app.name);
+ auto details = app.publisher;
+ if (!app.version.empty()) details += (details.empty() ? L"" : L"\n") + app.version;
+ alertas::Prompt(window, question, details, Get(words::Delete),
+ [generation, file, args, icon] {
+ if (window && generation == windowGeneration && !uninstallProcess)
+ RunUninstaller(file, args, icon);
+ }, icon, Get(words::Cancel));
+}
+
+struct Palette {
+ COLORREF background, panel, stripe, field, text, muted, border, accent, pressed;
+};
+
+Palette Colors() {
+ if (darkTheme) return { RGB(31,32,34), RGB(38,39,41), RGB(44,45,47), RGB(52,53,55),
+ RGB(239,239,241), RGB(166,168,172), RGB(59,60,63), RGB(0,102,209), RGB(0,84,181) };
+ return { RGB(246,246,248), RGB(255,255,255), RGB(245,245,247), RGB(255,255,255),
+ RGB(30,30,32), RGB(96,98,104), RGB(219,220,223), RGB(0,102,209), RGB(0,84,181) };
+}
+
+int Px(int value) { return MulDiv(value, GetDpiForWindow(window), 96); }
+
+void Fill(HDC dc, const RECT& rect, COLORREF color) {
+ SetDCBrushColor(dc, color);
+ FillRect(dc, &rect, (HBRUSH)GetStockObject(DC_BRUSH));
+}
+
+void Rounded(HDC dc, const RECT& r, int radius, COLORREF fill, COLORREF edge) {
+ auto pen = SelectObject(dc, GetStockObject(DC_PEN));
+ auto brush = SelectObject(dc, GetStockObject(DC_BRUSH));
+ SetDCPenColor(dc, edge);
+ SetDCBrushColor(dc, fill);
+ RoundRect(dc, r.left, r.top, r.right, r.bottom, radius, radius);
+ SelectObject(dc, pen);
+ SelectObject(dc, brush);
+}
+
+void Label(HDC dc, std::wstring_view value, RECT rect, COLORREF color, UINT align = DT_LEFT) {
+ SetTextColor(dc, color);
+ SetBkMode(dc, TRANSPARENT);
+ DrawTextW(dc, value.data(), (int)value.size(), &rect, align | DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_END_ELLIPSIS);
+}
+
+const wchar_t* ColumnName(int index) {
+ constexpr words::Message columns[]{words::Name, words::Kind, words::LastLaunch, words::Size};
+ return Get(columns[index]);
+}
+
+void PaintWindow(HWND h) {
+ PAINTSTRUCT paint{};
+ HDC dc = BeginPaint(h, &paint);
+ RECT area{};
+ GetClientRect(h, &area);
+ const auto theme = Colors();
+ Fill(dc, area, theme.background);
+ const auto saved = SelectObject(dc, headingFont);
+ Fill(dc, { Px(20), Px(39), area.right - Px(20), Px(39) + 1 }, theme.border);
+ if (headerIcon) DrawIconEx(dc,Px(22),Px(53),headerIcon,Px(30),Px(30),0,nullptr,DI_NORMAL);
+ auto title = std::wstring(Get(words::Applications)) + L" — " + totalSize;
+ Label(dc,title,{Px(64),Px(48),area.right-Px(220),Px(70)},theme.text);
+ SelectObject(dc,font);
+ Label(dc,Get(words::Description),{Px(64),Px(69),area.right-Px(24),Px(89)},theme.muted);
+ int bottom = area.bottom - Px(111);
+ Rounded(dc,{Px(20),Px(96),area.right-Px(20),bottom},Px(7),theme.panel,theme.border);
+ int x = Px(21);
+ for (int i=0;i<4;++i) {
+ int width = ListView_GetColumnWidth(list,i);
+ std::wstring caption = ColumnName(i);
+ if (i == 3) caption += L" ⌄";
+ Label(dc,caption,{x+Px(8),Px(97),x+width-Px(6),Px(122)},theme.text,i==3 ? DT_RIGHT : DT_LEFT);
+ x += width;
+ if(i<3) Fill(dc,{x,Px(102),x+1,Px(117)},theme.border);
+ }
+ Fill(dc,{Px(21),Px(122),area.right-Px(21),Px(123)},theme.border);
+ RECT path{Px(21),bottom-Px(22),area.right-Px(21),bottom-1};
+ Fill(dc,path,theme.stripe);
+ path.left+=Px(7);
+ int index=Selected();
+ std::wstring crumb = Get(words::Applications);
+ if(index>=0 && size_t(index)<appsList.size()) crumb += L" › " + appsList[index].name;
+ Label(dc,crumb,path,theme.muted);
+ Fill(dc,{0,area.bottom-Px(61),area.right,area.bottom-Px(61)+1},theme.border);
+ SelectObject(dc, saved);
+ EndPaint(h, &paint);
+}
+
+LRESULT PaintRow(NMLVCUSTOMDRAW* draw) {
+ if (draw->nmcd.dwDrawStage == CDDS_PREPAINT) return CDRF_NOTIFYITEMDRAW;
+ if (draw->nmcd.dwDrawStage != CDDS_ITEMPREPAINT) return CDRF_DODEFAULT;
+ const int row = (int)draw->nmcd.dwItemSpec;
+ RECT line{}, client{};
+ if (!ListView_GetItemRect(list, row, &line, LVIR_BOUNDS)) return CDRF_DODEFAULT;
+ GetClientRect(list, &client);
+ line.left = 0;
+ line.right = client.right;
+ HDC dc = draw->nmcd.hdc;
+ const auto theme = Colors();
+ const bool selected = (ListView_GetItemState(list, row, LVIS_SELECTED) & LVIS_SELECTED) != 0;
+ Fill(dc, line, row % 2 ? theme.stripe : theme.panel);
+ if (selected) {
+ RECT selection{line.left + Px(3), line.top + Px(1), line.right - Px(3), line.bottom - Px(1)};
+ Rounded(dc, selection, Px(8), theme.accent, theme.accent);
+ }
+ LVITEMW item{};
+ item.mask=LVIF_PARAM;
+ item.iItem=row;
+ if (ListView_GetItem(list,&item) && size_t(item.lParam)<appsList.size()) {
+ auto& app=appsList[item.lParam];
+ if (!app.triedIcon) {
+ app.triedIcon=true;
+ if (LocalPath(app.iconFile)) ExtractIconExW(app.iconFile.c_str(),app.iconIndex,nullptr,&app.icon,1);
+ }
+ HICON icon=app.icon ? app.icon : LoadIconW(nullptr,IDI_APPLICATION);
+ DrawIconEx(dc,Px(9),(line.top+line.bottom-Px(16))/2,icon,Px(16),Px(16),0,nullptr,DI_NORMAL);
+ }
+ const auto prev = SelectObject(dc, font);
+ int x = 0;
+ for (int i = 0; i < 4; ++i) {
+ wchar_t cell[512]{};
+ ListView_GetItemText(list, row, i, cell, ARRAYSIZE(cell));
+ const int width = ListView_GetColumnWidth(list, i);
+ Label(dc, cell, { x + Px(i==0 ? 32 : 8), line.top, x + width - Px(6), line.bottom },
+ selected ? RGB(255,255,255) : i == 0 ? theme.text : theme.muted,
+ i == 3 ? DT_RIGHT : DT_LEFT);
+ x += width;
+ }
+ SelectObject(dc, prev);
+ return CDRF_SKIPDEFAULT;
+}
+
+void PaintButton(const DRAWITEMSTRUCT& draw) {
+ const auto theme = Colors();
+ const bool primary = draw.CtlID == ID_DONE && !(draw.itemState & ODS_DISABLED);
+ const bool pressed = (draw.itemState & ODS_SELECTED) != 0;
+ const bool hover = hoveredButton == draw.hwndItem;
+ const COLORREF fill = primary ? (pressed ? theme.pressed : theme.accent) :
+ (pressed || hover ? theme.stripe : theme.field);
+ Fill(draw.hDC, draw.rcItem, theme.background);
+ if (draw.CtlID >= ID_CLOSE && draw.CtlID <= ID_ZOOM) {
+ static const COLORREF normal[]{ RGB(255,95,86), RGB(255,189,46), RGB(39,201,63) };
+ static const COLORREF down[]{ RGB(218,75,68), RGB(220,157,35), RGB(29,168,50) };
+ const auto color = semaforo::Grafite() ? theme.muted : (pressed ? down : normal)[draw.CtlID - ID_CLOSE];
+ RECT dot{Px(3), Px(3), Px(17), Px(17)};
+ Rounded(draw.hDC, dot, Px(14), color, color);
+ if (hover || (draw.itemState & ODS_FOCUS)) {
+ const wchar_t* glyph = draw.CtlID == ID_CLOSE ? L"×" : draw.CtlID == ID_MINIMIZE ? L"−" : zoomed ? L"↙" : L"↗";
+ const auto previous = SelectObject(draw.hDC, font);
+ Label(draw.hDC, glyph, dot, RGB(48,44,44), DT_CENTER);
+ SelectObject(draw.hDC, previous);
+ }
+ return;
+ }
+ Rounded(draw.hDC, draw.rcItem, Px(12), fill, primary ? fill : theme.border);
+ wchar_t text[128]{};
+ GetWindowTextW(draw.hwndItem, text, ARRAYSIZE(text));
+ const auto prev = SelectObject(draw.hDC, font);
+ Label(draw.hDC, text, draw.rcItem, primary ? RGB(255,255,255) :
+ (draw.itemState & ODS_DISABLED ? theme.muted : theme.text), DT_CENTER);
+ SelectObject(draw.hDC, prev);
+ if (draw.itemState & ODS_FOCUS) {
+ RECT focus = draw.rcItem;
+ InflateRect(&focus, -Px(4), -Px(4));
+ DrawFocusRect(draw.hDC, &focus);
+ }
+}
+
+void SetMetrics() {
+ if (font) DeleteObject(font);
+ if (headingFont) DeleteObject(headingFont);
+ const auto family = ui::family.empty() ? L"Segoe UI" : ui::family.c_str();
+ font = CreateFontW(-Px(13), 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
+ DEFAULT_CHARSET, 0, 0, CLEARTYPE_QUALITY, 0, family);
+ headingFont = CreateFontW(-Px(16), 0, 0, 0, FW_SEMIBOLD, FALSE, FALSE, FALSE,
+ DEFAULT_CHARSET, 0, 0, CLEARTYPE_QUALITY, 0, family);
+ for (auto control : { list, removeButton, openAppsButton, explorerButton, doneButton, closeButton, minimizeButton, zoomButton })
+ SendMessageW(control, WM_SETFONT, (WPARAM)font, TRUE);
+ auto image = ImageList_Create(1, Px(22), ILC_COLOR32, 1, 1);
+ ListView_SetImageList(list, image, LVSIL_SMALL);
+ if (rowMetrics) ImageList_Destroy(rowMetrics);
+ rowMetrics = image;
+}
+
+void Layout(HWND h) {
+ RECT area{};
+ GetClientRect(h, &area);
+ int width = area.right, height = area.bottom;
+ MoveWindow(closeButton,Px(17),Px(10),Px(20),Px(20),TRUE);
+ MoveWindow(minimizeButton,Px(39),Px(10),Px(20),Px(20),TRUE);
+ MoveWindow(zoomButton,Px(61),Px(10),Px(20),Px(20),TRUE);
+ MoveWindow(openAppsButton,width-Px(214),Px(49),Px(194),Px(27),TRUE);
+ MoveWindow(list,Px(21),Px(123),width-Px(42),height-Px(257),TRUE);
+ MoveWindow(explorerButton,Px(20),height-Px(102),Px(194),Px(27),TRUE);
+ MoveWindow(removeButton,width-Px(123),height-Px(102),Px(103),Px(27),TRUE);
+ MoveWindow(doneButton,width-Px(108),height-Px(43),Px(88),Px(27),TRUE);
+ RECT client{};
+ GetClientRect(list, &client);
+ const int available = (std::min)(int(client.right), width - Px(42) - GetSystemMetricsForDpi(SM_CXVSCROLL,GetDpiForWindow(h)));
+ const int kind = Px(105);
+ const int lastLaunch = Px(159);
+ const int size = Px(91);
+ ListView_SetColumnWidth(list, 0, available - kind - lastLaunch - size);
+ ListView_SetColumnWidth(list, 1, kind);
+ ListView_SetColumnWidth(list, 2, lastLaunch);
+ ListView_SetColumnWidth(list, 3, size);
+ InvalidateRect(h, nullptr, FALSE);
+}
+
+void ToggleZoom(HWND h) {
+ RECT bounds = normalBounds;
+ if (!zoomed) {
+ MONITORINFO monitor{sizeof(monitor)};
+ if (!GetMonitorInfoW(MonitorFromWindow(h, MONITOR_DEFAULTTONEAREST), &monitor)) return;
+ GetWindowRect(h, &normalBounds);
+ bounds = monitor.rcWork;
+ }
+ zoomed = !zoomed;
+ SetWindowTextW(zoomButton, Get(zoomed ? words::Restore : words::Zoom));
+ SetWindowPos(h, nullptr, bounds.left, bounds.top, bounds.right - bounds.left, bounds.bottom - bounds.top,
+ SWP_NOZORDER | SWP_NOACTIVATE);
+}
+
+void ApplyTheme(HWND h) {
+ darkTheme = ui::Dark();
+ const BOOL dark = darkTheme;
+ const auto theme = Colors();
+ DwmSetWindowAttribute(h, DWMWA_USE_IMMERSIVE_DARK_MODE, &dark, sizeof(dark));
+ DwmSetWindowAttribute(h, DWMWA_BORDER_COLOR, &theme.border, sizeof(theme.border));
+ if (list) {
+ SetWindowTheme(list, darkTheme ? L"DarkMode_Explorer" : L"Explorer", nullptr);
+ ListView_SetBkColor(list, theme.panel);
+ ListView_SetTextBkColor(list, theme.panel);
+ InvalidateRect(list, nullptr, TRUE);
+ }
+ RedrawWindow(h, nullptr, nullptr, RDW_INVALIDATE | RDW_ALLCHILDREN);
+}
+
+LRESULT CALLBACK HandlePanelKeys(HWND child, UINT message, WPARAM w, LPARAM l, UINT_PTR id, DWORD_PTR) {
+ if (message == WM_KEYDOWN && w == VK_ESCAPE) {
+ PostMessageW(GetParent(child), WM_CLOSE, 0, 0);
+ return 0;
+ }
+ if (message == WM_KEYDOWN && w == VK_TAB) {
+ HWND next = GetNextDlgTabItem(GetParent(child), child, GetKeyState(VK_SHIFT) < 0);
+ if (next) SetFocus(next);
+ return 0;
+ }
+ if (id == 2 && message == WM_MOUSEMOVE && hoveredButton != child) {
+ HWND previous = hoveredButton;
+ hoveredButton = child;
+ TRACKMOUSEEVENT track{sizeof(track), TME_LEAVE, child, 0};
+ TrackMouseEvent(&track);
+ if (previous) InvalidateRect(previous, nullptr, FALSE);
+ InvalidateRect(child, nullptr, FALSE);
+ }
+ if (id == 2 && message == WM_MOUSELEAVE && hoveredButton == child) {
+ hoveredButton = nullptr;
+ InvalidateRect(child, nullptr, FALSE);
+ }
+ if (message == WM_NCDESTROY) RemoveWindowSubclass(child, HandlePanelKeys, id);
+ return DefSubclassProc(child, message, w, l);
+}
+
+LRESULT CALLBACK Proc(HWND h, UINT message, WPARAM w, LPARAM l) {
+ switch (message) {
+ case WM_NCHITTEST: {
+ POINT pt{short(LOWORD(l)),short(HIWORD(l))};
+ ScreenToClient(h,&pt);
+ if (window && pt.y >= 0 && pt.y < Px(90) && ChildWindowFromPointEx(h, pt, CWP_SKIPINVISIBLE) == h)
+ return HTCAPTION;
+ break;
+ }
+ case WM_ERASEBKGND: return 1;
+ case WM_PAINT: PaintWindow(h); return 0;
+ case WM_DRAWITEM: PaintButton(*reinterpret_cast<const DRAWITEMSTRUCT*>(l)); return TRUE;
+ case WM_ACTIVATE:
+ if (window && LOWORD(w) != WA_INACTIVE && ui::Dark() != darkTheme) ApplyTheme(h);
+ break;
+ case WM_SETTINGCHANGE:
+ if (window) ApplyTheme(h);
+ break;
+ case WM_NCLBUTTONDBLCLK:
+ if (w == HTCAPTION) { ToggleZoom(h); return 0; }
+ break;
+ case WM_GETMINMAXINFO: {
+ auto* info = reinterpret_cast<MINMAXINFO*>(l);
+ info->ptMinTrackSize = { (LONG)(590 * ui::Scale(h)), (LONG)(350 * ui::Scale(h)) };
+ return 0;
+ }
+ case WM_SIZE:
+ if (list && w != SIZE_MINIMIZED) Layout(h);
+ return 0;
+ case WM_DPICHANGED: {
+ if (list) SetMetrics();
+ const auto* rect = reinterpret_cast<const RECT*>(l);
+ SetWindowPos(h, nullptr, rect->left, rect->top, rect->right - rect->left, rect->bottom - rect->top,
+ SWP_NOZORDER | SWP_NOACTIVATE);
+ return 0;
+ }
+ case WM_COMMAND:
+ if (LOWORD(w) == ID_REMOVE) RemoveSelected();
+ if (LOWORD(w) == ID_OPEN_APPS) ShellExecuteW(h,L"open",L"shell:AppsFolder",nullptr,nullptr,SW_SHOWNORMAL);
+ if (LOWORD(w) == ID_DONE || LOWORD(w) == ID_CLOSE) PostMessageW(h, WM_CLOSE, 0, 0);
+ if (LOWORD(w) == ID_MINIMIZE) ShowWindow(h, SW_MINIMIZE);
+ if (LOWORD(w) == ID_ZOOM) ToggleZoom(h);
+ if (LOWORD(w) == ID_EXPLORER && IsWindowEnabled(explorerButton)) {
+ int index=Selected();
+ if(index>=0 && size_t(index)<appsList.size()) ShellExecuteW(h,L"explore",appsList[index].directory.c_str(),nullptr,nullptr,SW_SHOWNORMAL);
+ }
+ return 0;
+ case WM_NOTIFY:
+ if (reinterpret_cast<const NMHDR*>(l)->hwndFrom == list) {
+ const auto code = reinterpret_cast<const NMHDR*>(l)->code;
+ if (code == NM_CUSTOMDRAW) return PaintRow(reinterpret_cast<NMLVCUSTOMDRAW*>(l));
+ if (code == LVN_ITEMCHANGED) UpdateButtons();
+ }
+ return 0;
+ case WM_TIMER:
+ if (uninstallProcess && WaitForSingleObject(uninstallProcess, 0) != WAIT_TIMEOUT) {
+ KillTimer(h, 1);
+ CloseHandle(uninstallProcess);
+ uninstallProcess = nullptr;
+ Reload();
+ }
+ return 0;
+ case WM_DESTROY:
+ if (uninstallProcess) CloseHandle(uninstallProcess);
+ uninstallProcess = nullptr;
+ if (font) DeleteObject(font);
+ if (headingFont) DeleteObject(headingFont);
+ if (rowMetrics) ImageList_Destroy(rowMetrics);
+ font = headingFont = nullptr;
+ rowMetrics = nullptr;
+ window = list = removeButton = openAppsButton = explorerButton = doneButton = closeButton = nullptr;
+ minimizeButton = zoomButton = hoveredButton = nullptr;
+ zoomed = false;
+ ReleaseIcons();
+ if(headerIcon) DestroyIcon(headerIcon);
+ headerIcon=nullptr;
+ appsList.clear();
+ return 0;
+ }
+ return DefWindowProcW(h, message, w, l);
+}
+}
+
+const wchar_t* installed_apps::MenuLabel() {
+ return Get(words::UninstallApp);
+}
+
+void installed_apps::Open(const std::wstring& preferredName) {
+ preferred = preferredName;
+ if (!window) {
+ INITCOMMONCONTROLSEX controls{ sizeof(controls), ICC_LISTVIEW_CLASSES };
+ InitCommonControlsEx(&controls);
+ WNDCLASSW wc{};
+ wc.lpfnWndProc = Proc;
+ wc.style = CS_DBLCLKS;
+ wc.hInstance = shell::inst;
+ wc.hCursor = LoadCursorW(nullptr, IDC_ARROW);
+ wc.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW + 1);
+ wc.lpszClassName = L"WacOSInstalledApps";
+ RegisterClassW(&wc);
+ auto title = Get(words::Title);
+ const UINT dpi = GetDpiForSystem();
+ window = CreateWindowExW(WS_EX_APPWINDOW, wc.lpszClassName, title, WS_POPUP | WS_SYSMENU | WS_MINIMIZEBOX | WS_CLIPCHILDREN,
+ 0, 0, MulDiv(650, dpi, 96), MulDiv(482, dpi, 96),
+ nullptr, nullptr, shell::inst, nullptr);
+ if (!window) return;
+ ++windowGeneration;
+ POINT cursor{};
+ GetCursorPos(&cursor);
+ MONITORINFO mon{sizeof(mon)};
+ GetMonitorInfoW(MonitorFromPoint(cursor,MONITOR_DEFAULTTONEAREST),&mon);
+ RECT bounds{};
+ GetWindowRect(window,&bounds);
+ SetWindowPos(window,nullptr,(mon.rcWork.left+mon.rcWork.right-bounds.right)/2,
+ (mon.rcWork.top+mon.rcWork.bottom-bounds.bottom)/2,0,0,SWP_NOSIZE|SWP_NOZORDER);
+ DWM_WINDOW_CORNER_PREFERENCE corners=DWMWCP_ROUND;
+ DwmSetWindowAttribute(window,DWMWA_WINDOW_CORNER_PREFERENCE,&corners,sizeof(corners));
+ SHSTOCKICONINFO icon{sizeof(icon)};
+ if (SUCCEEDED(SHGetStockIconInfo(SIID_APPLICATION, SHGSI_ICON, &icon))) headerIcon = icon.hIcon;
+ auto child = [&](const wchar_t* cls, const wchar_t* label, DWORD style, int id) {
+ HWND control = CreateWindowExW(0, cls, label, WS_CHILD | WS_VISIBLE | style,
+ 0, 0, 0, 0, window, (HMENU)(INT_PTR)id, shell::inst, nullptr);
+ SetWindowSubclass(control, HandlePanelKeys, id == ID_LIST ? 1 : 2, 0);
+ return control;
+ };
+ closeButton = child(WC_BUTTONW, Get(words::Close), BS_OWNERDRAW | WS_TABSTOP, ID_CLOSE);
+ minimizeButton = child(WC_BUTTONW, Get(words::Minimize), BS_OWNERDRAW | WS_TABSTOP, ID_MINIMIZE);
+ zoomButton = child(WC_BUTTONW, Get(words::Zoom), BS_OWNERDRAW | WS_TABSTOP, ID_ZOOM);
+ openAppsButton = child(WC_BUTTONW, Get(words::OpenApplications), BS_OWNERDRAW | WS_TABSTOP, ID_OPEN_APPS);
+ list = child(WC_LISTVIEWW, L"", LVS_REPORT | LVS_NOCOLUMNHEADER | LVS_SINGLESEL | LVS_SHOWSELALWAYS | WS_TABSTOP, ID_LIST);
+ ListView_SetExtendedListViewStyle(list, LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_LABELTIP);
+ for (int i = 0; i < 4; ++i) {
+ LVCOLUMNW column{};
+ column.mask = LVCF_TEXT | LVCF_FMT;
+ column.pszText = const_cast<wchar_t*>(ColumnName(i));
+ column.fmt = i == 3 ? LVCFMT_RIGHT : LVCFMT_LEFT;
+ ListView_InsertColumn(list, i, &column);
+ }
+ explorerButton = child(WC_BUTTONW, Get(words::ShowInExplorer), BS_OWNERDRAW | WS_TABSTOP, ID_EXPLORER);
+ removeButton = child(WC_BUTTONW, Get(words::Delete), BS_OWNERDRAW | WS_TABSTOP, ID_REMOVE);
+ doneButton = child(WC_BUTTONW, Get(words::Done), BS_OWNERDRAW | WS_TABSTOP, ID_DONE);
+ SetMetrics();
+ }
+ SetWindowTextW(window, Get(words::Title));
+ SetWindowTextW(closeButton, Get(words::Close));
+ SetWindowTextW(minimizeButton, Get(words::Minimize));
+ SetWindowTextW(zoomButton, Get(zoomed ? words::Restore : words::Zoom));
+ SetWindowTextW(openAppsButton, Get(words::OpenApplications));
+ SetWindowTextW(explorerButton, Get(words::ShowInExplorer));
+ SetWindowTextW(removeButton, Get(words::Delete));
+ SetWindowTextW(doneButton, Get(words::Done));
+ ApplyTheme(window);
+ Reload();
+ ShowWindow(window, SW_RESTORE);
+ SetForegroundWindow(window);
+ SetFocus(list);
+}
diff --git a/src/shell/installed_apps.h b/src/shell/installed_apps.h
new file mode 100644
index 0000000..9d8a085
--- /dev/null
+++ b/src/shell/installed_apps.h
@@ -0,0 +1,7 @@
+#pragma once
+#include <string>
+
+namespace installed_apps {
+const wchar_t* MenuLabel();
+void Open(const std::wstring& preferredName);
+}
diff --git a/src/shell/installed_apps_text.h b/src/shell/installed_apps_text.h
new file mode 100644
index 0000000..6e97cef
--- /dev/null
+++ b/src/shell/installed_apps_text.h
@@ -0,0 +1,41 @@
+#pragma once
+
+#include "../comum/idioma.h"
+
+namespace installed_apps_text {
+enum Message {
+ Title, Applications, Description, Name, Kind, LastLaunch, Size, OpenApplications,
+ ShowInExplorer, Delete, Done, Close, UninstallApp, ConfirmUninstall, WindowsFallback,
+ UninstallError, Cancel, OpenSettings, Ok, Minimize, Zoom, Restore, Count
+};
+
+inline const wchar_t* Get(Message message) {
+ // Columns follow idioma::Lang, including languages displayed later in the settings menu.
+ static constexpr const wchar_t* strings[][idioma::COUNT] = {
+ {L"Aplicativos instalados", L"Installed Applications", L"Aplicaciones instaladas", L"Applications installées", L"Installierte Apps", L"Applicazioni installate", L"インストール済みアプリ", L"已安装的应用", L"설치된 앱", L"Установленные приложения", L"Zainstalowane aplikacje", L"Yüklü uygulamalar"},
+ {L"Aplicativos", L"Applications", L"Aplicaciones", L"Applications", L"Apps", L"Applicazioni", L"アプリケーション", L"应用程序", L"응용 프로그램", L"Приложения", L"Aplikacje", L"Uygulamalar"},
+ {L"Remova aplicativos para liberar espaço.", L"Remove applications to free up storage space.", L"Elimina aplicaciones para liberar espacio.", L"Supprimez des applications pour libérer de l’espace.", L"Entferne Apps, um Speicherplatz freizugeben.", L"Rimuovi le applicazioni per liberare spazio.", L"アプリを削除してストレージの空き容量を増やせます。", L"移除应用以释放存储空间。", L"앱을 제거하여 저장 공간을 확보하세요.", L"Удалите приложения, чтобы освободить место.", L"Usuń aplikacje, aby zwolnić miejsce.", L"Depolama alanı açmak için uygulamaları kaldırın."},
+ {L"Nome", L"Name", L"Nombre", L"Nom", L"Name", L"Nome", L"名前", L"名称", L"이름", L"Название", L"Nazwa", L"Ad"},
+ {L"Tipo", L"Kind", L"Tipo", L"Type", L"Typ", L"Tipo", L"種類", L"类型", L"종류", L"Тип", L"Typ", L"Tür"},
+ {L"Última abertura", L"Last Opened", L"Última apertura", L"Dernière ouverture", L"Zuletzt geöffnet", L"Ultima apertura", L"最後に開いた日時", L"上次打开", L"마지막 실행", L"Последний запуск", L"Ostatnie uruchomienie", L"Son açılış"},
+ {L"Tamanho", L"Size", L"Tamaño", L"Taille", L"Größe", L"Dimensioni", L"サイズ", L"大小", L"크기", L"Размер", L"Rozmiar", L"Boyut"},
+ {L"Abrir Aplicativos", L"Open Applications", L"Abrir aplicaciones", L"Ouvrir Applications", L"Apps öffnen", L"Apri Applicazioni", L"アプリケーションを開く", L"打开应用程序", L"응용 프로그램 열기", L"Открыть приложения", L"Otwórz aplikacje", L"Uygulamaları aç"},
+ {L"Mostrar no Explorador", L"Show in Explorer", L"Mostrar en el Explorador", L"Afficher dans l’Explorateur", L"Im Explorer anzeigen", L"Mostra in Esplora file", L"エクスプローラーで表示", L"在资源管理器中显示", L"파일 탐색기에서 보기", L"Показать в Проводнике", L"Pokaż w Eksploratorze", L"Dosya Gezgini’nde göster"},
+ {L"Remover…", L"Delete…", L"Eliminar…", L"Supprimer…", L"Entfernen…", L"Rimuovi…", L"削除…", L"移除…", L"제거…", L"Удалить…", L"Usuń…", L"Kaldır…"},
+ {L"Concluído", L"Done", L"Listo", L"Terminé", L"Fertig", L"Fine", L"完了", L"完成", L"완료", L"Готово", L"Gotowe", L"Bitti"},
+ {L"Fechar", L"Close", L"Cerrar", L"Fermer", L"Schließen", L"Chiudi", L"閉じる", L"关闭", L"닫기", L"Закрыть", L"Zamknij", L"Kapat"},
+ {L"Desinstalar aplicativo…", L"Uninstall App…", L"Desinstalar aplicación…", L"Désinstaller l’application…", L"App deinstallieren…", L"Disinstalla applicazione…", L"アプリをアンインストール…", L"卸载应用…", L"앱 제거…", L"Удалить приложение…", L"Odinstaluj aplikację…", L"Uygulamayı kaldır…"},
+ {L"Desinstalar «%ls»?", L"Uninstall “%ls”?", L"¿Desinstalar «%ls»?", L"Désinstaller « %ls » ?", L"„%ls“ deinstallieren?", L"Disinstallare «%ls»?", L"「%ls」をアンインストールしますか?", L"要卸载“%ls”吗?", L"‘%ls’ 앱을 제거하시겠습니까?", L"Удалить «%ls»?", L"Odinstalować „%ls”?", L"“%ls” kaldırılsın mı?"},
+ {L"Abra os Aplicativos instalados do Windows para desinstalar este aplicativo.", L"Open Windows Installed Apps to uninstall this application.", L"Abre Aplicaciones instaladas de Windows para desinstalar esta aplicación.", L"Ouvrez les applications installées de Windows pour désinstaller cette application.", L"Öffne die installierten Apps in Windows, um diese App zu deinstallieren.", L"Apri App installate di Windows per disinstallare questa applicazione.", L"このアプリを削除するには、Windows の「インストールされているアプリ」を開いてください。", L"请打开 Windows 的“已安装的应用”来卸载此应用。", L"이 앱을 제거하려면 Windows의 설치된 앱을 여세요.", L"Чтобы удалить это приложение, откройте список установленных приложений Windows.", L"Otwórz Zainstalowane aplikacje systemu Windows, aby odinstalować tę aplikację.", L"Bu uygulamayı kaldırmak için Windows Yüklü uygulamalar sayfasını açın."},
+ {L"Não foi possível abrir o desinstalador.", L"Could not open the uninstaller.", L"No se pudo abrir el desinstalador.", L"Impossible d’ouvrir le programme de désinstallation.", L"Das Deinstallationsprogramm konnte nicht geöffnet werden.", L"Impossibile aprire il programma di disinstallazione.", L"アンインストーラーを開けませんでした。", L"无法打开卸载程序。", L"제거 프로그램을 열 수 없습니다.", L"Не удалось запустить деинсталлятор.", L"Nie udało się otworzyć deinstalatora.", L"Kaldırma programı açılamadı."},
+ {L"Cancelar", L"Cancel", L"Cancelar", L"Annuler", L"Abbrechen", L"Annulla", L"キャンセル", L"取消", L"취소", L"Отмена", L"Anuluj", L"İptal"},
+ {L"Abrir Configurações", L"Open Settings", L"Abrir Configuración", L"Ouvrir les paramètres", L"Einstellungen öffnen", L"Apri Impostazioni", L"設定を開く", L"打开设置", L"설정 열기", L"Открыть настройки", L"Otwórz ustawienia", L"Ayarları aç"},
+ {L"OK", L"OK", L"Aceptar", L"OK", L"OK", L"OK", L"OK", L"确定", L"확인", L"ОК", L"OK", L"Tamam"},
+ {L"Minimizar", L"Minimize", L"Minimizar", L"Réduire", L"Minimieren", L"Riduci a icona", L"最小化", L"最小化", L"최소화", L"Свернуть", L"Minimalizuj", L"Simge durumuna küçült"},
+ {L"Maximizar", L"Maximize", L"Maximizar", L"Agrandir", L"Maximieren", L"Ingrandisci", L"最大化", L"最大化", L"최대화", L"Развернуть", L"Maksymalizuj", L"Ekranı kapla"},
+ {L"Restaurar tamanho", L"Restore Size", L"Restaurar tamaño", L"Rétablir la taille", L"Größe wiederherstellen", L"Ripristina dimensioni", L"サイズを元に戻す", L"还原大小", L"크기 복원", L"Восстановить размер", L"Przywróć rozmiar", L"Boyutu geri yükle"},
+ };
+ static_assert(ARRAYSIZE(strings) == Count);
+ return strings[message][idioma::Current()];
+}
+}
diff --git a/src/shell/launchpad.cpp b/src/shell/launchpad.cpp
index 1bf041f..745638d 100644
--- a/src/shell/launchpad.cpp
+++ b/src/shell/launchpad.cpp
@@ -32,6 +32,7 @@ static ID2D1Bitmap* StyledBitmap(ID2D1RenderTarget* rt, UINT w, UINT h, const st
#include <thread>
#include "../comum/idioma.h"
#include "../menu/context_menu.h"
+#include "installed_apps.h"
namespace {
@@ -1008,14 +1009,16 @@ LRESULT CALLBACK Proc(HWND h, UINT m, WPARAM w, LPARAM l) {
{ Tr(L"Alterar Ícone…"), 3, false, false, false, L"", {}, 0xEB9F } };
if (apps::HasCustomIcon(name, exe)) extra.push_back({ Tr(L"Restaurar Ícone Original"), 4, false, false, false, L"", {}, 0xE7A7 });
extra.push_back({ Tr(L"Renomear…"), 5, false, false, false, L"", {}, 0xE8AC }); // pedido no Discord
+ extra.push_back({ installed_apps::MenuLabel(), 6, false, false, false, L"", {}, 0xE74D });
ctxmenu::ExtraNext(extra);
- auto res = ctxmenu::Show(h, sp, L"shell:AppsFolder", { path }, GetKeyState(VK_SHIFT) < 0);
+ auto res = ctxmenu::Show(h, sp, L"shell:AppsFolder", { path }, GetKeyState(VK_SHIFT) < 0, true);
ctxmenu::ExtraNext({});
Log(L"launchpad: menu de %ls%ls", name.c_str(), res.chosen ? L" (comando escolhido)" : L"");
if (res.extra == 2) { launchpad::Ocultar(name); { std::lock_guard<std::mutex> lk(g_mu); Filter(); } Paint(); return 0; }
if (res.extra == 3) { Close(); apps::ChooseIcon(name, exe); return 0; } // o Launchpad cobre a tela: fecha antes da janela de Abrir
if (res.extra == 4) { apps::RestoreIcon(name, exe); return 0; }
if (res.extra == 5) { Close(); apps::Renomear(name, exe); return 0; }
+ if (res.extra == 6 || res.verb == L"uninstall") { Close(); installed_apps::Open(name); return 0; }
if (res.chosen) Close();
return 0;
}
diff --git a/src/shell/shell.h b/src/shell/shell.h
index aaa9498..2427970 100644
--- a/src/shell/shell.h
+++ b/src/shell/shell.h
@@ -355,6 +355,8 @@ void Stop();
// icon: "" = Lixeira, "pack:<nome>" = icones\sequoia\<nome>.png, senão o caminho de um programa
// no: o texto do outro botão ("" = Cancelar). Devolve false se já havia um alerta aberto (este não aparece)
bool Confirm(const std::wstring& title, const std::wstring& info, const std::wstring& yes, std::function<void()> onYes, const std::wstring& icon = L"", const std::wstring& no = L"");
+bool Prompt(HWND owner, const std::wstring& title, const std::wstring& info, const std::wstring& yes,
+ std::function<void()> onYes, const std::wstring& icon, const std::wstring& cancel);
}
namespace progresso { // janela de progresso do Windows (copiar, mover, apagar...) trocada pela do Finder (progresso.cpp)
bool Create(HINSTANCE hi);