Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 136996
Collapse All | Expand All

(-)vnc_unixsrc/vncviewer/README (+12 lines)
Lines 59-64 Link Here
59
  been sent at the end of the update.  In some cases this can save time by
59
  been sent at the end of the update.  In some cases this can save time by
60
  skipping intermediate screen states.
60
  skipping intermediate screen states.
61
61
62
* The client can display a scaled output of the server desktop.
63
62
64
63
Resources
65
Resources
64
---------
66
---------
Lines 214-219 Link Here
214
    Similar to rawDelay, but highlights the areas copied using the copyrect
216
    Similar to rawDelay, but highlights the areas copied using the copyrect
215
    encoding.
217
    encoding.
216
218
219
  scaleNum
220
221
    The numerator for scaling the client's window with respect to the 
222
    server's desktop
223
224
  scaleDen
225
226
    The denominator for scaling the client's window with respect to the 
227
    server's desktop
228
217
229
218
How to customise the popup window
230
How to customise the popup window
219
---------------------------------
231
---------------------------------
(-)vnc_unixsrc/vncviewer/argsresources.c (-1 / +43 lines)
Lines 224-229 Link Here
224
  {"grabKeyboard", "GrabKeyboard", XtRBool, sizeof(Bool),
224
  {"grabKeyboard", "GrabKeyboard", XtRBool, sizeof(Bool),
225
   XtOffsetOf(AppData, grabKeyboard), XtRImmediate, (XtPointer) False},
225
   XtOffsetOf(AppData, grabKeyboard), XtRImmediate, (XtPointer) False},
226
226
227
  /* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es 
228
     command line scale parameters, like the Window's options */
229
  {"scaleNum", "ScaleNum", XtRInt, sizeof(int),
230
   XtOffsetOf(AppData, scaleNum), XtRImmediate, (XtPointer) 1},
231
232
  {"scaleDen", "ScaleDen", XtRInt, sizeof(int),
233
   XtOffsetOf(AppData, scaleDen), XtRImmediate, (XtPointer) 1},
234
  /* Miguel end */
235
227
  {"autoPass", "AutoPass", XtRBool, sizeof(Bool),
236
  {"autoPass", "AutoPass", XtRBool, sizeof(Bool),
228
   XtOffsetOf(AppData, autoPass), XtRImmediate, (XtPointer) False}
237
   XtOffsetOf(AppData, autoPass), XtRImmediate, (XtPointer) False}
229
};
238
};
Lines 253-259 Link Here
253
  {"-nojpeg",        "*enableJPEG",         XrmoptionNoArg,  "False"},
262
  {"-nojpeg",        "*enableJPEG",         XrmoptionNoArg,  "False"},
254
  {"-nocursorshape", "*useRemoteCursor",    XrmoptionNoArg,  "False"},
263
  {"-nocursorshape", "*useRemoteCursor",    XrmoptionNoArg,  "False"},
255
  {"-x11cursor",     "*useX11Cursor",       XrmoptionNoArg,  "True"},
264
  {"-x11cursor",     "*useX11Cursor",       XrmoptionNoArg,  "True"},
256
  {"-autopass",      "*autoPass",           XrmoptionNoArg,  "True"}
265
  {"-autopass",      "*autoPass",           XrmoptionNoArg,  "True"},
266
  /* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es 
267
     command line scale parameters, like the Window's options */
268
  {"-scale_num",     "*scaleNum",           XrmoptionSepArg, 0},
269
  {"-scale_den",     "*scaleDen",           XrmoptionSepArg, 0}
270
  /* Miguel end */
257
271
258
};
272
};
259
273
Lines 315-320 Link Here
315
	  "        -shared (set by default)\n"
329
	  "        -shared (set by default)\n"
316
	  "        -noshared\n"
330
	  "        -noshared\n"
317
	  "        -viewonly\n"
331
	  "        -viewonly\n"
