X-Git-Url: http://git.jankratochvil.net/?p=reactos.git;a=blobdiff_plain;f=subsys%2Fwin32k%2Fntuser%2Fwinsta.c;h=06a7f7a8761cdeb46d0a0ad4b3003901db821ffd;hp=9833d55d4ebf709eeb0a8ef5e7dbc589e377ce5e;hb=HEAD;hpb=7c0db166f81fbe8c8b913d7f26048e337d383605 diff --git a/subsys/win32k/ntuser/winsta.c b/subsys/win32k/ntuser/winsta.c index 9833d55..06a7f7a 100644 --- a/subsys/win32k/ntuser/winsta.c +++ b/subsys/win32k/ntuser/winsta.c @@ -1,3 +1,21 @@ +/* + * 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 @@ -17,14 +35,18 @@ /* INCLUDES ******************************************************************/ -#include +#define NTOS_MODE_KERNEL +#include +#include #include #include #include -#include #include #include #include +#include +#include +#include #define NDEBUG #include @@ -34,34 +56,89 @@ #define WINSTA_ROOT_NAME L"\\Windows\\WindowStations" LRESULT CALLBACK -W32kDesktopWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); +IntDesktopWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); STATIC PWNDCLASS_OBJECT DesktopWindowClass; /* Currently active desktop */ STATIC HDESK InputDesktopHandle = NULL; STATIC PDESKTOP_OBJECT InputDesktop = NULL; -STATIC PWINSTATION_OBJECT InputWindowStation = NULL; +//STATIC PWINSTATION_OBJECT InputWindowStation = NULL; static HDC ScreenDeviceContext = NULL; /* FUNCTIONS *****************************************************************/ -PDESKTOP_OBJECT -W32kGetActiveDesktop(VOID) + +PDESKTOP_OBJECT FASTCALL +IntGetActiveDesktop(VOID) { return(InputDesktop); } -NTSTATUS +PDESKTOP_OBJECT FASTCALL +IntGetDesktopObject ( HDESK hDesk ) +{ + /* FIXME - this obviously isn't right */ + return IntGetActiveDesktop(); +} + +VOID STDCALL +IntSetFocusMessageQueue(PUSER_MESSAGE_QUEUE NewQueue) +{ + PDESKTOP_OBJECT pdo = IntGetActiveDesktop(); + + pdo->ActiveMessageQueue = NewQueue; +} + +PUSER_MESSAGE_QUEUE FASTCALL +IntGetFocusMessageQueue(VOID) +{ + PDESKTOP_OBJECT pdo = IntGetActiveDesktop(); + + if (!pdo) + { + DPRINT("No active desktop\n"); + return(NULL); + } + + return (PUSER_MESSAGE_QUEUE)pdo->ActiveMessageQueue; +} + +PWINDOW_OBJECT STDCALL +IntGetCaptureWindow(VOID) +{ + PDESKTOP_OBJECT pdo = IntGetActiveDesktop(); + if (!pdo) + { + DPRINT("No active desktop\n"); + return(NULL); + } + return(pdo->CaptureWindow); +} + +VOID STDCALL +IntSetCaptureWindow(PWINDOW_OBJECT Window) +{ + PDESKTOP_OBJECT pdo = IntGetActiveDesktop(); + if (!pdo) + { + DPRINT("No active desktop\n"); + } + pdo->CaptureWindow = Window; +} + +NTSTATUS FASTCALL InitWindowStationImpl(VOID) { OBJECT_ATTRIBUTES ObjectAttributes; HANDLE WindowStationsDirectory; UNICODE_STRING UnicodeString; NTSTATUS Status; - WNDCLASSEX wcx; - + WNDCLASSEXW wcx; + + InputWindowStation = NULL; + /* * Create the '\Windows\WindowStations' directory */ @@ -88,25 +165,25 @@ InitWindowStationImpl(VOID) * Create the desktop window class */ wcx.style = 0; - wcx.lpfnWndProc = W32kDesktopWindowProc; + wcx.lpfnWndProc = IntDesktopWindowProc; wcx.cbClsExtra = wcx.cbWndExtra = 0; wcx.hInstance = wcx.hIcon = wcx.hCursor = NULL; wcx.hbrBackground = NULL; wcx.lpszMenuName = NULL; wcx.lpszClassName = L"DesktopWindowClass"; - DesktopWindowClass = W32kCreateClass(&wcx, TRUE); + DesktopWindowClass = IntCreateClass(&wcx, TRUE, (RTL_ATOM)32880); return(STATUS_SUCCESS); } -NTSTATUS +NTSTATUS FASTCALL CleanupWindowStationImpl(VOID) { return STATUS_SUCCESS; } -NTSTATUS +NTSTATUS STDCALL ValidateWindowStationHandle(HWINSTA WindowStation, KPROCESSOR_MODE AccessMode, ACCESS_MASK DesiredAccess, @@ -128,7 +205,7 @@ ValidateWindowStationHandle(HWINSTA WindowStation, return Status; } -NTSTATUS +NTSTATUS STDCALL ValidateDesktopHandle(HDESK Desktop, KPROCESSOR_MODE AccessMode, ACCESS_MASK DesiredAccess, @@ -255,7 +332,7 @@ NtUserCreateWindowStation(PUNICODE_STRING lpszWindowStationName, DPRINT("Creating window station (%wZ)\n", &WindowStationName); - Status = ObCreateObject(&WinSta, + Status = ObRosCreateObject(&WinSta, STANDARD_RIGHTS_REQUIRED, &ObjectAttributes, ExWindowStationObjectType, @@ -275,6 +352,30 @@ NtUserCreateWindowStation(PUNICODE_STRING lpszWindowStationName, SetLastNtError(STATUS_INSUFFICIENT_RESOURCES); return((HWINSTA)0); } + + ExInitializeFastMutex(&WinStaObject->SystemCursor.CursorMutex); + WinStaObject->SystemCursor.Enabled = FALSE; + WinStaObject->SystemCursor.CurrentCursor = 0; + WinStaObject->SystemCursor.x = (LONG)0; + WinStaObject->SystemCursor.y = (LONG)0; + WinStaObject->SystemCursor.CursorClipInfo.IsClipped = FALSE; + WinStaObject->SystemCursor.LastBtnDown = 0; + + /* FIXME Obtain the following information from the registry */ + WinStaObject->SystemCursor.SwapButtons = FALSE; + WinStaObject->SystemCursor.SafetySwitch = FALSE; + WinStaObject->SystemCursor.SafetySwitch2 = TRUE; + WinStaObject->SystemCursor.DblClickSpeed = 500; + WinStaObject->SystemCursor.DblClickWidth = 4; + WinStaObject->SystemCursor.DblClickHeight = 4; + + /* FIXME tell user32 to load the cursors from it's rosource file or + to load the user's cursor scheme */ + WinStaObject->SystemCursor.SystemCursors[0].hCursor = (HANDLE)1; + WinStaObject->SystemCursor.SystemCursors[0].cx = 32; + WinStaObject->SystemCursor.SystemCursors[0].cy = 32; + + /* FIXME setup system cursors */ DPRINT("Window station successfully created (%wZ)\n", &WindowStationName); @@ -341,7 +442,7 @@ NtUserOpenWindowStation( { OBJECT_ATTRIBUTES ObjectAttributes; UNICODE_STRING WindowStationName; - PWINSTATION_OBJECT WinStaObject; + //PWINSTATION_OBJECT WinStaObject; WCHAR NameBuffer[MAX_PATH]; NTSTATUS Status; HWINSTA WinSta; @@ -572,7 +673,7 @@ NtUserCreateDesktop(PUNICODE_STRING lpszDesktopName, DPRINT("Status for open operation (0x%X)\n", Status); - Status = ObCreateObject(&Desktop, + Status = ObRosCreateObject(&Desktop, STANDARD_RIGHTS_REQUIRED, &ObjectAttributes, ExDesktopObjectType, @@ -586,9 +687,8 @@ NtUserCreateDesktop(PUNICODE_STRING lpszDesktopName, /* Initialize some local (to win32k) desktop state. */ DesktopObject->ActiveMessageQueue = NULL; - InitializeListHead(&DesktopObject->WindowListHead); DesktopObject->DesktopWindow = - W32kCreateDesktopWindow(DesktopObject->WindowStation, + IntCreateDesktopWindow(DesktopObject->WindowStation, DesktopWindowClass, 640, 480); @@ -761,13 +861,10 @@ NtUserResolveDesktopForWOW(DWORD Unknown0) BOOL STDCALL NtUserSetThreadDesktop(HDESK hDesktop) -{ +{ PDESKTOP_OBJECT DesktopObject; NTSTATUS Status; - /* Initialize the Win32 state if necessary. */ - W32kGuiCheck(); - /* Validate the new desktop. */ Status = ValidateDesktopHandle(hDesktop, KernelMode, @@ -788,7 +885,10 @@ NtUserSetThreadDesktop(HDESK hDesktop) /* FIXME: Should check here to see if the thread has any windows. */ - ObDereferenceObject(PsGetWin32Thread()->Desktop); + if (PsGetWin32Thread()->Desktop != NULL) + { + ObDereferenceObject(PsGetWin32Thread()->Desktop); + } PsGetWin32Thread()->Desktop = DesktopObject; return(TRUE); @@ -838,35 +938,38 @@ NtUserSwitchDesktop(HDESK hDesktop) return(TRUE); } -VOID -W32kInitializeDesktopGraphics(VOID) +VOID FASTCALL +IntInitializeDesktopGraphics(VOID) { - ScreenDeviceContext = W32kCreateDC(L"DISPLAY", NULL, NULL, NULL); + ScreenDeviceContext = NtGdiCreateDC(L"DISPLAY", NULL, NULL, NULL); GDIOBJ_MarkObjectGlobal(ScreenDeviceContext); + /* not the best place to load the cursors but it's good for now */ + IntLoadDefaultCursors(); EnableMouse(ScreenDeviceContext); NtUserAcquireOrReleaseInputOwnership(FALSE); } -VOID -W32kEndDesktopGraphics(VOID) +VOID FASTCALL +IntEndDesktopGraphics(VOID) { NtUserAcquireOrReleaseInputOwnership(TRUE); EnableMouse(FALSE); if (NULL != ScreenDeviceContext) { - W32kDeleteDC(ScreenDeviceContext); + GDIOBJ_UnmarkObjectGlobal(ScreenDeviceContext); + NtGdiDeleteDC(ScreenDeviceContext); ScreenDeviceContext = NULL; } } -HDC -W32kGetScreenDC(VOID) +HDC FASTCALL +IntGetScreenDC(VOID) { return(ScreenDeviceContext); } LRESULT CALLBACK -W32kDesktopWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +IntDesktopWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { @@ -881,4 +984,17 @@ W32kDesktopWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) } } +BOOL FASTCALL +IntGetWindowStationObject(PWINSTATION_OBJECT Object) +{ + NTSTATUS Status; + + Status = ObReferenceObjectByPointer(Object, + KernelMode, + ExWindowStationObjectType, + 0); + + return NT_SUCCESS(Status); +} + /* EOF */