From e64818967374ebdadf6f22d18296e7bc6088277b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 25 Sep 2013 12:07:46 +0000 Subject: IsFullScreen(), IsWorkstationLocked(), IsScreenSaverRunning() moved to the core git-svn-id: http://svn.miranda-ng.org/main/trunk@6226 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/mir_core/winver.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'src/mir_core/winver.cpp') diff --git a/src/mir_core/winver.cpp b/src/mir_core/winver.cpp index b980d5138e..03a6e62a28 100644 --- a/src/mir_core/winver.cpp +++ b/src/mir_core/winver.cpp @@ -34,3 +34,58 @@ MIR_CORE_DLL(BOOL) IsWinVer7Plus() { return dwWinVer >= _WIN32_WINNT_WIN7; } + +MIR_CORE_DLL(BOOL) IsFullScreen() +{ + RECT rcScreen = {0}; + + rcScreen.right = GetSystemMetrics(SM_CXSCREEN); + rcScreen.bottom = GetSystemMetrics(SM_CYSCREEN); + + HMONITOR hMon = MonitorFromWindow(GetForegroundWindow(), MONITOR_DEFAULTTONEAREST); + MONITORINFO mi; + mi.cbSize = sizeof(mi); + if (GetMonitorInfo(hMon, &mi)) + rcScreen = mi.rcMonitor; + + HWND hWndDesktop = GetDesktopWindow(); + HWND hWndShell = GetShellWindow(); + + // check foregroundwindow + HWND hWnd = GetForegroundWindow(); + if (hWnd && hWnd != hWndDesktop && hWnd != hWndShell) { + TCHAR tszClassName[128] = _T(""); + GetClassName(hWnd, tszClassName, SIZEOF(tszClassName)); + if ( _tcscmp(tszClassName, _T("WorkerW"))) { + RECT rect, rectw, recti; + GetWindowRect(hWnd, &rectw); + + GetClientRect(hWnd, &rect); + ClientToScreen(hWnd, (LPPOINT)&rect); + ClientToScreen(hWnd, (LPPOINT)&rect.right); + + if (EqualRect(&rect, &rectw) && IntersectRect(&recti, &rect, &rcScreen) && + EqualRect(&recti, &rcScreen)) + return true; + } + } + + return false; +} + +MIR_CORE_DLL(BOOL) IsWorkstationLocked(void) +{ + HDESK hDesk = OpenInputDesktop(0, FALSE, DESKTOP_SWITCHDESKTOP); + if (hDesk == NULL) + return true; + + CloseDesktop(hDesk); + return false; +} + +MIR_CORE_DLL(BOOL) IsScreenSaverRunning(void) +{ + BOOL rc = FALSE; + SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, &rc, FALSE); + return rc != 0; +} -- cgit v1.2.3