/* Blt the pointer on the screen. */
if (pgp->psurfColor)
{
- IntEngBitBlt(psoDest,
- &pgp->psurfMask->SurfObj,
- NULL,
- NULL,
- NULL,
- &rclSurf,
- (POINTL*)&rclPointer,
- NULL,
- NULL,
- NULL,
- ROP4_FROM_INDEX(R3_OPINDEX_SRCAND));
-
- IntEngBitBlt(psoDest,
- &pgp->psurfColor->SurfObj,
- NULL,
- NULL,
- NULL,
- &rclSurf,
- (POINTL*)&rclPointer,
- NULL,
- NULL,
- NULL,
- ROP4_FROM_INDEX(R3_OPINDEX_SRCINVERT));
+ if(!(pgp->flags & SPS_ALPHA))
+ {
+ IntEngBitBlt(psoDest,
+ &pgp->psurfMask->SurfObj,
+ NULL,
+ NULL,
+ NULL,
+ &rclSurf,
+ (POINTL*)&rclPointer,
+ NULL,
+ NULL,
+ NULL,
+ ROP4_SRCAND);
+
+ IntEngBitBlt(psoDest,
+ &pgp->psurfColor->SurfObj,
+ NULL,
+ NULL,
+ NULL,
+ &rclSurf,
+ (POINTL*)&rclPointer,
+ NULL,
+ NULL,
+ NULL,
+ ROP4_SRCINVERT);
+ }
+ else
+ {
+ BLENDOBJ blendobj = { {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA } };
+ EXLATEOBJ exlo;
+ EXLATEOBJ_vInitialize(&exlo,
+ pgp->psurfColor->ppal,
+ ppdev->ppalSurf,
+ 0xFFFFFFFF,
+ 0xFFFFFFFF,
+ 0);
+ IntEngAlphaBlend(psoDest,
+ &pgp->psurfColor->SurfObj,
+ NULL,
+ &exlo.xlo,
+ &rclSurf,
+ &rclPointer,
+ &blendobj);
+ EXLATEOBJ_vCleanup(&exlo);
+ }
}
else
{
if (psoColor)
{
/* Color bitmap must have the same format as the dest surface */
- if (psoColor->iBitmapFormat != pso->iBitmapFormat) goto failure;
+ if (psoColor->iBitmapFormat != pso->iBitmapFormat)
+ {
+ /* It's OK if we have an alpha bitmap */
+ if(!(fl & SPS_ALPHA))
+ {
+ DPRINT1("Screen surface and cursor color bitmap format don't match!.\n");
+ goto failure;
+ }
+ }
/* Create a bitmap to copy the color bitmap to */
hbmColor = EngCreateBitmap(psoColor->sizlBitmap,
pgp->HotSpot.x = xHot;
pgp->HotSpot.y = yHot;
pgp->Size = sizel;
+ pgp->flags = fl;
if (x != -1)
{
LONG xHot,
LONG yHot,
LONG x,
- LONG y)
+ LONG y,
+ FLONG fl)
{
PDC pdc;
PSURFACE psurf, psurfMask, psurfColor;
EXLATEOBJ exlo;
- FLONG fl = 0;
ULONG ulResult = 0;
pdc = DC_LockDc(hdc);
if (hbmMask)
psurfMask = SURFACE_ShareLockSurface(hbmMask);
else
+ {
+ ASSERT(fl & SPS_ALPHA);
psurfMask = NULL;
+ }
/* Check for color bitmap */
if (hbmColor)
}
else
psurfColor = NULL;
+
+ /* We must have a valid surface in case of alpha bitmap */
+ ASSERT(((fl & SPS_ALPHA) && psurfColor) || !(fl & SPS_ALPHA));
/* Call the driver or eng function */
ulResult = IntEngSetPointerShape(&psurf->SurfObj,
LONG xHot,
LONG yHot,
LONG x,
- LONG y);
+ LONG y,
+ FLONG fl);
VOID
NTAPI
SURFACE *psurfColor;
SURFACE *psurfMask;
SURFACE *psurfSave;
+ FLONG flags;
/* Public pointer information */
RECTL Exclude; /* Required publicly for SPS_ACCEPT_EXCLUDE */
PCURICON_OBJECT CurIcon;
NTSTATUS Status = STATUS_SUCCESS;
BOOL Ret = FALSE;
- CURSORDATA dataSafe;
TRACE("Enter NtUserSetCursorIconData\n");
_SEH2_TRY
{
ProbeForRead(pCursorData, sizeof(*pCursorData), 1);
- RtlCopyMemory(&dataSafe, pCursorData, sizeof(dataSafe));
+ CurIcon->xHotspot = pCursorData->xHotspot;
+ CurIcon->yHotspot = pCursorData->yHotspot;
+ CurIcon->cx = pCursorData->cx;
+ CurIcon->cy = pCursorData->cy;
+ CurIcon->rt = pCursorData->rt;
+ CurIcon->bpp = pCursorData->bpp;
+ CurIcon->hbmMask = pCursorData->hbmMask;
+ CurIcon->hbmColor = pCursorData->hbmColor;
+ CurIcon->hbmAlpha = pCursorData->hbmAlpha;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
SetLastNtError(Status);
goto done;
}
-
- CurIcon->xHotspot = dataSafe.xHotspot;
- CurIcon->yHotspot = dataSafe.yHotspot;
- CurIcon->cx = dataSafe.cx;
- CurIcon->cy = dataSafe.cy;
- CurIcon->rt = dataSafe.rt;
- CurIcon->bpp = dataSafe.bpp;
- if(!dataSafe.hbmMask)
+ if(pustrModule)
+ {
+ /* We use this convenient function, because INTRESOURCEs and ATOMs are the same */
+ Status = ProbeAndCaptureUnicodeStringOrAtom(&CurIcon->strName, pustrRsrc);
+ if(!NT_SUCCESS(Status))
+ goto done;
+ Status = ProbeAndCaptureUnicodeString(&CurIcon->ustrModule, UserMode, pustrModule);
+ if(!NT_SUCCESS(Status))
+ goto done;
+ }
+
+
+ if(!CurIcon->hbmMask)
{
ERR("NtUserSetCursorIconData was got no hbmMask.\n");
EngSetLastError(ERROR_INVALID_PARAMETER);
goto done;
}
- CurIcon->hbmMask = BITMAP_CopyBitmap(dataSafe.hbmMask);
- if(!CurIcon->hbmMask)
- goto done;
GreSetObjectOwner(CurIcon->hbmMask, GDI_OBJ_HMGR_PUBLIC);
- if(dataSafe.hbmColor)
- {
- CurIcon->hbmColor = BITMAP_CopyBitmap(dataSafe.hbmColor);
- if(!CurIcon->hbmColor)
- goto done;
+ if(CurIcon->hbmColor)
GreSetObjectOwner(CurIcon->hbmColor, GDI_OBJ_HMGR_PUBLIC);
- }
- if(dataSafe.hbmAlpha)
- {
- CurIcon->hbmAlpha = BITMAP_CopyBitmap(dataSafe.hbmAlpha);
- if(!CurIcon->hbmAlpha)
- goto done;
+ if(CurIcon->hbmAlpha)
GreSetObjectOwner(CurIcon->hbmAlpha, GDI_OBJ_HMGR_PUBLIC);
- }
-
- if(pustrModule)
- {
- /* We use this convenient function, because INTRESOURCEs and ATOMs are the same */
- Status = ProbeAndCaptureUnicodeStringOrAtom(&CurIcon->strName, pustrRsrc);
- if(!NT_SUCCESS(Status))
- goto done;
- Status = ProbeAndCaptureUnicodeString(&CurIcon->ustrModule, UserMode, pustrModule);
- if(!NT_SUCCESS(Status))
- goto done;
- }
Ret = TRUE;
done:
if(!Ret)
{
- if (CurIcon->hbmMask)
- {
- GreSetObjectOwner(CurIcon->hbmMask, GDI_OBJ_HMGR_POWNED);
- GreDeleteObject(CurIcon->hbmMask);
- CurIcon->hbmMask = NULL;
- }
- if (CurIcon->hbmColor)
- {
- GreSetObjectOwner(CurIcon->hbmColor, GDI_OBJ_HMGR_POWNED);
- GreDeleteObject(CurIcon->hbmColor);
- CurIcon->hbmColor = NULL;
- }
- if (CurIcon->hbmAlpha)
- {
- GreSetObjectOwner(CurIcon->hbmAlpha, GDI_OBJ_HMGR_POWNED);
- GreDeleteObject(CurIcon->hbmAlpha);
- CurIcon->hbmAlpha = NULL;
- }
if(!IS_INTRESOURCE(CurIcon->strName.Buffer))
ExFreePoolWithTag(CurIcon->strName.Buffer, TAG_STRING);
if(CurIcon->ustrModule.Buffer)
/* Call GDI to set the new screen cursor */
#ifdef NEW_CURSORICON
GreSetPointerShape(hdcScreen,
- NewCursor->hbmMask,
- NewCursor->hbmColor,
+ NewCursor->hbmAlpha ? NULL : NewCursor->hbmMask,
+ NewCursor->hbmAlpha ? NewCursor->hbmAlpha : NewCursor->hbmColor,
NewCursor->xHotspot,
NewCursor->yHotspot,
gpsi->ptCursor.x,
- gpsi->ptCursor.y);
+ gpsi->ptCursor.y,
+ NewCursor->hbmAlpha ? SPS_ALPHA : 0);
#else
GreSetPointerShape(hdcScreen,
NewCursor->IconInfo.hbmMask,
NewCursor->IconInfo.xHotspot,
NewCursor->IconInfo.yHotspot,
gpsi->ptCursor.x,
- gpsi->ptCursor.y);
+ gpsi->ptCursor.y,
+ 0);
#endif
}
else /* Note: OldCursor != NewCursor so we have to hide cursor */
{
/* Call GDI to set the new screen cursor */
#ifdef NEW_CURSORICON
- GreSetPointerShape(hdcScreen,
- MessageQueue->CursorObject->hbmMask,
- MessageQueue->CursorObject->hbmColor,
- MessageQueue->CursorObject->xHotspot,
- MessageQueue->CursorObject->yHotspot,
- gpsi->ptCursor.x,
- gpsi->ptCursor.y);
+ GreSetPointerShape(hdcScreen,
+ MessageQueue->CursorObject->hbmAlpha ?
+ NULL : MessageQueue->CursorObject->hbmMask,
+ MessageQueue->CursorObject->hbmAlpha ?
+ MessageQueue->CursorObject->hbmAlpha : MessageQueue->CursorObject->hbmColor,
+ MessageQueue->CursorObject->xHotspot,
+ MessageQueue->CursorObject->yHotspot,
+ gpsi->ptCursor.x,
+ gpsi->ptCursor.y,
+ MessageQueue->CursorObject->hbmAlpha ? SPS_ALPHA : 0);
#else
GreSetPointerShape(hdcScreen,
MessageQueue->CursorObject->IconInfo.hbmMask,
MessageQueue->CursorObject->IconInfo.xHotspot,
MessageQueue->CursorObject->IconInfo.yHotspot,
gpsi->ptCursor.x,
- gpsi->ptCursor.y);
+ gpsi->ptCursor.y,
+ 0);
#endif
} else
GreMovePointer(hdcScreen, Msg->pt.x, Msg->pt.y);
hCurIcon = NtUserxCreateEmptyCurObject(bIcon ? 0 : 1);
if(!hCurIcon)
- goto end_clean;
+ goto end_error;
/* Tell win32k */
if(!NtUserSetCursorIconData(hCurIcon, NULL, NULL, &cursorData))
{
NtUserDestroyCursor(hCurIcon, TRUE);
- hCurIcon = NULL;
+ goto end_error;
}
- /* Clean up */
-end_clean:
+end:
+ UnmapViewOfFile(bits);
+ return hCurIcon;
+
+ /* Clean up */
+end_error:
DeleteObject(cursorData.hbmMask);
if(cursorData.hbmColor) DeleteObject(cursorData.hbmColor);
if(cursorData.hbmAlpha) DeleteObject(cursorData.hbmAlpha);
-end:
- UnmapViewOfFile(bits);
- return hCurIcon;
+ return NULL;
}
static
if(!bStatus)
goto done;
+ /* This is from resource */
+ cursorData.CURSORF_flags = CURSORF_FROMRESOURCE;
+
/* Create the handle */
hCurIcon = NtUserxCreateEmptyCurObject(bIcon ? 0 : 1);
if(!hCurIcon)
{
- DeleteObject(cursorData.hbmMask);
- if(cursorData.hbmColor) DeleteObject(cursorData.hbmColor);
- if(cursorData.hbmAlpha) DeleteObject(cursorData.hbmAlpha);
- goto done;
+ goto end_error;
}
/* Tell win32k */
if(fuLoad & LR_SHARED)
+ {
+ cursorData.CURSORF_flags |= CURSORF_LRSHARED;
bStatus = NtUserSetCursorIconData(hCurIcon, &ustrModule, &ustrRsrc, &cursorData);
+ }
else
bStatus = NtUserSetCursorIconData(hCurIcon, NULL, NULL, &cursorData);
if(!bStatus)
{
NtUserDestroyCursor(hCurIcon, TRUE);
- hCurIcon = NULL;
+ goto end_error;
}
-
- DeleteObject(cursorData.hbmMask);
- if(cursorData.hbmColor) DeleteObject(cursorData.hbmColor);
- if(cursorData.hbmAlpha) DeleteObject(cursorData.hbmAlpha);
done:
if(ustrModule.Buffer)
HeapFree(GetProcessHeap(), 0, ustrModule.Buffer);
return hCurIcon;
+
+end_error:
+ if(ustrModule.Buffer)
+ HeapFree(GetProcessHeap(), 0, ustrModule.Buffer);
+ DeleteObject(cursorData.hbmMask);
+ if(cursorData.hbmColor) DeleteObject(cursorData.hbmColor);
+ if(cursorData.hbmAlpha) DeleteObject(cursorData.hbmAlpha);
+
+ return NULL;
}
static
hIcon = NtUserxCreateEmptyCurObject(fIcon ? 0 : 1);
if(!hIcon)
- return NULL;
+ goto end_error;
if(!NtUserSetCursorIconData(hIcon, NULL, NULL, &cursorData))
{
ERR("NtUserSetCursorIconData failed.\n");
NtUserDestroyCursor(hIcon, TRUE);
- hIcon = NULL;
+ goto end_error;
}
+ return hIcon;
+
/* Clean up */
+end_error:
DeleteObject(cursorData.hbmMask);
if(cursorData.hbmColor) DeleteObject(cursorData.hbmColor);
if(cursorData.hbmAlpha) DeleteObject(cursorData.hbmAlpha);
- return hIcon;
+ return NULL;
}
HICON WINAPI CreateIconIndirect(
hiconRet = NtUserxCreateEmptyCurObject(piconinfo->fIcon ? 0 : 1);
if(!hiconRet)
- return NULL;
+ goto end_error;
if(!NtUserSetCursorIconData(hiconRet, NULL, NULL, &cursorData))
{
NtUserDestroyCursor(hiconRet, FALSE);
- hiconRet = NULL;
+ goto end_error;
}
+ TRACE("Returning 0x%08x.\n", hiconRet);
+
+ return hiconRet;
+
+end_error:
/* Clean up */
DeleteObject(cursorData.hbmMask);
if(cursorData.hbmColor) DeleteObject(cursorData.hbmColor);
if(cursorData.hbmAlpha) DeleteObject(cursorData.hbmAlpha);
- TRACE("Returning 0x%08x.\n", hiconRet);
-
- return hiconRet;
+ return NULL;
}
HCURSOR WINAPI CreateCursor(