| 157 | } |
| 158 | |
| 159 | static bool ProcessControlMessage( |
| 160 | HWND hwnd, |
| 161 | unsigned int message, |
| 162 | WPARAM wParam, |
| 163 | LPARAM lParam) { |
| 164 | static UINT sControlMessage |
| 165 | = RegisterWindowMessageW(WindowCaptureControl::WindowMessageName); |
| 166 | |
| 167 | if (message != sControlMessage) { |
| 168 | return false; |
| 169 | } |
| 170 | |
| 171 | using WParam = WindowCaptureControl::WParam; |
| 172 | switch (static_cast<WParam>(wParam)) { |
| 173 | case WParam::Initialize: |
| 174 | gTopLevelWindow = reinterpret_cast<HWND>(lParam); |
| 175 | InstallDetours(); |
| 176 | break; |
| 177 | case WParam::StartInjection: |
| 178 | gInjecting++; |
| 179 | gTopLevelWindow = reinterpret_cast<HWND>(lParam); |
| 180 | gLastSetForegroundWindow = gTopLevelWindow; |
| 181 | gLastInjectedAt = std::chrono::steady_clock::now(); |
| 182 | InstallDetours(); |
| 183 | break; |
| 184 | case WParam::EndInjection: |
| 185 | gInjecting--; |
| 186 | if (!gInjecting) { |
| 187 | gInjectedPoint = {}; |
| 188 | gLastSetForegroundWindow = {}; |
| 189 | } |
| 190 | break; |
| 191 | } |
| 192 | |
| 193 | return true; |
| 194 | } |
| 195 | |
| 196 | static bool |
| 197 | ProcessMessage(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { |
no test coverage detected