1 |
786 |
skrzyp |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// vnc-test.c
|
4 |
|
|
//
|
5 |
|
|
//====================================================================
|
6 |
|
|
// Copyright (C) 2003 Sweeney Design Ltd
|
7 |
|
|
//
|
8 |
|
|
// This software is provided 'as-is', without any express or implied
|
9 |
|
|
// warranty. Permission is granted to anyone to use this software for
|
10 |
|
|
// any purpose, including commercial applications, and to alter it and
|
11 |
|
|
// redistribute it freely.
|
12 |
|
|
//
|
13 |
|
|
// http://www.sweeneydesign.co.uk
|
14 |
|
|
//
|
15 |
|
|
//====================================================================
|
16 |
|
|
//
|
17 |
|
|
// Test app for eCos VNC-server
|
18 |
|
|
//
|
19 |
|
|
//==========================================================================
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
#include <vnc-server.h>
|
23 |
|
|
#include <cyg/kernel/kapi.h> /* Kernel API */
|
24 |
|
|
#include <cyg/infra/diag.h> /* diag_printf() */
|
25 |
|
|
#include <cyg/error/codes.h> /* Cyg_ErrNo, ENOENT */
|
26 |
|
|
#include <cyg/io/io.h> /* cyg_io_handle_t */
|
27 |
|
|
#include <sys/select.h> /* select() functions */
|
28 |
|
|
#include <fcntl.h> /* open() */
|
29 |
|
|
#include <unistd.h> /* read() */
|
30 |
|
|
#include <stdlib.h> /* rand() */
|
31 |
|
|
|
32 |
|
|
void DrawCursor(void);
|
33 |
|
|
void HideCursor(void);
|
34 |
|
|
|
35 |
|
|
int cursor_x, cursor_y; /* Cursor position */
|
36 |
|
|
vnc_frame_format_t *display_info; /* Display Info */
|
37 |
|
|
|
38 |
|
|
int main(int argc, char * argv[])
|
39 |
|
|
{
|
40 |
|
|
int mouse_handle = -1;
|
41 |
|
|
int kbd_handle = -1;
|
42 |
|
|
cyg_uint8 mouse_data[8], kbd_data[4];
|
43 |
|
|
cyg_uint8 last_mouse_button = 0;
|
44 |
|
|
cyg_uint32 mouse_len = 0;
|
45 |
|
|
cyg_uint32 kbd_len = 0;
|
46 |
|
|
vnc_printf_return_t print_area;
|
47 |
|
|
cyg_uint16 text_y_pos;
|
48 |
|
|
int i, j;
|
49 |
|
|
|
50 |
|
|
cyg_uint16 bell_text_x_pos, bell_text_y_pos; /* Bell message text position */
|
51 |
|
|
cyg_uint16 bell_text_width, bell_text_height; /* Bell text message size */
|
52 |
|
|
|
53 |
|
|
fd_set sock_desc; /* Set of descriptors for select */
|
54 |
|
|
int max_handle;
|
55 |
|
|
|
56 |
|
|
int bell_text_state = 0;
|
57 |
|
|
char bell_message[] = "***** Click on a yellow pixel to sound the bell *****";
|
58 |
|
|
|
59 |
|
|
/* Get information about the display */
|
60 |
|
|
display_info = VncGetInfo();
|
61 |
|
|
|
62 |
|
|
/* Initialise the VNC server display */
|
63 |
|
|
VncInit(VNC_WHITE);
|
64 |
|
|
|
65 |
|
|
/* Open the mouse device */
|
66 |
|
|
mouse_handle = open("/dev/vnc_mouse", O_RDONLY | O_NONBLOCK);
|
67 |
|
|
if (mouse_handle < 0)
|
68 |
|
|
{
|
69 |
|
|
diag_printf("Could not open mouse device: /dev/vnc_mouse\n");
|
70 |
|
|
}
|
71 |
|
|
|
72 |
|
|
/* Open the keyboard device */
|
73 |
|
|
kbd_handle = open("/dev/vnc_kbd", O_RDONLY | O_NONBLOCK);
|
74 |
|
|
if (kbd_handle < 0)
|
75 |
|
|
{
|
76 |
|
|
diag_printf("Could not open kbd device: /dev/vnc_kbd\n");
|
77 |
|
|
}
|
78 |
|
|
|
79 |
|
|
/* Draw and label 16 rectangles using the 16 defined colours */
|
80 |
|
|
VncFillRect(0, 0, 75, 50, VNC_BLACK);
|
81 |
|
|
VncPrintf(&font_helvR10, 1, VNC_WHITE, 1, 1, "BLACK");
|
82 |
|
|
VncFillRect(75, 0, 150, 50, VNC_BLUE);
|
83 |
|
|
VncPrintf(&font_helvR10, 1, VNC_WHITE, 76, 1, "BLUE");
|
84 |
|
|
VncFillRect(150, 0, 225, 50, VNC_GREEN);
|
85 |
|
|
VncPrintf(&font_helvR10, 1, VNC_WHITE, 151, 1, "GREEN");
|
86 |
|
|
VncFillRect(225, 0, 300, 50, VNC_CYAN);
|
87 |
|
|
VncPrintf(&font_helvR10, 1, VNC_WHITE, 226, 1, "CYAN");
|
88 |
|
|
|
89 |
|
|
VncFillRect(0, 50, 75, 100, VNC_RED);
|
90 |
|
|
VncPrintf(&font_helvR10, 1, VNC_WHITE, 1, 51, "RED");
|
91 |
|
|
VncFillRect(75, 50, 150, 100, VNC_MAGENTA);
|
92 |
|
|
VncPrintf(&font_helvR10, 1, VNC_WHITE, 76, 51, "MAGENTA");
|
93 |
|
|
VncFillRect(150, 50, 225, 100, VNC_BROWN);
|
94 |
|
|
VncPrintf(&font_helvR10, 1, VNC_WHITE, 151, 51, "BROWN");
|
95 |
|
|
VncFillRect(225, 50, 300, 100, VNC_GRAY);
|
96 |
|
|
VncPrintf(&font_helvR10, 1, VNC_WHITE, 226, 51, "GRAY");
|
97 |
|
|
|
98 |
|
|
VncFillRect(0, 100, 75, 150, VNC_LTGRAY);
|
99 |
|
|
VncPrintf(&font_helvR10, 1, VNC_BLACK, 1, 101, "LTGRAY");
|
100 |
|
|
VncFillRect(75, 100, 150, 150, VNC_LTBLUE);
|
101 |
|
|
VncPrintf(&font_helvR10, 1, VNC_BLACK, 76, 101, "LTBLUE");
|
102 |
|
|
VncFillRect(150, 100, 225, 150, VNC_LTGREEN);
|
103 |
|
|
VncPrintf(&font_helvR10, 1, VNC_BLACK, 151, 101, "LTGREEN");
|
104 |
|
|
VncFillRect(225, 100, 300, 150, VNC_LTCYAN);
|
105 |
|
|
VncPrintf(&font_helvR10, 1, VNC_BLACK, 226, 101, "LTCYAN");
|
106 |
|
|
|
107 |
|
|
VncFillRect(0, 150, 75, 200, VNC_LTRED);
|
108 |
|
|
VncPrintf(&font_helvR10, 1, VNC_BLACK, 1, 151, "LTRED");
|
109 |
|
|
VncFillRect(75, 150, 150, 200, VNC_LTMAGENTA);
|
110 |
|
|
VncPrintf(&font_helvR10, 1, VNC_BLACK, 76, 151, "LTMAGENTA");
|
111 |
|
|
VncFillRect(150, 150, 225, 200, VNC_YELLOW);
|
112 |
|
|
VncPrintf(&font_helvR10, 1, VNC_BLACK, 151, 151, "YELLOW");
|
113 |
|
|
VncFillRect(225, 150, 300, 200, VNC_WHITE);
|
114 |
|
|
VncPrintf(&font_helvR10, 1, VNC_BLACK, 226, 151, "WHITE");
|
115 |
|
|
|
116 |
|
|
/* Fade from black to while */
|
117 |
|
|
for (i = 0; i < 256; i++)
|
118 |
|
|
{
|
119 |
|
|
VncDrawVertLine(i, 215, 265, VNC_RGB2COL(i, i, i));
|
120 |
|
|
}
|
121 |
|
|
|
122 |
|
|
VncPrintf(&font_helvR10, 1, VNC_WHITE, 1, 216, "GRAYSCALE");
|
123 |
|
|
|
124 |
|
|
/* Draw a strip with random coloured pixels */
|
125 |
|
|
for (i = 0; i < 256; i++)
|
126 |
|
|
{
|
127 |
|
|
for (j = 280; j < 330; j++)
|
128 |
|
|
{
|
129 |
|
|
VncDrawPixel( i, j, VNC_RGB2COL(rand()%256 , rand()%256, rand()%256) );
|
130 |
|
|
}
|
131 |
|
|
}
|
132 |
|
|
|
133 |
|
|
/* Write a title for the bar of random colours */
|
134 |
|
|
print_area = VncPrintf(&font_helvR10, 0, VNC_BLACK, 1, 281, "RANDOM");
|
135 |
|
|
VncFillRect(1, 281, 1+print_area.width , 281+print_area.height, VNC_LTGRAY);
|
136 |
|
|
VncPrintf(&font_helvR10, 1, VNC_BLACK, 1, 281, "RANDOM");
|
137 |
|
|
|
138 |
|
|
/* Report the pixel format */
|
139 |
|
|
if (display_info->rgb332)
|
140 |
|
|
{
|
141 |
|
|
VncPrintf(0, 1, VNC_BLACK, 1, 345, "Pixel format: RGB332");
|
142 |
|
|
}
|
143 |
|
|
else if (display_info->rgb555)
|
144 |
|
|
{
|
145 |
|
|
VncPrintf(0, 1, VNC_BLACK, 1, 345, "Pixel format: RGB555");
|
146 |
|
|
}
|
147 |
|
|
else if (display_info->rgb565)
|
148 |
|
|
{
|
149 |
|
|
VncPrintf(0, 1, VNC_BLACK, 1, 345, "Pixel format: RGB565");
|
150 |
|
|
}
|
151 |
|
|
else if (display_info->bgr233)
|
152 |
|
|
{
|
153 |
|
|
VncPrintf(0, 1, VNC_BLACK, 1, 345, "Pixel format: BGR233");
|
154 |
|
|
}
|
155 |
|
|
else if (display_info->truecolor0888)
|
156 |
|
|
{
|
157 |
|
|
VncPrintf(0, 1, VNC_BLACK, 1, 345, "Pixel format: TrueColor0888");
|
158 |
|
|
}
|
159 |
|
|
else
|
160 |
|
|
{
|
161 |
|
|
VncPrintf(0, 1, VNC_BLACK, 1, 345, "Pixel format: Unknown");
|
162 |
|
|
}
|
163 |
|
|
|
164 |
|
|
/* Report the frame dimensions */
|
165 |
|
|
VncPrintf(0, 1, VNC_BLACK, 1, 360, "Frame size: %d x %d", display_info->frame_width, display_info->frame_height);
|
166 |
|
|
|
167 |
|
|
/* Write text messages using each of the available fonts */
|
168 |
|
|
text_y_pos = 5;
|
169 |
|
|
print_area = VncPrintf(&font_rom8x8, 1, VNC_BLACK, 350, text_y_pos, "Hello World!\nUsing rom8x8 font");
|
170 |
|
|
text_y_pos += (print_area.height * 1.5);
|
171 |
|
|
print_area = VncPrintf(&font_rom8x16, 1, VNC_BLUE, 350, text_y_pos, "Hello World!\nUsing rom8x16 font");
|
172 |
|
|
text_y_pos += (print_area.height * 1.5);
|
173 |
|
|
print_area = VncPrintf(&font_winFreeSansSerif11x13, 1, VNC_CYAN, 350, text_y_pos, "Hello World!\nUsing winFreeSansSerif11x13 font");
|
174 |
|
|
text_y_pos += (print_area.height * 1.5);
|
175 |
|
|
print_area = VncPrintf(0, 1, VNC_RED, 350, text_y_pos, "Hello World!\nUsing default (winFreeSystem14x16) font");
|
176 |
|
|
text_y_pos += (print_area.height * 1.5);
|
177 |
|
|
print_area = VncPrintf(&font_helvB10, 1, VNC_MAGENTA, 350, text_y_pos, "Hello World!\nUsing helvB10 font");
|
178 |
|
|
text_y_pos += (print_area.height * 1.5);
|
179 |
|
|
print_area = VncPrintf(&font_helvB12, 1, VNC_BROWN, 350, text_y_pos, "Hello World!\nUsing helvB12 font");
|
180 |
|
|
text_y_pos += (print_area.height * 1.5);
|
181 |
|
|
print_area = VncPrintf(&font_helvR10, 1, VNC_GREEN, 350, text_y_pos, "Hello World!\nUsing helvR10 font");
|
182 |
|
|
text_y_pos += (print_area.height * 1.5);
|
183 |
|
|
print_area = VncPrintf(&font_X5x7, 1, VNC_BLACK, 350, text_y_pos, "Hello World!\nUsing X5x7 font");
|
184 |
|
|
text_y_pos += (print_area.height * 1.5);
|
185 |
|
|
print_area = VncPrintf(&font_X6x13, 1, VNC_LTRED, 350, text_y_pos, "Hello World!\nUsing X6x13 font");
|
186 |
|
|
|
187 |
|
|
/* Write the message about ringing the bell */
|
188 |
|
|
/* Get the details of the area the text will occupy */
|
189 |
|
|
print_area = VncPrintf(0, 0, VNC_BLACK, 0, 0, "%s", bell_message);
|
190 |
|
|
bell_text_width = print_area.width;
|
191 |
|
|
bell_text_height = print_area.height;
|
192 |
|
|
|
193 |
|
|
/* Calculate x position to center the bell text */
|
194 |
|
|
bell_text_x_pos = (display_info->frame_width - bell_text_width) / 2;
|
195 |
|
|
|
196 |
|
|
bell_text_y_pos = 400; /* y position always the same */
|
197 |
|
|
|
198 |
|
|
/* Draw a background for the bell text */
|
199 |
|
|
VncFillRect(bell_text_x_pos, /* x1 */
|
200 |
|
|
bell_text_y_pos, /* y1 */
|
201 |
|
|
bell_text_x_pos + bell_text_width, /* x2 */
|
202 |
|
|
bell_text_y_pos + bell_text_height, /* y2 */
|
203 |
|
|
VNC_BLUE); /* Colour */
|
204 |
|
|
/* Write the text on the background */
|
205 |
|
|
VncPrintf(0, 1, VNC_YELLOW, bell_text_x_pos, bell_text_y_pos, "%s", bell_message);
|
206 |
|
|
|
207 |
|
|
/* Initialise the cursor */
|
208 |
|
|
cursor_x = display_info->frame_width / 2;
|
209 |
|
|
cursor_y = display_info->frame_height / 2;
|
210 |
|
|
DrawCursor();
|
211 |
|
|
|
212 |
|
|
/* Initialse the max handle variable */
|
213 |
|
|
max_handle = -1;
|
214 |
|
|
if (kbd_handle > max_handle)
|
215 |
|
|
{
|
216 |
|
|
max_handle = kbd_handle;
|
217 |
|
|
}
|
218 |
|
|
|
219 |
|
|
if (mouse_handle > max_handle)
|
220 |
|
|
{
|
221 |
|
|
max_handle = mouse_handle;
|
222 |
|
|
}
|
223 |
|
|
|
224 |
|
|
|
225 |
|
|
while(1)
|
226 |
|
|
{
|
227 |
|
|
FD_ZERO(&sock_desc); /* Zero the socket set descriptor */
|
228 |
|
|
|
229 |
|
|
if (kbd_handle)
|
230 |
|
|
{
|
231 |
|
|
FD_SET(kbd_handle, &sock_desc); /* Add the keyboard handle to the set */
|
232 |
|
|
}
|
233 |
|
|
|
234 |
|
|
if (mouse_handle)
|
235 |
|
|
{
|
236 |
|
|
FD_SET(mouse_handle, &sock_desc); /* Add the mouse handle to the set */
|
237 |
|
|
}
|
238 |
|
|
|
239 |
|
|
/* Use select to wait until a keyboard or mouse event occurs*/
|
240 |
|
|
select(max_handle+1, &sock_desc, NULL, NULL, NULL);
|
241 |
|
|
|
242 |
|
|
/* Check for a keyboard event */
|
243 |
|
|
if (FD_ISSET(kbd_handle, &sock_desc))
|
244 |
|
|
{
|
245 |
|
|
kbd_len = 4;
|
246 |
|
|
|
247 |
|
|
/* Read keyboard data until there is none left */
|
248 |
|
|
while (kbd_len == 4)
|
249 |
|
|
{
|
250 |
|
|
/* Read 4 bytes from keyboard */
|
251 |
|
|
kbd_len = read(kbd_handle, kbd_data, 4);
|
252 |
|
|
|
253 |
|
|
if (kbd_len == 4)
|
254 |
|
|
{
|
255 |
|
|
if (kbd_data[1])
|
256 |
|
|
{
|
257 |
|
|
diag_printf("Keyboard data: keysym value 0x%x is pressed\n",
|
258 |
|
|
kbd_data[2]*256 + kbd_data[3]);
|
259 |
|
|
}
|
260 |
|
|
else
|
261 |
|
|
{
|
262 |
|
|
diag_printf("Keyboard data: keysym value 0x%x is released\n",
|
263 |
|
|
kbd_data[2]*256 + kbd_data[3]);
|
264 |
|
|
}
|
265 |
|
|
}
|
266 |
|
|
}
|
267 |
|
|
}
|
268 |
|
|
|
269 |
|
|
/* Check for a mouse event */
|
270 |
|
|
if (FD_ISSET(mouse_handle, &sock_desc))
|
271 |
|
|
{
|
272 |
|
|
mouse_len = 8;
|
273 |
|
|
|
274 |
|
|
/* Read mouse data until there is none left */
|
275 |
|
|
while (mouse_len == 8)
|
276 |
|
|
{
|
277 |
|
|
/* Read 8 bytes from mouse */
|
278 |
|
|
mouse_len = read(mouse_handle, mouse_data, 8);
|
279 |
|
|
|
280 |
|
|
if (mouse_len == 8)
|
281 |
|
|
{
|
282 |
|
|
HideCursor(); /* Hide the old cursor */
|
283 |
|
|
cursor_x = mouse_data[2]*256 + mouse_data[3];
|
284 |
|
|
cursor_y = mouse_data[4]*256 + mouse_data[5];
|
285 |
|
|
|
286 |
|
|
if (mouse_data[1] && !last_mouse_button)
|
287 |
|
|
{
|
288 |
|
|
/* Ring bell and change colours of bell message text if the */
|
289 |
|
|
/* mouse button is pressed on a yellow pixel */
|
290 |
|
|
if (VncReadPixel(mouse_data[2]*256 + mouse_data[3],
|
291 |
|
|
mouse_data[4]*256 + mouse_data[5]) == VNC_YELLOW)
|
292 |
|
|
{
|
293 |
|
|
VncSoundBell(); /* Ring bell on the client */
|
294 |
|
|
|
295 |
|
|
if (bell_text_state)
|
296 |
|
|
{
|
297 |
|
|
bell_text_state = 0;
|
298 |
|
|
/* Draw a background for the text */
|
299 |
|
|
VncFillRect(bell_text_x_pos, /* x1 */
|
300 |
|
|
bell_text_y_pos, /* y1 */
|
301 |
|
|
bell_text_x_pos + bell_text_width, /* x2 */
|
302 |
|
|
bell_text_y_pos + bell_text_height, /* y2 */
|
303 |
|
|
VNC_BLUE); /* Colour */
|
304 |
|
|
/* Write the text on the background */
|
305 |
|
|
print_area = VncPrintf(0, 1, VNC_YELLOW, bell_text_x_pos, bell_text_y_pos, "%s", bell_message);
|
306 |
|
|
|
307 |
|
|
}
|
308 |
|
|
else
|
309 |
|
|
{
|
310 |
|
|
bell_text_state = 1;
|
311 |
|
|
/* Draw a background for the text */
|
312 |
|
|
VncFillRect(bell_text_x_pos, /* x1 */
|
313 |
|
|
bell_text_y_pos, /* y1 */
|
314 |
|
|
bell_text_x_pos + bell_text_width, /* x2 */
|
315 |
|
|
bell_text_y_pos + bell_text_height, /* y2 */
|
316 |
|
|
VNC_YELLOW); /* Colour */
|
317 |
|
|
/* Write the text on the background */
|
318 |
|
|
print_area = VncPrintf(0, 1, VNC_BLUE, bell_text_x_pos, bell_text_y_pos, "%s", bell_message);
|
319 |
|
|
}
|
320 |
|
|
}
|
321 |
|
|
}
|
322 |
|
|
|
323 |
|
|
last_mouse_button = mouse_data[1]; /* Save mouse button data */
|
324 |
|
|
DrawCursor(); /* Draw the new cursor */
|
325 |
|
|
}
|
326 |
|
|
}
|
327 |
|
|
|
328 |
|
|
}
|
329 |
|
|
}
|
330 |
|
|
|
331 |
|
|
return 1;
|
332 |
|
|
}
|
333 |
|
|
|
334 |
|
|
|
335 |
|
|
vnc_colour_t under_cursor[16][16]; /* Buffer to hold display area under cursor */
|
336 |
|
|
|
337 |
|
|
/* Buffer holding cursor data */
|
338 |
|
|
#define BLK VNC_BLACK
|
339 |
|
|
#define TRN VNC_BLUE
|
340 |
|
|
#define WHT VNC_WHITE
|
341 |
|
|
#define GRY VNC_LTGRAY
|
342 |
|
|
vnc_colour_t cursor[16][16] = {{BLK, BLK, BLK, TRN, TRN, TRN, TRN, TRN, TRN, TRN, TRN, TRN, TRN, TRN, TRN, TRN},
|
343 |
|
|
{BLK, GRY, GRY, BLK, BLK, TRN, TRN, TRN, TRN, TRN, TRN, TRN, TRN, TRN, TRN, TRN},
|
344 |
|
|
{BLK, WHT, GRY, GRY, GRY, BLK, BLK, TRN, TRN, TRN, TRN, TRN, TRN, TRN, TRN, TRN},
|
345 |
|
|
{TRN, BLK, WHT, GRY, GRY, GRY, GRY, BLK, BLK, TRN, TRN, TRN, TRN, TRN, TRN, TRN},
|
346 |
|
|
{TRN, BLK, WHT, WHT, GRY, GRY, GRY, GRY, GRY, BLK, BLK, TRN, TRN, TRN, TRN, TRN},
|
347 |
|
|
{TRN, TRN, BLK, WHT, WHT, GRY, GRY, GRY, GRY, GRY, GRY, BLK, BLK, TRN, TRN, TRN},
|
348 |
|
|
{TRN, TRN, BLK, WHT, WHT, WHT, GRY, GRY, GRY, GRY, GRY, GRY, GRY, BLK, TRN, TRN},
|
349 |
|
|
{TRN, TRN, TRN, BLK, WHT, WHT, WHT, GRY, GRY, BLK, BLK, BLK, BLK, BLK, TRN, TRN},
|
350 |
|
|
{TRN, TRN, TRN, BLK, WHT, WHT, WHT, WHT, GRY, GRY, BLK, TRN, TRN, TRN, TRN, TRN},
|
351 |
|
|
{TRN, TRN, TRN, TRN, BLK, WHT, WHT, BLK, WHT, GRY, GRY, BLK, TRN, TRN, TRN, TRN},
|
352 |
|
|
{TRN, TRN, TRN, TRN, BLK, WHT, WHT, BLK, BLK, WHT, GRY, GRY, BLK, TRN, TRN, TRN},
|
353 |
|
|
{TRN, TRN, TRN, TRN, TRN, BLK, WHT, BLK, TRN, BLK, WHT, GRY, GRY, BLK, TRN, TRN},
|
354 |
|
|
{TRN, TRN, TRN, TRN, TRN, BLK, WHT, BLK, TRN, TRN, BLK, WHT, GRY, GRY, BLK, TRN},
|
355 |
|
|
{TRN, TRN, TRN, TRN, TRN, TRN, BLK, TRN, TRN, TRN, TRN, BLK, WHT, GRY, GRY, BLK},
|
356 |
|
|
{TRN, TRN, TRN, TRN, TRN, TRN, TRN, TRN, TRN, TRN, TRN, TRN, BLK, WHT, BLK, TRN},
|
357 |
|
|
{TRN, TRN, TRN, TRN, TRN, TRN, TRN, TRN, TRN, TRN, TRN, TRN, TRN, BLK, TRN, TRN}};
|
358 |
|
|
#undef BLK
|
359 |
|
|
#undef TRN
|
360 |
|
|
#undef WHT
|
361 |
|
|
#undef GRY
|
362 |
|
|
|
363 |
|
|
void DrawCursor(void)
|
364 |
|
|
{
|
365 |
|
|
int rect_width, rect_height;
|
366 |
|
|
|
367 |
|
|
if (cursor_x >= display_info->frame_width)
|
368 |
|
|
{
|
369 |
|
|
/* Cursor is off the screen */
|
370 |
|
|
return;
|
371 |
|
|
}
|
372 |
|
|
else if ((cursor_x + 16) >= display_info->frame_width)
|
373 |
|
|
{
|
374 |
|
|
/* Cursor is partially off the screen */
|
375 |
|
|
rect_width = display_info->frame_width - cursor_x;
|
376 |
|
|
}
|
377 |
|
|
else
|
378 |
|
|
{
|
379 |
|
|
/* Cursor is fully on the screen */
|
380 |
|
|
rect_width = 16;
|
381 |
|
|
}
|
382 |
|
|
|
383 |
|
|
if (cursor_y >= display_info->frame_height)
|
384 |
|
|
{
|
385 |
|
|
/* Cursor is off the screen */
|
386 |
|
|
return;
|
387 |
|
|
}
|
388 |
|
|
else if ((cursor_y + 16) >= display_info->frame_height)
|
389 |
|
|
{
|
390 |
|
|
/* Cursor is partially off the screen */
|
391 |
|
|
rect_height = display_info->frame_height - cursor_y;
|
392 |
|
|
}
|
393 |
|
|
else
|
394 |
|
|
{
|
395 |
|
|
/* Cursor is fully on the screen */
|
396 |
|
|
rect_height = 16;
|
397 |
|
|
}
|
398 |
|
|
|
399 |
|
|
/* Save the area under the cursor */
|
400 |
|
|
VncCopyRect2Buffer(cursor_x, cursor_y, rect_width, rect_height, under_cursor, 16, 16, 0, 0);
|
401 |
|
|
|
402 |
|
|
/* Draw the new cursor */
|
403 |
|
|
VncCopyBuffer2RectMask(cursor, 16, 16, 0, 0, cursor_x, cursor_y, rect_width, rect_height, VNC_BLUE);
|
404 |
|
|
}
|
405 |
|
|
|
406 |
|
|
|
407 |
|
|
void HideCursor(void)
|
408 |
|
|
{
|
409 |
|
|
int rect_width, rect_height;
|
410 |
|
|
|
411 |
|
|
if (cursor_x >= display_info->frame_width)
|
412 |
|
|
{
|
413 |
|
|
/* Cursor is off the screen */
|
414 |
|
|
return;
|
415 |
|
|
}
|
416 |
|
|
else if ((cursor_x + 16) >= display_info->frame_width)
|
417 |
|
|
{
|
418 |
|
|
/* Cursor is partially off the screen */
|
419 |
|
|
rect_width = display_info->frame_width - cursor_x;
|
420 |
|
|
}
|
421 |
|
|
else
|
422 |
|
|
{
|
423 |
|
|
/* Cursor is fully on the screen */
|
424 |
|
|
rect_width = 16;
|
425 |
|
|
}
|
426 |
|
|
|
427 |
|
|
if (cursor_y >= display_info->frame_height)
|
428 |
|
|
{
|
429 |
|
|
/* Cursor is off the screen */
|
430 |
|
|
return;
|
431 |
|
|
}
|
432 |
|
|
else if ((cursor_y + 16) >= display_info->frame_height)
|
433 |
|
|
{
|
434 |
|
|
/* Cursor is partially off the screen */
|
435 |
|
|
rect_height = display_info->frame_height - cursor_y;
|
436 |
|
|
}
|
437 |
|
|
else
|
438 |
|
|
{
|
439 |
|
|
/* Cursor is fully on the screen */
|
440 |
|
|
rect_height = 16;
|
441 |
|
|
}
|
442 |
|
|
|
443 |
|
|
/* Restore the saved area under the cursor */
|
444 |
|
|
VncCopyBuffer2Rect(under_cursor, 16, 16, 0, 0, cursor_x, cursor_y, rect_width, rect_height);
|
445 |
|
|
}
|