332
	  /* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es 
333
	     command line scale parameters, like the Window's options */
334
	  "        -scale_num <NUMERATOR> (for scaling)\n"
335
	  "        -scale_den <DENOMINATOR> (for scaling)\n"
336
	  /* Miguel end */
318
	  "        -fullscreen\n"
337
	  "        -fullscreen\n"
319
	  "        -noraiseonbeep\n"
338
	  "        -noraiseonbeep\n"
320
	  "        -passwd <PASSWD-FILENAME> (standard VNC authentication)\n"
339
	  "        -passwd <PASSWD-FILENAME> (standard VNC authentication)\n"
Lines 337-342 Link Here
337
  exit(1);
356
  exit(1);
338
}
357
}
339
358
359
/* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es 
360
   to simplify the factors, like the Window's options */
361
/* Greatest common denominator, by Euclid */
362
int gcd( int a, int b) {
363
  if ( a < b) return gcd( b, a);
364
  if ( b == 0) return a;
365
  return gcd( b, a % b);
366
}
367
/* Miguel end */
340
368
341
/*
369
/*
342
 * GetArgsAndResources() deals with resources and any command-line arguments
370
 * GetArgsAndResources() deals with resources and any command-line arguments
Lines 357-362 Link Here
357
  XtGetApplicationResources(toplevel, &appData, appDataResourceList,
385
  XtGetApplicationResources(toplevel, &appData, appDataResourceList,
358
			    XtNumber(appDataResourceList), 0, 0);
386
			    XtNumber(appDataResourceList), 0, 0);
359
387
388
  /* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es 
389
     let's simplify the scale factors */
390
  if ( appData.scaleNum < 1) appData.scaleNum = 1;
391
  if ( appData.scaleDen < 1) appData.scaleDen = 1;
392
  if ( appData.scaleNum == appData.scaleDen) {
393
    appData.scaled = 0;
394
  } else {
395
    appData.scaled = 1;
396
  }
397
  i = gcd( appData.scaleNum, appData.scaleDen);
398
  appData.scaleNum /= i;
399
  appData.scaleDen /= i;	
400
  /* Miguel end */
401
360
  /* Add our actions to the actions table so they can be used in widget
402
  /* Add our actions to the actions table so they can be used in widget
361
     resource specs */
403
     resource specs */
362
404
(-)vnc_unixsrc/vncviewer/corre.c (-2 / +6 lines)
Lines 54-60 Link Here
54
#endif
54
#endif
55
55
56
    XChangeGC(dpy, gc, GCForeground, &gcv);
56
    XChangeGC(dpy, gc, GCForeground, &gcv);
57
    XFillRectangle(dpy, desktopWin, gc, rx, ry, rw, rh);
57
    /* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es 
58
       let's scale the data */
59
    XFillRectangleScaled(dpy, desktopWin, gc, rx, ry, rw, rh);
58
60
59
    if (!ReadFromRFBServer(buffer, hdr.nSubrects * (4 + (BPP / 8))))
61
    if (!ReadFromRFBServer(buffer, hdr.nSubrects * (4 + (BPP / 8))))
60
	return False;
62
	return False;
Lines 76-82 Link Here
76
#endif
78
#endif
77
79
78
	XChangeGC(dpy, gc, GCForeground, &gcv);
80
	XChangeGC(dpy, gc, GCForeground, &gcv);
79
	XFillRectangle(dpy, desktopWin, gc, rx + x, ry + y, w, h);
81
	/* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es 
82
	   let's scale the data */
83
	XFillRectangleScaled(dpy, desktopWin, gc, rx + x, ry + y, w, h);
80
    }
84
    }
81
85
82
    return True;
86
    return True;
(-)vnc_unixsrc/vncviewer/cursor.c (-2 / +6 lines)
Lines 459-468 Link Here
459
    if (appData.useShm)
459
    if (appData.useShm)
460
      XSync(dpy, False);
460
      XSync(dpy, False);
