Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

187 lines
4.2 KiB

  1. #include "precomp.h"
  2. //
  3. // SWL.CPP
  4. // Shared Window List
  5. //
  6. // Copyright(c) Microsoft 1997-
  7. //
  8. #define MLZ_FILE_ZONE ZONE_CORE
  9. //
  10. // SWL strategy when network packets are not available
  11. //
  12. // The SWL only sends one type of message - the window structure message.
  13. // When no network packets are available the SWL will drop its current
  14. // packet and remember that the window structure has changed since it was
  15. // last able to send a packet. SWL_Periodic will also return FALSE when
  16. // this happens so that the DCS will know not to send any updates if it
  17. // failed to send a window structure.
  18. //
  19. // This pending of window structure messages is integrated with the
  20. // ignore envelopes where the SWL wants to ignore changes caused by itself
  21. // (or other components if they call the SWL_Begin/EndIgnoreWindowChanges
  22. // functions).
  23. //
  24. //
  25. // SWL strategy for backward compatibility.
  26. //
  27. // The differences between the R2.0 and 3.0 SWL protocol are:
  28. // 1. Tokenless packets.
  29. // 2. No shadows.
  30. //
  31. //
  32. // SWL_HostStarting()
  33. //
  34. BOOL ASHost::SWL_HostStarting(void)
  35. {
  36. BOOL rc = FALSE;
  37. DebugEntry(ASHost::SWL_HostStarting);
  38. //
  39. // If this is NT, get the name of our startup desktop
  40. //
  41. if (!g_asWin95)
  42. {
  43. ASSERT(m_aswlOurDesktopName[0] == 0);
  44. GetUserObjectInformation(GetThreadDesktop(g_asMainThreadId),
  45. UOI_NAME, m_aswlOurDesktopName,
  46. sizeof(m_aswlOurDesktopName), NULL);
  47. TRACE_OUT(("Our desktop name is %s", m_aswlOurDesktopName));
  48. }
  49. if (!m_aswlOurDesktopName[0])
  50. {
  51. // Use default name
  52. TRACE_OUT(("Couldn't get desktop name; using %s",
  53. NAME_DESKTOP_DEFAULT));
  54. lstrcpy(m_aswlOurDesktopName, NAME_DESKTOP_DEFAULT);
  55. }
  56. rc = TRUE;
  57. DebugExitBOOL(ASHost::SWL_HostStarting, rc);
  58. return(rc);
  59. }
  60. //
  61. // SWL_UpdateCurrentDesktop()
  62. //
  63. // This checks what the current desktop is, and if it's changed, updates
  64. // the NT input hooks for winlogon/screensaver for the service. But normal
  65. // SWL and AWC also make use of this info.
  66. //
  67. void ASHost::SWL_UpdateCurrentDesktop(void)
  68. {
  69. HDESK hDeskCurrent = NULL;
  70. UINT newCurrentDesktop;
  71. char szName[SWL_DESKTOPNAME_MAX];
  72. DebugEntry(ASHost::SWL_UpdateCurrentDesktop);
  73. newCurrentDesktop = DESKTOP_OURS;
  74. if (g_asWin95)
  75. {
  76. // Nothing to do
  77. DC_QUIT;
  78. }
  79. //
  80. // Get the current desktop. If we can't even get it, assume it's the
  81. // winlogon desktop.
  82. //
  83. hDeskCurrent = OpenInputDesktop(0, TRUE, DESKTOP_READOBJECTS);
  84. if (!hDeskCurrent)
  85. {
  86. TRACE_OUT(("OpenInputDesktop failed; must be WINLOGON"));
  87. newCurrentDesktop = DESKTOP_WINLOGON;
  88. DC_QUIT;
  89. }
  90. // Get the name of the current desktop
  91. szName[0] = 0;
  92. GetUserObjectInformation(hDeskCurrent, UOI_NAME, szName,
  93. sizeof(szName), NULL);
  94. TRACE_OUT(("GetUserObjectInformation returned %s for name", szName));
  95. if (!lstrcmpi(szName, m_aswlOurDesktopName))
  96. {
  97. newCurrentDesktop = DESKTOP_OURS;
  98. }
  99. else if (!lstrcmpi(szName, NAME_DESKTOP_SCREENSAVER))
  100. {
  101. newCurrentDesktop = DESKTOP_SCREENSAVER;
  102. }
  103. else if (!lstrcmpi(szName, NAME_DESKTOP_WINLOGON))
  104. {
  105. newCurrentDesktop = DESKTOP_WINLOGON;
  106. }
  107. else
  108. {
  109. newCurrentDesktop = DESKTOP_OTHER;
  110. }
  111. DC_EXIT_POINT:
  112. if (newCurrentDesktop != m_swlCurrentDesktop)
  113. {
  114. //
  115. // If this is the service, adjust where we playback events
  116. // and/or block local input.
  117. //
  118. OSI_DesktopSwitch(m_swlCurrentDesktop, newCurrentDesktop);
  119. m_swlCurrentDesktop = newCurrentDesktop;
  120. }
  121. if (hDeskCurrent != NULL)
  122. {
  123. CloseDesktop(hDeskCurrent);
  124. }
  125. DebugExitVOID(ASHost::SWL_UpdateCurrentDesktop);
  126. }
  127. //
  128. // SWL_IsOurDesktopActive()
  129. //
  130. BOOL ASHost::SWL_IsOurDesktopActive(void)
  131. {
  132. return(!g_asSharedMemory->fullScreen && (m_swlCurrentDesktop == DESKTOP_OURS));
  133. }
  134. //
  135. // SWL_Periodic()
  136. //
  137. // DESCRIPTION:
  138. //
  139. // Called periodically. If the window structure has changed (such that it
  140. // impacts remote systems) then send a new one if we can.
  141. //
  142. //
  143. void ASHost::SWL_Periodic(void)
  144. {
  145. DebugEntry(ASSHost::SWL_Periodic);
  146. SWL_UpdateCurrentDesktop();
  147. DebugExitVOID(ASHost::SWL_Periodic);
  148. }