From 70e192b9cf4c109c4b6e56e02e2a8e405ee79ea4 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Sun, 2 Jun 2002 21:29:23 +0000 Subject: [PATCH] Removed CURSORICON_IconToCursor now that we support color cursors. --- dlls/x11drv/mouse.c | 14 +++++++- dlls/x11drv/winpos.c | 6 ++-- include/cursoricon.h | 3 -- windows/cursoricon.c | 96 ---------------------------------------------------- windows/win.c | 23 ++----------- 5 files changed, 18 insertions(+), 124 deletions(-) diff --git a/dlls/x11drv/mouse.c b/dlls/x11drv/mouse.c index d64c4e04f6f..5b31211aba9 100644 --- a/dlls/x11drv/mouse.c +++ b/dlls/x11drv/mouse.c @@ -348,6 +348,8 @@ Cursor X11DRV_GetCursor( Display *display, CURSORICONINFO *ptr ) if (pixmapBits && pixmapMask && pixmapMaskInv) { + POINT hotspot; + /* We have to do some magic here, as cursors are not fully * compatible between Windows and X11. Under X11, there * are only 3 possible color cursor: black, white and @@ -393,8 +395,18 @@ Cursor X11DRV_GetCursor( Display *display, CURSORICONINFO *ptr ) XCopyArea( display, pixmapMaskInv, pixmapBits, gc, 0, 0, ptr->nWidth, ptr->nHeight, 1, 1 ); XSetFunction( display, gc, GXcopy ); + + /* Make sure hotspot is valid */ + hotspot.x = ptr->ptHotSpot.x; + hotspot.y = ptr->ptHotSpot.y; + if (hotspot.x < 0 || hotspot.x >= ptr->nWidth || + hotspot.y < 0 || hotspot.y >= ptr->nHeight) + { + hotspot.x = ptr->nWidth / 2; + hotspot.y = ptr->nHeight / 2; + } cursor = XCreatePixmapCursor( display, pixmapBits, pixmapMask, - &fg, &bg, ptr->ptHotSpot.x, ptr->ptHotSpot.y ); + &fg, &bg, hotspot.x, hotspot.y ); } /* Now free everything */ diff --git a/dlls/x11drv/winpos.c b/dlls/x11drv/winpos.c index 558a207fec8..78c6628a56e 100644 --- a/dlls/x11drv/winpos.c +++ b/dlls/x11drv/winpos.c @@ -1877,9 +1877,8 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam ) if( iconic ) /* create a cursor for dragging */ { - HICON hIcon = GetClassLongA( hwnd, GCL_HICON); - if(!hIcon) hIcon = (HICON)SendMessageA( hwnd, WM_QUERYDRAGICON, 0, 0L); - if( hIcon ) hDragCursor = CURSORICON_IconToCursor( hIcon, TRUE ); + hDragCursor = GetClassLongA( hwnd, GCL_HICON); + if( !hDragCursor ) hDragCursor = (HCURSOR)SendMessageA( hwnd, WM_QUERYDRAGICON, 0, 0L); if( !hDragCursor ) iconic = FALSE; } @@ -2005,7 +2004,6 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam ) ShowCursor( FALSE ); SetCursor( hOldCursor ); } - DestroyCursor( hDragCursor ); } else if (moved && !DragFullWindows) draw_moving_frame( hdc, &sizingRect, thickframe ); diff --git a/include/cursoricon.h b/include/cursoricon.h index f902d340ab4..1ec053f5703 100644 --- a/include/cursoricon.h +++ b/include/cursoricon.h @@ -84,9 +84,6 @@ typedef struct #define CID_WIN32 0x0004 #define CID_NONSHARED 0x0008 -extern HCURSOR16 CURSORICON_IconToCursor( HICON16 hIcon, - BOOL bSemiTransparent ); - extern HGLOBAL CURSORICON_Load( HINSTANCE hInstance, LPCWSTR name, int width, int height, int colors, BOOL fCursor, UINT loadflags); diff --git a/windows/cursoricon.c b/windows/cursoricon.c index 615bdee569a..ac62a1e9643 100644 --- a/windows/cursoricon.c +++ b/windows/cursoricon.c @@ -51,7 +51,6 @@ #include "wine/winbase16.h" #include "wine/winuser16.h" #include "wine/exception.h" -#include "palette.h" #include "bitmap.h" #include "cursoricon.h" #include "module.h" @@ -955,101 +954,6 @@ HGLOBAL CURSORICON_ExtCopy(HGLOBAL Handle, UINT nType, return hNew; } -/*********************************************************************** - * CURSORICON_IconToCursor - * - * Converts bitmap to mono and truncates if icon is too large (should - * probably do StretchBlt() instead). - */ -HCURSOR16 CURSORICON_IconToCursor(HICON16 hIcon, BOOL bSemiTransparent) -{ - HCURSOR16 hRet = 0; - CURSORICONINFO *pIcon = NULL; - - if(hIcon) - if (!(pIcon = (CURSORICONINFO*)GlobalLock16( hIcon ))) return FALSE; - if (pIcon->bPlanes * pIcon->bBitsPerPixel == 1) - { - hRet = CURSORICON_Copy( 0, hIcon ); - - - pIcon = GlobalLock16(hRet); - - pIcon->ptHotSpot.x = pIcon->ptHotSpot.y = 15; - - GlobalUnlock16(hRet); - } - else - { - BYTE pAndBits[128]; - BYTE pXorBits[128]; - int maxx, maxy, ix, iy, bpp = pIcon->bBitsPerPixel; - BYTE* psPtr, *pxbPtr = pXorBits; - unsigned xor_width, and_width, val_base = 0xffffffff >> (32 - bpp); - BYTE* pbc = NULL; - - CURSORICONINFO cI; - - TRACE_(icon)("[%04x] %ix%i %ibpp (bogus %ibps)\n", - hIcon, pIcon->nWidth, pIcon->nHeight, pIcon->bBitsPerPixel, pIcon->nWidthBytes ); - - xor_width = BITMAP_GetWidthBytes( pIcon->nWidth, bpp ); - and_width = BITMAP_GetWidthBytes( pIcon->nWidth, 1 ); - psPtr = (BYTE *)(pIcon + 1) + pIcon->nHeight * and_width; - - memset(pXorBits, 0, 128); - cI.bBitsPerPixel = 1; cI.bPlanes = 1; - cI.ptHotSpot.x = cI.ptHotSpot.y = 15; - cI.nWidth = 32; cI.nHeight = 32; - cI.nWidthBytes = 4; /* 32x1bpp */ - - maxx = (pIcon->nWidth > 32) ? 32 : pIcon->nWidth; - maxy = (pIcon->nHeight > 32) ? 32 : pIcon->nHeight; - - for( iy = 0; iy < maxy; iy++ ) - { - unsigned shift = iy % 2; - - memcpy( pAndBits + iy * 4, (BYTE *)(pIcon + 1) + iy * and_width, - (and_width > 4) ? 4 : and_width ); - for( ix = 0; ix < maxx; ix++ ) - { - if( bSemiTransparent && ((ix+shift)%2) ) - { - /* set AND bit, XOR bit stays 0 */ - - pbc = pAndBits + iy * 4 + ix/8; - *pbc |= 0x80 >> (ix%8); - } - else - { - /* keep AND bit, set XOR bit */ - - unsigned *psc = (unsigned*)(psPtr + (ix * bpp)/8); - unsigned val = ((*psc) >> (ix * bpp)%8) & val_base; - if(PALETTE_Driver && !PALETTE_Driver->pIsDark(val)) - { - pbc = pxbPtr + ix/8; - *pbc |= 0x80 >> (ix%8); - } - } - } - psPtr += xor_width; - pxbPtr += 4; - } - - hRet = CreateCursorIconIndirect16( 0 , &cI, pAndBits, pXorBits); - - if( !hRet ) /* fall back on default drag cursor */ - hRet = CURSORICON_Copy( 0 , - CURSORICON_Load(0,MAKEINTRESOURCEW(OCR_DRAGOBJECT), - GetSystemMetrics(SM_CXCURSOR), - GetSystemMetrics(SM_CYCURSOR), 1, TRUE, 0) ); - } - - return hRet; -} - /*********************************************************************** * LoadCursor (USER.173) diff --git a/windows/win.c b/windows/win.c index f88d1e1890b..551d56c6073 100644 --- a/windows/win.c +++ b/windows/win.c @@ -3223,7 +3223,7 @@ DWORD WINAPI DragObject16( HWND16 hwndScope, HWND16 hWnd, UINT16 wObj, MSG msg; LPDRAGINFO16 lpDragInfo; SEGPTR spDragInfo; - HCURSOR16 hDragCursor=0, hOldCursor=0, hBummer=0; + HCURSOR16 hOldCursor=0, hBummer=0; HGLOBAL16 hDragInfo = GlobalAlloc16( GMEM_SHARE | GMEM_ZEROINIT, 2*sizeof(DRAGINFO16)); HCURSOR16 hCurrentCursor = 0; HWND16 hCurrentWnd = 0; @@ -3239,19 +3239,7 @@ DWORD WINAPI DragObject16( HWND16 hwndScope, HWND16 hWnd, UINT16 wObj, return 0L; } - if(hCursor) - { - if( !(hDragCursor = CURSORICON_IconToCursor(hCursor, FALSE)) ) - { - GlobalFree16(hDragInfo); - return 0L; - } - - if( hDragCursor == hCursor ) hDragCursor = 0; - else hCursor = hDragCursor; - - hOldCursor = SetCursor(hDragCursor); - } + if(hCursor) hOldCursor = SetCursor(hCursor); lpDragInfo->hWnd = hWnd; lpDragInfo->hScope = 0; @@ -3308,11 +3296,7 @@ DWORD WINAPI DragObject16( HWND16 hwndScope, HWND16 hWnd, UINT16 wObj, ReleaseCapture(); ShowCursor( FALSE ); - if( hCursor ) - { - SetCursor( hOldCursor ); - if (hDragCursor) DestroyCursor( hDragCursor ); - } + if( hCursor ) SetCursor( hOldCursor ); if( hCurrentCursor != hBummer ) msg.lParam = SendMessage16( lpDragInfo->hScope, WM_DROPOBJECT, @@ -3395,4 +3379,3 @@ BOOL WINAPI GetWindowInfo( HWND hwnd, PWINDOWINFO pwi) WIN_ReleasePtr(wndInfo); return TRUE; } - -- 2.11.4.GIT