4 * Copyright 2006 - 2007 Thomas Weidenmueller <w3seek@reactos.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 typedef struct _DESKCREATEINFO
28 } DESKCREATEINFO
, *PDESKCREATEINFO
;
31 DesktopThreadProc(IN OUT LPVOID lpParameter
)
33 volatile DESKCREATEINFO
*DeskCreateInfo
= (volatile DESKCREATEINFO
*)lpParameter
;
34 IShellDesktopTray
*pSdt
;
40 hRet
= ITrayWindow_QueryInterface(DeskCreateInfo
->Tray
,
41 &IID_IShellDesktopTray
,
46 hDesktop
= SHCreateDesktop(pSdt
);
48 IShellDesktopTray_Release(pSdt
);
52 (void)InterlockedExchangePointer(&DeskCreateInfo
->hDesktop
,
55 if (!SetEvent(DeskCreateInfo
->hEvent
))
57 /* Failed to notify that we initialized successfully, kill ourselves
58 to make the main thread wake up! */
62 SHDesktopMessageLoop(hDesktop
);
64 /* FIXME: Properly rundown the main thread! */
71 DesktopCreateWindow(IN OUT ITrayWindow
*Tray
)
75 DWORD DesktopThreadId
;
76 HANDLE hDesktop
= NULL
;
80 hEvent
= CreateEvent(NULL
,
86 volatile DESKCREATEINFO DeskCreateInfo
;
88 DeskCreateInfo
.hEvent
= hEvent
;
89 DeskCreateInfo
.Tray
= Tray
;
90 DeskCreateInfo
.hDesktop
= NULL
;
92 hThread
= CreateThread(NULL
,
95 (PVOID
)&DeskCreateInfo
,
100 Handles
[0] = hThread
;
105 WaitResult
= MsgWaitForMultipleObjects(sizeof(Handles
) / sizeof(Handles
[0]),
110 if (WaitResult
== WAIT_OBJECT_0
+ (sizeof(Handles
) / sizeof(Handles
[0])))
111 TrayProcessMessages(Tray
);
112 else if (WaitResult
!= WAIT_FAILED
&& WaitResult
!= WAIT_OBJECT_0
)
114 hDesktop
= DeskCreateInfo
.hDesktop
;
119 CloseHandle(hThread
);
129 DesktopDestroyShellWindow(IN HANDLE hDesktop
)