window->setMenuKey(options.menuKey);
window->setDisableWinKeys(options.disableWinKeys);
window->setShowToolbar(options.showToolbar);
- window->setDesktopScale(options.scale);
+ if (options.autoScaling) {
+ window->setAutoScaling(true);
+ } else {
+ window->setAutoScaling(false);
+ window->setDesktopScale(options.scale);
+ }
if (!options.useLocalCursor)
window->setCursor(0, 0, Point(), 0, 0);
}
// Show the window
window = new DesktopWindow(this);
- applyOptions(options);
window->setName(cp.name());
window->setSize(cp.width, cp.height);
+ applyOptions(options);
// Save the server's current format
serverDefaultPF = cp.pf();
DesktopWindow::DesktopWindow(Callback* cb)
: buffer(0),
- showToolbar(false),
+ showToolbar(false), autoScaling(false),
client_size(0, 0, 16, 16), window_size(0, 0, 32, 32),
cursorVisible(false), cursorAvailable(false), cursorInBuffer(false),
systemCursorVisible(true), trackingMouseLeave(false),
case WM_WINDOWPOSCHANGING:
{
WINDOWPOS* wpos = (WINDOWPOS*)lParam;
- if (wpos->flags & SWP_NOSIZE)
+ if ((wpos->flags & SWP_NOSIZE) || isAutoScaling())
break;
// Work out how big the window should ideally be
GetClientRect(frameHandle, &r);
client_size = Rect(r.left, r.top, r.right, r.bottom);
- // Determine whether scrollbars are required
- calculateScrollBars();
+ // Perform the AutoScaling operation
+ if (isAutoScaling()) {
+ fitBufferToWindow(false);
+ } else {
+ // Determine whether scrollbars are required
+ calculateScrollBars();
+ }
// Redraw if required
- if ((!old_offset.equals(desktopToClient(Point(0, 0)))))
+ if ((!old_offset.equals(desktopToClient(Point(0, 0)))) || isAutoScaling())
InvalidateRect(frameHandle, 0, TRUE);
}
break;
// Send a pointer event to the server
oldpos = p;
if (buffer->isScaling()) {
- p.x /= double(buffer->getScale()) / 100.0;
- p.y /= double(buffer->getScale()) / 100.0;
+ p.x /= buffer->getScaleRatio();
+ p.y /= buffer->getScaleRatio();
}
ptr.pointerEvent(callback, p, mask);
#ifdef WM_MOUSEWHEEL
// Resize the backing buffer
buffer->setSize(w, h);
+ // Calculate the pixel buffer aspect correlation. It's used
+ // for the autoScaling operation.
+ aspect_corr = (double)w / h;
+
// If the window is not maximised or full-screen then resize it
if (!(GetWindowLong(handle, GWL_STYLE) & WS_MAXIMIZE) && !fullscreenActive) {
// Resize the window to the required size
PixelFormat getPF() const { return buffer->getPF(); }
void setSize(int w, int h);
void setColour(int i, int r, int g, int b) {buffer->setColour(i, r, g, b);}
+ void setAutoScaling(bool as) {
+ autoScaling = as;
+ if (as) fitBufferToWindow();
+ }
+ bool isAutoScaling() const { return autoScaling; }
void setDesktopScale(int scale);
void fitBufferToWindow(bool repaint = true);
win32::ScaledDIBSectionBuffer* buffer;
double aspect_corr;
bool has_focus;
+ bool autoScaling;
Rect window_size;
Rect client_size;
Point scrolloffset;