Keep new screenshots visible in open clipboard history
This commit is contained in:
1 parent
1f97e9c50e
commit
b3f0f4ab0f
2 files changed
+28
-8
No files matched your search
+22
-6
@@ -336,11 +336,26 @@ static void historyLayoutChecks(ks::App &app, const std::filesystem::path &temp,
|
||||
require(SendDlgItemMessageW(history,102,LB_GETCURSEL,0,0)==0 &&
|
||||
SendDlgItemMessageW(history,102,LB_GETTOPINDEX,0,0)==0,
|
||||
"fresh history invocation selects and reveals newest screenshot instead of saved selection");
|
||||
SendDlgItemMessageW(history,102,LB_SETCURSEL,2,0);
|
||||
app.history->add(ks::textClip(L"background clipboard update"),L"test",app.settings);
|
||||
ks::refreshHistory(app);
|
||||
require(pumpUntil(4),"background refresh loads a new item");
|
||||
require(SendDlgItemMessageW(history,102,LB_GETCURSEL,0,0)==3,
|
||||
"background refresh preserves the selected record while browsing");
|
||||
SendDlgItemMessageW(history,102,LB_SETTOPINDEX,0,0);
|
||||
screenshot.bgra[0] ^= 1;
|
||||
app.history->add(ks::Clip{{ks::imageDib(screenshot)}},L"new screenshot",app.settings);
|
||||
ks::refreshHistory(app);
|
||||
require(pumpUntil(5),"open history loads the new screenshot");
|
||||
require(SendDlgItemMessageW(history,102,LB_GETTOPINDEX,0,0)==0,
|
||||
"history at the top immediately shows the new screenshot");
|
||||
require(SendDlgItemMessageW(history,102,LB_GETCURSEL,0,0)==4,
|
||||
"showing a new screenshot preserves the selection");
|
||||
if (capturePreview)
|
||||
{
|
||||
RedrawWindow(history, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN);
|
||||
ks::InputRegressionAccess::finishHistoryPreviews(app);
|
||||
pumpUntil(3);
|
||||
pumpUntil(5);
|
||||
RedrawWindow(history, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN);
|
||||
RECT historyClient{};
|
||||
GetClientRect(history, &historyClient);
|
||||
@@ -350,12 +365,13 @@ static void historyLayoutChecks(ks::App &app, const std::filesystem::path &temp,
|
||||
ks::atomicWrite(std::filesystem::path(ks::executable()).parent_path() / L"clipboard-history.png",
|
||||
ks::encodePng(ks::decodeImage(preview)));
|
||||
}
|
||||
SendDlgItemMessageW(history,102,LB_SETCURSEL,2,0);
|
||||
app.history->add(ks::textClip(L"background clipboard update"),L"test",app.settings);
|
||||
SendDlgItemMessageW(history,102,LB_SETTOPINDEX,1,0);
|
||||
require(SendDlgItemMessageW(history,102,LB_GETTOPINDEX,0,0)==1,
|
||||
"history can scroll past the newest item");
|
||||
app.history->add(ks::textClip(L"another clipboard update"),L"test",app.settings);
|
||||
ks::refreshHistory(app);
|
||||
require(pumpUntil(4),"background refresh loads a new item");
|
||||
require(SendDlgItemMessageW(history,102,LB_GETCURSEL,0,0)==3,
|
||||
"background refresh preserves the selected record while browsing");
|
||||
require(pumpUntil(6) && SendDlgItemMessageW(history,102,LB_GETTOPINDEX,0,0)==2,
|
||||
"history preserves the top record when scrolled down");
|
||||
ShowWindow(history,SW_HIDE);
|
||||
}
|
||||
auto childRect=[&](int id) { RECT r{}; GetWindowRect(GetDlgItem(history,id),&r); MapWindowPoints(nullptr,history,(POINT*)&r,2); return r; };
|
||||
|
||||
Reference in new issue
Block a user