Browse Source

Minimize calls into shell APIs

Adam Johnson 11 years ago
parent
commit
3a354020e1
  1. 25
      Sources/Plasma/Apps/plClient/plClient.cpp

25
Sources/Plasma/Apps/plClient/plClient.cpp

@ -1279,19 +1279,28 @@ void plClient::IProgressMgrCallbackProc(plOperationProgress * progress)
// Increments the taskbar progress [Windows 7+] // Increments the taskbar progress [Windows 7+]
#ifdef HS_BUILD_FOR_WIN32 #ifdef HS_BUILD_FOR_WIN32
if (gTaskbarList) if (gTaskbarList && fInstance->GetWindowHandle())
{ {
HWND hwnd = fInstance->GetWindowHandle(); // lazy static TBPFLAG lastState = TBPF_NOPROGRESS;
TBPFLAG myState;
// So, calling making these kernel calls is kind of SLOW. So, let's
// hide that behind a userland check--this helps linking go faster!
if (progress->IsAborting()) if (progress->IsAborting())
// We'll assume this is fatal myState = TBPF_ERROR;
gTaskbarList->SetProgressState(hwnd, TBPF_ERROR);
else if (progress->IsLastUpdate()) else if (progress->IsLastUpdate())
gTaskbarList->SetProgressState(hwnd, TBPF_NOPROGRESS); myState = TBPF_NOPROGRESS;
else if (progress->GetMax() == 0.f) else if (progress->GetMax() == 0.f)
gTaskbarList->SetProgressState(hwnd, TBPF_INDETERMINATE); myState = TBPF_INDETERMINATE;
else else
// This will set TBPF_NORMAL for us myState = TBPF_NORMAL;
gTaskbarList->SetProgressValue(hwnd, (ULONGLONG)progress->GetProgress(), (ULONGLONG)progress->GetMax());
if (myState == TBPF_NORMAL)
// This sets us to TBPF_NORMAL
gTaskbarList->SetProgressValue(fInstance->GetWindowHandle(), (ULONGLONG)progress->GetProgress(), (ULONGLONG)progress->GetMax());
else if (myState != lastState)
gTaskbarList->SetProgressState(fInstance->GetWindowHandle(), myState);
lastState = myState;
} }
#endif #endif

Loading…
Cancel
Save