From 1bfa806843c71bffa442c88e987ced9e1f08dabd Mon Sep 17 00:00:00 2001 From: John Johns Date: Sat, 5 Jun 2021 17:40:41 -0700 Subject: [PATCH] Hoikas' client window flashing when unfocused https://github.com/H-uru/Plasma/commit/5beda0ab87e69d41f713644e7667e88979537d38 --- Sources/Plasma/Apps/plClient/plClient.cpp | 17 +++++++++++++++++ Sources/Plasma/Apps/plClient/plClient.h | 1 + Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp | 7 +++++++ Sources/Plasma/FeatureLib/pfPython/cyMisc.h | 9 +++++++++ .../Plasma/FeatureLib/pfPython/cyMiscGlue.cpp | 4 ++++ .../Plasma/NucleusLib/pnMessage/plClientMsg.h | 2 ++ 6 files changed, 40 insertions(+) diff --git a/Sources/Plasma/Apps/plClient/plClient.cpp b/Sources/Plasma/Apps/plClient/plClient.cpp index c1013bf1..4924aedc 100644 --- a/Sources/Plasma/Apps/plClient/plClient.cpp +++ b/Sources/Plasma/Apps/plClient/plClient.cpp @@ -771,6 +771,12 @@ hsBool plClient::MsgReceive(plMessage* msg) } break; + case plClientMsg::kFlashWindow: + { + FlashWindow(); + } + break; + } return true; } @@ -2429,6 +2435,17 @@ void plClient::WindowActivate(bool active) fWindowActive = active; } +void plClient::FlashWindow() +{ +#ifdef HS_BUILD_FOR_WIN32 + FLASHWINFO info; + info.cbSize = sizeof(info); + info.dwFlags = FLASHW_TIMERNOFG | FLASHW_ALL; + info.hwnd = fWindowHndl; + info.uCount = -1; + FlashWindowEx(&info); +#endif +} //============================================================================ void plClient::IOnAsyncInitComplete () { diff --git a/Sources/Plasma/Apps/plClient/plClient.h b/Sources/Plasma/Apps/plClient/plClient.h index 1038a8f5..acbbb58c 100644 --- a/Sources/Plasma/Apps/plClient/plClient.h +++ b/Sources/Plasma/Apps/plClient/plClient.h @@ -292,6 +292,7 @@ public: virtual void WindowActivate(bool active); virtual hsBool WindowActive() const { return fWindowActive; } + void FlashWindow(); void SetMessagePumpProc( plMessagePumpProc proc ) { fMessagePumpProc = proc; } void ResetDisplayDevice(int Width, int Height, int ColorDepth, hsBool Windowed, int NumAASamples, int MaxAnisotropicSamples, hsBool VSync = false); void ResizeDisplayDevice(int Width, int Height, hsBool Windowed); diff --git a/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp b/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp index d2b350cd..da07dff5 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp @@ -722,6 +722,13 @@ void cyMisc::ExcludeRegionSetNow(pyKey& sender, pyKey& exKey, UInt16 state) plgDispatch::MsgSend( msg ); // whoosh... off it goes } +void cyMisc::FlashWindow() +{ + plKey clientKey = hsgResMgr::ResMgr()->FindKey(kClient_KEY); + plClientMsg* pMsg = new plClientMsg(plClientMsg::kFlashWindow); + pMsg->Send(clientKey); // whoosh... off it goes +} + #include "hsTimer.h" ///////////////////////////////////////////////////////////////////////////// // diff --git a/Sources/Plasma/FeatureLib/pfPython/cyMisc.h b/Sources/Plasma/FeatureLib/pfPython/cyMisc.h index de629c1c..12391023 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyMisc.h +++ b/Sources/Plasma/FeatureLib/pfPython/cyMisc.h @@ -244,6 +244,15 @@ public: // static hsBool WasLocallyNotified(pyKey &selfkey); + ///////////////////////////////////////////////////////////////////////////// + // + // Function : FlashWindow + // PARAMETERS : + // + // PURPOSE : Flashes the client window if it is not focused + // + static void FlashWindow(); + ///////////////////////////////////////////////////////////////////////////// // // Function : GetClientName diff --git a/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue.cpp index 053d9230..a12030d8 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue.cpp @@ -48,6 +48,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include +PYTHON_BASIC_GLOBAL_METHOD_DEFINITION(PtFlashWindow, cyMisc::FlashWindow, "Flashes the client window if it is not focused"); + PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetAgeName, "DEPRECIATED - use ptDniInfoSource instead") { return PyString_FromString(cyMisc::GetAgeName()); @@ -496,6 +498,8 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtDumpLogs, args, "Params: folder\nDumps all cur void cyMisc::AddPlasmaMethods(std::vector &methods) { + PYTHON_GLOBAL_METHOD_NOARGS(methods, PtFlashWindow); + PYTHON_GLOBAL_METHOD_NOARGS(methods, PtGetAgeName); PYTHON_GLOBAL_METHOD_NOARGS(methods, PtGetAgeInfo); PYTHON_GLOBAL_METHOD_NOARGS(methods, PtGetAgeTime); diff --git a/Sources/Plasma/NucleusLib/pnMessage/plClientMsg.h b/Sources/Plasma/NucleusLib/pnMessage/plClientMsg.h index f4f6ce6c..5ed1fac2 100644 --- a/Sources/Plasma/NucleusLib/pnMessage/plClientMsg.h +++ b/Sources/Plasma/NucleusLib/pnMessage/plClientMsg.h @@ -94,6 +94,8 @@ public: kEnableRenderScene, kResetGraphicsDevice, kSetGraphicsDefaults, + + kFlashWindow, }; // graphics settings fields