Additional change for r897.

This commit is contained in:
spx 2011-08-13 10:03:16 +00:00
parent 04ebdd5186
commit fab4bdb088
3 changed files with 40 additions and 17 deletions

View File

@ -3540,7 +3540,7 @@ void CRainmeter::RefreshAll()
GetMeterWindowsByLoadOrder(windows); GetMeterWindowsByLoadOrder(windows);
// Prepare the helper window // Prepare the helper window
CSystem::PrepareHelperWindow(CSystem::GetWorkerW()); CSystem::PrepareHelperWindow();
// Refresh all // Refresh all
std::multimap<int, CMeterWindow*>::const_iterator iter = windows.begin(); std::multimap<int, CMeterWindow*>::const_iterator iter = windows.begin();

View File

@ -561,44 +561,68 @@ HWND CSystem::GetDefaultShellWindow()
else else
{ {
WCHAR className[16]; WCHAR className[16];
if (GetClassName(ShellW, className, 16) > 0 && if (!(GetClassName(ShellW, className, 16) > 0 &&
wcscmp(className, L"Progman") == 0) wcscmp(className, L"Progman") == 0))
{ {
c_ShellW = ShellW; ShellW = NULL;
return ShellW;
} }
} }
} }
c_ShellW = NULL; c_ShellW = ShellW;
return NULL; return ShellW;
} }
/* /*
** GetWorkerW ** GetWorkerW
** **
** Finds the WorkerW window. ** Finds the WorkerW window.
** If the window is not found, returns NULL. ** If the WorkerW window is not active, returns NULL.
** **
*/ */
HWND CSystem::GetWorkerW() HWND CSystem::GetWorkerW()
{ {
static HWND c_DefView = NULL; // cache
HWND ShellW = GetDefaultShellWindow(); HWND ShellW = GetDefaultShellWindow();
if (!ShellW) return NULL; // Default Shell (Explorer) not running if (!ShellW) return NULL; // Default Shell (Explorer) not running
if (FindWindowEx(ShellW, NULL, L"SHELLDLL_DefView", L"") == NULL) if (c_DefView && IsWindow(c_DefView))
{ {
HWND WorkerW = NULL; HWND parent = GetAncestor(c_DefView, GA_PARENT);
while (WorkerW = FindWindowEx(NULL, WorkerW, L"WorkerW", L"")) if (parent)
{ {
if (BelongToSameProcess(ShellW, WorkerW) && FindWindowEx(WorkerW, NULL, L"SHELLDLL_DefView", L"")) if (parent == ShellW)
{ {
return WorkerW; return NULL;
}
else
{
WCHAR className[16];
if (GetClassName(parent, className, 16) > 0 &&
wcscmp(className, L"WorkerW") == 0)
{
return parent;
}
} }
} }
} }
return NULL; HWND WorkerW = NULL, DefView = FindWindowEx(ShellW, NULL, L"SHELLDLL_DefView", L"");
if (DefView == NULL)
{
while (WorkerW = FindWindowEx(NULL, WorkerW, L"WorkerW", L""))
{
if (IsWindowVisible(WorkerW) &&
BelongToSameProcess(ShellW, WorkerW) &&
(DefView = FindWindowEx(WorkerW, NULL, L"SHELLDLL_DefView", L"")))
{
break;
}
}
}
c_DefView = DefView;
return WorkerW;
} }
/* /*

View File

@ -66,10 +66,8 @@ public:
static bool GetShowDesktop() { return c_ShowDesktop; } static bool GetShowDesktop() { return c_ShowDesktop; }
static HWND GetWorkerW();
static HWND GetHelperWindow() { return c_HelperWindow; } static HWND GetHelperWindow() { return c_HelperWindow; }
static void PrepareHelperWindow(HWND WorkerW); static void PrepareHelperWindow(HWND WorkerW = GetWorkerW());
static OSPLATFORM GetOSPlatform(); static OSPLATFORM GetOSPlatform();
static ULONGLONG GetTickCount64(); static ULONGLONG GetTickCount64();
@ -93,6 +91,7 @@ private:
static void UpdateWorkareaInfo(); static void UpdateWorkareaInfo();
static HWND GetDefaultShellWindow(); static HWND GetDefaultShellWindow();
static HWND GetWorkerW();
static void ChangeZPosInOrder(); static void ChangeZPosInOrder();
static bool CheckDesktopState(HWND WorkerW); static bool CheckDesktopState(HWND WorkerW);