Commit in reactos/subsys/win32k on MAIN
include/guicheck.h+21.9 -> 1.10
       /msgqueue.h+31.40 -> 1.41
main/dllmain.c+8-11.78 -> 1.79
ntuser/desktop.c+18-21.17 -> 1.18
      /guicheck.c+22-111.19 -> 1.20
      /msgqueue.c+10-11.102 -> 1.103
+63-15
6 modified files
serialize gui switching and switching the focus message queue

reactos/subsys/win32k/include
guicheck.h 1.9 -> 1.10
diff -u -r1.9 -r1.10
--- guicheck.h	25 Nov 2003 22:06:31 -0000	1.9
+++ guicheck.h	8 Aug 2004 17:57:34 -0000	1.10
@@ -8,6 +8,8 @@
 BOOL FASTCALL IntCreatePrimarySurface();
 VOID FASTCALL IntDestroyPrimarySurface();
 
+NTSTATUS FASTCALL InitGuiCheckImpl (VOID);
+
 #endif /* _WIN32K_GUICHECK_H */
 
 /* EOF */

reactos/subsys/win32k/include
msgqueue.h 1.40 -> 1.41
diff -u -r1.40 -r1.41
--- msgqueue.h	4 Aug 2004 22:31:17 -0000	1.40
+++ msgqueue.h	8 Aug 2004 17:57:34 -0000	1.41
@@ -104,6 +104,9 @@
   LIST_ENTRY DispatchingMessagesHead;
   /* messages that are currently dispatched by this message queue, required for cleanup */
   LIST_ENTRY LocalDispatchingMessagesHead;
+  
+  /* Desktop that the message queue is attached to */
+  struct _DESKTOP_OBJECT *Desktop;
 } USER_MESSAGE_QUEUE, *PUSER_MESSAGE_QUEUE;
 
 BOOL FASTCALL

reactos/subsys/win32k/main
dllmain.c 1.78 -> 1.79
diff -u -r1.78 -r1.79
--- dllmain.c	2 Aug 2004 15:07:26 -0000	1.78
+++ dllmain.c	8 Aug 2004 17:57:34 -0000	1.79
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  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
  */
@@ -298,6 +298,13 @@
       return(Status);
     }
 
+  Status = InitGuiCheckImpl();
+  if (!NT_SUCCESS(Status))
+    {
+      DbgPrint("Failed to initialize GUI check implementation.\n");
+      return(Status);
+    }
+
   InitGdiObjectHandleTable ();
 
   /* Initialize FreeType library */

reactos/subsys/win32k/ntuser
desktop.c 1.17 -> 1.18
diff -u -r1.17 -r1.18
--- desktop.c	9 Jul 2004 20:57:38 -0000	1.17
+++ desktop.c	8 Aug 2004 17:57:34 -0000	1.18
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  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
  *  PROJECT:          ReactOS kernel
@@ -186,13 +186,29 @@
 VOID FASTCALL
 IntSetFocusMessageQueue(PUSER_MESSAGE_QUEUE NewQueue)
 {
+   PUSER_MESSAGE_QUEUE Old;
    PDESKTOP_OBJECT pdo = IntGetActiveDesktop();
    if (!pdo)
    {
       DPRINT("No active desktop\n");
       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)

reactos/subsys/win32k/ntuser
guicheck.c 1.19 -> 1.20
diff -u -r1.19 -r1.20
--- guicheck.c	21 May 2004 10:09:31 -0000	1.19
+++ guicheck.c	8 Aug 2004 17:57:34 -0000	1.20
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  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
  * PROJECT:          ReactOS kernel
@@ -40,7 +40,8 @@
 
 /* GLOBALS *******************************************************************/
 
-static ULONG NrGuiApplicationsRunning = 0;
+static LONG NrGuiAppsRunning = 0;
+static FAST_MUTEX GuiSwitchLock;
 
 /* FUNCTIONS *****************************************************************/
 
@@ -48,16 +49,21 @@
 AddGuiApp(PW32PROCESS W32Data)
 {
   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;
-          NrGuiApplicationsRunning--;
+          InterlockedDecrement(&NrGuiAppsRunning);
           return FALSE;
         }
     }
-
   return TRUE;
 }
 
@@ -65,13 +71,11 @@
 RemoveGuiApp(PW32PROCESS W32Data)
 {
   W32Data->Flags &= ~W32PF_CREATEDWINORDC;
-  if (0 < NrGuiApplicationsRunning)
-    {
-      NrGuiApplicationsRunning--;
-    }
-  if (0 == NrGuiApplicationsRunning)
+  if (InterlockedDecrement(&NrGuiAppsRunning) == 0)
     {
+      ExAcquireFastMutex(&GuiSwitchLock);
       IntEndDesktopGraphics();
+      ExReleaseFastMutex(&GuiSwitchLock);
     }
 }
 
@@ -125,4 +129,11 @@
     }
 }
 
+NTSTATUS FASTCALL
+InitGuiCheckImpl (VOID)
+{
+  ExInitializeFastMutex(&GuiSwitchLock);
+  return STATUS_SUCCESS;
+}
+
 /* EOF */

reactos/subsys/win32k/ntuser
msgqueue.c 1.102 -> 1.103
diff -u -r1.102 -r1.103
--- msgqueue.c	4 Aug 2004 22:31:17 -0000	1.102
+++ msgqueue.c	8 Aug 2004 17:57:34 -0000	1.103
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  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
  * PROJECT:          ReactOS kernel
@@ -1223,6 +1223,15 @@
 VOID FASTCALL
 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);
   /* decrease the reference counter, if it hits zero, the queue will be freed */
   IntDereferenceMessageQueue(MessageQueue);
CVSspam 0.2.8