game mode check

This commit is contained in:
SeraphimaZ 2021-11-17 11:24:33 +03:00
parent 4d888627e8
commit 0c60d64b09
2 changed files with 20 additions and 1 deletions

View file

@ -1,12 +1,24 @@
#include "pch.h"
#include "AlwaysOnTop.h"
#include <mmsystem.h>
#include <mmsystem.h> // sound
#include <shellapi.h> // game mode
const static wchar_t* HOTKEY_WINDOW_CLASS_NAME = L"HotkeyHandleWindowClass";
// common
extern "C" IMAGE_DOS_HEADER __ImageBase;
// common
inline bool detect_game_mode()
{
QUERY_USER_NOTIFICATION_STATE notification_state;
if (SHQueryUserNotificationState(&notification_state) != S_OK)
{
return false;
}
return (notification_state == QUNS_RUNNING_D3D_FULL_SCREEN);
}
AlwaysOnTop::AlwaysOnTop()
{
s_instance = this;
@ -52,6 +64,12 @@ LRESULT AlwaysOnTop::WndProc(HWND window, UINT message, WPARAM wparam, LPARAM lp
void AlwaysOnTop::ProcessCommand(HWND window)
{
bool gameMode = detect_game_mode();
if (!m_activateInGameMode && gameMode)
{
return;
}
bool topmost = IsTopmost(window);
if (topmost)
{

View file

@ -29,6 +29,7 @@ private:
HWND hotKeyHandleWindow{ nullptr };
std::vector<HWND> topmostWindows;
bool m_activateInGameMode = false;
LRESULT WndProc(HWND, UINT, WPARAM, LPARAM) noexcept;