]> source.dussan.org Git - tigervnc.git/commitdiff
Added the desktop image scaling support to vncviewer.
authorgeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Tue, 23 May 2006 15:39:47 +0000 (15:39 +0000)
committergeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Tue, 23 May 2006 15:39:47 +0000 (15:39 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@579 3789f03b-4d11-0410-bbf8-ca57d06f2519

vncviewer/DesktopWindow.cxx
vncviewer/DesktopWindow.h

index e49b7253935712161b42352885a81805de2d3604..c7b496bbd4fbefec93fd6f209c7d09d68a0cc250 100644 (file)
@@ -220,7 +220,7 @@ DesktopWindow::DesktopWindow(Callback* cb)
   clipboard.setNotifier(this);
 
   // Create the backing buffer
-  buffer = new win32::DIBSectionBuffer(frameHandle);
+  buffer = new win32::ScaledDIBSectionBuffer(frameHandle);
 
   // Show the window
   centerWindow(handle, 0);
@@ -774,8 +774,10 @@ DesktopWindow::processFrameMessage(UINT msg, WPARAM wParam, LPARAM lParam) {
           break;
 
         // Send a pointer event to the server
-        ptr.pointerEvent(callback, p, mask);
         oldpos = p;
+        p.x /= double(buffer->getScale()) / 100;
+        p.y /= double(buffer->getScale()) / 100;
+        ptr.pointerEvent(callback, p, mask);
 #ifdef WM_MOUSEWHEEL
       }
 #endif
@@ -795,8 +797,8 @@ DesktopWindow::hideLocalCursor() {
   // *** ALWAYS call this BEFORE changing buffer PF!!!
   if (cursorVisible) {
     cursorVisible = false;
-    buffer->imageRect(cursorBackingRect, cursorBacking.data);
-    invalidateDesktopRect(cursorBackingRect);
+    buffer->DIBSectionBuffer::imageRect(cursorBackingRect, cursorBacking.data);
+    invalidateDesktopRect(cursorBackingRect, false);
   }
 }
 
@@ -818,7 +820,7 @@ DesktopWindow::showLocalCursor() {
 
     renderLocalCursor();
 
-    invalidateDesktopRect(cursorBackingRect);
+    invalidateDesktopRect(cursorBackingRect, false);
   }
 }
 
@@ -834,7 +836,7 @@ DesktopWindow::renderLocalCursor()
 {
   Rect r = cursor.getRect();
   r = r.translate(cursorPos).translate(cursor.hotspot.negate());
-  buffer->maskRect(r, cursor.data, cursor.mask.buf);
+  buffer->DIBSectionBuffer::maskRect(r, cursor.data, cursor.mask.buf);
 }
 
 void
@@ -857,8 +859,11 @@ DesktopWindow::showSystemCursor() {
 
 
 bool
-DesktopWindow::invalidateDesktopRect(const Rect& crect) {
-  Rect rect = desktopToClient(crect);
+DesktopWindow::invalidateDesktopRect(const Rect& crect, bool scaling) {
+  Rect rect;
+  if (buffer->isScaling() && scaling) {
+    rect = desktopToClient(buffer->calculateScaleBoundary(crect));
+  } else rect = desktopToClient(crect);
   if (rect.intersect(client_size).is_empty()) return false;
   RECT invalid = {rect.tl.x, rect.tl.y, rect.br.x, rect.br.y};
   InvalidateRect(frameHandle, &invalid, FALSE);
@@ -1059,18 +1064,21 @@ DesktopWindow::serverCutText(const char* str, int len) {
 
 
 void DesktopWindow::fillRect(const Rect& r, Pixel pix) {
-  if (cursorBackingRect.overlaps(r)) hideLocalCursor();
+  Rect img_rect = buffer->isScaling() ? buffer->calculateScaleBoundary(r) : r;
+  if (cursorBackingRect.overlaps(img_rect)) hideLocalCursor();
   buffer->fillRect(r, pix);
   invalidateDesktopRect(r);
 }
 void DesktopWindow::imageRect(const Rect& r, void* pixels) {
-  if (cursorBackingRect.overlaps(r)) hideLocalCursor();
+  Rect img_rect = buffer->isScaling() ? buffer->calculateScaleBoundary(r) : r;
+  if (cursorBackingRect.overlaps(img_rect)) hideLocalCursor();
   buffer->imageRect(r, pixels);
   invalidateDesktopRect(r);
 }
 void DesktopWindow::copyRect(const Rect& r, int srcX, int srcY) {
-  if (cursorBackingRect.overlaps(r) ||
-      cursorBackingRect.overlaps(Rect(srcX, srcY, srcX+r.width(), srcY+r.height())))
+  Rect img_rect = buffer->isScaling() ? buffer->calculateScaleBoundary(r) : r;
+  if (cursorBackingRect.overlaps(img_rect) ||
+      cursorBackingRect.overlaps(Rect(srcX, srcY, srcX+img_rect.width(), srcY+img_rect.height())))
     hideLocalCursor();
   buffer->copyRect(r, Point(r.tl.x-srcX, r.tl.y-srcY));
   invalidateDesktopRect(r);
@@ -1078,7 +1086,8 @@ void DesktopWindow::copyRect(const Rect& r, int srcX, int srcY) {
 
 void DesktopWindow::invertRect(const Rect& r) {
   int stride;
-  rdr::U8* p = buffer->getPixelsRW(r, &stride);
+  rdr::U8* p = buffer->isScaling() ? buffer->getPixelsRW(buffer->calculateScaleBoundary(r), &stride) 
+   : buffer->getPixelsRW(r, &stride);
   for (int y = 0; y < r.height(); y++) {
     for (int x = 0; x < r.width(); x++) {
       switch (buffer->getPF().bpp) {
index d54cd5f7a4f941192b14d0bf9c3571ba2b028804..3d2211f8175e70f5347c0a4d10ae4e6f60f8180e 100644 (file)
@@ -34,7 +34,7 @@
 #include <rfb_win32/CKeyboard.h>
 #include <rfb_win32/CPointer.h>
 #include <rfb_win32/Clipboard.h>
-#include <rfb_win32/DIBSectionBuffer.h>
+#include <rfb_win32/ScaledDIBSectionBuffer.h>
 #include <rfb_win32/LogicalPalette.h>
 #include <vncviewer/ViewerToolBar.h>
 
@@ -195,7 +195,7 @@ namespace rfb {
       void cursorOutsideBuffer();
 
       // Returns true if part of the supplied rect is visible, false otherwise
-      bool invalidateDesktopRect(const Rect& crect);
+      bool invalidateDesktopRect(const Rect& crect, bool scaling=true);
 
       // Determine whether or not we need to enable/disable scrollbars and set the
       // window style accordingly
@@ -232,7 +232,7 @@ namespace rfb {
       bool showToolbar;
 
       // Local window state
-      win32::DIBSectionBuffer* buffer;
+      win32::ScaledDIBSectionBuffer* buffer;
       bool has_focus;
       Rect window_size;
       Rect client_size;