diff options
author | Jean-Francois Mauguit <jfmauguit@mac.com> | 2024-09-24 09:03:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-24 09:03:25 -0400 |
commit | bab614c421ed7ae329d26bf028c4a3b1d2450f5a (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Wasabi/api/wnd/deactivatemgr.cpp | |
parent | 4bde6044fddf053f31795b9eaccdd2a5a527d21f (diff) | |
parent | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (diff) | |
download | winamp-bab614c421ed7ae329d26bf028c4a3b1d2450f5a.tar.gz |
Merge pull request #5 from WinampDesktop/community
Merge to main
Diffstat (limited to 'Src/Wasabi/api/wnd/deactivatemgr.cpp')
-rw-r--r-- | Src/Wasabi/api/wnd/deactivatemgr.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/Src/Wasabi/api/wnd/deactivatemgr.cpp b/Src/Wasabi/api/wnd/deactivatemgr.cpp new file mode 100644 index 00000000..f011db52 --- /dev/null +++ b/Src/Wasabi/api/wnd/deactivatemgr.cpp @@ -0,0 +1,55 @@ +#include <precomp.h> +#include "deactivatemgr.h" + +#define FAKE_PTR (ifc_window *)-1 +#define BYPASS_DEACTIVATE_ATOM "BYPASS_DEACTIVATE_MGR" + +int AppDeactivationMgr::is_deactivation_allowed(ifc_window *w) { +#ifdef WIN32 + if (FindAtomA(BYPASS_DEACTIVATE_ATOM) != NULL) return 1; // so people don't _need_ an api pointer to bypass us, however, if you can please call api->appdeactivation_setbypass +#else + DebugString( "portme -- AppDeactivationMgr::is_deactivation_allowed\n"); +#endif + return list.getNumItems() == 0; +} + +void AppDeactivationMgr::push_disallow(ifc_window *w) { + if (w == NULL) + w = FAKE_PTR; + list.addItem(w); +} + +void AppDeactivationMgr::pop_disallow(ifc_window *w) { + if (w == NULL) + w = FAKE_PTR; + if (list.getNumItems() == 0) { + return; + } + while (list.getNumItems()>0) { + int p = list.searchItem(w); + if (p >= 0) + list.removeByPos(p); + else break; + } +} + +void AppDeactivationMgr::setbypass(int i) { +#ifdef WIN32 + if (i) { + ATOM a = FindAtomA(BYPASS_DEACTIVATE_ATOM); + if (a != NULL) return; + AddAtomA(BYPASS_DEACTIVATE_ATOM); + } else { + ATOM a = FindAtomA(BYPASS_DEACTIVATE_ATOM); + if (a != NULL) { + DeleteAtom(a); + return; + } + } +#else + DebugString( "portme -- AppDeactivationMgr::setbypass\n" ); +#endif +} + +PtrList<ifc_window> AppDeactivationMgr::list; + |