Author: jimtabor
Date: Mon Jan 11 08:36:48 2010
New Revision: 45042

URL: http://svn.reactos.org/svn/reactos?rev=45042&view=rev
Log:
[Win32k]
- More movement to WND with updates to related files. Added new scroll and 
get/post message routines. In the mix we did moved to the MONITOR structure.

Modified:
    trunk/reactos/subsystems/win32/win32k/include/monitor.h
    trunk/reactos/subsystems/win32/win32k/include/scroll.h
    trunk/reactos/subsystems/win32/win32k/include/win32.h
    trunk/reactos/subsystems/win32/win32k/include/window.h
    trunk/reactos/subsystems/win32/win32k/ntuser/defwnd.c
    trunk/reactos/subsystems/win32/win32k/ntuser/focus.c
    trunk/reactos/subsystems/win32/win32k/ntuser/input.c
    trunk/reactos/subsystems/win32/win32k/ntuser/message.c
    trunk/reactos/subsystems/win32/win32k/ntuser/monitor.c
    trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c
    trunk/reactos/subsystems/win32/win32k/ntuser/painting.c
    trunk/reactos/subsystems/win32/win32k/ntuser/scrollbar.c
    trunk/reactos/subsystems/win32/win32k/ntuser/timer.c
    trunk/reactos/subsystems/win32/win32k/ntuser/window.c
    trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c

Modified: trunk/reactos/subsystems/win32/win32k/include/monitor.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/include/monitor.h?rev=45042&r1=45041&r2=45042&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/monitor.h [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/include/monitor.h [iso-8859-1] Mon 
Jan 11 08:36:48 2010
@@ -1,35 +1,36 @@
 #ifndef _WIN32K_MONITOR_H
 #define _WIN32K_MONITOR_H
 
-//struct PDEVOBJ;
-
 /* monitor object */
-typedef struct _MONITOR_OBJECT
+typedef struct _MONITOR
 {
-       HANDLE         Handle;     /* system object handle */
-       FAST_MUTEX     Lock;       /* R/W lock */
-
-       BOOL           IsPrimary;  /* wether this is the primary monitor */
-       UNICODE_STRING DeviceName; /* name of the monitor */
-       PDEVOBJ     *GdiDevice;  /* pointer to the GDI device to
-                                     which this monitor is attached */
-       struct _MONITOR_OBJECT *Prev, *Next; /* doubly linked list */
-
-       // This is the structure Windows uses:
-//    HEAD head;
-//    struct _MONITOR_OBJECT *pMonitorNext;
-//    DWORD   dwMONFlags;
+    HEAD head;
+//
+    FAST_MUTEX     Lock;       /* R/W lock */
+    UNICODE_STRING DeviceName; /* name of the monitor */
+    PDEVOBJ     *GdiDevice;    /* pointer to the GDI device to
+                                 which this monitor is attached */
+// This is the structure Windows uses:
+//    struct _MONITOR* pMonitorNext;
+    union  {        
+    DWORD   dwMONFlags;
+    struct {
+    DWORD   IsVisible:1;
+    DWORD   IsPalette:1;
+    DWORD   IsPrimary:1;  /* wether this is the primary monitor */
+    };};
     RECT    rcMonitor;
     RECT    rcWork;
-//    HRGN    hrgnMonitor;
-//    SHORT   Spare0;
-//    SHORT   cWndStack;
-//    HDEV    hDev;
-//    HDEV    hDevReal;
+    HRGN    hrgnMonitor;
+    SHORT   Spare0;
+    SHORT   cWndStack;
+    HDEV    hDev;
+    HDEV    hDevReal;
 //    BYTE    DockTargets[4][7];
-//    struct _MONITOR_OBJECT* Flink;
-//    struct _MONITOR_OBJECT* Blink;
-} MONITOR_OBJECT, *PMONITOR_OBJECT;
+// Use LIST_ENTRY
+    struct _MONITOR* Next; //Flink;
+    struct _MONITOR* Prev; //Blink;
+} MONITOR, *PMONITOR;
 
 /* functions */
 NTSTATUS InitMonitorImpl();
@@ -37,7 +38,8 @@
 
 NTSTATUS IntAttachMonitor(PDEVOBJ *pGdiDevice, ULONG DisplayNumber);
 NTSTATUS IntDetachMonitor(PDEVOBJ *pGdiDevice);
-PMONITOR_OBJECT FASTCALL UserGetMonitorObject(IN HMONITOR);
+PMONITOR FASTCALL UserGetMonitorObject(IN HMONITOR);
+PMONITOR FASTCALL IntGetPrimaryMonitor(VOID);
 
 #endif /* _WIN32K_MONITOR_H */
 

