Browse Source

Hoikas' Windows 7 taskbar loading indicator

dcba1fb60a
and
3a354020e1
tickets/12/12/1
John Johns 4 years ago
parent
commit
23126d3135
  1. 32
      Sources/Plasma/Apps/plClient/plClient.cpp
  2. 47
      Sources/Plasma/Apps/plClient/winmain.cpp

32
Sources/Plasma/Apps/plClient/plClient.cpp

@ -162,6 +162,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plTweak.h"
#include <ShObjIdl.h>
#define MSG_LOADING_BAR
// static hsVector3 gAbsDown(0,0,-hsScalar1);
@ -170,6 +172,10 @@ static plDispatchBase* gDisp = nil;
static plTimerCallbackManager* gTimerMgr = nil;
static plAudioSystem* gAudio = nil;
#ifdef HS_BUILD_FOR_WIN32
extern ITaskbarList3* gTaskbarList;
#endif
hsBool plClient::fDelayMS = false;
plClient* plClient::fInstance=nil;
@ -1286,6 +1292,32 @@ void plClient::IProgressMgrCallbackProc(plOperationProgress * progress)
if(!fInstance)
return;
// Increments the taskbar progress [Windows 7+]
#ifdef HS_BUILD_FOR_WIN32
if (gTaskbarList && fInstance->GetWindowHandle())
{
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->IsLastUpdate())
myState = TBPF_NOPROGRESS;
else if (progress->GetMax() == 0.f)
myState = TBPF_INDETERMINATE;
else
// This will set TBPF_NORMAL for us
myState = TBPF_NORMAL;
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
fInstance->fMessagePumpProc();
fInstance->IDraw();
}

47
Sources/Plasma/Apps/plClient/winmain.cpp

@ -77,6 +77,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <shellapi.h>
#include "WinHttp.h"
#include "loginfix.h"
#include <ShObjIdl.h>
//
// Defines
//
@ -99,6 +100,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// Globals
//
hsBool gHasMouse = false;
ITaskbarList3* gTaskbarList = nil; // NT 6.1+ taskbar stuff
extern hsBool gDataServerLocal;
extern hsBool gUseBackgroundDownloader;
@ -137,6 +139,7 @@ bool gPendingActivateFlag = false;
static bool s_loginDlgRunning = false;
static CEvent s_statusEvent(kEventManualReset);
static UINT s_WmTaskbarList = RegisterWindowMessage("TaskbarButtonCreated");
FILE *errFP = nil;
HINSTANCE gHInst = NULL; // Instance of this app
@ -502,7 +505,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (gClient->WindowActive() && gClient->GetInputManager())
gClient->GetInputManager()->HandleWin32ControlEvent(message, wParam, lParam, hWnd);
}
break;
return TRUE;
case WM_LBUTTONUP:
case WM_RBUTTONUP:
case WM_MBUTTONUP:
@ -514,19 +517,19 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_KEYUP:
if (gClient && gClient->WindowActive() && gClient->GetInputManager())
gClient->GetInputManager()->HandleWin32ControlEvent(message, wParam, lParam, hWnd);
break;
return TRUE;
case WM_MOUSEMOVE:
{
if (gClient && gClient->GetInputManager())
gClient->GetInputManager()->HandleWin32ControlEvent(message, wParam, lParam, hWnd);
}
break;
return TRUE;
#if 0
case WM_KILLFOCUS:
SetForegroundWindow(hWnd);
break;
return TRUE;
#endif
case WM_SYSKEYUP:
@ -538,7 +541,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
}
//DefWindowProc(hWnd, message, wParam, lParam);
}
break;
return TRUE;
case WM_SYSCOMMAND:
switch (wParam) {
@ -554,9 +557,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (plNetClientMgr * mgr = plNetClientMgr::GetInstance())
mgr->QueueDisableNet(false, nil);
DestroyWindow(gClient->GetWindowHandle());
break;
return TRUE;
}
break;
return TRUE;
case WM_SETCURSOR:
{
@ -579,9 +582,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
plMouseDevice::HideCursor();
}
}
return TRUE;
}
break;
return TRUE;
case WM_ACTIVATE:
{
@ -601,7 +603,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
gPendingActivateFlag = active;
}
}
break;
return TRUE;
// Let go of the mouse if the window is being moved.
case WM_ENTERSIZEMOVE:
@ -609,7 +611,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
gDragging = true;
if( gClient )
gClient->WindowActivate(false);
break;
return TRUE;
// Redo the mouse capture if the window gets moved
case WM_EXITSIZEMOVE:
@ -617,7 +619,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
gDragging = false;
if( gClient )
gClient->WindowActivate(true);
break;
return TRUE;
// Redo the mouse capture if the window gets moved (special case for Colin
// and his cool program that bumps windows out from under the taskbar)
@ -629,7 +631,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
}
else
DebugMsgF("Got WM_MOVE, but ignoring");
break;
return TRUE;
/// Resize the window
// (we do WM_SIZING here instead of WM_SIZE because, for some reason, WM_SIZE is
@ -644,7 +646,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
::GetClientRect(hWnd, &r);
gClient->GetPipeline()->Resize(r.right - r.left, r.bottom - r.top);
}
break;
return TRUE;
case WM_SIZE:
// Let go of the mouse if the window is being minimized
@ -661,7 +663,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (gClient)
gClient->WindowActivate(true);
}
break;
return TRUE;
case WM_CLOSE:
gClient->SetDone(TRUE);
@ -677,8 +679,21 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
return TRUE;
case WM_CREATE:
// Create renderer
break;
return TRUE;
}
// Messages we registered for manually (no const value)
if (message == s_WmTaskbarList)
{
// Grab the Windows 7 taskbar list stuff
if (gTaskbarList)
gTaskbarList->Release();
HRESULT result = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_ALL, IID_ITaskbarList3, (void**)&gTaskbarList);
if (FAILED(result))
gTaskbarList = nil;
return TRUE;
}
else
return DefWindowProc(hWnd, message, wParam, lParam);
}

Loading…
Cancel
Save