ReactOS 0.4.15-dev-5667-ged97270
pointer.c
Go to the documentation of this file.
1/*
2 * ReactOS Generic Framebuffer display driver
3 *
4 * Copyright (C) 2007 Magnus Olsen
5 *
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.
10 *
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.
15 *
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.
19 */
20
21#include "framebufacc.h"
22
23
24
25/*
26 * DrvMovePointer
27 *
28 * Moves the pointer to a new position and ensures that GDI does not interfere
29 * with the display of the pointer.
30 *
31 * Status
32 * @implemented
33 */
34
37 IN LONG x,
38 IN LONG y,
39 IN RECTL *prcl)
40{
41 PPDEV ppdev = (PPDEV) pso->dhpdev;
42 DWORD returnedDataLength;
43 VIDEO_POINTER_POSITION NewPointerPosition;
44
45 x -= ppdev->ScreenOffsetXY.x;
46 y -= ppdev->ScreenOffsetXY.y;
47
48 /* position of (-1,-1) hide the pointer */
49 if ((x == -1) || (y == -1))
50 {
51 if (EngDeviceIoControl(ppdev->hDriver, IOCTL_VIDEO_DISABLE_POINTER, NULL, 0, NULL, 0, &returnedDataLength))
52 {
53 /* hw did not disable the mouse, we try then with software */
55 }
56 }
57 else
58 {
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);
62
63 if (EngDeviceIoControl(ppdev->hDriver, IOCTL_VIDEO_SET_POINTER_POSITION, &NewPointerPosition,
64 sizeof(VIDEO_POINTER_POSITION), NULL, 0, &returnedDataLength))
65 {
66 /* hw did not disable the mouse, we try then with software */
68 }
69 }
70}
71
72
73/*
74 * DrvSetPointerShape
75 *
76 * Sets the new pointer shape.
77 *
78 * Status
79 * @implemented
80 */
81
84 IN SURFOBJ *pso,
88 IN LONG xHot,
89 IN LONG yHot,
90 IN LONG x,
91 IN LONG y,
92 IN RECTL *prcl,
93 IN FLONG fl)
94{
95 PPDEV ppdev = (PPDEV) pso->dhpdev;
96 ULONG returnedDataLength = 0;
97
98 if (ppdev->pPointerAttributes == NULL)
99 {
100 /* hw did not support hw mouse pointer, we try then with software */
102 }
103
104 /* check see if the apps ask to hide the mouse or not */
105 if (psoMask == NULL)
106 {
107 if (EngDeviceIoControl(ppdev->hDriver, IOCTL_VIDEO_DISABLE_POINTER, NULL, 0, NULL, 0, &returnedDataLength))
108 {
109 /* no hw support found for the mouse we try then the software version */
111 }
112
113 return TRUE;
114 }
115
116 /* set our hotspot */
117 ppdev->PointerHotSpot.x = xHot;
118 ppdev->PointerHotSpot.y = yHot;
119
120 /* Set the hw mouse shape */
121
122 if (psoColor != NULL)
123 {
124 /* We got a color mouse pointer */
127 {
129 }
130 else
131 {
132 /* No color mouse pointer being set, so we need try the software version then */
133 if (ppdev->HwMouseActive)
134 {
135 ppdev->HwMouseActive = FALSE;
136 if (EngDeviceIoControl(ppdev->hDriver, IOCTL_VIDEO_DISABLE_POINTER, NULL, 0, NULL, 0, &returnedDataLength))
137 {
138 /* hw did not support hw mouse pointer, we try then with software */
140 }
141 }
142 return SPS_DECLINE ;
143 }
144 }
145 else
146 {
147 /* We got a mono mouse pointer */
149 (CopyMonoPointer(ppdev, psoMask)))
150 {
152 }
153 else
154 {
155 /* No mono mouse pointer being set, so we need try the software version then */
156 if (ppdev->HwMouseActive)
157 {
158 ppdev->HwMouseActive = FALSE;
159 if (EngDeviceIoControl(ppdev->hDriver, IOCTL_VIDEO_DISABLE_POINTER, NULL, 0, NULL, 0, &returnedDataLength))
160 {
161 /* hw did not support hw mouse pointer, we try then with software */
163 }
164 }
165 return SPS_DECLINE ;
166 }
167 }
168
169 /* we goto hw mouse pointer then we contnue filling in more info */
170
171 /* calc the mouse point positions */
172 if ((x != -1) || (y != -1))
173 {
174 ppdev->pPointerAttributes->Column -= (SHORT)(ppdev->PointerHotSpot.x);
175 ppdev->pPointerAttributes->Row -= (SHORT)(ppdev->PointerHotSpot.y);
176 }
177
178 /* set correct flags if it animated or need be updated anime or no flags at all */
179 if (fl & SPS_ANIMATESTART)
180 {
182 }
183 else if (fl & SPS_ANIMATEUPDATE)
184 {
186 }
187
188 ppdev->pPointerAttributes->Enable = 1;
189 ppdev->pPointerAttributes->Column = (SHORT)(x);
190 ppdev->pPointerAttributes->Row = (SHORT)(y);
191
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))
195 {
196 /* no hw support found for the mouse we try then the software version */
198 }
199
200 /* we got real hw support */
201 ppdev->HwMouseActive = TRUE;
203}
204
205
206/* Internal api that are only use in DrvSetPointerShape */
207
208BOOL
212 XLATEOBJ *pxlo)
213{
214 /* FIXME unimplement */
215 return FALSE;
216}
217
218BOOL
220 SURFOBJ *pso)
221{
222 /* FIXME unimplement */
223 return FALSE;
224}
225
226
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define APIENTRY
Definition: api.h:79
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
struct _PDEV * PPDEV
BOOL CopyMonoPointer(PPDEV ppdev, SURFOBJ *pso)
Definition: pointer.c:219
BOOL CopyColorPointer(PPDEV ppdev, SURFOBJ *psoMask, SURFOBJ *psoColor, XLATEOBJ *pxlo)
Definition: pointer.c:209
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
if(dx< 0)
Definition: linetemp.h:194
unsigned long FLONG
Definition: ntbasedef.h:366
#define IOCTL_VIDEO_SET_POINTER_ATTR
Definition: ntddvdeo.h:164
#define VIDEO_MODE_ANIMATE_START
Definition: ntddvdeo.h:457
#define VIDEO_MODE_MONO_POINTER
Definition: ntddvdeo.h:455
#define IOCTL_VIDEO_SET_POINTER_POSITION
Definition: ntddvdeo.h:167
#define IOCTL_VIDEO_DISABLE_POINTER
Definition: ntddvdeo.h:80
#define VIDEO_MODE_ANIMATE_UPDATE
Definition: ntddvdeo.h:458
#define VIDEO_MODE_COLOR_POINTER
Definition: ntddvdeo.h:456
short SHORT
Definition: pedump.c:59
long LONG
Definition: pedump.c:60
Definition: framebuf.h:34
VIDEO_POINTER_CAPABILITIES PointerCapabilities
Definition: driver.h:44
BOOL HwMouseActive
Definition: framebufacc.h:66
ULONG PointerAttributesSize
Definition: framebufacc.h:64
PVIDEO_POINTER_ATTRIBUTES pPointerAttributes
Definition: driver.h:45
HANDLE hDriver
Definition: framebuf.h:35
POINTL ScreenOffsetXY
Definition: framebufacc.h:55
POINTL PointerHotSpot
Definition: framebufacc.h:65
LONG y
Definition: windef.h:330
LONG x
Definition: windef.h:329
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
_In_ HANDLE _In_ SURFOBJ * pso
Definition: winddi.h:3665
_In_ FLONG fl
Definition: winddi.h:1279
_In_opt_ SURFOBJ _In_opt_ SURFOBJ _In_ XLATEOBJ _In_ LONG xHot
Definition: winddi.h:4052
ENGAPI VOID APIENTRY EngMovePointer(_In_ SURFOBJ *pso, _In_ LONG x, _In_ LONG y, _In_ RECTL *prcl)
Definition: mouse.c:575
#define SPS_ANIMATESTART
Definition: winddi.h:4037
_In_opt_ SURFOBJ _In_opt_ SURFOBJ _In_ XLATEOBJ _In_ LONG _In_ LONG yHot
Definition: winddi.h:4053
FN_DrvSetPointerShape DrvSetPointerShape
#define SPS_ACCEPT_NOEXCLUDE
Definition: winddi.h:4030
_In_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ * pxlo
Definition: winddi.h:3416
_In_opt_ SURFOBJ _In_opt_ SURFOBJ * psoMask
Definition: winddi.h:3434
FN_DrvMovePointer DrvMovePointer
_In_opt_ SURFOBJ _In_opt_ SURFOBJ * psoColor
Definition: winddi.h:4050
#define SPS_ANIMATEUPDATE
Definition: winddi.h:4038
_In_ ULONG _In_ CLIPOBJ _In_ RECTL * prcl
Definition: winddi.h:3531
#define SPS_DECLINE
Definition: winddi.h:4029
ENGAPI ULONG APIENTRY EngSetPointerShape(_In_ SURFOBJ *pso, _In_opt_ SURFOBJ *psoMask, _In_opt_ SURFOBJ *psoColor, _In_opt_ XLATEOBJ *pxlo, _In_ LONG xHot, _In_ LONG yHot, _In_ LONG x, _In_ LONG y, _In_ RECTL *prcl, _In_ FLONG fl)
Definition: mouse.c:330