461
#endif
461
#endif
462
    XCopyArea(dpy, desktopWin, rcSavedArea, gc, x, y, w, h, 0, 0);
462
    /* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es 
463
       let's scale the data */
464
    XCopyAreaScaled(dpy, desktopWin, rcSavedArea, gc, x, y, w, h, 0, 0);
463
  } else {
465
  } else {
464
    /* Restore screen area. */
466
    /* Restore screen area. */
465
    XCopyArea(dpy, rcSavedArea, desktopWin, gc, 0, 0, w, h, x, y);
467
    /* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es 
468
       let's scale the data */
469
    XCopyAreaScaled(dpy, rcSavedArea, desktopWin, gc, 0, 0, w, h, x, y);
466
  }
470
  }
467
}
471
}
468
472
(-)vnc_unixsrc/vncviewer/desktop.c (-40 / +132 lines)
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
(-)vnc_unixsrc/vncviewer/hextile.c (-3 / +9 lines)
Lines 73-79 Link Here
73
	gcv.foreground = bg;
73
	gcv.foreground = bg;
74
74
75
      XChangeGC(dpy, gc, GCForeground, &gcv);
75
      XChangeGC(dpy, gc, GCForeground, &gcv);
76
      XFillRectangle(dpy, desktopWin, gc, x, y, w, h);
76
      /* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es 
77
	 let's scale the data */
78
      XFillRectangleScaled(dpy, desktopWin, gc, x, y, w, h);
77
79
78
      if (subencoding & rfbHextileForegroundSpecified)
80
      if (subencoding & rfbHextileForegroundSpecified)
79
	if (!ReadFromRFBServer((char *)&fg, sizeof(fg)))
81
	if (!ReadFromRFBServer((char *)&fg, sizeof(fg)))
Lines 108-114 Link Here
108
	    gcv.foreground = fg;
110
	    gcv.foreground = fg;
109
111
110
	  XChangeGC(dpy, gc, GCForeground, &gcv);
112
	  XChangeGC(dpy, gc, GCForeground, &gcv);
111
	  XFillRectangle(dpy, desktopWin, gc, x+sx, y+sy, sw, sh);
113
	  /* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es 
114
	     let's scale the data */
115
	  XFillRectangleScaled(dpy, desktopWin, gc, x+sx, y+sy, sw, sh);
112
	}
116
	}
113
117
114
      } else {
118
      } else {
Lines 131-137 Link Here
131
	  sw = rfbHextileExtractW(*ptr);
135
	  sw = rfbHextileExtractW(*ptr);
132
	  sh = rfbHextileExtractH(*ptr);
136
	  sh = rfbHextileExtractH(*ptr);
133
	  ptr++;
137
	  ptr++;
134
	  XFillRectangle(dpy, desktopWin, gc, x+sx, y+sy, sw, sh);
138
	  /* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es 
139
	     let's scale the data */
140
	  XFillRectangleScaled(dpy, desktopWin, gc, x+sx, y+sy, sw, sh);
135
	}
141
	}
136
      }
142
      }
137
    }
143
    }
(-)vnc_unixsrc/vncviewer/misc.c (-4 / +8 lines)
Lines 57-64 Link Here
57
  sprintf(title, titleFormat, desktopName);
57
  sprintf(title, titleFormat, desktopName);
58
  XtVaSetValues(toplevel, XtNtitle, title, XtNiconName, title, NULL);
58
  XtVaSetValues(toplevel, XtNtitle, title, XtNiconName, title, NULL);
