2 * ReactOS Generic Framebuffer display driver
4 * Copyright (C) 2007 Magnus Olsen
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.
21 #include "framebufacc.h"
28 * Moves the pointer to a new position and ensures that GDI does not interfere
29 * with the display of the pointer.
36 DrvMovePointer(IN SURFOBJ
*pso
,
41 PPDEV ppdev
= (PPDEV
) pso
->dhpdev
;
42 DWORD returnedDataLength
;
43 VIDEO_POINTER_POSITION NewPointerPosition
;
45 x
-= ppdev
->ScreenOffsetXY
.x
;
46 y
-= ppdev
->ScreenOffsetXY
.y
;
48 /* position of (-1,-1) hide the pointer */
49 if ((x
== -1) || (y
== -1))
51 if (EngDeviceIoControl(ppdev
->hDriver
, IOCTL_VIDEO_DISABLE_POINTER
, NULL
, 0, NULL
, 0, &returnedDataLength
))
53 /* hw did not disable the mouse, we try then with software */
54 EngMovePointer(pso
, x
, y
, prcl
);
59 /* Calc the mouse positions and set it to the new positions */
60 NewPointerPosition
.Column
= (SHORT
) x
- (SHORT
) (ppdev
->PointerHotSpot
.x
);
61 NewPointerPosition
.Row
= (SHORT
) y
- (SHORT
) (ppdev
->PointerHotSpot
.y
);
63 if (EngDeviceIoControl(ppdev
->hDriver
, IOCTL_VIDEO_SET_POINTER_POSITION
, &NewPointerPosition
,
64 sizeof(VIDEO_POINTER_POSITION
), NULL
, 0, &returnedDataLength
))
66 /* hw did not disable the mouse, we try then with software */
67 EngMovePointer(pso
, x
, y
, prcl
);
76 * Sets the new pointer shape.
95 PPDEV ppdev
= (PPDEV
) pso
->dhpdev
;
96 ULONG returnedDataLength
= 0;
98 if (ppdev
->pPointerAttributes
== NULL
)
100 /* hw did not support hw mouse pointer, we try then with software */
101 return EngSetPointerShape(pso
, psoMask
, psoColor
, pxlo
, xHot
, yHot
, x
, y
, prcl
, fl
);
104 /* check see if the apps ask to hide the mouse or not */
105 if (psoMask
== (SURFOBJ
*) NULL
)
107 if (EngDeviceIoControl(ppdev
->hDriver
, IOCTL_VIDEO_DISABLE_POINTER
, NULL
, 0, NULL
, 0, &returnedDataLength
))
109 /* no hw support found for the mouse we try then the software version */
110 return EngSetPointerShape(pso
, psoMask
, psoColor
, pxlo
, xHot
, yHot
, x
, y
, prcl
, fl
);
116 /* set our hotspot */
117 ppdev
->PointerHotSpot
.x
= xHot
;
118 ppdev
->PointerHotSpot
.y
= yHot
;
120 /* Set the hw mouse shape */
122 if (psoColor
!= (SURFOBJ
*) NULL
)
124 /* We got a color mouse pointer */
125 if ((ppdev
->PointerCapabilities
.Flags
& VIDEO_MODE_COLOR_POINTER
) &&
126 (CopyColorPointer(ppdev
, psoMask
, psoColor
, pxlo
)) )
128 ppdev
->pPointerAttributes
->Flags
|= VIDEO_MODE_COLOR_POINTER
;
132 /* No color mouse pointer being set, so we need try the software version then */
133 if (ppdev
->HwMouseActive
)
135 ppdev
->HwMouseActive
= FALSE
;
136 if (EngDeviceIoControl(ppdev
->hDriver
, IOCTL_VIDEO_DISABLE_POINTER
, NULL
, 0, NULL
, 0, &returnedDataLength
))
138 /* hw did not support hw mouse pointer, we try then with software */
139 return EngSetPointerShape(pso
, psoMask
, psoColor
, pxlo
, xHot
, yHot
, x
, y
, prcl
, fl
);
147 /* We got a mono mouse pointer */
148 if ( (ppdev
->PointerCapabilities
.Flags
& VIDEO_MODE_MONO_POINTER
) &&
149 (CopyMonoPointer(ppdev
, psoMask
)))
151 ppdev
->pPointerAttributes
->Flags
|= VIDEO_MODE_MONO_POINTER
;
155 /* No mono mouse pointer being set, so we need try the software version then */
156 if (ppdev
->HwMouseActive
)
158 ppdev
->HwMouseActive
= FALSE
;
159 if (EngDeviceIoControl(ppdev
->hDriver
, IOCTL_VIDEO_DISABLE_POINTER
, NULL
, 0, NULL
, 0, &returnedDataLength
))
161 /* hw did not support hw mouse pointer, we try then with software */
162 return EngSetPointerShape(pso
, psoMask
, psoColor
, pxlo
, xHot
, yHot
, x
, y
, prcl
, fl
);
169 /* we goto hw mouse pointer then we contnue filling in more info */
171 /* calc the mouse point positions */
172 if ((x
!= -1) || (y
!= -1))
174 ppdev
->pPointerAttributes
->Column
-= (SHORT
)(ppdev
->PointerHotSpot
.x
);
175 ppdev
->pPointerAttributes
->Row
-= (SHORT
)(ppdev
->PointerHotSpot
.y
);
178 /* set correct flags if it animated or need be updated anime or no flags at all */
179 if (fl
& SPS_ANIMATESTART
)
181 ppdev
->pPointerAttributes
->Flags
|= VIDEO_MODE_ANIMATE_START
;
183 else if (fl
& SPS_ANIMATEUPDATE
)
185 ppdev
->pPointerAttributes
->Flags
|= VIDEO_MODE_ANIMATE_UPDATE
;
188 ppdev
->pPointerAttributes
->Enable
= 1;
189 ppdev
->pPointerAttributes
->Column
= (SHORT
)(x
);
190 ppdev
->pPointerAttributes
->Row
= (SHORT
)(y
);
192 /* Set the new mouse pointer shape */
193 if (EngDeviceIoControl(ppdev
->hDriver
, IOCTL_VIDEO_SET_POINTER_ATTR
, ppdev
->pPointerAttributes
,
194 ppdev
->PointerAttributesSize
, NULL
, 0, &returnedDataLength
))
196 /* no hw support found for the mouse we try then the software version */
197 return EngSetPointerShape(pso
, psoMask
, psoColor
, pxlo
, xHot
, yHot
, x
, y
, prcl
, fl
);
200 /* we got real hw support */
201 ppdev
->HwMouseActive
= TRUE
;
202 return SPS_ACCEPT_NOEXCLUDE
;
206 /* Internal api that are only use in DrvSetPointerShape */
209 CopyColorPointer(PPDEV ppdev
,
214 /* FIXME unimplement */
219 CopyMonoPointer(PPDEV ppdev
,
222 /* FIXME unimplement */