Lines 73-80
Link Here
|
73 |
XtNborderWidth, 0, |
73 |
XtNborderWidth, 0, |
74 |
NULL); |
74 |
NULL); |
75 |
|
75 |
|
76 |
XtVaSetValues(desktop, XtNwidth, si.framebufferWidth, |
76 |
/* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es |
77 |
XtNheight, si.framebufferHeight, NULL); |
77 |
size of the scaled desktop */ |
|
|
78 |
XtVaSetValues(desktop, XtNwidth, appData.windowWidth, |
79 |
XtNheight, appData.windowHeight, NULL); |
78 |
|
80 |
|
79 |
XtAddEventHandler(desktop, LeaveWindowMask|ExposureMask, |
81 |
XtAddEventHandler(desktop, LeaveWindowMask|ExposureMask, |
80 |
True, HandleBasicDesktopEvent, NULL); |
82 |
True, HandleBasicDesktopEvent, NULL); |
Lines 93-100
Link Here
|
93 |
#endif |
95 |
#endif |
94 |
|
96 |
|
95 |
if (!image) { |
97 |
if (!image) { |
|
|
98 |
/* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es |
99 |
size of the scaled desktop */ |
96 |
image = XCreateImage(dpy, vis, visdepth, ZPixmap, 0, NULL, |
100 |
image = XCreateImage(dpy, vis, visdepth, ZPixmap, 0, NULL, |
97 |
si.framebufferWidth, si.framebufferHeight, |
101 |
appData.windowWidth, appData.windowHeight, |
98 |
BitmapPad(dpy), 0); |
102 |
BitmapPad(dpy), 0); |
99 |
|
103 |
|
100 |
image->data = malloc(image->bytes_per_line * image->height); |
104 |
image->data = malloc(image->bytes_per_line * image->height); |
Lines 161-179
Link Here
|
161 |
/* sometimes due to scrollbars being added/removed we get an expose outside |
165 |
/* sometimes due to scrollbars being added/removed we get an expose outside |
162 |
the actual desktop area. Make sure we don't pass it on to the RFB |
166 |
the actual desktop area. Make sure we don't pass it on to the RFB |
163 |
server. */ |
167 |
server. */ |
164 |
|
168 |
{ |
165 |
if (ev->xexpose.x + ev->xexpose.width > si.framebufferWidth) { |
169 |
/* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es |
166 |
ev->xexpose.width = si.framebufferWidth - ev->xexpose.x; |
170 |
let's scale back the coordinates */ |
167 |
if (ev->xexpose.width <= 0) break; |
171 |
int Width = si.framebufferWidth; |
168 |
} |
172 |
int Height = si.framebufferHeight; |
169 |
|
173 |
int x = ev->xexpose.x, y = ev->xexpose.y; |
170 |
if (ev->xexpose.y + ev->xexpose.height > si.framebufferHeight) { |
174 |
int width = ev->xexpose.width, height = ev->xexpose.height; |
171 |
ev->xexpose.height = si.framebufferHeight - ev->xexpose.y; |
175 |
|
172 |
if (ev->xexpose.height <= 0) break; |
176 |
GetOriginalDimensions( &x, &y, &width, &height); |
|
|
177 |
|
178 |
if (x + width > Width) { |
179 |
width = Width - x; |
180 |
if (width <= 0) break; |
181 |
} |
182 |
|
183 |
if (y + height > Height) { |
184 |
height = Height - y; |
185 |
if (height <= 0) break; |
186 |
} |
187 |
|
188 |
SendFramebufferUpdateRequest(x, y, width, height, False); |
173 |
} |
189 |
} |
174 |
|
|
|
175 |
SendFramebufferUpdateRequest(ev->xexpose.x, ev->xexpose.y, |
176 |
ev->xexpose.width, ev->xexpose.height, False); |
177 |
break; |
190 |
break; |
178 |
|
191 |
|
179 |
case LeaveNotify: |
192 |
case LeaveNotify: |
Lines 291-310
Link Here
|
291 |
while (XCheckTypedWindowEvent(dpy, desktopWin, MotionNotify, ev)) |
304 |
while (XCheckTypedWindowEvent(dpy, desktopWin, MotionNotify, ev)) |
292 |
; /* discard all queued motion notify events */ |
305 |
; /* discard all queued motion notify events */ |
293 |
|
306 |
|
294 |
SendPointerEvent(ev->xmotion.x, ev->xmotion.y, |
307 |
/* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es |
295 |
(ev->xmotion.state & 0x1f00) >> 8); |
308 |
let's scale back the coordinates */ |
|
|
309 |
SendPointerEventScaled(ev->xmotion.x, ev->xmotion.y, |
310 |
(ev->xmotion.state & 0x1f00) >> 8); |
296 |
return; |
311 |
return; |
297 |
|
312 |
|
298 |
case ButtonPress: |
313 |
case ButtonPress: |
299 |
SendPointerEvent(ev->xbutton.x, ev->xbutton.y, |
314 |
/* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es |
300 |
(((ev->xbutton.state & 0x1f00) >> 8) | |
315 |
let's scale back the coordinates */ |
301 |
(1 << (ev->xbutton.button - 1)))); |
316 |
SendPointerEventScaled(ev->xbutton.x, ev->xbutton.y, |
|
|
317 |
(((ev->xbutton.state & 0x1f00) >> 8) | |
318 |
(1 << (ev->xbutton.button - 1)))); |
302 |
return; |
319 |
return; |
303 |
|
320 |
|
304 |
case ButtonRelease: |
321 |
case ButtonRelease: |
305 |
SendPointerEvent(ev->xbutton.x, ev->xbutton.y, |
322 |
/* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es |
306 |
(((ev->xbutton.state & 0x1f00) >> 8) & |
323 |
let's scale back the coordinates */ |
307 |
~(1 << (ev->xbutton.button - 1)))); |
324 |
SendPointerEventScaled(ev->xbutton.x, ev->xbutton.y, |
|
|
325 |
(((ev->xbutton.state & 0x1f00) >> 8) & |
326 |
~(1 << (ev->xbutton.button - 1)))); |
308 |
return; |
327 |
return; |
309 |
|
328 |
|
310 |
case KeyPress: |
329 |
case KeyPress: |
Lines 356-364
Link Here
|
356 |
* CopyDataToScreen. |
375 |
* CopyDataToScreen. |
357 |
*/ |
376 |
*/ |
358 |
|
377 |
|
|
|
378 |
/* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es |
379 |
let's scale the data */ |
380 |
void ScaleImageData( int bytesPerPixel, int dstRowStride, int srcRowStride, |
381 |
int x, int y, |
382 |
int srcWidth, int srcHeight, const char *srcImage, |
383 |
int dst_x, int dst_y, |
384 |
int dstWidth, int dstHeight, char *dstImage ) { |
385 |
int h, w, ip; |
386 |
|
387 |
for ( h = 0; h < dstHeight; h++) { |
388 |
int org_h = ( int)( 0.5 + ( double)( ( h + dst_y) * appData.scaleDen) / ( double)appData.scaleNum) - y; |
389 |
if ( org_h >= srcHeight) org_h = srcHeight - 1; |
390 |
if ( org_h < 0) org_h = 0; |
391 |
for ( w = 0; w < dstWidth; w++) { |
392 |
int org_w = ( int)( 0.5 + ( double)( ( w + dst_x) * appData.scaleDen) / ( double)appData.scaleNum) - x; |
393 |
if ( org_w >= srcWidth) org_w = srcWidth - 1; |
394 |
if ( org_w < 0) org_w = 0; |
395 |
for ( ip = 0; ip < bytesPerPixel; ip++) { |
396 |
dstImage[ dstRowStride * ( dst_y + h) + ( w + dst_x) * bytesPerPixel + ip] = |
397 |
srcImage[ srcRowStride * org_h + org_w * bytesPerPixel + ip]; |
398 |
} |
399 |
} |
400 |
} |
401 |
} |
402 |
/* Miguel end */ |
403 |
|
359 |
void |
404 |
void |
360 |
CopyDataToScreen(char *buf, int x, int y, int width, int height) |
405 |
CopyDataToScreen(char *buf, int x, int y, int width, int height) |
361 |
{ |
406 |
{ |
|
|
407 |
/* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es |
408 |
nothing to do */ |
409 |
if ( !width || !height) return; |
362 |
if (appData.rawDelay != 0) { |
410 |
if (appData.rawDelay != 0) { |
363 |
XFillRectangle(dpy, desktopWin, gc, x, y, width, height); |
411 |
XFillRectangle(dpy, desktopWin, gc, x, y, width, height); |
364 |
|
412 |
|
Lines 368-384
Link Here
|
368 |
} |
416 |
} |
369 |
|
417 |
|
370 |
if (!appData.useBGR233) { |
418 |
if (!appData.useBGR233) { |
371 |
int h; |
419 |
/* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es |
372 |
int widthInBytes = width * myFormat.bitsPerPixel / 8; |
420 |
at the moment we only know how to scale with bitsPerPixel >= 8 */ |
373 |
int scrWidthInBytes = si.framebufferWidth * myFormat.bitsPerPixel / 8; |
421 |
if ( !appData.scaled || ( myFormat.bitsPerPixel < 8)) { |
374 |
|
422 |
int h; |
375 |
char *scr = (image->data + y * scrWidthInBytes |
423 |
int widthInBytes = width * myFormat.bitsPerPixel / 8; |
376 |
+ x * myFormat.bitsPerPixel / 8); |
424 |
int scrWidthInBytes = appData.windowWidth * myFormat.bitsPerPixel / 8; |
377 |
|
425 |
char *scr = (image->data + y * scrWidthInBytes |
378 |
for (h = 0; h < height; h++) { |
426 |
+ x * myFormat.bitsPerPixel / 8); |
379 |
memcpy(scr, buf, widthInBytes); |
427 |
|
380 |
buf += widthInBytes; |
428 |
for (h = 0; h < height; h++) { |
381 |
scr += scrWidthInBytes; |
429 |
memcpy(scr, buf, widthInBytes); |
|
|
430 |
buf += widthInBytes; |
431 |
scr += scrWidthInBytes; |
432 |
} |
433 |
} else { |
434 |
/* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es |
435 |
let's scale the data and coordinates */ |
436 |
int dst_x = x; |
437 |
int dst_y = y; |
438 |
int dst_width = width; |
439 |
int dst_height = height; |
440 |
int bufWidthInBytes = width * myFormat.bitsPerPixel / 8; |
441 |
int scrWidthInBytes = appData.windowWidth * myFormat.bitsPerPixel / 8; /* de momento */ |
442 |
|
443 |
char *scr; |
444 |
|
445 |
int h, w, ip; |
446 |
int tam_buf_tmp = 0; |
447 |
int tmp_WidthInBytes = dst_width * myFormat.bitsPerPixel / 8; |
448 |
char *tmp; |
449 |
|
450 |
ScaleDimensions( &dst_x, &dst_y, &dst_width, &dst_height); |
451 |
|
452 |
scr = (image->data + dst_y * scrWidthInBytes + dst_x * myFormat.bitsPerPixel / 8); |
453 |
if ( height && width && dst_width && dst_height) { |
454 |
scr = image->data; |
455 |
ScaleImageData( myFormat.bitsPerPixel / 8, scrWidthInBytes, bufWidthInBytes, |
456 |
x, y, width, height, buf, |
457 |
dst_x, dst_y, dst_width, dst_height, scr); |
458 |
} |
459 |
|
460 |
x = dst_x; |
461 |
y = dst_y; |
462 |
width = dst_width; |
463 |
height = dst_height; |
464 |
/* Miguel end */ |
382 |
} |
465 |
} |
383 |
} else { |
466 |
} else { |
384 |
CopyBGR233ToScreen((CARD8 *)buf, x, y, width, height); |
467 |
CopyBGR233ToScreen((CARD8 *)buf, x, y, width, height); |
Lines 407-415
Link Here
|
407 |
int fbwb = si.framebufferWidth / 8; |
490 |
int fbwb = si.framebufferWidth / 8; |
408 |
CARD8 *scr1 = ((CARD8 *)image->data) + y * fbwb + x / 8; |
491 |
CARD8 *scr1 = ((CARD8 *)image->data) + y * fbwb + x / 8; |
409 |
CARD8 *scrt; |
492 |
CARD8 *scrt; |
410 |
CARD8 *scr8 = ((CARD8 *)image->data) + y * si.framebufferWidth + x; |
493 |
/* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es |
411 |
CARD16 *scr16 = ((CARD16 *)image->data) + y * si.framebufferWidth + x; |
494 |
size of the scaled desktop */ |
412 |
CARD32 *scr32 = ((CARD32 *)image->data) + y * si.framebufferWidth + x; |
495 |
CARD8 *scr8 = ((CARD8 *)image->data) + y * appData.windowWidth + x; |
|
|
496 |
CARD16 *scr16 = ((CARD16 *)image->data) + y * appData.windowWidth + x; |
497 |
CARD32 *scr32 = ((CARD32 *)image->data) + y * appData.windowWidth + x; |
413 |
|
498 |
|
414 |
switch (visbpp) { |
499 |
switch (visbpp) { |
415 |
|
500 |
|
Lines 437-443
Link Here
|
437 |
for (p = 0; p < width; p++) { |
522 |
for (p = 0; p < width; p++) { |
438 |
*(scr8++) = BGR233ToPixel[*(buf++)]; |
523 |
*(scr8++) = BGR233ToPixel[*(buf++)]; |
439 |
} |
524 |
} |
440 |
scr8 += si.framebufferWidth - width; |
525 |
/* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es |
|
|
526 |
size of the scaled desktop */ |
527 |
scr8 += appData.windowWidth - width; |
441 |
} |
528 |
} |
442 |
break; |
529 |
break; |
443 |
|
530 |
|
Lines 446-452
Link Here
|
446 |
for (p = 0; p < width; p++) { |
533 |
for (p = 0; p < width; p++) { |
447 |
*(scr16++) = BGR233ToPixel[*(buf++)]; |
534 |
*(scr16++) = BGR233ToPixel[*(buf++)]; |
448 |
} |
535 |
} |
449 |
scr16 += si.framebufferWidth - width; |
536 |
/* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es |
|
|
537 |
size of the scaled desktop */ |
538 |
scr16 += appData.windowWidth - width; |
450 |
} |
539 |
} |
451 |
break; |
540 |
break; |
452 |
|
541 |
|
Lines 455-462
Link Here
|
455 |
for (p = 0; p < width; p++) { |
544 |
for (p = 0; p < width; p++) { |
456 |
*(scr32++) = BGR233ToPixel[*(buf++)]; |
545 |
*(scr32++) = BGR233ToPixel[*(buf++)]; |
457 |
} |
546 |
} |
458 |
scr32 += si.framebufferWidth - width; |
547 |
/* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es |
|
|
548 |
size of the scaled desktop */ |
549 |
scr32 += appData.windowWidth - width; |
459 |
} |
550 |
} |
460 |
break; |
551 |
break; |
461 |
} |
552 |
} |
462 |
} |
553 |
} |
|
|
554 |
|