59
59
60
  XtVaSetValues(toplevel, XtNmaxWidth, si.framebufferWidth,
60
  /* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es 
61
		XtNmaxHeight, si.framebufferHeight, NULL);
61
     size of the scaled desktop */
62
  XtVaSetValues(toplevel, XtNmaxWidth, appData.windowWidth,
63
		XtNmaxHeight, appData.windowHeight, NULL);
62
64
63
  dpyWidth = WidthOfScreen(DefaultScreenOfDisplay(dpy));
65
  dpyWidth = WidthOfScreen(DefaultScreenOfDisplay(dpy));
64
  dpyHeight = HeightOfScreen(DefaultScreenOfDisplay(dpy));
66
  dpyHeight = HeightOfScreen(DefaultScreenOfDisplay(dpy));
Lines 80-87 Link Here
80
82
81
    if (geometry == NULL) {
83
    if (geometry == NULL) {
82
      Dimension toplevelX, toplevelY;
84
      Dimension toplevelX, toplevelY;
83
      Dimension toplevelWidth = si.framebufferWidth;
85
      /* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es 
84
      Dimension toplevelHeight = si.framebufferHeight;
86
	 size of the scaled desktop */
87
      Dimension toplevelWidth = appData.windowWidth;
88
      Dimension toplevelHeight = appData.windowHeight;
85
89
86
      if ((toplevelWidth + appData.wmDecorationWidth) >= dpyWidth)
90
      if ((toplevelWidth + appData.wmDecorationWidth) >= dpyWidth)
87
	toplevelWidth = dpyWidth - appData.wmDecorationWidth;
91
	toplevelWidth = dpyWidth - appData.wmDecorationWidth;
(-)vnc_unixsrc/vncviewer/rfbproto.c (-9 / +25 lines)
Lines 918-923 Link Here
918
  return WriteExact(rfbsock, (char *)&pe, sz_rfbPointerEventMsg);
918
  return WriteExact(rfbsock, (char *)&pe, sz_rfbPointerEventMsg);
919
}
919
}
920
920
921
/* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es 
922
   let's scale the data */
923
Bool SendPointerEventScaled(int x, int y, int buttonMask) {
924
  int nx = x, ny = y;
925
  if ( appData.scaled) {
926
    nx = ( int)( 0.5 + ( double)( x * appData.scaleDen) / ( double)appData.scaleNum);
927
    ny = ( int)( 0.5 + ( double)( y * appData.scaleDen) / ( double)appData.scaleNum);
928
  }
929
  SendPointerEvent( nx, ny, buttonMask);
930
}
931
/* Miguel end */
921
932
922
/*
933
/*
923
 * SendKeyEvent.
934
 * SendKeyEvent.
Lines 1092-1115 Link Here
1092
	/* If RichCursor encoding is used, we should extend our
1103
	/* If RichCursor encoding is used, we should extend our
1093
	   "cursor lock area" (previously set to destination
1104
	   "cursor lock area" (previously set to destination
1094
	   rectangle) to the source rectangle as well. */
1105
	   rectangle) to the source rectangle as well. */
1095
	SoftCursorLockArea(cr.srcX, cr.srcY, rect.r.w, rect.r.h);
1106
	SoftCursorLockArea(cr.srcX, cr.srcY, rect.r.w, rect.r.h);	
1096
1107
1097
	if (appData.copyRectDelay != 0) {
1108
	if (appData.copyRectDelay != 0) {
1098
	  XFillRectangle(dpy, desktopWin, srcGC, cr.srcX, cr.srcY,
1109
	  /* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es 
1110
	     let's scale the data */
1111
	  XFillRectangleScaled(dpy, desktopWin, srcGC, cr.srcX, cr.srcY,
1099
			 rect.r.w, rect.r.h);
1112
			 rect.r.w, rect.r.h);
1100
	  XFillRectangle(dpy, desktopWin, dstGC, rect.r.x, rect.r.y,
1113
	  XFillRectangleScaled(dpy, desktopWin, dstGC, rect.r.x, rect.r.y,
1101
			 rect.r.w, rect.r.h);
1114
			 rect.r.w, rect.r.h);
1102
	  XSync(dpy,False);
1115
	  XSync(dpy,False);
1103
	  usleep(appData.copyRectDelay * 1000);
1116
	  usleep(appData.copyRectDelay * 1000);
1104
	  XFillRectangle(dpy, desktopWin, dstGC, rect.r.x, rect.r.y,
1117
	  /* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es 
1118
	     let's scale the data */
1119
	  XFillRectangleScaled(dpy, desktopWin, dstGC, rect.r.x, rect.r.y,
1105
			 rect.r.w, rect.r.h);
1120
			 rect.r.w, rect.r.h);
1106
	  XFillRectangle(dpy, desktopWin, srcGC, cr.srcX, cr.srcY,
1121
	  XFillRectangleScaled(dpy, desktopWin, srcGC, cr.srcX, cr.srcY,
1107
			 rect.r.w, rect.r.h);
1122
			 rect.r.w, rect.r.h);
1108
	}
1123
	}
