serialize gui switching and switching the focus message queue

svn path=/trunk/; revision=10419
This commit is contained in:
Thomas Bluemel 2004-08-08 17:57:34 +00:00
parent 35b0435a15
commit a2b32fbcd6
6 changed files with 63 additions and 15 deletions

View file

@ -8,6 +8,8 @@ BOOL FASTCALL IntGraphicsCheck(BOOL Create);
BOOL FASTCALL IntCreatePrimarySurface(); BOOL FASTCALL IntCreatePrimarySurface();
VOID FASTCALL IntDestroyPrimarySurface(); VOID FASTCALL IntDestroyPrimarySurface();
NTSTATUS FASTCALL InitGuiCheckImpl (VOID);
#endif /* _WIN32K_GUICHECK_H */ #endif /* _WIN32K_GUICHECK_H */
/* EOF */ /* EOF */

View file

@ -104,6 +104,9 @@ typedef struct _USER_MESSAGE_QUEUE
LIST_ENTRY DispatchingMessagesHead; LIST_ENTRY DispatchingMessagesHead;
/* messages that are currently dispatched by this message queue, required for cleanup */ /* messages that are currently dispatched by this message queue, required for cleanup */
LIST_ENTRY LocalDispatchingMessagesHead; LIST_ENTRY LocalDispatchingMessagesHead;
/* Desktop that the message queue is attached to */
struct _DESKTOP_OBJECT *Desktop;
} USER_MESSAGE_QUEUE, *PUSER_MESSAGE_QUEUE; } USER_MESSAGE_QUEUE, *PUSER_MESSAGE_QUEUE;
BOOL FASTCALL BOOL FASTCALL

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: dllmain.c,v 1.78 2004/08/02 15:07:26 blight Exp $ /* $Id: dllmain.c,v 1.79 2004/08/08 17:57:34 weiden Exp $
* *
* Entry Point for win32k.sys * Entry Point for win32k.sys
*/ */
@ -298,6 +298,13 @@ DllMain (
return(Status); return(Status);
} }
Status = InitGuiCheckImpl();
if (!NT_SUCCESS(Status))
{
DbgPrint("Failed to initialize GUI check implementation.\n");
return(Status);
}
InitGdiObjectHandleTable (); InitGdiObjectHandleTable ();
/* Initialize FreeType library */ /* Initialize FreeType library */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* *
* $Id: desktop.c,v 1.17 2004/07/09 20:57:38 gvg Exp $ * $Id: desktop.c,v 1.18 2004/08/08 17:57:34 weiden Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -186,13 +186,29 @@ IntGetFocusMessageQueue(VOID)
VOID FASTCALL VOID FASTCALL
IntSetFocusMessageQueue(PUSER_MESSAGE_QUEUE NewQueue) IntSetFocusMessageQueue(PUSER_MESSAGE_QUEUE NewQueue)
{ {
PUSER_MESSAGE_QUEUE Old;
PDESKTOP_OBJECT pdo = IntGetActiveDesktop(); PDESKTOP_OBJECT pdo = IntGetActiveDesktop();
if (!pdo) if (!pdo)
{ {
DPRINT("No active desktop\n"); DPRINT("No active desktop\n");
return; return;
} }
pdo->ActiveMessageQueue = NewQueue; if(NewQueue != NULL)
{
if(NewQueue->Desktop != NULL)
{
DPRINT("Message Queue already attached to another desktop!\n");
return;
}
IntReferenceMessageQueue(NewQueue);
InterlockedExchange((LONG*)&NewQueue->Desktop, (LONG)pdo);
}
Old = (PUSER_MESSAGE_QUEUE)InterlockedExchange((LONG*)&pdo->ActiveMessageQueue, (LONG)NewQueue);
if(Old != NULL)
{
InterlockedExchange((LONG*)&Old->Desktop, 0);
IntDereferenceMessageQueue(Old);
}
} }
HWND FASTCALL IntGetDesktopWindow(VOID) HWND FASTCALL IntGetDesktopWindow(VOID)

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: guicheck.c,v 1.19 2004/05/21 10:09:31 weiden Exp $ /* $Id: guicheck.c,v 1.20 2004/08/08 17:57:34 weiden Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -40,7 +40,8 @@
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
static ULONG NrGuiApplicationsRunning = 0; static LONG NrGuiAppsRunning = 0;
static FAST_MUTEX GuiSwitchLock;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
@ -48,16 +49,21 @@ static BOOL FASTCALL
AddGuiApp(PW32PROCESS W32Data) AddGuiApp(PW32PROCESS W32Data)
{ {
W32Data->Flags |= W32PF_CREATEDWINORDC; W32Data->Flags |= W32PF_CREATEDWINORDC;
if (0 == NrGuiApplicationsRunning++) if (InterlockedIncrement(&NrGuiAppsRunning) == 1)
{ {
if (! IntInitializeDesktopGraphics()) BOOL Initialized;
ExAcquireFastMutex(&GuiSwitchLock);
Initialized = IntInitializeDesktopGraphics();
ExReleaseFastMutex(&GuiSwitchLock);
if (!Initialized)
{ {
W32Data->Flags &= ~W32PF_CREATEDWINORDC; W32Data->Flags &= ~W32PF_CREATEDWINORDC;
NrGuiApplicationsRunning--; InterlockedDecrement(&NrGuiAppsRunning);
return FALSE; return FALSE;
} }
} }
return TRUE; return TRUE;
} }
@ -65,13 +71,11 @@ static void FASTCALL
RemoveGuiApp(PW32PROCESS W32Data) RemoveGuiApp(PW32PROCESS W32Data)
{ {
W32Data->Flags &= ~W32PF_CREATEDWINORDC; W32Data->Flags &= ~W32PF_CREATEDWINORDC;
if (0 < NrGuiApplicationsRunning) if (InterlockedDecrement(&NrGuiAppsRunning) == 0)
{
NrGuiApplicationsRunning--;
}
if (0 == NrGuiApplicationsRunning)
{ {
ExAcquireFastMutex(&GuiSwitchLock);
IntEndDesktopGraphics(); IntEndDesktopGraphics();
ExReleaseFastMutex(&GuiSwitchLock);
} }
} }
@ -125,4 +129,11 @@ NtUserManualGuiCheck(LONG Check)
} }
} }
NTSTATUS FASTCALL
InitGuiCheckImpl (VOID)
{
ExInitializeFastMutex(&GuiSwitchLock);
return STATUS_SUCCESS;
}
/* EOF */ /* EOF */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: msgqueue.c,v 1.102 2004/08/04 22:31:17 weiden Exp $ /* $Id: msgqueue.c,v 1.103 2004/08/08 17:57:34 weiden Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -1223,6 +1223,15 @@ MsqCreateMessageQueue(struct _ETHREAD *Thread)
VOID FASTCALL VOID FASTCALL
MsqDestroyMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue) MsqDestroyMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue)
{ {
PDESKTOP_OBJECT desk;
/* remove the message queue from any desktops */
if((desk = (PDESKTOP_OBJECT)InterlockedExchange((LONG*)&MessageQueue->Desktop, 0)))
{
InterlockedExchange((LONG*)&desk->ActiveMessageQueue, 0);
IntDereferenceMessageQueue(MessageQueue);
}
/* clean it up */
MsqCleanupMessageQueue(MessageQueue); MsqCleanupMessageQueue(MessageQueue);
/* decrease the reference counter, if it hits zero, the queue will be freed */ /* decrease the reference counter, if it hits zero, the queue will be freed */
IntDereferenceMessageQueue(MessageQueue); IntDereferenceMessageQueue(MessageQueue);