update for HEAD-2003091401
[reactos.git] / subsys / win32k / ntuser / metric.c
index 70894a5..b065692 100644 (file)
@@ -1,9 +1,27 @@
+/*
+ *  ReactOS W32 Subsystem
+ *  Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
 /* $Id$
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
  * PURPOSE:          Window classes
- * FILE:             subsys/win32k/ntuser/class.c
+ * FILE:             subsys/win32k/ntuser/metric.c
  * PROGRAMER:        Casper S. Hornstrup (chorns@users.sourceforge.net)
  * REVISION HISTORY:
  *       06-06-2001  CSH  Created
@@ -18,6 +36,7 @@
 #include <include/error.h>
 #include <include/winsta.h>
 #include <include/msgqueue.h>
+#include <include/window.h>
 
 #define NDEBUG
 #include <debug.h>
 ULONG STDCALL
 NtUserGetSystemMetrics(ULONG Index)
 {
+  NTSTATUS Status;
+  PWINSTATION_OBJECT WinStaObject;
+  PWINDOW_OBJECT DesktopWindow;
+  ULONG Width, Height, Result;
+
+  Result = 0;
   switch (Index)
     {
     case SM_ARRANGE:
@@ -47,7 +72,30 @@ NtUserGetSystemMetrics(ULONG Index)
       return(3);
     case SM_CXDOUBLECLK:
     case SM_CYDOUBLECLK:
-      return(4);
+    case SM_SWAPBUTTON:
+      Status = ValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
+                                           KernelMode,
+                                           0,
+                                           &WinStaObject);
+      if (!NT_SUCCESS(Status))
+        return 0xFFFFFFFF;
+      
+      switch(Index)
+      {
+        case SM_CXDOUBLECLK:
+          Result = WinStaObject->SystemCursor.DblClickWidth;
+          break;
+        case SM_CYDOUBLECLK:
+          Result = WinStaObject->SystemCursor.DblClickWidth;
+          break;
+        case SM_SWAPBUTTON:
+          Result = (UINT)WinStaObject->SystemCursor.SwapButtons;
+          break;
+      }
+      
+      ObDereferenceObject(WinStaObject);
+      return Result;
+
     case SM_CXDRAG:
     case SM_CYDRAG:
       return(2);
@@ -58,12 +106,14 @@ NtUserGetSystemMetrics(ULONG Index)
     case SM_CYFRAME:
       return(4);
     case SM_CXFULLSCREEN:
-      return(640);
+      /* FIXME: shouldn't we take borders etc into account??? */
+      return NtUserGetSystemMetrics(SM_CXSCREEN);
     case SM_CYFULLSCREEN:
-      return(480);
+      return NtUserGetSystemMetrics(SM_CYSCREEN);
     case SM_CXHSCROLL:
     case SM_CYHSCROLL:
       return(16);
+    case SM_CYVTHUMB:
     case SM_CXHTHUMB:
       return(16);
     case SM_CXICON:
@@ -71,7 +121,7 @@ NtUserGetSystemMetrics(ULONG Index)
       return(32);
     case SM_CXICONSPACING:
     case SM_CYICONSPACING:
-      return(75);
+      return(44);
     case SM_CXMAXIMIZED:
       return(NtUserGetSystemMetrics(SM_CXSCREEN) + 8); /* This seems to be 8
                                                           pixels greater than
@@ -108,9 +158,20 @@ NtUserGetSystemMetrics(ULONG Index)
     case SM_CYMINTRACK:
       return(27);
     case SM_CXSCREEN:
-      return(640);
     case SM_CYSCREEN:
-      return(480);
+      DesktopWindow = IntGetWindowObject(IntGetDesktopWindow());
+      if (NULL != DesktopWindow)
+         {
+           Width = DesktopWindow->WindowRect.right;
+           Height = DesktopWindow->WindowRect.bottom;
+         }
+      else
+         {
+           Width = 640;
+           Height = 480;
+         }
+      IntReleaseWindowObject(DesktopWindow);
+      return SM_CXSCREEN == Index ? Width : Height;
     case SM_CXSIZE:
     case SM_CYSIZE:
       return(18);
@@ -132,7 +193,6 @@ NtUserGetSystemMetrics(ULONG Index)
       return(19);
     case SM_CYSMCAPTION:
       return(16);
-    case SM_CYVTHUMB:
     case SM_DBCSENABLED:
     case SM_DEBUG:
     case SM_MENUDROPALIGNMENT: 
@@ -146,7 +206,6 @@ NtUserGetSystemMetrics(ULONG Index)
     case SM_SECURE:            
     case SM_SHOWSOUNDS:        
     case SM_SLOWMACHINE:       
-    case SM_SWAPBUTTON:        
       return(0);
     default:
       return(0xFFFFFFFF);