1109
1124
	
1110
	XCopyArea(dpy, desktopWin, desktopWin, gc, cr.srcX, cr.srcY,
1125
	/* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es 
1111
		  rect.r.w, rect.r.h, rect.r.x, rect.r.y);
1126
	   let's scale the data */
1112
1127
	XCopyAreaScaled(dpy, desktopWin, desktopWin, gc, cr.srcX, cr.srcY,
1128
			rect.r.w, rect.r.h, rect.r.x, rect.r.y);	
1113
	break;
1129
	break;
1114
      }
1130
      }
1115
1131
(-)vnc_unixsrc/vncviewer/rre.c (-3 / +8 lines)
Lines 53-59 Link Here
53
#endif
53
#endif
54
54
55
  XChangeGC(dpy, gc, GCForeground, &gcv);
55
  XChangeGC(dpy, gc, GCForeground, &gcv);
56
  XFillRectangle(dpy, desktopWin, gc, rx, ry, rw, rh);
56
57
/* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es 
58
   let's scale the data */
59
  XFillRectangleScaled(dpy, desktopWin, gc, rx, ry, rw, rh);
57
60
58
  for (i = 0; i < hdr.nSubrects; i++) {
61
  for (i = 0; i < hdr.nSubrects; i++) {
59
    if (!ReadFromRFBServer((char *)&pix, sizeof(pix)))
62
    if (!ReadFromRFBServer((char *)&pix, sizeof(pix)))
Lines 74-81 Link Here
74
#endif
77
#endif
75
78
76
    XChangeGC(dpy, gc, GCForeground, &gcv);
79
    XChangeGC(dpy, gc, GCForeground, &gcv);
77
    XFillRectangle(dpy, desktopWin, gc, rx + subrect.x, ry + subrect.y,
80
    /* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es 
78
		   subrect.w, subrect.h);
81
       let's scale the data */
82
    XFillRectangleScaled(dpy, desktopWin, gc, rx + subrect.x, ry + subrect.y,
83
			 subrect.w, subrect.h);
79
  }
84
  }
80
85
81
  return True;
86
  return True;
(-)vnc_unixsrc/vncviewer/shm.c (-1 / +3 lines)
Lines 57-64 Link Here
57
  if (!XShmQueryExtension(dpy))
57
  if (!XShmQueryExtension(dpy))
58
    return NULL;
58
    return NULL;
59
59
60
  /* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es 
61
     size of the scaled desktop */
60
  image = XShmCreateImage(dpy, vis, visdepth, ZPixmap, NULL, &shminfo,
62
  image = XShmCreateImage(dpy, vis, visdepth, ZPixmap, NULL, &shminfo,
61
			  si.framebufferWidth, si.framebufferHeight);
63
			  appData.windowWidth, appData.windowHeight);
62
  if (!image) return NULL;
64
  if (!image) return NULL;
63
65
64
  shminfo.shmid = shmget(IPC_PRIVATE,
66
  shminfo.shmid = shmget(IPC_PRIVATE,
(-)vnc_unixsrc/vncviewer/tight.c (-1 / +4 lines)
Lines 136-142 Link Here
136
#endif
136
#endif
137
137
138
    XChangeGC(dpy, gc, GCForeground, &gcv);
138
    XChangeGC(dpy, gc, GCForeground, &gcv);
139
    XFillRectangle(dpy, desktopWin, gc, rx, ry, rw, rh);
139
140
    /* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es 
141
       let's scale the data */
142
    XFillRectangleScaled(dpy, desktopWin, gc, rx, ry, rw, rh);
140
    return True;
143
    return True;
141
  }
144
  }
142
145
(-)vnc_unixsrc/vncviewer/vncviewer.c (+10 lines)
Lines 98-103 Link Here
98
  /* Create the "desktop" widget, and perform initialisation which needs doing
98
  /* Create the "desktop" widget, and perform initialisation which needs doing
99
     before the widgets are realized */
99
     before the widgets are realized */
100
100
101
  /* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es 
102
     compute the window size if scaled */
103
  appData.windowWidth = si.framebufferWidth;
104
  appData.windowHeight = si.framebufferHeight;
105
  if ( appData.scaled && ( myFormat.bitsPerPixel >= 8)) {
106
    appData.windowWidth = appData.windowWidth * appData.scaleNum / appData.scaleDen;
107
    appData.windowHeight = appData.windowHeight * appData.scaleNum / appData.scaleDen;
108
  }
109
  /* Miguel end */
110
101
  ToplevelInitBeforeRealization();
111
  ToplevelInitBeforeRealization();
102
112
103
  DesktopInitBeforeRealization();
113
  DesktopInitBeforeRealization();
(-)vnc_unixsrc/vncviewer/vncviewer.h (+76 lines)
Lines 110-115 Link Here
110
  Bool useX11Cursor;
110
  Bool useX11Cursor;
111
  Bool autoPass;
111
  Bool autoPass;
112
112
113
  /* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es 
114
     data needed to scale up/down the view */
115
  Bool scaled;
116
  int scaleNum;
117
  int scaleDen;
118
  int windowWidth;
119
  int windowHeight;
120
  /* Miguel end */
121
113
} AppData;
122
} AppData;
114
123
115
extern AppData appData;
124
extern AppData appData;
Lines 231-236 Link Here
231
240
232
extern void PrintPixelFormat(rfbPixelFormat *format);
241
extern void PrintPixelFormat(rfbPixelFormat *format);
233
242
243
/* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es 
244
   let's scale the data */
