Compare commits

...

2 Commits

14 changed files with 57 additions and 27 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.24)
project(KSwitcher VERSION 0.6.40 LANGUAGES CXX RC)
project(KSwitcher VERSION 0.6.42 LANGUAGES CXX RC)
if(NOT WIN32)
message(FATAL_ERROR "KSwitcher uses native Windows APIs")
endif()
+4
View File
@@ -720,6 +720,10 @@ Consecutive duplicates use SHA-256 fingerprints inside the encrypted history ind
Moving OCR isolates its temporary memory rather than reducing the combined processing peak. A controlled three-run comparison retained about 0.8 MiB less private RAM in the caller after recognition; combined peak RAM was about 55.6 MiB before and 56.6 MiB with the helper. Results depend on the image, OCR engine and system.
### Pinned history checkbox — v0.6.42
Check **★ Pinned only** beside the history search box to show only pinned entries; uncheck it to show all entries. The checkbox sits on the left, immediately followed by the search box; its right edge stays aligned with the history list when resizing. The text search applies within that filter. Unpinning an item removes it from the pinned view immediately. The checkbox state and search are remembered after closing and reopening history. **Clear history…** still deletes the entire history after confirmation, including entries hidden by the filter.
### History process and clipboard memory — v0.6.40
History opens in a separate, short-lived instance of **KSwitcher.exe**. **Esc** closes it even when focus is on the window or an action button, releasing Windows UI allocations with the process. The resident keeps keyboard hooks, clipboard capture and history storage. Search, selection and the top entry are preserved in encrypted view state. If a full-text item viewer is still open, the helper stays alive until the last viewer closes. Pin/delete, formatted/plain paste and OCR remain available; settings and default shortcuts are unchanged.
Binary file not shown.
+7 -10
View File
@@ -1,19 +1,16 @@
# Latest Windows release
## v0.6.40 — 2026-11-04
v0.6.40 supersedes v0.6.39 to align Windows resource version metadata in the tagged source with the shipped binaries. Functional memory fixes are unchanged.
## v0.6.42 — 2026-11-04
## Changes
- Clipboard history runs in a separate, short-lived instance of KSwitcher.exe. Closing history with Esc releases its UI process instead of retaining Windows UI allocations in the resident. Esc also works when the window itself or an action button has focus.
- Search, selected/top entry, pinning, deletion, formatted/plain paste and OCR remain available. Search and selection are saved in encrypted view state. An open full-text viewer keeps the history process alive until that viewer closes.
- Large image clipboard backups and image thumbnail decoding run in KSwitcher.Screenshot.exe. Encrypted temporary files and clipboard-sequence checks preserve the clipboard without keeping full backup images in the resident. Selection reads avoid unnecessary image copies.
- History paste waits briefly for the target application's foreground activation after the history process closes, while retaining input and clipboard ownership checks. Settings and default shortcuts are unchanged; UI Automation remains in the resident.
- Replaced the history filter dropdown with a one-click **★ Pinned only** checkbox. Checked shows pinned entries; unchecked shows all entries.
- The checkbox sits on the left, with the search field immediately alongside it. The search field keeps its right edge aligned with the history list when the window is resized.
- Existing filter state, search, Unpin behavior and persistence across Esc are preserved. No shortcut or default changed. Clear history still deletes every entry after confirmation, including hidden entries.
## Validation and memory
The complete staged build passed dictionary equivalence (140,939 words), 105 sync checks, 315 native checks, 561 input checks, screenshot UI/save/registration, 48 updater checks and progress UI, clipboard snapshot/image capture integration, conversion/snippet integration and Windows OCR. Dedicated 500-entry history tests cover repeated Esc, search persistence, pin/delete, full-viewer lifetime, text/image paste, clipboard restoration, rejected foreign requests and helper shutdown. Actual selected/repeated Viber conversion and live Esc were also checked during development.
## Validation
The dedicated 500-entry history integration suite verifies checkbox clicks, combined search/filter, removal after Unpin, remembered state after helper restart, text/image paste and helper shutdown. The compact layout was checked visually in the installed development build.
A local live development-build comparison measured **4.37 MiB before opening history and 4.35 MiB after two open/Esc cycles**, versus an earlier roughly 8–9 MiB plateau after closing history. A same-image backup benchmark reduced retained private resident memory from 12.78 MiB to 0.05 MiB. These are workload-specific observations, not a guaranteed footprint. Count all helper processes while history/OCR is active: combined active memory can be higher. No forced working-set trimming was used.
The release build also passed dictionary equivalence (140,939 words), 105 sync checks, 315 native checks, 561 input checks, screenshot UI/save/registration, 48 updater checks and updater progress UI.
## Upgrade
Choose **Update** in the tray menu. Legacy v0.3.0–v0.4.1 clients first receive the v0.4.2 compatibility bridge, then the current full release. v0.2.3 and earlier require manual installation.
+1 -1
View File
@@ -1 +1 @@
cbe7839c849758b4623939dc025ec246a9fb97f5587df37ca6c3bd8eec244136 KSwitcher-win-x64.zip
67cb67d4c08a8722fdd91bb513a9254d781cbee524d2e2eb39721251503b01c9 KSwitcher-win-x64.zip
+3 -3
View File
@@ -9,8 +9,8 @@ IDC_SCREENSHOT_PENCIL CURSOR "icons/lucide/pencil.cur"
1 RT_MANIFEST "app.manifest"
201 RCDATA "update.ps1"
1 VERSIONINFO
FILEVERSION 0,6,40,0
PRODUCTVERSION 0,6,40,0
FILEVERSION 0,6,42,0
PRODUCTVERSION 0,6,42,0
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_APP
BEGIN
@@ -20,7 +20,7 @@ BEGIN
BEGIN
VALUE "FileDescription", "KSwitcher — native keyboard and clipboard utility"
VALUE "ProductName", "KSwitcher"
VALUE "FileVersion", "0.6.40"
VALUE "FileVersion", "0.6.42"
END
END
BLOCK "VarFileInfo"
+1
View File
@@ -2078,6 +2078,7 @@ int App::execute()
historySelection = wide(state.value("selection", std::string{}));
historyTop = wide(state.value("top", std::string{}));
historyQuery = wide(state.value("query", std::string{}));
historyPinnedOnly = state.value("pinnedOnly", false);
} catch (...) {}
showHistory(*this);
remoteHistory("ready", std::to_wstring(reinterpret_cast<uintptr_t>(historyWindow)));
+2 -1
View File
@@ -37,6 +37,7 @@ class App
bool isolateHistory{};
unsigned historyEntryWindows{};
std::wstring historySelection, historyTop, historyQuery;
bool historyPinnedOnly{};
HINSTANCE instance{};
std::filesystem::path data;
std::vector<Layout> layouts;
@@ -80,7 +81,7 @@ class App
void refreshHistoryProcess();
void remoteHistory(const char *action, const std::wstring &id = {}, bool plain = false);
LRESULT historyRequest(HWND, const COPYDATASTRUCT &);
void saveHistoryView(const std::wstring &, const std::wstring &, const std::wstring &);
void saveHistoryView(const std::wstring &, const std::wstring &, const std::wstring &, bool);
void clearLog(bool previous);
void setHotkeyCapture(HWND);
bool isHotkey(DWORD, UINT);
+2 -2
View File
@@ -90,11 +90,11 @@ LRESULT App::historyRequest(HWND sender, const COPYDATASTRUCT &message)
return TRUE;
} catch (...) { return FALSE; }
}
void App::saveHistoryView(const std::wstring &selection, const std::wstring &top, const std::wstring &query)
void App::saveHistoryView(const std::wstring &selection, const std::wstring &top, const std::wstring &query, bool pinnedOnly)
{
if (!historyService) return;
try {
auto text = HistoryJson{{"selection", utf8(selection)}, {"top", utf8(top)}, {"query", utf8(query)}}.dump();
auto text = HistoryJson{{"selection", utf8(selection)}, {"top", utf8(top)}, {"query", utf8(query)}, {"pinnedOnly", pinnedOnly}}.dump();
atomicWrite(data / L"history-view.bin", protect(Bytes(text.begin(), text.end())));
} catch (...) {} // Closing the UI must still release its process if state cannot be saved.
}
+2 -1
View File
@@ -924,9 +924,10 @@ std::optional<std::wstring> History::ocrText(const std::wstring &id, const std::
if (bytes.empty() || bytes.front() != 1) throw std::runtime_error("Invalid OCR text format");
return wide(std::string(bytes.begin() + 1, bytes.end()));
}
std::vector<Entry> History::search(const std::wstring &query) const
std::vector<Entry> History::search(const std::wstring &query, bool pinnedOnly) const
{
auto items = entries();
if (pinnedOnly) std::erase_if(items, [](const Entry &entry) { return !entry.pinned; });
if (query.empty())
return items;
auto q = lower(query);
+1 -1
View File
@@ -43,7 +43,7 @@ class History
void remove(const std::wstring &);
void pin(const std::wstring &);
void clear();
std::vector<Entry> search(const std::wstring &) const;
std::vector<Entry> search(const std::wstring &, bool pinnedOnly = false) const;
};
Bytes encodeClip(const Clip &);
Clip decodeClip(const Bytes &);
+16 -5
View File
@@ -514,15 +514,16 @@ void search(HWND w, HistoryView *v)
v->previewActive = std::make_shared<std::atomic<bool>>(true);
v->closed = false;
auto q = value(w, 101);
const bool pinnedOnly = SendDlgItemMessageW(w, 117, BM_GETCHECK, 0, 0) == BST_CHECKED;
auto generation = ++v->generation;
v->pending.clear();
auto *app = v->app;
app->enqueueHistorySearch(
[w, app, q, generation]
[w, app, q, generation, pinnedOnly]
{
try
{
auto result = new SearchResult{generation, app->history->search(q)};
auto result = new SearchResult{generation, app->history->search(q, pinnedOnly)};
if (!PostMessageW(w, ResultsMessage, 0, (LPARAM)result))
delete result;
}
@@ -739,6 +740,12 @@ LRESULT CALLBACK historyProc(HWND w, UINT msg, WPARAM wp, LPARAM lp)
case WM_COMMAND:
{
int id = LOWORD(wp);
if (id == 117 && HIWORD(wp) == BN_CLICKED)
{
KillTimer(w, 1);
search(w, v);
return 0;
}
if (id == 101 && HIWORD(wp) == EN_CHANGE)
{
// Reject an older result even during the debounce interval.
@@ -910,7 +917,8 @@ LRESULT CALLBACK historyProc(HWND w, UINT msg, WPARAM wp, LPARAM lp)
v->rememberedSelection = selected(w, v);
int top = (int)SendDlgItemMessageW(w,102,LB_GETTOPINDEX,0,0);
v->rememberedTop = top >= 0 && top < (int)v->items.size() ? v->items[top].id : L"";
v->app->saveHistoryView(v->rememberedSelection, v->rememberedTop, value(w, 101));
v->app->saveHistoryView(v->rememberedSelection, v->rememberedTop, value(w, 101),
SendDlgItemMessageW(w, 117, BM_GETCHECK, 0, 0) == BST_CHECKED);
KillTimer(w, 1);
v->closed = true;
v->previewActive->store(false);
@@ -1737,8 +1745,11 @@ void showHistory(App &app, bool visible)
HWND w = makeWindow(app, L"KSwitcher.History", L"Clipboard history", historyProc, 760, 500);
app.historyWindow = w;
windowLayoutState(w)->history = true;
label(w, L"&Search clipboard history", 16, 12, 500);
edit(w, 101, 16, 38, 728);
auto filter = control(w, L"BUTTON", L"★ Pinned only", WS_TABSTOP | BS_AUTOCHECKBOX,
117, 16, 38, 112, 25);
SendMessageW(filter, BM_SETCHECK, app.historyPinnedOnly ? BST_CHECKED : BST_UNCHECKED, 0);
label(w, L"&Search clipboard history", 136, 12, 500);
edit(w, 101, 136, 38, 608);
auto list = control(w, L"LISTBOX", L"",
WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT | WS_BORDER |
LBS_OWNERDRAWFIXED | LBS_HASSTRINGS,
+1 -1
View File
@@ -2,7 +2,7 @@
#include "platform.h"
namespace ks
{
inline constexpr wchar_t AppVersion[] = L"0.6.40";
inline constexpr wchar_t AppVersion[] = L"0.6.42";
inline constexpr UINT UpdateMessage = WM_APP + 7;
inline constexpr UINT UpdateCheckIntervalMs = 6 * 60 * 60 * 1000;
inline constexpr UINT UpdateNotificationRetryMs = 5 * 60 * 1000;
+16 -1
View File
@@ -112,9 +112,24 @@ int main() {
auto w=open();send(w,WM_COMMAND,112);
until([&]{history.reload();return history.entries().front().pinned;},"resident pin mutation");
require(history.entries().front().id==textId,"pin preserves history identity");
auto filter=[&](HWND window,int index) {
auto checkbox=GetDlgItem(window,117);
if(send(checkbox,BM_GETCHECK)!=(index ? BST_CHECKED : BST_UNCHECKED)) send(checkbox,BM_CLICK);
};
filter(w,1);
until([&]{return send(GetDlgItem(w,102),LB_GETCOUNT)==1;},"pinned filter hides unpinned entries");
send(GetDlgItem(w,101),WM_SETTEXT,0,LPARAM(L"History fixture 497"));
until([&]{return send(GetDlgItem(w,102),LB_GETCOUNT)==0;},"search cannot match an unpinned item in pinned view");
send(GetDlgItem(w,101),WM_SETTEXT,0,LPARAM(L"History fixture 498"));
until([&]{return send(GetDlgItem(w,102),LB_GETCOUNT)==1;},"history search");
send(w,WM_COMMAND,112);
until([&]{return send(GetDlgItem(w,102),LB_GETCOUNT)==0;},"unpin removes the last pinned result");
filter(w,0);
until([&]{return send(GetDlgItem(w,102),LB_GETCOUNT)==1;},"all items restores the matching unpinned entry");
send(w,WM_COMMAND,112);
filter(w,1);
close(w);w=open();
require(send(GetDlgItem(w,117),BM_GETCHECK)==BST_CHECKED,"pinned checkbox survives helper restart");
wchar_t query[100]{};send(GetDlgItem(w,101),WM_GETTEXT,100,LPARAM(query));
require(std::wstring(query)==L"History fixture 498","search survives helper restart");
send(w,WM_COMMAND,114);
@@ -124,7 +139,7 @@ int main() {
require(WaitForSingleObject(child,0)==WAIT_TIMEOUT && IsWindow(entry),"full item remains usable after closing history");
send(entry,WM_CLOSE);
until([&]{return WaitForSingleObject(child,0)==WAIT_OBJECT_0;},"helper exits after last full item closes");CloseHandle(child);
w=open();send(GetDlgItem(w,101),WM_SETTEXT,0,LPARAM(L""));
w=open();filter(w,0);send(GetDlgItem(w,101),WM_SETTEXT,0,LPARAM(L""));
until([&]{return send(GetDlgItem(w,102),LB_GETCOUNT)==500;},"clear search");close(w);
ks::writeClipboard(target,excluded(image));
w=open();send(w,WM_COMMAND,111);