aboutsummaryrefslogtreecommitdiff
path: root/Src/Wasabi/api/wnd/deactivatemgr.cpp
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Wasabi/api/wnd/deactivatemgr.cpp
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/Wasabi/api/wnd/deactivatemgr.cpp')
-rw-r--r--Src/Wasabi/api/wnd/deactivatemgr.cpp55
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;
+