forked from rainmeter/rainmeter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSystem.h
105 lines (76 loc) · 3.47 KB
/
System.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* Copyright (C) 2010 Rainmeter Project Developers
*
* This Source Code Form is subject to the terms of the GNU General Public
* License; either version 2 of the License, or (at your option) any later
* version. If a copy of the GPL was not distributed with this file, You can
* obtain one at <https://www.gnu.org/licenses/gpl-2.0.html>. */
#ifndef __RAINMETER_SYSTEM_H__
#define __RAINMETER_SYSTEM_H__
#include <windows.h>
#include <queue>
#include <vector>
struct MonitorInfo
{
bool active;
HMONITOR handle;
RECT screen;
RECT work;
std::wstring deviceName; // Device name (E.g. "\\.\DISPLAY1")
std::wstring monitorName; // Monitor name (E.g. "Generic Non-PnP Monitor")
};
struct MultiMonitorInfo
{
bool useEnumDisplayDevices; // If true, use EnumDisplayDevices function to obtain the multi-monitor information
bool useEnumDisplayMonitors; // If true, use EnumDisplayMonitors function to obtain the multi-monitor information
int vsT, vsL, vsH, vsW; // Coordinates of the top-left corner (vsT,vsL) and size (vsH,vsW) of the virtual screen
int primary; // Index of the primary monitor
std::vector<MonitorInfo> monitors;
};
class System
{
public:
System(const System& other) = delete;
System& operator=(System other) = delete;
static void Initialize(HINSTANCE instance);
static void Finalize();
static const MultiMonitorInfo& GetMultiMonitorInfo() { return c_Monitors; }
static size_t GetMonitorCount();
static bool GetShowDesktop() { return c_ShowDesktop; }
static HWND GetWindow() { return c_Window; }
static HWND GetBackmostTopWindow();
static HWND GetHelperWindow() { return c_HelperWindow; }
static void PrepareHelperWindow(HWND WorkerW = GetWorkerW());
static POINT GetCursorPosition();
static bool IsFileWritable(LPCWSTR file);
static HMODULE RmLoadLibrary(LPCWSTR lpLibFileName, DWORD* dwError = nullptr);
static void ResetWorkingDirectory();
static void InitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection);
static void SetClipboardText(const std::wstring& text);
static void SetWallpaper(const std::wstring& wallpaper, const std::wstring& style);
static bool CopyFiles(std::wstring from, std::wstring to, bool bMove = false);
static bool CopyFilesWithNoCollisions(std::wstring from, const std::wstring& to);
static bool RemoveFile(const std::wstring& file);
static bool RemoveFolder(std::wstring folder);
static void UpdateIniFileMappingList();
static std::wstring GetTemporaryFile(const std::wstring& iniFile);
static bool IsProcessRunningCached(const std::wstring& lowercaseName);
private:
static void CALLBACK MyWinEventProc(HWINEVENTHOOK hWinEventHook, DWORD event, HWND hwnd, LONG idObject, LONG idChild, DWORD dwEventThread, DWORD dwmsEventTime);
static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
static void SetMultiMonitorInfo();
static void ClearMultiMonitorInfo() { c_Monitors.monitors.clear(); }
static void UpdateWorkareaInfo();
static HWND GetDefaultShellWindow();
static HWND GetWorkerW();
static void ChangeZPosInOrder();
static bool CheckDesktopState(HWND WorkerW);
static bool BelongToSameProcess(HWND hwndA, HWND hwndB);
static HWND c_Window;
static HWND c_HelperWindow;
static HWINEVENTHOOK c_WinEventHook;
static MultiMonitorInfo c_Monitors;
static bool c_ShowDesktop;
static std::wstring c_WorkingDirectory;
static std::vector<std::wstring> c_IniFileMappings;
};
#endif