Modified: trunk/reactos/subsystems/win32/win32k/include/scroll.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/include/scroll.h?rev=45042&r1=45041&r2=45042&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/scroll.h [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/include/scroll.h [iso-8859-1] Mon Jan 
11 08:36:48 2010
@@ -1,5 +1,49 @@
 #ifndef _WIN32K_SCROLL_H
 #define _WIN32K_SCROLL_H
+
+typedef struct tagSBCALC
+{
+    INT posMin;
+    INT posMax;
+    INT page;
+    INT pos;
+    INT pxTop;
+    INT pxBottom;
+    INT pxLeft;
+    INT pxRight;
+    INT cpxThumb;
+    INT pxUpArrow;
+    INT pxDownArrow;
+    INT pxStart;
+    INT pxThumbBottom;
+    INT pxThumbTop;
+    INT cpx;
+    INT pxMin;
+} SBCALC, *PSBCALC;
+
+typedef VOID (NEAR NTAPI *PFN_SCROLLBAR)(PWND, UINT, WPARAM, LPARAM, PSBCALC);
+
+typedef struct tagSBTRACK
+{
+    ULONG    fHitOld:1;
+    ULONG    fTrackVert:1;
+    ULONG    fCtlSB:1;
+    ULONG    fTrackRecalc:1;
+    PWND     spwndTrack;
+    PWND     spwndSB;
+    PWND     spwndSBNotify;
+    RECT     rcTrack;
+    PFN_SCROLLBAR xxxpfnSB;
+    UINT     cmdSB;
+    UINT_PTR hTimerSB;
+    INT      dpxThumb;
+    INT      pxOld;
+    INT      posOld;
+    INT      posNew;
+    INT      nBar;
+    PSBCALC  pSBCalc;
+} SBTRACK, *PSBTRACK;
+
 
 typedef struct _SBINFOEX
 {

Modified: trunk/reactos/subsystems/win32/win32k/include/win32.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/include/win32.h?rev=45042&r1=45041&r2=45042&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/win32.h [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/include/win32.h [iso-8859-1] Mon Jan 
11 08:36:48 2010
@@ -88,6 +88,11 @@
     PTHREADINFO         ptiSibling;
     ULONG               fsHooks;
     PHOOK               sphkCurrent;
+    LPARAM              lParamHkCurrent;
+    WPARAM              wParamHkCurrent;
+    struct tagSBTRACK*  pSBTrack;
+    HANDLE              hEventQueueClient;
+    PKEVENT             pEventQueueServer;
     LIST_ENTRY          PtiLink;
 
     CLIENTTHREADINFO    cti;  // Used only when no Desktop or pcti NULL.
@@ -107,6 +112,23 @@
     ULONG_PTR Limit;
     ULONG Count;
 } W32HEAP_USER_MAPPING, *PW32HEAP_USER_MAPPING;
+
+
+/*
+ Information from STARTUPINFOW, psdk/winbase.h.
+ Set from PsGetCurrentProcess()->Peb->ProcessParameters.
+*/
+typedef struct tagUSERSTARTUPINFO
+{
+    ULONG cb;
+    DWORD dwX;        // STARTF_USEPOSITION StartupInfo->dwX/Y
+    DWORD dwY;
+    DWORD dwXSize;    // STARTF_USESIZE StartupInfo->dwX/YSize
+    DWORD dwYSize;
+    DWORD dwFlags;    // STARTF_ StartupInfo->dwFlags
+    WORD wShowWindow; // StartupInfo->wShowWindow
+    USHORT cbReserved2;
+} USERSTARTUPINFO, *PUSERSTARTUPINFO;
 
 typedef struct _W32PROCESS
 {
@@ -130,10 +152,17 @@
 typedef struct _PROCESSINFO
 {
   W32PROCESS;
-
+  PTHREADINFO ptiList;
+  PTHREADINFO ptiMainThread;
+  struct _DESKTOP* rpdeskStartup;
   PCLS pclsPrivateList;
   PCLS pclsPublicList;
 
+  HMONITOR hMonitor;
+
+  USERSTARTUPINFO usi;
+  ULONG Flags;
+  DWORD dwLayout;
   DWORD dwRegisteredClasses;
   /* ReactOS */
   LIST_ENTRY ClassList;

Modified: trunk/reactos/subsystems/win32/win32k/include/window.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/include/window.h?rev=45042&r1=45041&r2=45042&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/window.h [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/include/window.h [iso-8859-1] Mon Jan 
11 08:36:48 2010
@@ -39,8 +39,6 @@
   HANDLE hrgnUpdate;
   /* Handle of the window region. */
   HANDLE hrgnClip;
-  /* Pointer to the owning thread's message queue. */
-  PUSER_MESSAGE_QUEUE MessageQueue;
   struct _WINDOW_OBJECT* spwndChild;
   struct _WINDOW_OBJECT* spwndNext;
   struct _WINDOW_OBJECT* spwndPrev;
@@ -54,9 +52,7 @@
   PDCE Dce;
   /* Scrollbar info */
   PSBINFOEX pSBInfo; // convert to PSBINFO
-  PETHREAD OwnerThread; // Use Wnd->head.pti
-  /* counter for tiled child windows */
-  ULONG TiledCounter;
+  PETHREAD OwnerThread; // Use Wnd->head.pti->pEThread
   /* WNDOBJ list */
   LIST_ENTRY WndObjListHead; // Use Props
 } WINDOW_OBJECT; /* PWINDOW_OBJECT already declared at top of file */

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/defwnd.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/defwnd.c?rev=45042&r1=45041&r2=45042&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/defwnd.c [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/defwnd.c [iso-8859-1] Mon Jan 
11 08:36:48 2010
@@ -67,7 +67,7 @@
              co_IntSendMessage(WndChild->hSelf, WM_ENDSESSION, KillTimers, 
lParams);
              if (KillTimers)
              {
-                MsqRemoveTimersWindow(WndChild->MessageQueue, WndChild->hSelf);
+                MsqRemoveTimersWindow(WndChild->pti->MessageQueue, 
WndChild->hSelf);
              }
              lResult = MCSR_SHUTDOWNFINISHED;
           }
@@ -90,7 +90,7 @@
       co_IntSendMessage(pWindow->hSelf, WM_ENDSESSION, KillTimers, lParams);
       if (KillTimers)
       {
-         MsqRemoveTimersWindow(pWindow->MessageQueue, pWindow->hSelf);
+         MsqRemoveTimersWindow(pWindow->pti->MessageQueue, pWindow->hSelf);
       }
       lResult = MCSR_SHUTDOWNFINISHED;
    }

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/focus.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/focus.c?rev=45042&r1=45041&r2=45042&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/focus.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/focus.c [iso-8859-1] Mon Jan 
11 08:36:48 2010
@@ -235,26 +235,26 @@
       return TRUE;
    }
 
-   hWndFocusPrev = (PrevForegroundQueue == FocusWindow->MessageQueue
-                    ? FocusWindow->MessageQueue->FocusWindow : NULL);
+   hWndFocusPrev = (PrevForegroundQueue == FocusWindow->pti->MessageQueue
+                    ? FocusWindow->pti->MessageQueue->FocusWindow : NULL);
 
    /* FIXME: Call hooks. */
 
    co_IntSendDeactivateMessages(hWndPrev, hWnd);
    co_IntSendKillFocusMessages(hWndFocusPrev, hWndFocus);
 
-   IntSetFocusMessageQueue(Window->MessageQueue);
-   if (Window->MessageQueue)
-   {
-      Window->MessageQueue->ActiveWindow = hWnd;
-   }
-
-   if (FocusWindow->MessageQueue)
-   {
-      FocusWindow->MessageQueue->FocusWindow = hWndFocus;
-   }
-
-   if (PrevForegroundQueue != Window->MessageQueue)
+   IntSetFocusMessageQueue(Window->pti->MessageQueue);
+   if (Window->pti->MessageQueue)
+   {
+      Window->pti->MessageQueue->ActiveWindow = hWnd;
+   }
+
+   if (FocusWindow->pti->MessageQueue)
+   {
+      FocusWindow->pti->MessageQueue->FocusWindow = hWndFocus;
+   }
+
+   if (PrevForegroundQueue != Window->pti->MessageQueue)
    {
       /* FIXME: Send WM_ACTIVATEAPP to all thread windows. */
    }
@@ -482,7 +482,7 @@
       pti = PsGetCurrentThreadWin32Thread();
       ThreadQueue = pti->MessageQueue;
 
-      if (Window->MessageQueue != ThreadQueue)
+      if (Window->pti->MessageQueue != ThreadQueue)
       {
          SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
          RETURN( 0);
@@ -546,7 +546,7 @@
 
    if((Window = UserGetWindowObject(hWnd)))
    {
-      if(Window->MessageQueue != ThreadQueue)
+      if(Window->pti->MessageQueue != ThreadQueue)
       {
          RETURN(NULL);
       }
@@ -596,7 +596,7 @@
          return( (ThreadQueue ? ThreadQueue->FocusWindow : 0));
       }
 
-      if (Window->MessageQueue != ThreadQueue)
+      if (Window->pti->MessageQueue != ThreadQueue)
       {
          SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
          return( 0);

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/input.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/input.c?rev=45042&r1=45041&r2=45042&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/input.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/input.c [iso-8859-1] Mon Jan 
11 08:36:48 2010
@@ -458,7 +458,7 @@
    Mesg.lParam = 0;
 
    /* The QS_HOTKEY is just a guess */
-   MsqPostMessage(Window->MessageQueue, &Mesg, FALSE, QS_HOTKEY);
+   MsqPostMessage(Window->pti->MessageQueue, &Mesg, FALSE, QS_HOTKEY);
 }
 
 static VOID APIENTRY

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/message.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/message.c?rev=45042&r1=45041&r2=45042&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/message.c [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/message.c [iso-8859-1] Mon Jan 
11 08:36:48 2010
@@ -541,7 +541,7 @@
 
    UserRefObjectCo(Window, &Ref);
 
-   if ( ThreadQueue == Window->MessageQueue &&
+   if ( ThreadQueue == Window->pti->MessageQueue &&
         ThreadQueue->CaptureWindow != Window->hSelf)
    {
       /* only send WM_NCHITTEST messages if we're not capturing the window! */
@@ -559,7 +559,7 @@
 
             UserRefObjectCo(DesktopWindow, &DesktopRef);
 
-            co_WinPosWindowFromPoint(DesktopWindow, Window->MessageQueue, 
&Msg->pt, &Wnd);
+            co_WinPosWindowFromPoint(DesktopWindow, Window->pti->MessageQueue, 
&Msg->pt, &Wnd);
             if (Wnd)
             {
                if (Wnd != Window)
@@ -568,7 +568,7 @@
                   Msg->hwnd = Wnd->hSelf;
                   if(!(Wnd->state & WINDOWSTATUS_DESTROYING))
                   {
-                     MsqPostMessage(Wnd->MessageQueue, Msg, FALSE,
+                     MsqPostMessage(Wnd->pti->MessageQueue, Msg, FALSE,
                                     Msg->message == WM_MOUSEMOVE ? 
QS_MOUSEMOVE :
                                     QS_MOUSEBUTTON);
                   }
@@ -671,9 +671,27 @@
    ThreadQueue = pti->MessageQueue;
 
    /* Inspect RemoveMsg flags */
-   /* FIXME: The only flag we process is PM_REMOVE - processing of others must 
still be implemented */
+   /* Note:
+       The only flag we process is PM_REMOVE.
+       Processing (High word) PM_QS_Xx Is needed. This and MsgFilterXxx can 
result
+       with QS_Xx flags to be used to isolate which message check to test for.
+       ATM, we look at all messages and the filters are sent to 
co_MsqFindMessage
+       and there, it is cross checked.
+       Example: Wine server/queue.c is_keyboard_msg, check_msg_filter and
+                filter_contains_hw_range.
+    */
    RemoveMessages = RemoveMsg & PM_REMOVE;
 
+/*
+   If no filter is specified, messages are processed in the following order:
+
+    * Sent messages
+    * Posted messages
+    * Input (hardware) messages and system internal events
+    * Sent messages (again)
+    * WM_PAINT messages
+    * WM_TIMER messages
+ */
 CheckMessages:
 
    Present = FALSE;
@@ -834,7 +852,8 @@
          goto MsgExit;
       }
 
-      if ( ( Msg->Msg.hwnd && Msg->Msg.message >= WM_MOUSEFIRST &&
+      if ( ( Msg->Msg.hwnd &&
+             Msg->Msg.message >= WM_MOUSEFIRST &&
              Msg->Msg.message <= WM_MOUSELAST ) &&
            co_IntTranslateMouseMessage( ThreadQueue,
                                        &Msg->Msg,
@@ -908,6 +927,139 @@
    return Present;
 }
 
+static NTSTATUS FASTCALL
+CopyMsgToKernelMem(MSG *KernelModeMsg, MSG *UserModeMsg, PMSGMEMORY 
MsgMemoryEntry)
+{
+   NTSTATUS Status;
+
+   PVOID KernelMem;
+   UINT Size;
+
+   *KernelModeMsg = *UserModeMsg;
+
+   /* See if this message type is present in the table */
+   if (NULL == MsgMemoryEntry)
+   {
+      /* Not present, no copying needed */
+      return STATUS_SUCCESS;
+   }
+
+   /* Determine required size */
+   Size = MsgMemorySize(MsgMemoryEntry, UserModeMsg->wParam, 
UserModeMsg->lParam);
+
+   if (0 != Size)
+   {
+      /* Allocate kernel mem */
+      KernelMem = ExAllocatePoolWithTag(PagedPool, Size, TAG_MSG);
+      if (NULL == KernelMem)
+      {
+         DPRINT1("Not enough memory to copy message to kernel mem\n");
+         return STATUS_NO_MEMORY;
+      }
+      KernelModeMsg->lParam = (LPARAM) KernelMem;
+
+      /* Copy data if required */
+      if (0 != (MsgMemoryEntry->Flags & MMS_FLAG_READ))
+      {
+         Status = MmCopyFromCaller(KernelMem, (PVOID) UserModeMsg->lParam, 
Size);
+         if (! NT_SUCCESS(Status))
+         {
+            DPRINT1("Failed to copy message to kernel: invalid usermode 
buffer\n");
+            ExFreePoolWithTag(KernelMem, TAG_MSG);
+            return Status;
+         }
+      }
+      else
+      {
+         /* Make sure we don't pass any secrets to usermode */
+         RtlZeroMemory(KernelMem, Size);
+      }
+   }
+   else
+   {
+      KernelModeMsg->lParam = 0;
+   }
+
+   return STATUS_SUCCESS;
+}
+
+static NTSTATUS FASTCALL
+CopyMsgToUserMem(MSG *UserModeMsg, MSG *KernelModeMsg)
+{
+   NTSTATUS Status;
+   PMSGMEMORY MsgMemoryEntry;
+   UINT Size;
+
+   /* See if this message type is present in the table */
+   MsgMemoryEntry = FindMsgMemory(UserModeMsg->message);
+   if (NULL == MsgMemoryEntry)
+   {
+      /* Not present, no copying needed */
+      return STATUS_SUCCESS;
+   }
+
+   /* Determine required size */
+   Size = MsgMemorySize(MsgMemoryEntry, UserModeMsg->wParam, 
UserModeMsg->lParam);
+
+   if (0 != Size)
+   {
+      /* Copy data if required */
+      if (0 != (MsgMemoryEntry->Flags & MMS_FLAG_WRITE))
+      {
+         Status = MmCopyToCaller((PVOID) UserModeMsg->lParam, (PVOID) 
KernelModeMsg->lParam, Size);
+         if (! NT_SUCCESS(Status))
+         {
+            DPRINT1("Failed to copy message from kernel: invalid usermode 
buffer\n");
+            ExFreePool((PVOID) KernelModeMsg->lParam);
+            return Status;
+         }
+      }
+
+      ExFreePool((PVOID) KernelModeMsg->lParam);
+   }
+
+   return STATUS_SUCCESS;
+}
+
+static BOOL FASTCALL
+co_IntWaitMessage( PWINDOW_OBJECT Window,
+                   UINT MsgFilterMin,
+                   UINT MsgFilterMax )
+{
+   PTHREADINFO pti;
+   PUSER_MESSAGE_QUEUE ThreadQueue;
+   NTSTATUS Status = STATUS_SUCCESS;
+   USER_MESSAGE Msg;
+
+   pti = PsGetCurrentThreadWin32Thread();
+   ThreadQueue = pti->MessageQueue;
+
+   do
+   {
+      if ( co_IntPeekMessage( &Msg,
+                               Window,
+                               MsgFilterMin,
+                               MsgFilterMax,
+                               PM_NOREMOVE))
+      {
+         return TRUE;
+      }
+      /* Nothing found. Wait for new messages. */
+      Status = co_MsqWaitForNewMessages( ThreadQueue,
+                                         Window,
+                                         MsgFilterMin,
+                                         MsgFilterMax);
+   }
+   while ( (STATUS_WAIT_0 <= Status && Status <= STATUS_WAIT_63) ||
+           STATUS_TIMEOUT == Status );
+
+   SetLastNtError(Status);
+
+   DPRINT1("Exit co_IntWaitMessage on error!\n");
+
+   return FALSE;
+}
+
 BOOL FASTCALL
 co_IntGetPeekMessage( PMSG pMsg,
                       HWND hWnd,
@@ -916,142 +1068,72 @@
                       UINT RemoveMsg,
                       BOOL bGMSG )
 {
+   BOOL Present;
+   PWINDOW_OBJECT Window;
+   USER_MESSAGE Msg;
+
+   if ( hWnd == HWND_TOPMOST ||
+        hWnd == HWND_BROADCAST )
+      hWnd = HWND_BOTTOM;
+
+   /* Validate input */
+   if (hWnd && hWnd != HWND_BOTTOM)
+   {
+      if (!(Window = UserGetWindowObject(hWnd)))
+      {
+         if (bGMSG)
+            return -1;
+         else
+            return FALSE;
+      }
+   }
+   else
+   {
+      Window = (PWINDOW_OBJECT)hWnd;
+   }
+
+   if (MsgFilterMax < MsgFilterMin)
+   {
+      MsgFilterMin = 0;
+      MsgFilterMax = 0;
+   }
+
+   do
+   {
+      Present = co_IntPeekMessage( &Msg,
+                                    Window,
+                                    MsgFilterMin,
+                                    MsgFilterMax,
+                                    RemoveMsg );
+      if (Present)
+      {
+         RtlCopyMemory( pMsg, &Msg.Msg, sizeof(MSG));
+
+         if (bGMSG)
+            return (WM_QUIT != pMsg->message);
+         else
+            return TRUE;
+      }
+
+      if ( bGMSG && !co_IntWaitMessage(Window, MsgFilterMin, MsgFilterMax) )
+      {
+         return -1;
+      }
+      else
+      {
+         if (!(RemoveMsg & PM_NOYIELD))
+         {
+         // Yield this thread!
+            UserLeave();
+            ZwYieldExecution();
+            UserEnterExclusive();
+         // Fall through to fail.
+         }
+      }
+   }
+   while( bGMSG && !Present );
+
    return FALSE;
-}
-
-
-static BOOL FASTCALL
-co_IntWaitMessage( PWINDOW_OBJECT Window,
-                   UINT MsgFilterMin,
-                   UINT MsgFilterMax )
-{
-   PTHREADINFO pti;
-   PUSER_MESSAGE_QUEUE ThreadQueue;
-   NTSTATUS Status = STATUS_SUCCESS;
-   USER_MESSAGE Msg;
-
-   pti = PsGetCurrentThreadWin32Thread();
-   ThreadQueue = pti->MessageQueue;
-
-   do
-   {
-      if ( co_IntPeekMessage( &Msg,
-                               Window,
-                               MsgFilterMin,
-                               MsgFilterMax,
-                               PM_NOREMOVE))
-      {
-         return TRUE;
-      }
-      /* Nothing found. Wait for new messages. */
-      Status = co_MsqWaitForNewMessages( ThreadQueue,
-                                         Window,
-                                         MsgFilterMin,
-                                         MsgFilterMax);
-   }
-   while ( (STATUS_WAIT_0 <= Status && Status <= STATUS_WAIT_63) ||
-           STATUS_TIMEOUT == Status );
-
-   SetLastNtError(Status);
-
-   DPRINT1("Exit co_IntWaitMessage on error!\n");
-
-   return FALSE;
-}
-
-
-static NTSTATUS FASTCALL
-CopyMsgToKernelMem(MSG *KernelModeMsg, MSG *UserModeMsg, PMSGMEMORY 
MsgMemoryEntry)
-{
-   NTSTATUS Status;
-
-   PVOID KernelMem;
-   UINT Size;
-
-   *KernelModeMsg = *UserModeMsg;
-
-   /* See if this message type is present in the table */
-   if (NULL == MsgMemoryEntry)
-   {
-      /* Not present, no copying needed */
-      return STATUS_SUCCESS;
-   }
-
-   /* Determine required size */
-   Size = MsgMemorySize(MsgMemoryEntry, UserModeMsg->wParam, 
UserModeMsg->lParam);
-
-   if (0 != Size)
-   {
-      /* Allocate kernel mem */
-      KernelMem = ExAllocatePoolWithTag(PagedPool, Size, TAG_MSG);
-      if (NULL == KernelMem)
-      {
-         DPRINT1("Not enough memory to copy message to kernel mem\n");
-         return STATUS_NO_MEMORY;
-      }
-      KernelModeMsg->lParam = (LPARAM) KernelMem;
-
-      /* Copy data if required */
-      if (0 != (MsgMemoryEntry->Flags & MMS_FLAG_READ))
-      {
-         Status = MmCopyFromCaller(KernelMem, (PVOID) UserModeMsg->lParam, 
Size);
-         if (! NT_SUCCESS(Status))
-         {
-            DPRINT1("Failed to copy message to kernel: invalid usermode 
buffer\n");
-            ExFreePoolWithTag(KernelMem, TAG_MSG);
-            return Status;
-         }
-      }
-      else
-      {
-         /* Make sure we don't pass any secrets to usermode */
-         RtlZeroMemory(KernelMem, Size);
-      }
-   }
-   else
-   {
-      KernelModeMsg->lParam = 0;
-   }
-
-   return STATUS_SUCCESS;
-}
-
-static NTSTATUS FASTCALL
-CopyMsgToUserMem(MSG *UserModeMsg, MSG *KernelModeMsg)
-{
-   NTSTATUS Status;
-   PMSGMEMORY MsgMemoryEntry;
-   UINT Size;
-
-   /* See if this message type is present in the table */
-   MsgMemoryEntry = FindMsgMemory(UserModeMsg->message);
-   if (NULL == MsgMemoryEntry)
-   {
-      /* Not present, no copying needed */
-      return STATUS_SUCCESS;
-   }
-
-   /* Determine required size */
-   Size = MsgMemorySize(MsgMemoryEntry, UserModeMsg->wParam, 
UserModeMsg->lParam);
-
-   if (0 != Size)
-   {
-      /* Copy data if required */
-      if (0 != (MsgMemoryEntry->Flags & MMS_FLAG_WRITE))
-      {
-         Status = MmCopyToCaller((PVOID) UserModeMsg->lParam, (PVOID) 
KernelModeMsg->lParam, Size);
-         if (! NT_SUCCESS(Status))
-         {
-            DPRINT1("Failed to copy message from kernel: invalid usermode 
buffer\n");
-            ExFreePool((PVOID) KernelModeMsg->lParam);
-            return Status;
-         }
-      }
-
-      ExFreePool((PVOID) KernelModeMsg->lParam);
-   }
-
-   return STATUS_SUCCESS;
 }
 
 BOOL FASTCALL
@@ -1079,7 +1161,9 @@
    if( Status == STATUS_SUCCESS )
    {
       pThread = (PTHREADINFO)peThread->Tcb.Win32Thread;
-      if( !pThread || !pThread->MessageQueue || (pThread->TIF_flags & 
TIF_INCLEANUP))
+      if( !pThread ||
+          !pThread->MessageQueue ||
+         (pThread->TIF_flags & TIF_INCLEANUP))
       {
          ObDereferenceObject( peThread );
          return FALSE;
@@ -1168,7 +1252,7 @@
 
       if (WM_QUIT == Msg)
       {
-          MsqPostQuitMessage(Window->MessageQueue, wParam);
+          MsqPostQuitMessage(Window->pti->MessageQueue, wParam);
       }
       else
       {
@@ -1179,7 +1263,7 @@
          Message.pt = gpsi->ptCursor;
          KeQueryTickCount(&LargeTickCount);
          pti->timeLast = Message.time = 
MsqCalculateMessageTime(&LargeTickCount);
-         MsqPostMessage(Window->MessageQueue, &Message, FALSE, QS_POSTMESSAGE);
+         MsqPostMessage(Window->pti->MessageQueue, &Message, FALSE, 
QS_POSTMESSAGE);
       }
    }
    return TRUE;
@@ -1232,7 +1316,7 @@
    IntCallWndProc( Window, hWnd, Msg, wParam, lParam);
 
    if ( NULL != Win32Thread &&
-        Window->MessageQueue == Win32Thread->MessageQueue)
+        Window->pti->MessageQueue == Win32Thread->MessageQueue)
    {
       if (Win32Thread->TIF_flags & TIF_INCLEANUP)
       {
@@ -1280,7 +1364,7 @@
       RETURN( TRUE);
    }
 
-   if (uFlags & SMTO_ABORTIFHUNG && MsqIsHung(Window->MessageQueue))
+   if (uFlags & SMTO_ABORTIFHUNG && MsqIsHung(Window->pti->MessageQueue))
    {
       /* FIXME - Set a LastError? */
       RETURN( FALSE);
@@ -1295,19 +1379,19 @@
 
    do
    {
-      Status = co_MsqSendMessage( Window->MessageQueue,
-                                                  hWnd,
-                                                   Msg,
-                                                wParam,
-                                                lParam,
-                                              uTimeout,
-                                 (uFlags & SMTO_BLOCK),
-                                            MSQ_NORMAL,
-                                               uResult );
+      Status = co_MsqSendMessage( Window->pti->MessageQueue,
+                                                       hWnd,
+                                                        Msg,
+                                                     wParam,
+                                                     lParam,
+                                                   uTimeout,
+                                      (uFlags & SMTO_BLOCK),
+                                                 MSQ_NORMAL,
+                                                    uResult );
    }
    while ((STATUS_TIMEOUT == Status) &&
           (uFlags & SMTO_NOTIMEOUTIFNOTHUNG) &&
-          !MsqIsHung(Window->MessageQueue));
+          !MsqIsHung(Window->pti->MessageQueue));
 
    IntCallWndProcRet( Window, hWnd, Msg, wParam, lParam, (LRESULT *)uResult);
 
@@ -1404,7 +1488,7 @@
 
    pti = PsGetCurrentThreadWin32Thread();
 
-   if ( Window->MessageQueue != pti->MessageQueue &&
+   if ( Window->pti->MessageQueue != pti->MessageQueue &&
         FindMsgMemory(Msg) == 0 )
    {
       Result = UserPostMessage(hWnd, Msg, wParam, lParam);
@@ -1464,7 +1548,7 @@
    // This is checked in user mode!!!!!!!
    if ( HWND_BROADCAST != hWnd &&
         NULL != pti &&
-        Window->MessageQueue == pti->MessageQueue &&
+        Window->pti->MessageQueue == pti->MessageQueue &&
        !ISITHOOKED(WH_CALLWNDPROC) &&
        !ISITHOOKED(WH_CALLWNDPROCRET) &&
         ( Msg < WM_DDE_FIRST || Msg > WM_DDE_LAST ) )
@@ -1585,7 +1669,7 @@
 
       pti = PsGetCurrentThreadWin32Thread();
 
-      if (Window->MessageQueue != pti->MessageQueue)
+      if (Window->pti->MessageQueue != pti->MessageQueue)
       { // Send message w/o waiting for it.
          Result = UserPostMessage(hWnd, Msg, wParam, lParam);
       }
@@ -1926,6 +2010,8 @@
       RETURN( Ret);
    }
 
+   RtlZeroMemory(&Msg, sizeof(MSG));
+
    Ret = co_IntGetPeekMessage(&Msg, hWnd, MsgFilterMin, MsgFilterMax, 
PM_REMOVE, TRUE);
 
    if (Ret)
@@ -2071,6 +2157,8 @@
       SetLastWin32Error(ERROR_INVALID_FLAGS);
       RETURN( Ret);
    }
+
+   RtlZeroMemory(&Msg, sizeof(MSG));
 
    Ret = co_IntGetPeekMessage(&Msg, hWnd, MsgFilterMin, MsgFilterMax, 
RemoveMsg, FALSE);
 

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/monitor.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/monitor.c?rev=45042&r1=45041&r2=45042&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/monitor.c [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/monitor.c [iso-8859-1] Mon Jan 
11 08:36:48 2010
@@ -41,7 +41,7 @@
 /* GLOBALS *******************************************************************/
 
 /* list of monitors */
-static PMONITOR_OBJECT gMonitorList = NULL;
+static PMONITOR gMonitorList = NULL;
 
 /* INITALIZATION FUNCTIONS 
****************************************************/
 
@@ -76,26 +76,26 @@
 
 /* IntCreateMonitorObject
  *
- * Creates a MONITOR_OBJECT
+ * Creates a MONITOR
  *
  * Return value
- *   If the function succeeds a pointer to a MONITOR_OBJECT is returned. On 
failure
+ *   If the function succeeds a pointer to a MONITOR is returned. On failure
  *   NULL is returned.
  */
 static
-PMONITOR_OBJECT
+PMONITOR
 IntCreateMonitorObject()
 {
    HANDLE Handle;
-   PMONITOR_OBJECT Monitor;
-
-   Monitor = UserCreateObject(gHandleTable, &Handle, otMonitor, sizeof 
(MONITOR_OBJECT));
+   PMONITOR Monitor;
+
+   Monitor = UserCreateObject(gHandleTable, &Handle, otMonitor, sizeof 
(MONITOR));
    if (Monitor == NULL)
    {
       return NULL;
    }
 
-   Monitor->Handle = Handle;
+   Monitor->head.h = Handle;
    ExInitializeFastMutex(&Monitor->Lock);
 
    return Monitor;
@@ -103,27 +103,27 @@
 
 /* IntDestroyMonitorObject
  *
- * Destroys a MONITOR_OBJECT
+ * Destroys a MONITOR
  * You have to be the owner of the monitors lock to safely destroy it.
  *
  * Arguments
  *
  *   pMonitor
- *      Pointer to the MONITOR_OBJECT which shall be deleted
+ *      Pointer to the MONITOR which shall be deleted
  */
 static
 void
-IntDestroyMonitorObject(IN PMONITOR_OBJECT pMonitor)
+IntDestroyMonitorObject(IN PMONITOR pMonitor)
 {
    RtlFreeUnicodeString(&pMonitor->DeviceName);
    UserDereferenceObject(pMonitor);
 }
 
 
-PMONITOR_OBJECT FASTCALL
+PMONITOR FASTCALL
 UserGetMonitorObject(IN HMONITOR hMonitor)
 {
-   PMONITOR_OBJECT Monitor;
+   PMONITOR Monitor;
 
    if (!hMonitor)
    {
@@ -132,7 +132,7 @@
    }
 
 
-   Monitor = (PMONITOR_OBJECT)UserGetObject(gHandleTable, hMonitor, otMonitor);
+   Monitor = (PMONITOR)UserGetObject(gHandleTable, hMonitor, otMonitor);
    if (!Monitor)
    {
       SetLastWin32Error(ERROR_INVALID_MONITOR_HANDLE);
@@ -147,7 +147,7 @@
 
 /* IntAttachMonitor
  *
- * Creates a new MONITOR_OBJECT and appends it to the list of monitors.
+ * Creates a new MONITOR and appends it to the list of monitors.
  *
  * Arguments
  *
@@ -161,7 +161,7 @@
 IntAttachMonitor(IN PDEVOBJ *pGdiDevice,
                  IN ULONG DisplayNumber)
 {
-   PMONITOR_OBJECT Monitor;
+   PMONITOR Monitor;
    WCHAR Buffer[CCHDEVICENAME];
 
    DPRINT("Attaching monitor...\n");
@@ -179,11 +179,18 @@
    {
       DPRINT("Couldn't duplicate monitor name!\n");
       UserDereferenceObject(Monitor);
-      UserDeleteObject(Monitor->Handle, otMonitor);
+      UserDeleteObject(Monitor->head.h, otMonitor);
       return STATUS_INSUFFICIENT_RESOURCES;
    }
 
    Monitor->GdiDevice = pGdiDevice;
+   Monitor->rcMonitor.left  = 0;
+   Monitor->rcMonitor.top   = 0;   
+   Monitor->rcMonitor.right  = Monitor->rcMonitor.left + 
pGdiDevice->gdiinfo.ulHorzRes; 
+   Monitor->rcMonitor.bottom = Monitor->rcMonitor.top + 
pGdiDevice->gdiinfo.ulVertRes;
+   Monitor->rcWork = Monitor->rcMonitor;
+   Monitor->cWndStack = 0;
+
    if (gMonitorList == NULL)
    {
       DPRINT("Primary monitor is beeing attached\n");
@@ -192,7 +199,7 @@
    }
    else
    {
-      PMONITOR_OBJECT p;
+      PMONITOR p;
       DPRINT("Additional monitor is beeing attached\n");
       for (p = gMonitorList; p->Next != NULL; p = p->Next)
       {
@@ -206,7 +213,7 @@
 
 /* IntDetachMonitor
  *
- * Deletes a MONITOR_OBJECT and removes it from the list of monitors.
+ * Deletes a MONITOR and removes it from the list of monitors.
  *
  * Arguments
  *
@@ -218,7 +225,7 @@
 NTSTATUS
 IntDetachMonitor(IN PDEVOBJ *pGdiDevice)
 {
-   PMONITOR_OBJECT Monitor;
+   PMONITOR Monitor;
 
    for (Monitor = gMonitorList; Monitor != NULL; Monitor = Monitor->Next)
    {
@@ -234,7 +241,7 @@
 
    if (Monitor->IsPrimary && (Monitor->Next != NULL || Monitor->Prev != NULL))
    {
-      PMONITOR_OBJECT NewPrimaryMonitor = (Monitor->Prev != NULL) ? 
(Monitor->Prev) : (Monitor->Next);
+      PMONITOR NewPrimaryMonitor = (Monitor->Prev != NULL) ? (Monitor->Prev) : 
(Monitor->Next);
 
       ExEnterCriticalRegionAndAcquireFastMutexUnsafe(&NewPrimaryMonitor->Lock);
       NewPrimaryMonitor->IsPrimary = TRUE;
@@ -261,16 +268,16 @@
 
 /* IntGetPrimaryMonitor
  *
- * Returns a PMONITOR_OBJECT for the primary monitor
+ * Returns a PMONITOR for the primary monitor
  *
  * Return value
- *   PMONITOR_OBJECT
- */
-static
-PMONITOR_OBJECT
+ *   PMONITOR
+ */
+PMONITOR
+FASTCALL
 IntGetPrimaryMonitor()
 {
-   PMONITOR_OBJECT Monitor;
+   PMONITOR Monitor;
 
    for (Monitor = gMonitorList; Monitor != NULL; Monitor = Monitor->Next)
    {
@@ -321,7 +328,7 @@
                        OPTIONAL IN DWORD listSize,
                        OPTIONAL IN DWORD flags)
 {
-   PMONITOR_OBJECT Monitor, NearestMonitor = NULL, PrimaryMonitor = NULL;
+   PMONITOR Monitor, NearestMonitor = NULL, PrimaryMonitor = NULL;
    UINT iCount = 0;
    LONG iNearestDistanceX = 0x7fffffff, iNearestDistanceY = 0x7fffffff;
 
@@ -391,7 +398,7 @@
       if (iCount < listSize)
       {
          if (hMonitorList != NULL)
-            hMonitorList[iCount] = Monitor->Handle;
+            hMonitorList[iCount] = Monitor->head.h;
          if (monitorRectList != NULL)
             monitorRectList[iCount] = IntersectionRect;
       }
@@ -403,7 +410,7 @@
       if (iCount < listSize)
       {
          if (hMonitorList != NULL)
-            hMonitorList[iCount] = NearestMonitor->Handle;
+            hMonitorList[iCount] = NearestMonitor->head.h;
       }
       iCount++;
    }
@@ -412,7 +419,7 @@
       if (iCount < listSize)
       {
          if (hMonitorList != NULL)
-            hMonitorList[iCount] = PrimaryMonitor->Handle;
+            hMonitorList[iCount] = PrimaryMonitor->head.h;
       }
       iCount++;
    }
@@ -628,7 +635,7 @@
    IN HMONITOR hMonitor,
    OUT LPMONITORINFO pMonitorInfo)
 {
-   PMONITOR_OBJECT Monitor;
+   PMONITOR Monitor;
    MONITORINFOEXW MonitorInfo;
    NTSTATUS Status;
    DECLARE_RETURN(BOOL);
@@ -746,9 +753,9 @@
    {
       if (dwFlags == MONITOR_DEFAULTTOPRIMARY)
       {
-         PMONITOR_OBJECT MonitorObj = IntGetPrimaryMonitor();
+         PMONITOR MonitorObj = IntGetPrimaryMonitor();
          if (MonitorObj)
-            hMonitor = MonitorObj->Handle;
+            hMonitor = MonitorObj->head.h;
       }
       else if (dwFlags == MONITOR_DEFAULTTONEAREST)
       {
@@ -811,9 +818,9 @@
    {
       if (dwFlags == MONITOR_DEFAULTTOPRIMARY)
       {
-         PMONITOR_OBJECT monitorObj = IntGetPrimaryMonitor();
+         PMONITOR monitorObj = IntGetPrimaryMonitor();
          if (monitorObj)
-            return monitorObj->Handle;
+            return monitorObj->head.h;
       }
       else if (dwFlags == MONITOR_DEFAULTTONEAREST)
       {

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c?rev=45042&r1=45041&r2=45042&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c [iso-8859-1] Mon 
Jan 11 08:36:48 2010
@@ -395,7 +395,7 @@
       return(FALSE);
    }
 
-   if (CaptureWindow->MessageQueue != MessageQueue)
+   if (CaptureWindow->pti->MessageQueue != MessageQueue)
    {
       if (! FromGlobalQueue)
       {
@@ -418,34 +418,34 @@
 
       /* lock the destination message queue, so we don't get in trouble with 
other
          threads, messing with it at the same time */
-      IntLockHardwareMessageQueue(CaptureWindow->MessageQueue);
-      InsertTailList(&CaptureWindow->MessageQueue->HardwareMessagesListHead,
+      IntLockHardwareMessageQueue(CaptureWindow->pti->MessageQueue);
+      
InsertTailList(&CaptureWindow->pti->MessageQueue->HardwareMessagesListHead,
                      &Message->ListEntry);
       if(Message->Msg.message == WM_MOUSEMOVE)
       {
-         if(CaptureWindow->MessageQueue->MouseMoveMsg)
+         if(CaptureWindow->pti->MessageQueue->MouseMoveMsg)
          {
             /* remove the old WM_MOUSEMOVE message, we're processing a more 
recent
                one */
-            
RemoveEntryList(&CaptureWindow->MessageQueue->MouseMoveMsg->ListEntry);
-            ExFreePool(CaptureWindow->MessageQueue->MouseMoveMsg);
+            
RemoveEntryList(&CaptureWindow->pti->MessageQueue->MouseMoveMsg->ListEntry);
+            ExFreePool(CaptureWindow->pti->MessageQueue->MouseMoveMsg);
          }
          /* save the pointer to the WM_MOUSEMOVE message in the new queue */
-         CaptureWindow->MessageQueue->MouseMoveMsg = Message;
-
-         CaptureWindow->MessageQueue->QueueBits |= QS_MOUSEMOVE;
-         CaptureWindow->MessageQueue->ChangedBits |= QS_MOUSEMOVE;
-         if (CaptureWindow->MessageQueue->WakeMask & QS_MOUSEMOVE)
-            KeSetEvent(CaptureWindow->MessageQueue->NewMessages, 
IO_NO_INCREMENT, FALSE);
+         CaptureWindow->pti->MessageQueue->MouseMoveMsg = Message;
+
+         CaptureWindow->pti->MessageQueue->QueueBits |= QS_MOUSEMOVE;
+         CaptureWindow->pti->MessageQueue->ChangedBits |= QS_MOUSEMOVE;
+         if (CaptureWindow->pti->MessageQueue->WakeMask & QS_MOUSEMOVE)
+            KeSetEvent(CaptureWindow->pti->MessageQueue->NewMessages, 
IO_NO_INCREMENT, FALSE);
       }
       else
       {
-         CaptureWindow->MessageQueue->QueueBits |= QS_MOUSEBUTTON;
-         CaptureWindow->MessageQueue->ChangedBits |= QS_MOUSEBUTTON;
-         if (CaptureWindow->MessageQueue->WakeMask & QS_MOUSEBUTTON)
-            KeSetEvent(CaptureWindow->MessageQueue->NewMessages, 
IO_NO_INCREMENT, FALSE);
-      }
-      IntUnLockHardwareMessageQueue(CaptureWindow->MessageQueue);
+         CaptureWindow->pti->MessageQueue->QueueBits |= QS_MOUSEBUTTON;
+         CaptureWindow->pti->MessageQueue->ChangedBits |= QS_MOUSEBUTTON;
+         if (CaptureWindow->pti->MessageQueue->WakeMask & QS_MOUSEBUTTON)
+            KeSetEvent(CaptureWindow->pti->MessageQueue->NewMessages, 
IO_NO_INCREMENT, FALSE);
+      }
+      IntUnLockHardwareMessageQueue(CaptureWindow->pti->MessageQueue);
 
       *Freed = FALSE;
       UserDereferenceObject(CaptureWindow);
@@ -466,21 +466,21 @@
          /* Lock the message queue so no other thread can mess with it.
             Our own message queue is not locked while fetching from the global
             queue, so we have to make sure nothing interferes! */
-         IntLockHardwareMessageQueue(CaptureWindow->MessageQueue);
+         IntLockHardwareMessageQueue(CaptureWindow->pti->MessageQueue);
          /* if we're from the global queue, we need to add our message to our
             private queue so we don't loose it! */
-         InsertTailList(&CaptureWindow->MessageQueue->HardwareMessagesListHead,
+         
InsertTailList(&CaptureWindow->pti->MessageQueue->HardwareMessagesListHead,
                         &Message->ListEntry);
       }
 
       if (Message->Msg.message == WM_MOUSEMOVE)
       {
-         if(CaptureWindow->MessageQueue->MouseMoveMsg &&
-               (CaptureWindow->MessageQueue->MouseMoveMsg != Message))
+         if(CaptureWindow->pti->MessageQueue->MouseMoveMsg &&
+               (CaptureWindow->pti->MessageQueue->MouseMoveMsg != Message))
          {
             /* delete the old message */
-            
RemoveEntryList(&CaptureWindow->MessageQueue->MouseMoveMsg->ListEntry);
-            ExFreePool(CaptureWindow->MessageQueue->MouseMoveMsg);
+            
RemoveEntryList(&CaptureWindow->pti->MessageQueue->MouseMoveMsg->ListEntry);
+            ExFreePool(CaptureWindow->pti->MessageQueue->MouseMoveMsg);
             if (!FromGlobalQueue)
             {
                // We might have deleted the next one in our queue, so fix next
@@ -489,11 +489,11 @@
          }
          /* always save a pointer to this WM_MOUSEMOVE message here because 
we're
             sure that the message is in the private queue */
-         CaptureWindow->MessageQueue->MouseMoveMsg = Message;
+         CaptureWindow->pti->MessageQueue->MouseMoveMsg = Message;
       }
       if(FromGlobalQueue)
       {
-         IntUnLockHardwareMessageQueue(CaptureWindow->MessageQueue);
+         IntUnLockHardwareMessageQueue(CaptureWindow->pti->MessageQueue);
       }
 
       UserDereferenceObject(CaptureWindow);
@@ -516,22 +516,22 @@
          /* Lock the message queue so no other thread can mess with it.
             Our own message queue is not locked while fetching from the global
             queue, so we have to make sure nothing interferes! */
-         IntLockHardwareMessageQueue(CaptureWindow->MessageQueue);
-         if(CaptureWindow->MessageQueue->MouseMoveMsg)
+         IntLockHardwareMessageQueue(CaptureWindow->pti->MessageQueue);
+         if(CaptureWindow->pti->MessageQueue->MouseMoveMsg)
          {
             /* delete the WM_(NC)MOUSEMOVE message in the private queue, we're 
dealing
                with one that's been sent later */
-            
RemoveEntryList(&CaptureWindow->MessageQueue->MouseMoveMsg->ListEntry);
-            ExFreePool(CaptureWindow->MessageQueue->MouseMoveMsg);
+            
RemoveEntryList(&CaptureWindow->pti->MessageQueue->MouseMoveMsg->ListEntry);
+            ExFreePool(CaptureWindow->pti->MessageQueue->MouseMoveMsg);
             /* our message is not in the private queue so we can remove the 
pointer
                instead of setting it to the current message we're processing */
-            CaptureWindow->MessageQueue->MouseMoveMsg = NULL;
+            CaptureWindow->pti->MessageQueue->MouseMoveMsg = NULL;
          }
-         IntUnLockHardwareMessageQueue(CaptureWindow->MessageQueue);
-      }
-      else if (CaptureWindow->MessageQueue->MouseMoveMsg == Message)
-      {
-         CaptureWindow->MessageQueue->MouseMoveMsg = NULL;
+         IntUnLockHardwareMessageQueue(CaptureWindow->pti->MessageQueue);
+      }
+      else if (CaptureWindow->pti->MessageQueue->MouseMoveMsg == Message)
+      {
+         CaptureWindow->pti->MessageQueue->MouseMoveMsg = NULL;
       }
    }
 
@@ -884,7 +884,7 @@
    KeQueryTickCount(&LargeTickCount);
    Mesg.time = MsqCalculateMessageTime(&LargeTickCount);
    Mesg.pt = gpsi->ptCursor;
-   MsqPostMessage(Window->MessageQueue, &Mesg, FALSE, QS_HOTKEY);
+   MsqPostMessage(Window->pti->MessageQueue, &Mesg, FALSE, QS_HOTKEY);
    UserDereferenceObject(Window);
    ObDereferenceObject (Thread);
 
@@ -1057,7 +1057,7 @@
 
    ASSERT(Window);
 
-   MessageQueue = Window->MessageQueue;
+   MessageQueue = Window->pti->MessageQueue;
    ASSERT(MessageQueue);
 
    /* remove the posted messages for this window */
@@ -1363,9 +1363,12 @@
 
    if (Hardware)
    {
-      return(co_MsqPeekHardwareMessage(MessageQueue, Window,
-                                       MsgFilterLow, MsgFilterHigh,
-                                       Remove, Message));
+      return(co_MsqPeekHardwareMessage( MessageQueue,
+                                        Window,
+                                        MsgFilterLow,
+                                        MsgFilterHigh,
+                                        Remove,
+                                        Message));
    }
 
    CurrentEntry = MessageQueue->PostedMessagesListHead.Flink;
@@ -1374,10 +1377,12 @@
    {
       CurrentMessage = CONTAINING_RECORD(CurrentEntry, USER_MESSAGE,
                                          ListEntry);
-      if ((!Window || PtrToInt(Window) == 1 || Window->hSelf == 
CurrentMessage->Msg.hwnd) &&
-            ((MsgFilterLow == 0 && MsgFilterHigh == 0) ||
-             (MsgFilterLow <= CurrentMessage->Msg.message &&
-              MsgFilterHigh >= CurrentMessage->Msg.message)))
+      if ( ( !Window ||
+            PtrToInt(Window) == 1 ||
+            Window->hSelf == CurrentMessage->Msg.hwnd ) &&
+            ( (MsgFilterLow == 0 && MsgFilterHigh == 0) ||
+              ( MsgFilterLow <= CurrentMessage->Msg.message &&
+                MsgFilterHigh >= CurrentMessage->Msg.message ) ) )
       {
          if (Remove)
          {

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/painting.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/painting.c?rev=45042&r1=45041&r2=45042&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/painting.c [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/painting.c [iso-8859-1] Mon 
Jan 11 08:36:48 2010
@@ -196,7 +196,7 @@
             GreDeleteObject(Window->hrgnUpdate);
             Window->hrgnUpdate = NULL;
             if (!(Window->state & WINDOWOBJECT_NEED_INTERNALPAINT))
-               MsqDecPaintCountQueue(Window->MessageQueue);
+               MsqDecPaintCountQueue(Window->pti->MessageQueue);
          }
       }
 
@@ -248,7 +248,7 @@
          {
             TempRegion = IntGetNCUpdateRgn(Window, TRUE);
             Window->state &= ~WINDOWOBJECT_NEED_NCPAINT;
-            MsqDecPaintCountQueue(Window->MessageQueue);
+            MsqDecPaintCountQueue(Window->pti->MessageQueue);
             co_IntSendMessage(hWnd, WM_NCPAINT, (WPARAM)TempRegion, 0);
             if ((HANDLE) 1 != TempRegion && NULL != TempRegion)
             {
@@ -465,17 +465,17 @@
    if (HasPaintMessage != HadPaintMessage)
    {
       if (HadPaintMessage)
-         MsqDecPaintCountQueue(Window->MessageQueue);
+         MsqDecPaintCountQueue(Window->pti->MessageQueue);
       else
-         MsqIncPaintCountQueue(Window->MessageQueue);
+         MsqIncPaintCountQueue(Window->pti->MessageQueue);
    }
 
    if (HasNCPaintMessage != HadNCPaintMessage)
    {
       if (HadNCPaintMessage)
-         MsqDecPaintCountQueue(Window->MessageQueue);
+         MsqDecPaintCountQueue(Window->pti->MessageQueue);
       else
-         MsqIncPaintCountQueue(Window->MessageQueue);
+         MsqIncPaintCountQueue(Window->pti->MessageQueue);
    }
 
 }
@@ -776,7 +776,7 @@
 
       hRgn = IntGetNCUpdateRgn(Window, FALSE);
       Window->state &= ~WINDOWOBJECT_NEED_NCPAINT;
-      MsqDecPaintCountQueue(Window->MessageQueue);
+      MsqDecPaintCountQueue(Window->pti->MessageQueue);
       co_IntSendMessage(hWnd, WM_NCPAINT, (WPARAM)hRgn, 0);
       if (hRgn != (HANDLE)1 && hRgn != NULL)
       {
@@ -795,7 +795,7 @@
 
    if (Window->hrgnUpdate != NULL)
    {
-      MsqDecPaintCountQueue(Window->MessageQueue);
+      MsqDecPaintCountQueue(Window->pti->MessageQueue);
       GdiGetClipBox(Ps.hdc, &Ps.rcPaint);
       GDIOBJ_SetOwnership(Window->hrgnUpdate, PsGetCurrentProcess());
       /* The region is part of the dc now and belongs to the process! */
@@ -804,7 +804,7 @@
    else
    {
       if (Window->state & WINDOWOBJECT_NEED_INTERNALPAINT)
-         MsqDecPaintCountQueue(Window->MessageQueue);
+         MsqDecPaintCountQueue(Window->pti->MessageQueue);
 
       IntGetClientRect(Window, &Ps.rcPaint);
    }

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/scrollbar.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/scrollbar.c?rev=45042&r1=45041&r2=45042&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/scrollbar.c [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/scrollbar.c [iso-8859-1] Mon 
Jan 11 08:36:48 2010
@@ -228,6 +228,53 @@
    }
 
    return TRUE;
+}
+
+BOOL FASTCALL
+NEWco_IntGetScrollInfo(
+  PWND pWnd,
+  INT nBar,
+  PSBDATA pSBData,
+  LPSCROLLINFO lpsi)
+{
+  UINT Mask;
+  PSBTRACK pSBTrack = pWnd->head.pti->pSBTrack;
+
+  if (!SBID_IS_VALID(nBar))
+  {
+     SetLastWin32Error(ERROR_INVALID_PARAMETER);
+     DPRINT1("Trying to get scrollinfo for unknown scrollbar type %d\n", nBar);
+     return FALSE;
+  }
+
+  Mask = lpsi->fMask;
+
+  if (0 != (Mask & SIF_PAGE))
+  {
+     lpsi->nPage = pSBData->page;
+  }
+
+  if (0 != (Mask & SIF_POS))
+  {
+     lpsi->nPos = pSBData->pos;
+  }
+
+  if (0 != (Mask & SIF_RANGE))
+  {
+     lpsi->nMin = pSBData->posMin;
+     lpsi->nMax = pSBData->posMax;
+  }
+
+  if (0 != (Mask & SIF_TRACKPOS))
+  {
+     if ( pSBTrack &&
+          pSBTrack->nBar == nBar &&
+          pSBTrack->spwndTrack == pWnd )
+        lpsi->nTrackPos = pSBTrack->posNew;
+     else
+        lpsi->nTrackPos = pSBData->pos;
+  }
+  return (Mask & SIF_ALL) !=0;
 }
 
 static DWORD FASTCALL

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/timer.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/timer.c?rev=45042&r1=45041&r2=45042&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/timer.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/timer.c [iso-8859-1] Mon Jan 
11 08:36:48 2010
@@ -427,7 +427,7 @@
       }
 
       Ret = IDEvent;
-      MessageQueue = Window->MessageQueue;
+      MessageQueue = Window->pti->MessageQueue;
    }
 
 #if 0
@@ -489,7 +489,7 @@
                                 IDEvent, SystemTimer ? WM_SYSTIMER : WM_TIMER))
       {
          // Give it another chance to find the timer.
-         if (Window && !( MsqKillTimer(Window->MessageQueue, Wnd,
+         if (Window && !( MsqKillTimer(Window->pti->MessageQueue, Wnd,
                             IDEvent, SystemTimer ? WM_SYSTIMER : WM_TIMER)))
          {
             DPRINT1("Unable to locate timer in message queue for Window.\n");

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/window.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/window.c?rev=45042&r1=45041&r2=45042&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] Mon Jan 
11 08:36:48 2010
@@ -1608,28 +1608,31 @@
  * calculates the default position of a window
  */
 BOOL FASTCALL
-IntCalcDefPosSize(PWINDOW_OBJECT Parent, PWINDOW_OBJECT Window, RECTL *rc, 
BOOL IncPos)
+IntCalcDefPosSize(PWINDOW_OBJECT Parent, RECTL *rc, BOOL IncPos)
 {
    SIZE Sz;
+   PMONITOR pMonitor;
    POINT Pos = {0, 0};
+   
+   pMonitor = IntGetPrimaryMonitor();
 
    if(Parent != NULL)
    {
-      RECTL_bIntersectRect(rc, rc, &Parent->Wnd->rcClient);
+      RECTL_bIntersectRect(rc, rc, &pMonitor->rcMonitor);
 
       if(IncPos)
       {
-         Pos.x = Parent->TiledCounter * (UserGetSystemMetrics(SM_CXSIZE) + 
UserGetSystemMetrics(SM_CXFRAME));
-         Pos.y = Parent->TiledCounter * (UserGetSystemMetrics(SM_CYSIZE) + 
UserGetSystemMetrics(SM_CYFRAME));
-         if(Pos.x > ((rc->right - rc->left) / 4) ||
-               Pos.y > ((rc->bottom - rc->top) / 4))
+         Pos.x = pMonitor->cWndStack * (UserGetSystemMetrics(SM_CXSIZE) + 
UserGetSystemMetrics(SM_CXFRAME));
+         Pos.y = pMonitor->cWndStack * (UserGetSystemMetrics(SM_CYSIZE) + 
UserGetSystemMetrics(SM_CYFRAME));
+         if (Pos.x > ((rc->right - rc->left) / 4) ||
+             Pos.y > ((rc->bottom - rc->top) / 4))
          {
             /* reset counter and position */
             Pos.x = 0;
             Pos.y = 0;
-            Parent->TiledCounter = 0;
+            pMonitor->cWndStack = 0;
          }
-         Parent->TiledCounter++;
+         pMonitor->cWndStack++;
       }
       Pos.x += rc->left;
       Pos.y += rc->top;
@@ -1857,8 +1860,7 @@
    Wnd->hModule = hInstance;
    Window->hSelf = hWnd;
 
-   Window->MessageQueue = pti->MessageQueue;
-   IntReferenceMessageQueue(Window->MessageQueue);
+   IntReferenceMessageQueue(Window->pti->MessageQueue);
    Window->spwndParent = ParentWindow;
    Wnd->spwndParent = ParentWindow ? ParentWindow->Wnd : NULL;
    if (Wnd->spwndParent != NULL && hWndParent != 0)
@@ -2112,7 +2114,7 @@
 
       if(x == CW_USEDEFAULT || x == CW_USEDEFAULT16)
       {
-         CalculatedDefPosSize = IntCalcDefPosSize(ParentWindow, Window, &rc, 
TRUE);
+         CalculatedDefPosSize = IntCalcDefPosSize(ParentWindow, &rc, TRUE);
 
          if(ProcessParams->WindowFlags & STARTF_USEPOSITION)
          {
@@ -2156,7 +2158,7 @@
       {
          if(!CalculatedDefPosSize)
          {
-            IntCalcDefPosSize(ParentWindow, Window, &rc, FALSE);
+            IntCalcDefPosSize(ParentWindow, &rc, FALSE);
          }
          if(ProcessParams->WindowFlags & STARTF_USESIZE)
          {
@@ -2646,14 +2648,14 @@
       }
    }
 
-   if (Window->MessageQueue->ActiveWindow == Window->hSelf)
-      Window->MessageQueue->ActiveWindow = NULL;
-   if (Window->MessageQueue->FocusWindow == Window->hSelf)
-      Window->MessageQueue->FocusWindow = NULL;
-   if (Window->MessageQueue->CaptureWindow == Window->hSelf)
-      Window->MessageQueue->CaptureWindow = NULL;
-
-   IntDereferenceMessageQueue(Window->MessageQueue);
+   if (Window->pti->MessageQueue->ActiveWindow == Window->hSelf)
+      Window->pti->MessageQueue->ActiveWindow = NULL;
+   if (Window->pti->MessageQueue->FocusWindow == Window->hSelf)
+      Window->pti->MessageQueue->FocusWindow = NULL;
+   if (Window->pti->MessageQueue->CaptureWindow == Window->hSelf)
+      Window->pti->MessageQueue->CaptureWindow = NULL;
+
+   IntDereferenceMessageQueue(Window->pti->MessageQueue);
 
    IntEngWindowChanged(Window, WOC_DELETE);
    isChild = (0 != (Wnd->style & WS_CHILD));
@@ -4197,7 +4199,7 @@
          break;
 
       case QUERY_WINDOW_ISHUNG:
-         Result = (DWORD)MsqIsHung(Window->MessageQueue);
+         Result = (DWORD)MsqIsHung(Window->pti->MessageQueue);
          break;
 
       case QUERY_WINDOW_REAL_ID:
@@ -5111,7 +5113,7 @@
        }
        case otMonitor:
        {
-         PMONITOR_OBJECT Monitor;
+         PMONITOR Monitor;
          if ((Monitor = UserGetMonitorObject((HMONITOR) handle))) return TRUE;
          return FALSE;
        }

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c?rev=45042&r1=45041&r2=45042&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c [iso-8859-1] Mon Jan 
11 08:36:48 2010
@@ -1612,7 +1612,7 @@
 
          UserRefObjectCo(Current, &Ref);
 
-         if (OnlyHitTests && (Current->MessageQueue == OnlyHitTests))
+         if (OnlyHitTests && (Current->pti->MessageQueue == OnlyHitTests))
          {
             *HitTest = co_IntSendMessage(Current->hSelf, WM_NCHITTEST, 0,
                                          MAKELONG(Point->x, Point->y));


Reply via email to