summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorgeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>2007-03-10 08:55:35 +0000
committergeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>2007-03-10 08:55:35 +0000
commit2446ed081f1631e7feaca9e89c7fb4024bf62eb2 (patch)
tree79ee9db2278b185dfb50be0f3ab6461ac15966e1 /win
parentf0775131d6ede2806899f6f53b33dcec15be247f (diff)
downloadtigervnc-2446ed081f1631e7feaca9e89c7fb4024bf62eb2.tar.gz
tigervnc-2446ed081f1631e7feaca9e89c7fb4024bf62eb2.zip
Fixed the bug with crashing vncviewer when it works in the
scaling mode and scale < 10%. Scale part of vncviewer code improvements. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2232 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'win')
-rw-r--r--win/rfb_win32/ScaledDIBSectionBuffer.cxx16
-rw-r--r--win/rfb_win32/ScaledDIBSectionBuffer.h5
-rw-r--r--win/vncviewer/DesktopWindow.cxx14
-rw-r--r--win/vncviewer/DesktopWindow.h3
4 files changed, 19 insertions, 19 deletions
diff --git a/win/rfb_win32/ScaledDIBSectionBuffer.cxx b/win/rfb_win32/ScaledDIBSectionBuffer.cxx
index 1a287c06..5ac83614 100644
--- a/win/rfb_win32/ScaledDIBSectionBuffer.cxx
+++ b/win/rfb_win32/ScaledDIBSectionBuffer.cxx
@@ -39,19 +39,19 @@ ScaledDIBSectionBuffer::~ScaledDIBSectionBuffer() {
if (src_buffer) delete src_buffer;
}
-void ScaledDIBSectionBuffer::setScaleRatio(double scale_ratio_) {
- if (scale_ratio == scale_ratio_ || scale_ratio <= 0) return;
+void ScaledDIBSectionBuffer::setScale(int scale_) {
+ if (scale == scale_ || scale_ <= 0) return;
- scale_ratio = scale_ratio_;
- if (scale_ratio == 1) scaling = false;
+ scale = scale_;
+ if (scale == 100) scaling = false;
else scaling = true;
// FIXME:
// Calculate the scale weight tabs must be in the ScalePixelBuffer class
freeWeightTabs();
calculateScaledBufferSize();
- scaleFilters.makeWeightTabs(scaleFilterID, src_width, scaled_width, scale_ratio, &xWeightTabs);
- scaleFilters.makeWeightTabs(scaleFilterID, src_height, scaled_height, scale_ratio, &yWeightTabs);
+ scaleFilters.makeWeightTabs(scaleFilterID, src_width, scaled_width, &xWeightTabs);
+ scaleFilters.makeWeightTabs(scaleFilterID, src_height, scaled_height, &yWeightTabs);
recreateBuffers();
}
@@ -86,8 +86,8 @@ void ScaledDIBSectionBuffer::setSize(int src_width_, int src_height_) {
// Calculate the scale weight tabs must be in the ScalePixelBuffer class
freeWeightTabs();
calculateScaledBufferSize();
- scaleFilters.makeWeightTabs(scaleFilterID, src_width, scaled_width, scale_ratio, &xWeightTabs);
- scaleFilters.makeWeightTabs(scaleFilterID, src_height, scaled_height, scale_ratio, &yWeightTabs);
+ scaleFilters.makeWeightTabs(scaleFilterID, src_width, scaled_width, &xWeightTabs);
+ scaleFilters.makeWeightTabs(scaleFilterID, src_height, scaled_height, &yWeightTabs);
recreateBuffers();
}
diff --git a/win/rfb_win32/ScaledDIBSectionBuffer.h b/win/rfb_win32/ScaledDIBSectionBuffer.h
index eb1d093f..509411c0 100644
--- a/win/rfb_win32/ScaledDIBSectionBuffer.h
+++ b/win/rfb_win32/ScaledDIBSectionBuffer.h
@@ -50,9 +50,8 @@ namespace rfb {
virtual const PixelFormat& getPixelFormat() const { return pf; }
virtual const PixelFormat& getScaledPixelFormat() const { return getPF(); }
virtual void setSize(int w, int h);
- virtual void setScale(int scale) { setScaleRatio(double(scale)/100.0); };
- virtual void setScaleRatio(double scale_ratio);
-
+ virtual void setScale(int scale);
+
virtual void calculateScaledBufferSize();
Rect getRect() const { return ScaledPixelBuffer::getRect(); }
diff --git a/win/vncviewer/DesktopWindow.cxx b/win/vncviewer/DesktopWindow.cxx
index 5aba7802..4a316ad5 100644
--- a/win/vncviewer/DesktopWindow.cxx
+++ b/win/vncviewer/DesktopWindow.cxx
@@ -858,8 +858,8 @@ DesktopWindow::processMouseMessage(UINT msg, WPARAM wParam, LPARAM lParam)
// Send a pointer event to the server
oldpos = p;
if (buffer->isScaling()) {
- p.x /= buffer->getScaleRatio();
- p.y /= buffer->getScaleRatio();
+ p.x /= buffer->getScaleRatioX();
+ p.y /= buffer->getScaleRatioY();
}
ptr.pointerEvent(callback, p, mask);
#ifdef WM_MOUSEWHEEL
@@ -1005,13 +1005,15 @@ DesktopWindow::setSize(int w, int h) {
void DesktopWindow::setAutoScaling(bool as) {
autoScaling = as;
+ if (isToolbarEnabled()) refreshToolbarButtons();
if (as) fitBufferToWindow();
}
-void DesktopWindow::setDesktopScaleRatio(double scale_ratio) {
- buffer->setScaleRatio(scale_ratio);
- if (!isAutoScaling()) resizeDesktopWindowToBuffer();
+void DesktopWindow::setDesktopScale(int scale_) {
+ if (buffer->getScale() == scale_ || scale_ <= 0) return;
+ buffer->setScale(scale_);
if (isToolbarEnabled()) refreshToolbarButtons();
+ if (!isAutoScaling()) resizeDesktopWindowToBuffer();
char *newTitle = new char[strlen(desktopName)+20];
sprintf(newTitle, "%s @ %i%%", desktopName, getDesktopScale());
SetWindowText(handle, TStr(newTitle));
@@ -1037,7 +1039,7 @@ void DesktopWindow::fitBufferToWindow(bool repaint) {
} else {
scale_ratio = double(client_size.width()) / buffer->getSrcWidth();
}
- setDesktopScaleRatio(scale_ratio);
+ setDesktopScale(int(scale_ratio * 100));
}
void
diff --git a/win/vncviewer/DesktopWindow.h b/win/vncviewer/DesktopWindow.h
index bce7cf72..7a8fa2c3 100644
--- a/win/vncviewer/DesktopWindow.h
+++ b/win/vncviewer/DesktopWindow.h
@@ -88,8 +88,7 @@ namespace rfb {
void setColour(int i, int r, int g, int b) {buffer->setColour(i, r, g, b);}
void setAutoScaling(bool as);
bool isAutoScaling() const { return autoScaling; }
- void setDesktopScaleRatio(double scale_ratio);
- void setDesktopScale(int scale) { setDesktopScaleRatio(double(scale)/100); }
+ void setDesktopScale(int scale);
int getDesktopScale() const { return buffer->getScale(); }
void fitBufferToWindow(bool repaint = true);