Compare commits

...

1 Commits

Author SHA1 Message Date
Milan Burda
e471224090 chore: debounce gpu-info-update 2024-03-25 22:36:17 +01:00
3 changed files with 23 additions and 1 deletions

View File

@@ -111,3 +111,20 @@ for (const name of events) {
webContents.emit(name, event, ...args);
});
}
function debounce (callback: () => void) {
let immediate: NodeJS.Immediate | undefined;
return () => {
if (immediate) {
clearImmediate(immediate);
}
immediate = setImmediate(() => {
immediate = undefined;
callback();
});
};
}
app.on('-gpu-info-update' as any, debounce(() => {
app.emit('gpu-info-update');
}));

View File

@@ -768,7 +768,11 @@ base::OnceClosure App::SelectClientCertificate(
}
void App::OnGpuInfoUpdate() {
Emit("gpu-info-update");
Emit("-gpu-info-update");
}
void App::OnGpuExtraInfoUpdate() {
Emit("-gpu-info-update");
}
void App::BrowserChildProcessLaunchedAndConnected(

View File

@@ -154,6 +154,7 @@ class App : public ElectronBrowserClient::Delegate,
// content::GpuDataManagerObserver:
void OnGpuInfoUpdate() override;
void OnGpuExtraInfoUpdate() override;
// content::BrowserChildProcessObserver:
void BrowserChildProcessLaunchedAndConnected(