Leaked source code of windows server 2003
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.

234 lines
6.3 KiB

  1. /*
  2. * Copyright (c) 1985 - 1999, Microsoft Corporation
  3. */
  4. #include "precomp.h"
  5. #pragma hdrstop
  6. // ----------------------------------------------------------------------------
  7. //
  8. // IsVSlick() -
  9. //
  10. // TRUE if window is positioned at +100,+100 from bottom right of screen --
  11. // probably VSlick -- which has two Tray Windows, one is unowned but off the
  12. // screen....we want the owned one since its on the screen
  13. //
  14. // ----------------------------------------------------------------------------
  15. BOOL IsVSlick(PWND pwnd)
  16. {
  17. if (gpDispInfo->cMonitors == 1 &&
  18. ((unsigned) pwnd->rcWindow.left > (unsigned) gpDispInfo->rcScreen.right ) &&
  19. ((unsigned) pwnd->rcWindow.top > (unsigned) gpDispInfo->rcScreen.bottom) &&
  20. (pwnd->rcWindow.top == (gpDispInfo->rcScreen.bottom+100)) &&
  21. (pwnd->rcWindow.left == (gpDispInfo->rcScreen.right+100)))
  22. {
  23. // MUST BE THE ONE AND ONLY V-SLICK
  24. return(TRUE);
  25. }
  26. return(FALSE);
  27. }
  28. // ----------------------------------------------------------------------------
  29. //
  30. // Is31TrayWindow() -
  31. //
  32. // extra grilling required for 3.1 and earlier apps before letting 'em in the
  33. // tray -- trust me, you DON'T want to change this code. -- JEFFBOG 11/10/94
  34. //
  35. // ----------------------------------------------------------------------------
  36. BOOL Is31TrayWindow(PWND pwnd)
  37. {
  38. PWND pwnd2;
  39. if (!(pwnd2 = pwnd->spwndOwner))
  40. return (!IsVSlick(pwnd)); // unowned -- do we want you?
  41. if (TestWF(pwnd2, WEFTOOLWINDOW))
  42. return(FALSE); // owned by a tool window -- we don't want
  43. return((FHas31TrayStyles(pwnd2) ? (IsVSlick(pwnd2)) : TRUE));
  44. }
  45. // ----------------------------------------------------------------------------
  46. //
  47. // IsTrayWindow() -
  48. //
  49. // TRUE if the window passes all the necessary checks -- making it a window
  50. // that should appear in the tray.
  51. //
  52. // ----------------------------------------------------------------------------
  53. BOOL IsTrayWindow(PWND pwnd)
  54. {
  55. if ((pwnd==NULL) || !(FDoTray() && (FCallHookTray() || FPostTray(pwnd->head.rpdesk))) ||
  56. !FTopLevel(pwnd))
  57. return(FALSE);
  58. // Check for WS_EX_APPWINDOW or WS_EX_TOOLWINDOW "overriding" bits
  59. if (TestWF(pwnd, WEFAPPWINDOW))
  60. return(TRUE);
  61. if (TestWF(pwnd, WEFTOOLWINDOW))
  62. return(FALSE);
  63. if (TestWF(pwnd, WEFNOACTIVATE)) {
  64. return FALSE;
  65. }
  66. if (TestWF(pwnd, WFWIN40COMPAT)) {
  67. if (pwnd->spwndOwner == NULL)
  68. return(TRUE);
  69. if (TestWF(pwnd->spwndOwner, WFWIN40COMPAT))
  70. return(FALSE);
  71. // if this window is owned by a 3.1 window, check it like a 3.1 window
  72. }
  73. if (!FHas31TrayStyles(pwnd))
  74. return(FALSE);
  75. return(Is31TrayWindow(pwnd));
  76. }
  77. /***************************************************************************\
  78. * xxxSetTrayWindow
  79. *
  80. * History:
  81. * 11-Dec-1996 adams Created.
  82. \***************************************************************************/
  83. void xxxSetTrayWindow(PDESKTOP pdesk, PWND pwnd, PMONITOR pMonitor)
  84. {
  85. HWND hwnd;
  86. CheckLock(pMonitor);
  87. if (pwnd == STW_SAME) {
  88. pwnd = pdesk->spwndTray;
  89. hwnd = PtoH(pwnd);
  90. } else {
  91. CheckLock(pwnd);
  92. hwnd = PtoH(pwnd);
  93. Lock(&(pdesk->spwndTray), pwnd);
  94. }
  95. if (!pMonitor) {
  96. if (pwnd) {
  97. pMonitor = _MonitorFromWindow(pwnd, MONITOR_DEFAULTTOPRIMARY);
  98. } else {
  99. pMonitor = GetPrimaryMonitor();
  100. }
  101. }
  102. if ( FPostTray(pdesk)) {
  103. PostShellHookMessages(
  104. pMonitor->cFullScreen ?
  105. HSHELL_RUDEAPPACTIVATED : HSHELL_WINDOWACTIVATED,
  106. (LPARAM) hwnd);
  107. }
  108. if ( FCallHookTray() ) {
  109. xxxCallHook(
  110. HSHELL_WINDOWACTIVATED,
  111. (WPARAM) hwnd,
  112. (pMonitor->cFullScreen ? 1 : 0),
  113. WH_SHELL);
  114. }
  115. }
  116. /***************************************************************************\
  117. * xxxAddFullScreen
  118. *
  119. * Adds an app to the fullscreen list and moves the tray if it is
  120. * the first fullscreen app.
  121. *
  122. * History:
  123. * 27-Feb-1997 adams Commented.
  124. \***************************************************************************/
  125. BOOL xxxAddFullScreen(PWND pwnd, PMONITOR pMonitor)
  126. {
  127. BOOL fYielded;
  128. PDESKTOP pdesk = pwnd->head.rpdesk;
  129. CheckLock(pwnd);
  130. CheckLock(pMonitor);
  131. if (pdesk == NULL)
  132. return FALSE;
  133. fYielded = FALSE;
  134. if (!TestWF(pwnd, WFFULLSCREEN) && FCallTray(pdesk))
  135. {
  136. SetWF(pwnd, WFFULLSCREEN);
  137. if (pMonitor->cFullScreen++ == 0) {
  138. xxxSetTrayWindow(pdesk, STW_SAME, pMonitor);
  139. fYielded = TRUE;
  140. }
  141. pwnd = pwnd->spwndOwner;
  142. if ( pwnd &&
  143. !TestWF(pwnd, WFCHILD) &&
  144. pwnd->rcWindow.right == 0 &&
  145. pwnd->rcWindow.left == 0 &&
  146. !TestWF(pwnd, WFVISIBLE)) {
  147. TL tlpwnd;
  148. ThreadLock(pwnd, &tlpwnd);
  149. if (xxxAddFullScreen(pwnd, pMonitor)) {
  150. fYielded = TRUE;
  151. }
  152. ThreadUnlock(&tlpwnd);
  153. }
  154. }
  155. return fYielded;
  156. }
  157. /***************************************************************************\
  158. * xxxRemoveFullScreen
  159. *
  160. * Adds an app to the fullscreen list and moves the tray if there
  161. * are no more fullscreen apps.
  162. *
  163. * History:
  164. * 27-Feb-1997 adams Commented.
  165. \***************************************************************************/
  166. BOOL xxxRemoveFullScreen(PWND pwnd, PMONITOR pMonitor)
  167. {
  168. PDESKTOP pdesk = pwnd->head.rpdesk;
  169. BOOL fYielded;
  170. CheckLock(pwnd);
  171. CheckLock(pMonitor);
  172. if (pdesk == NULL)
  173. return FALSE;
  174. fYielded = FALSE;
  175. if (TestWF(pwnd, WFFULLSCREEN) && FCallTray(pdesk)) {
  176. ClrWF(pwnd, WFFULLSCREEN);
  177. if (--pMonitor->cFullScreen == 0) {
  178. xxxSetTrayWindow(pdesk, STW_SAME, pMonitor);
  179. fYielded = TRUE;
  180. }
  181. /*
  182. * (adams): Remove this assertion temporarily while I work on
  183. * a fix for the problem.
  184. *
  185. * UserAssert(pMonitor->cFullScreen >= 0);
  186. */
  187. }
  188. return fYielded;
  189. }