2 * ReactOS Generic Framebuffer display driver
4 * Copyright (C) 2004 Filip Navara
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #ifndef EXPERIMENTAL_MOUSE_CURSOR_SUPPORT
28 * Sets the new pointer shape.
47 /* return SPS_DECLINE;*/
48 return EngSetPointerShape(pso
, psoMask
, psoColor
, pxlo
, xHot
, yHot
, x
, y
, prcl
, fl
);
54 * Moves the pointer to a new position and ensures that GDI does not interfere
55 * with the display of the pointer.
68 EngMovePointer(pso
, x
, y
, prcl
);
74 IntHideMousePointer(PPDEV ppdev
, SURFOBJ
*DestSurface
)
76 if (ppdev
->PointerAttributes
.Enable
== FALSE
)
81 ppdev
->PointerAttributes
.Enable
= FALSE
;
82 if (ppdev
->PointerSaveSurface
!= NULL
)
89 DestRect
.left
= max(ppdev
->PointerAttributes
.Column
, 0);
90 DestRect
.top
= max(ppdev
->PointerAttributes
.Row
, 0);
92 ppdev
->PointerAttributes
.Column
+ ppdev
->PointerAttributes
.Width
,
93 ppdev
->ScreenWidth
- 1);
94 DestRect
.bottom
= min(
95 ppdev
->PointerAttributes
.Row
+ ppdev
->PointerAttributes
.Height
,
96 ppdev
->ScreenHeight
- 1);
98 SrcPoint
.x
= max(-ppdev
->PointerAttributes
.Column
, 0);
99 SrcPoint
.y
= max(-ppdev
->PointerAttributes
.Row
, 0);
101 SaveSurface
= EngLockSurface(ppdev
->PointerSaveSurface
);
102 MaskSurface
= EngLockSurface(ppdev
->PointerMaskSurface
);
103 EngBitBlt(DestSurface
, SaveSurface
, MaskSurface
, NULL
, NULL
,
104 &DestRect
, &SrcPoint
, &SrcPoint
, NULL
, NULL
, SRCCOPY
);
105 EngUnlockSurface(MaskSurface
);
106 EngUnlockSurface(SaveSurface
);
111 IntShowMousePointer(PPDEV ppdev
, SURFOBJ
*DestSurface
)
113 if (ppdev
->PointerAttributes
.Enable
== TRUE
)
118 ppdev
->PointerAttributes
.Enable
= TRUE
;
121 * Copy the pixels under the cursor to temporary surface.
124 if (ppdev
->PointerSaveSurface
!= NULL
)
128 SURFOBJ
*SaveSurface
;
130 SrcPoint
.x
= max(ppdev
->PointerAttributes
.Column
, 0);
131 SrcPoint
.y
= max(ppdev
->PointerAttributes
.Row
, 0);
133 DestRect
.left
= SrcPoint
.x
- ppdev
->PointerAttributes
.Column
;
134 DestRect
.top
= SrcPoint
.y
- ppdev
->PointerAttributes
.Row
;
135 DestRect
.right
= min(
136 ppdev
->PointerAttributes
.Width
,
137 ppdev
->ScreenWidth
- ppdev
->PointerAttributes
.Column
- 1);
138 DestRect
.bottom
= min(
139 ppdev
->PointerAttributes
.Height
,
140 ppdev
->ScreenHeight
- ppdev
->PointerAttributes
.Row
- 1);
142 SaveSurface
= EngLockSurface(ppdev
->PointerSaveSurface
);
143 EngBitBlt(SaveSurface
, DestSurface
, NULL
, NULL
, NULL
,
144 &DestRect
, &SrcPoint
, NULL
, NULL
, NULL
, SRCCOPY
);
145 EngUnlockSurface(SaveSurface
);
149 * Blit the cursor on the screen.
158 DestRect
.left
= max(ppdev
->PointerAttributes
.Column
, 0);
159 DestRect
.top
= max(ppdev
->PointerAttributes
.Row
, 0);
160 DestRect
.right
= min(
161 ppdev
->PointerAttributes
.Column
+ ppdev
->PointerAttributes
.Width
,
162 ppdev
->ScreenWidth
- 1);
163 DestRect
.bottom
= min(
164 ppdev
->PointerAttributes
.Row
+ ppdev
->PointerAttributes
.Height
,
165 ppdev
->ScreenHeight
- 1);
167 SrcPoint
.x
= max(-ppdev
->PointerAttributes
.Column
, 0);
168 SrcPoint
.y
= max(-ppdev
->PointerAttributes
.Row
, 0);
170 MaskSurf
= EngLockSurface(ppdev
->PointerMaskSurface
);
171 if (ppdev
->PointerColorSurface
!= NULL
)
173 ColorSurf
= EngLockSurface(ppdev
->PointerColorSurface
);
174 EngBitBlt(DestSurface
, ColorSurf
, MaskSurf
, NULL
, ppdev
->PointerXlateObject
,
175 &DestRect
, &SrcPoint
, &SrcPoint
, NULL
, NULL
, 0xAACC);
176 EngUnlockSurface(ColorSurf
);
181 EngBitBlt(DestSurface
, MaskSurf
, NULL
, NULL
, ppdev
->PointerXlateObject
,
182 &DestRect
, &SrcPoint
, NULL
, NULL
, NULL
, SRCAND
);
183 SrcPoint
.y
+= ppdev
->PointerAttributes
.Height
;
184 EngBitBlt(DestSurface
, MaskSurf
, NULL
, NULL
, ppdev
->PointerXlateObject
,
185 &DestRect
, &SrcPoint
, NULL
, NULL
, NULL
, SRCINVERT
);
187 EngUnlockSurface(MaskSurf
);
194 * Sets the new pointer shape.
204 IN SURFOBJ
*psoColor
,
213 PPDEV ppdev
= (PPDEV
)pso
->dhpdev
;
214 SURFOBJ
*TempSurfObj
;
216 IntHideMousePointer(ppdev
, pso
);
218 if (ppdev
->PointerColorSurface
!= NULL
)
220 /* FIXME: Is this really needed? */
221 TempSurfObj
= EngLockSurface(ppdev
->PointerColorSurface
);
222 EngFreeMem(TempSurfObj
->pvBits
);
223 TempSurfObj
->pvBits
= 0;
224 EngUnlockSurface(TempSurfObj
);
226 EngDeleteSurface(ppdev
->PointerColorSurface
);
227 ppdev
->PointerMaskSurface
= NULL
;
230 if (ppdev
->PointerMaskSurface
!= NULL
)
232 /* FIXME: Is this really needed? */
233 TempSurfObj
= EngLockSurface(ppdev
->PointerMaskSurface
);
234 EngFreeMem(TempSurfObj
->pvBits
);
235 TempSurfObj
->pvBits
= 0;
236 EngUnlockSurface(TempSurfObj
);
238 EngDeleteSurface(ppdev
->PointerMaskSurface
);
239 ppdev
->PointerMaskSurface
= NULL
;
242 if (ppdev
->PointerSaveSurface
!= NULL
)
244 EngDeleteSurface(ppdev
->PointerSaveSurface
);
245 ppdev
->PointerSaveSurface
= NULL
;
249 * See if we are being asked to hide the pointer.
254 return SPS_ACCEPT_EXCLUDE
;
257 ppdev
->PointerHotSpot
.x
= xHot
;
258 ppdev
->PointerHotSpot
.y
= yHot
;
260 ppdev
->PointerXlateObject
= pxlo
;
261 ppdev
->PointerAttributes
.Column
= x
- xHot
;
262 ppdev
->PointerAttributes
.Row
= y
- yHot
;
263 ppdev
->PointerAttributes
.Width
= psoMask
->lDelta
<< 3;
264 ppdev
->PointerAttributes
.Height
= (psoMask
->cjBits
/ psoMask
->lDelta
) >> 1;
266 if (psoColor
!= NULL
)
271 Size
.cx
= ppdev
->PointerAttributes
.Width
;
272 Size
.cy
= ppdev
->PointerAttributes
.Height
;
273 Bits
= EngAllocMem(0, psoColor
->cjBits
, ALLOC_TAG
);
274 memcpy(Bits
, psoColor
->pvBits
, psoColor
->cjBits
);
276 ppdev
->PointerColorSurface
= (HSURF
)EngCreateBitmap(Size
,
277 psoColor
->lDelta
, psoColor
->iBitmapFormat
, 0, Bits
);
281 ppdev
->PointerColorSurface
= NULL
;
289 Size
.cx
= ppdev
->PointerAttributes
.Width
;
290 Size
.cy
= ppdev
->PointerAttributes
.Height
<< 1;
291 Bits
= EngAllocMem(0, psoMask
->cjBits
, ALLOC_TAG
);
292 memcpy(Bits
, psoMask
->pvBits
, psoMask
->cjBits
);
294 ppdev
->PointerMaskSurface
= (HSURF
)EngCreateBitmap(Size
,
295 psoMask
->lDelta
, psoMask
->iBitmapFormat
, 0, Bits
);
299 ppdev
->PointerMaskSurface
= NULL
;
303 * Create surface for saving the pixels under the cursor.
310 Size
.cx
= ppdev
->PointerAttributes
.Width
;
311 Size
.cy
= ppdev
->PointerAttributes
.Height
;
313 switch (pso
->iBitmapFormat
)
315 case BMF_8BPP
: lDelta
= Size
.cx
; break;
316 case BMF_16BPP
: lDelta
= Size
.cx
<< 1; break;
317 case BMF_24BPP
: lDelta
= Size
.cx
* 3; break;
318 case BMF_32BPP
: lDelta
= Size
.cx
<< 2; break;
321 ppdev
->PointerSaveSurface
= (HSURF
)EngCreateBitmap(
322 Size
, lDelta
, pso
->iBitmapFormat
, BMF_NOZEROINIT
, NULL
);
325 IntShowMousePointer(ppdev
, pso
);
327 return SPS_ACCEPT_EXCLUDE
;
333 * Moves the pointer to a new position and ensures that GDI does not interfere
334 * with the display of the pointer.
347 PPDEV ppdev
= (PPDEV
)pso
->dhpdev
;
350 WasVisible
= ppdev
->PointerAttributes
.Enable
;
353 IntHideMousePointer(ppdev
, pso
);
361 ppdev
->PointerAttributes
.Column
= x
- ppdev
->PointerHotSpot
.x
;
362 ppdev
->PointerAttributes
.Row
= y
- ppdev
->PointerHotSpot
.y
;
366 IntShowMousePointer(ppdev
, pso
);