245
extern Bool SendPointerEventScaled(int x, int y, int buttonMask);
246
234
/* selection.c */
247
/* selection.c */
235
248
236
extern void InitialiseSelection();
249
extern void InitialiseSelection();
Lines 271-273 Link Here
271
extern XtAppContext appContext;
284
extern XtAppContext appContext;
272
extern Display* dpy;
285
extern Display* dpy;
273
extern Widget toplevel;
286
extern Widget toplevel;
287
288
/* Miguel Pasenau: 16 May 2003 miguel@cimne.upc.es 
289
   functions to scale dimensions */
290
291
static void ScaleDimensions( int *x, int *y, int *width, int *height) {
292
  if ( appData.scaled) {
293
    int dst_x = ( int)( 0.5 + ( double)( *x * appData.scaleNum) / ( double)appData.scaleDen);
294
    int dst_y = ( int)( 0.5 + ( double)( *y * appData.scaleNum) / ( double)appData.scaleDen);
295
    int dst_width = ( int)( 0.5 + ( double)( ( *x + *width) * appData.scaleNum) / ( double)appData.scaleDen) - dst_x;
296
    int dst_height = ( int)( 0.5 + ( double)( ( *y + *height) * appData.scaleNum)  / ( double)appData.scaleDen) - dst_y;
297
298
    if ( width && ( dst_width < 1)) dst_width = 1;
299
    if ( height && ( dst_height < 1)) dst_height = 1;
300
    if ( dst_x >= appData.windowWidth) dst_x = appData.windowWidth - 1;
301
    if ( dst_y >= appData.windowHeight) dst_y = appData.windowHeight - 1;
302
    if ( dst_width + dst_x >= appData.windowWidth) dst_width = appData.windowWidth - dst_x - 1;
303
    if ( dst_height + dst_y >= appData.windowHeight) dst_height = appData.windowHeight - dst_y - 1;
304
305
    *x = dst_x;
306
    *y = dst_y;
307
    *width = dst_width;
308
    *height = dst_height;
309
  }
310
}
311
312
static void GetOriginalDimensions(  int *x, int *y, int *width, int *height) {
313
  if ( appData.scaled) {
314
    int org_x = ( int)( 0.5 + ( double)( *x * appData.scaleDen) / ( double)appData.scaleNum);
315
    int org_y = ( int)( 0.5 + ( double)( *y * appData.scaleDen) / ( double)appData.scaleNum);
316
    int org_width = ( int)( 0.5 + ( double)( ( *x + *width) * appData.scaleDen) / ( double)appData.scaleNum) - org_x;
317
    int org_height = ( int)( 0.5 + ( double)( ( *y + *height) * appData.scaleDen)  / ( double)appData.scaleNum) - org_y;
318
319
    if ( width && ( org_width < 1)) org_width = 1;
320
    if ( height && ( org_height < 1)) org_height = 1;
321
    if ( org_x >= si.framebufferWidth) org_x = si.framebufferWidth - 1;
322
    if ( org_y >= si.framebufferHeight) org_y = si.framebufferHeight - 1;
323
    if ( org_width + org_x >= si.framebufferWidth) org_width = si.framebufferWidth - org_x - 1;
324
    if ( org_height + org_y >= si.framebufferHeight) org_height = si.framebufferHeight - org_y - 1;
325
326
    *x = org_x;
327
    *y = org_y;
328
    *width = org_width;
329
    *height = org_height;
330
  }
331
}
332
333
static int XFillRectangleScaled( Display *display, Drawable d, GC gc, 
334
				 int x, int y, unsigned int width, unsigned int height) {
335
  int nx = x, ny = y, nw = width, nh = height;
336
  ScaleDimensions( &nx, &ny, &nw, &nh);
337
  return XFillRectangle( display, d, gc, nx, ny, nw, nh);
338
}
339
340
static int XCopyAreaScaled( Display *display, Drawable src, Drawable dest, GC gc,
341
			    int src_x, int src_y, unsigned int width, unsigned int height,
342
			    int dest_x, int dest_y) {
343
  int sx = src_x, sy = src_y, dx = dest_x, dy = dest_y;
344
  int sw = width, sh = height, dw = width, dh = height;
345
  ScaleDimensions( &sx, &sy, &sw, &sh);
346
  ScaleDimensions( &dx, &dy, &dw, &dh);
347
  return XCopyArea( display, src, dest, gc, sx, sy, sw, sh, dx, dy);
348
}
349
/* Miguel end */
(-)vnc_unixsrc/vncviewer/vncviewer.man (+4 lines)
Lines 168-173 Link Here
168
\fB\-autopass\fR
168
\fB\-autopass\fR
169
Read a plain-text password from stdin. This option affects only the
169
Read a plain-text password from stdin. This option affects only the
170
standard VNC authentication.
170
standard VNC authentication.
171
.TP
172
\fB\-scale_num \fInumerator\fR\fB, \-scale_den \fIdenominator\fR
173
The client's windows is scaled \fInumerator / denominator\fR with
174
respect to the server's desktop size.
171
.SH ENCODINGS
175
.SH ENCODINGS
172
The server supplies information in whatever format is desired by the
176
The server supplies information in whatever format is desired by the
173
client, in order to make the client as easy as possible to implement. 
177
client, in order to make the client as easy as possible to implement. 

Return to bug 136996