diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index 91db1b88..b16726cd 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -539,15 +539,18 @@ void CMeterWindow::ChangeZPos(ZPOSITION zPos, bool all) { if(!m_ChildWindow) { - HWND winPos = HWND_NOTOPMOST; m_WindowZPosition = zPos; + HWND winPos = HWND_NOTOPMOST; + UINT flags = SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING; + switch (zPos) { case ZPOSITION_ONTOPMOST: case ZPOSITION_ONTOP: winPos = HWND_TOPMOST; - break; + flags |= SWP_NOOWNERZORDER; + break; case ZPOSITION_ONBOTTOM: if (all) @@ -572,13 +575,15 @@ void CMeterWindow::ChangeZPos(ZPOSITION zPos, bool all) case ZPOSITION_ONDESKTOP: if (CSystem::GetShowDesktop()) { + flags |= SWP_NOOWNERZORDER; + // Set WS_EX_TOPMOST flag - SetWindowPos(m_Window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING); + SetWindowPos(m_Window, HWND_TOPMOST, 0, 0, 0, 0, flags); if (all) { // Insert after the helper window - SetWindowPos(m_Window, CSystem::GetHelperWindow(), 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING); + SetWindowPos(m_Window, CSystem::GetHelperWindow(), 0, 0, 0, 0, flags); } else { @@ -589,7 +594,7 @@ void CMeterWindow::ChangeZPos(ZPOSITION zPos, bool all) if (GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST) { // Insert after the found window - if (0 != SetWindowPos(m_Window, hwnd, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING)) + if (0 != SetWindowPos(m_Window, hwnd, 0, 0, 0, 0, flags)) { break; } @@ -613,7 +618,7 @@ void CMeterWindow::ChangeZPos(ZPOSITION zPos, bool all) break; } - SetWindowPos(m_Window, winPos, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING); + SetWindowPos(m_Window, winPos, 0, 0, 0, 0, flags); } } diff --git a/Library/System.cpp b/Library/System.cpp index 07d4b9bb..c1e88c7b 100644 --- a/Library/System.cpp +++ b/Library/System.cpp @@ -682,7 +682,7 @@ BOOL CALLBACK MyEnumWindowsProc(HWND hwnd, LPARAM lParam) Rainmeter && (Window = Rainmeter->GetMeterWindow(hwnd))) { ZPOSITION zPos = Window->GetWindowZPosition(); - if (zPos == ZPOSITION_ONDESKTOP) + if (zPos == ZPOSITION_ONDESKTOP || zPos == ZPOSITION_ONBOTTOM) { if (logging) DebugLog(L"+ [%c] 0x%08X : %s (Name: \"%s\", zPos=%i)", IsWindowVisible(hwnd) ? L'V' : L'H', hwnd, className, Window->GetSkinName().c_str(), (int)zPos); @@ -722,10 +722,27 @@ void CSystem::ChangeZPosInOrder() // Retrieve the Rainmeter's meter windows in Z-order EnumWindows(MyEnumWindowsProc, (LPARAM)(&windowsInZOrder)); - // Reset ZPos in Z-order - for (size_t i = 0; i < windowsInZOrder.size(); ++i) + if (!c_ShowDesktop) { - windowsInZOrder[i]->ChangeZPos(windowsInZOrder[i]->GetWindowZPosition()); // reset + // Reset ZPos in Z-order (Bottom) + std::vector::const_iterator iter = windowsInZOrder.begin(), iterEnd = windowsInZOrder.end(); + for ( ; iter != iterEnd; ++iter) + { + if ((*iter)->GetWindowZPosition() == ZPOSITION_ONBOTTOM) + { + (*iter)->ChangeZPos(ZPOSITION_ONBOTTOM); // reset + } + } + } + + // Reset ZPos in Z-order (On Desktop) + std::vector::const_iterator iter = windowsInZOrder.begin(), iterEnd = windowsInZOrder.end(); + for ( ; iter != iterEnd; ++iter) + { + if ((*iter)->GetWindowZPosition() == ZPOSITION_ONDESKTOP) + { + (*iter)->ChangeZPos(ZPOSITION_ONDESKTOP); // reset + } } if (logging)