deactivatemgr.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include <precomp.h>
  2. #include "deactivatemgr.h"
  3. #define FAKE_PTR (ifc_window *)-1
  4. #define BYPASS_DEACTIVATE_ATOM "BYPASS_DEACTIVATE_MGR"
  5. int AppDeactivationMgr::is_deactivation_allowed(ifc_window *w) {
  6. #ifdef WIN32
  7. 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
  8. #else
  9. DebugString( "portme -- AppDeactivationMgr::is_deactivation_allowed\n");
  10. #endif
  11. return list.getNumItems() == 0;
  12. }
  13. void AppDeactivationMgr::push_disallow(ifc_window *w) {
  14. if (w == NULL)
  15. w = FAKE_PTR;
  16. list.addItem(w);
  17. }
  18. void AppDeactivationMgr::pop_disallow(ifc_window *w) {
  19. if (w == NULL)
  20. w = FAKE_PTR;
  21. if (list.getNumItems() == 0) {
  22. return;
  23. }
  24. while (list.getNumItems()>0) {
  25. int p = list.searchItem(w);
  26. if (p >= 0)
  27. list.removeByPos(p);
  28. else break;
  29. }
  30. }
  31. void AppDeactivationMgr::setbypass(int i) {
  32. #ifdef WIN32
  33. if (i) {
  34. ATOM a = FindAtomA(BYPASS_DEACTIVATE_ATOM);
  35. if (a != NULL) return;
  36. AddAtomA(BYPASS_DEACTIVATE_ATOM);
  37. } else {
  38. ATOM a = FindAtomA(BYPASS_DEACTIVATE_ATOM);
  39. if (a != NULL) {
  40. DeleteAtom(a);
  41. return;
  42. }
  43. }
  44. #else
  45. DebugString( "portme -- AppDeactivationMgr::setbypass\n" );
  46. #endif
  47. }
  48. PtrList<ifc_window> AppDeactivationMgr::list;