3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * PURPOSE: GUI state check
6 * FILE: subsys/win32k/ntuser/guicheck.c
7 * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
8 * NOTES: The GuiCheck() function performs a few delayed operations:
9 * 1) A GUI process is assigned a window station
10 * 2) A message queue is created for a GUI thread before use
11 * 3) The system window classes are registered for a process
13 * 06-06-2001 CSH Created
16 /* INCLUDES ******************************************************************/
18 #include <ddk/ntddk.h>
20 #include <win32k/win32k.h>
21 #include <include/guicheck.h>
22 #include <include/msgqueue.h>
23 #include <include/object.h>
24 #include <napi/win32.h>
25 #include <include/winsta.h>
30 /* GLOBALS *******************************************************************/
32 static ULONG NrGuiApplicationsRunning = 0;
34 /* FUNCTIONS *****************************************************************/
37 W32kGraphicsCheck(BOOL Create)
41 if (0 == NrGuiApplicationsRunning)
43 W32kInitializeDesktopGraphics();
45 NrGuiApplicationsRunning++;
49 if (0 < NrGuiApplicationsRunning)
51 NrGuiApplicationsRunning--;
53 if (0 == NrGuiApplicationsRunning)
55 W32kEndDesktopGraphics();
64 if (PsGetWin32Process() == NULL)
68 PsCreateWin32Process(PsGetCurrentProcess());
70 InitializeListHead(&PsGetWin32Process()->ClassListHead);
71 ExInitializeFastMutex(&PsGetWin32Process()->ClassListLock);
74 ValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
77 &PsGetWin32Process()->WindowStation);
78 if (!NT_SUCCESS(Status))
80 DbgPrint("W32K: Failed to reference a window station for "
85 if (PsGetWin32Thread() == NULL)
89 PsCreateWin32Thread(PsGetCurrentThread());
90 PsGetWin32Thread()->MessageQueue = MsqCreateMessageQueue();
91 InitializeListHead(&PsGetWin32Thread()->WindowListHead);
92 ExInitializeFastMutex(&PsGetWin32Thread()->WindowListLock);
94 /* By default threads get assigned their process's desktop. */
95 PsGetWin32Thread()->Desktop = NULL;
96 Status = ObReferenceObjectByHandle(PsGetCurrentProcess()->Win32Desktop,
100 (PVOID*)&PsGetWin32Thread()->Desktop,
102 if (!NT_SUCCESS(Status))
104 DbgPrint("W32K: Failed to reference a desktop for thread.\n");