Wait longer after first paint, then show window.

This commit is contained in:
John Preston 2024-01-16 12:51:24 +04:00
parent 0db88bdec1
commit 564e354c1d

View file

@ -497,27 +497,25 @@ void WindowHelper::init() {
window()->shownValue() | rpl::filter([=](bool shown) { window()->shownValue() | rpl::filter([=](bool shown) {
return !shown; return !shown;
}) | rpl::start_with_next([=] { }) | rpl::start_with_next([=] {
BOOL cloak = TRUE; const auto toggleCloak = [=](bool enabled) {
DwmSetWindowAttribute(_handle, DWMWA_CLOAK, &cloak, sizeof(cloak)); const auto flag = BOOL(enabled ? TRUE : FALSE);
DwmSetWindowAttribute(_handle, DWMWA_CLOAK, &flag, sizeof(flag));
};
toggleCloak(true);
const auto firstPaintEventFilter = std::make_shared<QObject*>(nullptr); const auto qwindow = window()->windowHandle();
const auto firstPaintEventFilter = std::make_shared<QObject*>();
*firstPaintEventFilter = base::install_event_filter( *firstPaintEventFilter = base::install_event_filter(
window()->windowHandle(), qwindow,
[=](not_null<QEvent*> e) { [=](not_null<QEvent*> e) {
if (!*firstPaintEventFilter if (e->type() == QEvent::Expose && qwindow->isExposed()) {
|| e->type() != QEvent::Expose InvokeQueued(qwindow, [=] {
|| !window()->windowHandle()->isExposed()) { InvokeQueued(qwindow, [=] {
return base::EventFilterResult::Continue; toggleCloak(false);
} });
InvokeQueued(*firstPaintEventFilter, [=] { });
BOOL cloak = FALSE;
DwmSetWindowAttribute(
_handle,
DWMWA_CLOAK,
&cloak,
sizeof(cloak));
delete base::take(*firstPaintEventFilter); delete base::take(*firstPaintEventFilter);
}); }
return base::EventFilterResult::Continue; return base::EventFilterResult::Continue;
}); });
}, window()->lifetime()); }, window()->lifetime());