Author: fireball
Date: Sun May 23 12:22:09 2010
New Revision: 47320
URL:
http://svn.reactos.org/svn/reactos?rev=47320&view=rev
Log:
- Initial cursor icons support, work in progress. When it's finished, improvements and
optimisations are welcome.
Modified:
branches/arwinss/reactos/dll/win32/winent.drv/mouse.c
branches/arwinss/reactos/dll/win32/winent.drv/userdrv.c
branches/arwinss/reactos/dll/win32/winent.drv/winent.h
branches/arwinss/reactos/include/reactos/win32k/rosuser.h
branches/arwinss/reactos/subsystems/win32/win32k/include/cursor.h
branches/arwinss/reactos/subsystems/win32/win32k/main/cursor.c
branches/arwinss/reactos/subsystems/win32/win32k/main/init.c
branches/arwinss/reactos/subsystems/win32/win32k/swm/winman.c
branches/arwinss/reactos/subsystems/win32/win32k/w32ksvc.db
Modified: branches/arwinss/reactos/dll/win32/winent.drv/mouse.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winen…
==============================================================================
--- branches/arwinss/reactos/dll/win32/winent.drv/mouse.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/dll/win32/winent.drv/mouse.c [iso-8859-1] Sun May 23 12:22:09
2010
@@ -107,6 +107,7 @@
BYTE* key_state_table)
{
MSLLHOOKSTRUCT hook;
+ HCURSOR cursor;
hook.pt.x = x;
hook.pt.y = y;
@@ -129,9 +130,38 @@
req->time = time;
req->info = extra_info;
wine_server_call( req );
+ cursor = (reply->count >= 0) ? wine_server_ptr_handle(reply->cursor) :
0;
}
SERVER_END_REQ;
+ if (hwnd)
+ {
+ // TODO: Add cursor change support
+ /*Cursor xcursor;
+ struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
+ if (data && cursor != data->cursor)
+ {
+ wine_tsx11_lock();
+ if ((xcursor = get_x11_cursor( cursor )))
+ XDefineCursor( gdi_display, data->whole_window, xcursor );
+ data->cursor = cursor;
+ wine_tsx11_unlock();
+ }*/
+ }
+}
+
+/***********************************************************************
+ * set_window_cursor
+ */
+void set_window_cursor( HWND hwnd, HCURSOR handle )
+{
+ struct ntdrv_win_data *data;
+
+ if (!(data = NTDRV_get_win_data( hwnd ))) return;
+
+ /* Set the cursor */
+ SwmDefineCursor(hwnd, handle);
+ data->cursor = handle;
}
@@ -493,16 +523,13 @@
#endif
/* Create cursor bitmaps */
- RosDrv_GetIconInfo( lpCursor, &IconInfo );
-
- //cursor = create_cursor( gdi_display, info );
- //if (cursor)
- //{
- //if (!cursor_context) cursor_context = XUniqueContext();
- //XSaveContext( gdi_display, (XID)handle, cursor_context, (char *)cursor );
- FIXME( "cursor %p %ux%u, planes %u, bpp %u -> xid %lx\n",
+ RosDrv_GetIconInfo( info, &IconInfo );
+
+ /* Create the cursor icon */
+ RosUserCreateCursorIcon( &IconInfo, handle );
+
+ FIXME( "cursor %p %ux%u, planes %u, bpp %u -> xid %lx\n",
handle, info->nWidth, info->nHeight, info->bPlanes,
info->bBitsPerPixel, /*cursor*/ 0);
- //}
}
/***********************************************************************
@@ -510,22 +537,25 @@
*/
void CDECL RosDrv_DestroyCursorIcon( HCURSOR handle )
{
- //Cursor cursor;
+ ICONINFO IconInfo;
FIXME( "%p xid %lx\n", handle, /*cursor*/ 0 );
- /*if ((cursor = get_x11_cursor( handle )))
- {
- TRACE( "%p xid %lx\n", handle, cursor );
- XFreeCursor( gdi_display, cursor );
- XDeleteContext( gdi_display, (XID)handle, cursor_context );
- }*/
+ /* Destroy kernel mode part of the cursor icon */
+ RosUserDestroyCursorIcon( &IconInfo, handle );
+
+ /* Destroy usermode-created bitmaps */
+ // FIXME: Will it delete kernelmode bitmaps?!
+ if (IconInfo.hbmColor) DeleteObject( IconInfo.hbmColor );
+ if (IconInfo.hbmMask) DeleteObject( IconInfo.hbmMask );
}
void CDECL RosDrv_SetCursor( HCURSOR handle )
{
- //if (cursor_window) SendNotifyMessageW( cursor_window, WM_X11DRV_SET_CURSOR, 0,
(LPARAM)handle );
+ if (cursor_window) SendNotifyMessageW( cursor_window, WM_NTDRV_SET_CURSOR, 0,
(LPARAM)handle );
FIXME("handle %x, cursor_window %x\n", handle, cursor_window);
+
+ // FIXME: Remove!
RosUserSetCursor(NULL);
}
Modified: branches/arwinss/reactos/dll/win32/winent.drv/userdrv.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winen…
==============================================================================
--- branches/arwinss/reactos/dll/win32/winent.drv/userdrv.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/dll/win32/winent.drv/userdrv.c [iso-8859-1] Sun May 23
12:22:09 2010
@@ -761,8 +761,15 @@
LRESULT CDECL RosDrv_WindowMessage( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
- UNIMPLEMENTED;
- return 0;
+ switch(msg)
+ {
+ case WM_NTDRV_SET_CURSOR:
+ set_window_cursor( hwnd, (HCURSOR)lparam );
+ return 0;
+ default:
+ FIXME( "got window msg %x hwnd %p wp %lx lp %lx\n", msg, hwnd, wparam,
lparam );
+ return 0;
+ }
}
void CDECL RosDrv_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flags,
Modified: branches/arwinss/reactos/dll/win32/winent.drv/winent.h
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winen…
==============================================================================
--- branches/arwinss/reactos/dll/win32/winent.drv/winent.h [iso-8859-1] (original)
+++ branches/arwinss/reactos/dll/win32/winent.drv/winent.h [iso-8859-1] Sun May 23
12:22:09 2010
@@ -14,6 +14,12 @@
NTDRV_GET_GLX_DRAWABLE, /* get current glx drawable for a DC */
NTDRV_SYNC_PIXMAP, /* sync the dibsection to its pixmap */
NTDRV_FLUSH_GL_DRAWABLE /* flush changes made to the gl drawable */
+};
+
+/* NT driver private messages, must be in the range 0x80001000..0x80001fff */
+enum ntdrv_window_messages
+{
+ WM_NTDRV_SET_CURSOR = 0x80001000
};
struct ntdrv_escape_set_drawable
@@ -35,6 +41,7 @@
RECT window_rect; /* USER window rectangle relative to parent */
RECT whole_rect; /* X window rectangle for the whole window relative to
parent */
RECT client_rect; /* client area relative to parent */
+ HCURSOR cursor; /* current cursor */
};
/* gdidrv.c */
@@ -56,6 +63,9 @@
const RECT *lprect, LPCWSTR wstr, UINT count,
const INT *lpDx );
+/* mouse.c */
+void set_window_cursor( HWND hwnd, HCURSOR handle );
+
void NTDRV_SendMouseInput( HWND hwnd, DWORD flags, DWORD x, DWORD y,
DWORD data, DWORD time, DWORD extra_info, UINT
injected_flags );
Modified: branches/arwinss/reactos/include/reactos/win32k/rosuser.h
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/include/reactos…
==============================================================================
--- branches/arwinss/reactos/include/reactos/win32k/rosuser.h [iso-8859-1] (original)
+++ branches/arwinss/reactos/include/reactos/win32k/rosuser.h [iso-8859-1] Sun May 23
12:22:09 2010
@@ -37,17 +37,25 @@
);
#endif
-BOOL NTAPI
+BOOL NTAPI
RosUserGetCursorPos( LPPOINT pt );
-BOOL NTAPI
+BOOL NTAPI
RosUserSetCursorPos( INT x, INT y );
-BOOL NTAPI
+BOOL NTAPI
RosUserClipCursor( LPCRECT clip );
-void NTAPI
+void NTAPI
RosUserSetCursor( ICONINFO* IconInfo );
+
+VOID APIENTRY
+RosUserCreateCursorIcon(ICONINFO* IconInfoUnsafe,
+ HCURSOR Handle);
+
+VOID APIENTRY
+RosUserDestroyCursorIcon(ICONINFO* IconInfoUnsafe,
+ HCURSOR Handle);
LONG
APIENTRY
@@ -160,6 +168,9 @@
SwmAddDesktopWindow(HWND hWnd, UINT Width, UINT Height);
VOID NTAPI
+SwmDefineCursor(HWND hWnd, HCURSOR hCursor);
+
+VOID NTAPI
SwmRemoveWindow(HWND hWnd);
VOID NTAPI
Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/cursor.h
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/include/cursor.h [iso-8859-1]
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/include/cursor.h [iso-8859-1] Sun May
23 12:22:09 2010
@@ -21,4 +21,14 @@
RECTL Exclude; /* required publicly for SPS_ACCEPT_EXCLUDE */
} GDIPOINTER, *PGDIPOINTER;
+typedef struct _CURSORICONENTRY
+{
+ HANDLE hbmMask;
+ HANDLE hbmColor;
+ HANDLE hUser;
+ LIST_ENTRY Entry;
+} CURSORICONENTRY, *PCURSORICONENTRY;
+
extern SYSTEM_CURSORINFO CursorInfo;
+
+VOID NTAPI USER_InitCursorIcons();
Modified: branches/arwinss/reactos/subsystems/win32/win32k/main/cursor.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/main/cursor.c [iso-8859-1]
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/main/cursor.c [iso-8859-1] Sun May 23
12:22:09 2010
@@ -10,6 +10,10 @@
#define NDEBUG
#include <debug.h>
+/* Cursor icons list */
+LIST_ENTRY CursorIcons;
+ERESOURCE CursorIconsLock;
+
SYSTEM_CURSORINFO CursorInfo;
extern PDEVOBJ PrimarySurface;
@@ -140,3 +144,89 @@
}
}
+VOID
+APIENTRY
+RosUserCreateCursorIcon(ICONINFO* IconInfoUnsafe,
+ HCURSOR Handle)
+{
+ PCURSORICONENTRY pCursorIcon;
+
+ // FIXME: SEH!
+
+ /* Allocate an entry in the cursor icons list */
+ pCursorIcon = ExAllocatePool(PagedPool, sizeof(CURSORICONENTRY));
+ RtlZeroMemory(pCursorIcon, sizeof(CURSORICONENTRY));
+
+ /* Save the usermode handle and other fields */
+ pCursorIcon->hUser = Handle;
+ //pCursorIcon->hbmMask = GDI_MapUserHandle(IconInfoUnsafe->hbmMask);
+ //pCursorIcon->hbmColor = GDI_MapUserHandle(IconInfoUnsafe->hbmColor);
+ pCursorIcon->hbmMask = IconInfoUnsafe->hbmMask;
+ pCursorIcon->hbmColor = IconInfoUnsafe->hbmColor;
+
+ /* Acquire lock */
+ KeEnterCriticalRegion();
+ ExAcquireResourceExclusiveLite(&CursorIconsLock, TRUE);
+
+ /* Add it to the list */
+ InsertTailList(&CursorIcons, &pCursorIcon->Entry);
+
+ /* Release lock */
+ ExReleaseResourceLite(&CursorIconsLock);
+ KeLeaveCriticalRegion();
+}
+
+VOID
+APIENTRY
+RosUserDestroyCursorIcon(ICONINFO* IconInfoUnsafe,
+ HCURSOR Handle)
+{
+ PLIST_ENTRY Current;
+ PCURSORICONENTRY pCursorIcon;
+
+ /* Acquire lock */
+ KeEnterCriticalRegion();
+ ExAcquireResourceExclusiveLite(&CursorIconsLock, TRUE);
+
+ /* Traverse the list to find our mapping */
+ Current = CursorIcons.Flink;
+ while(Current != &CursorIcons)
+ {
+ pCursorIcon = CONTAINING_RECORD(Current, CURSORICONENTRY, Entry);
+
+ /* Check if it's our entry */
+ if (pCursorIcon->hUser == Handle)
+ {
+ /* Remove it from the list */
+ RemoveEntryList(Current);
+
+ /* Get handles back to the user for proper disposal */
+ IconInfoUnsafe->hbmColor = pCursorIcon->hbmColor;
+ IconInfoUnsafe->hbmMask = pCursorIcon->hbmMask;
+
+ /* Free memory */
+ ExFreePool(pCursorIcon);
+ break;
+ }
+
+ /* Advance to the next pair */
+ Current = Current->Flink;
+ }
+
+ /* Release lock */
+ ExReleaseResourceLite(&CursorIconsLock);
+ KeLeaveCriticalRegion();
+}
+
+VOID NTAPI
+USER_InitCursorIcons()
+{
+ NTSTATUS Status;
+
+ /* Initialize cursor icons list and a spinlock */
+ InitializeListHead(&CursorIcons);
+ Status = ExInitializeResourceLite(&CursorIconsLock);
+ if (!NT_SUCCESS(Status))
+ DPRINT1("Initializing cursor icons lock failed with Status 0x%08X\n",
Status);
+}
+
Modified: branches/arwinss/reactos/subsystems/win32/win32k/main/init.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/main/init.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/main/init.c [iso-8859-1] Sun May 23
12:22:09 2010
@@ -357,6 +357,9 @@
/* Initialize handle-mapping */
GDI_InitHandleMapping();
+ /* Initialize cursor icons */
+ USER_InitCursorIcons();
+
/* Create stock objects */
CreateStockBitmap();
PALETTE_Init();
Modified: branches/arwinss/reactos/subsystems/win32/win32k/swm/winman.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/swm/winman.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/swm/winman.c [iso-8859-1] Sun May 23
12:22:09 2010
@@ -800,6 +800,11 @@
return 0;
}
+VOID
+NTAPI
+SwmDefineCursor(HWND hWnd, HCURSOR hCursor)
+{
+}
VOID
NTAPI
Modified: branches/arwinss/reactos/subsystems/win32/win32k/w32ksvc.db
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/w32ksvc.db [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/w32ksvc.db [iso-8859-1] Sun May 23
12:22:09 2010
@@ -64,6 +64,8 @@
RosGdiSwapBuffers 1
RosGdiUnrealizePalette 1
RosUserConnectCsrss 0
+RosUserCreateCursorIcon 2
+RosUserDestroyCursorIcon 2
RosUserGetCursorPos 1
RosUserSetCursorPos 2
RosUserClipCursor 1
@@ -86,6 +88,7 @@
RosUserGetAsyncKeyState 1
SwmAddWindow 2
SwmAddDesktopWindow 3
+SwmDefineCursor 2
SwmRemoveWindow 1
SwmSetForeground 1
SwmPosChanging 2