summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2007-08-23 11:08:59 +0000
committertruelight <truelight@openttd.org>2007-08-23 11:08:59 +0000
commitda8d778622be5c98b1d2fa8f938d47824d13c153 (patch)
tree2606ba7144c5cdc58df88bd436f647a0327a90ac /src
parent043e502d14551fbd934fd3461cd4eac30f6f67f8 (diff)
downloadopenttd-da8d778622be5c98b1d2fa8f938d47824d13c153.tar.xz
(svn r10967) -Fix: in case of moving the window on create (because it doesn't fit in the screen), make sure to move the viewport too if we are an extra viewport (spotted by Maedhros)
Diffstat (limited to 'src')
-rw-r--r--src/window.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/window.cpp b/src/window.cpp
index 9be96bf53..ba105839a 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -693,11 +693,21 @@ static Window *LocalAllocateWindow(
w->wndproc(w, &e);
}
- if (w->left + w->width > _screen.width) w->left -= (w->left + w->width - _screen.width);
+ int nx = w->left;
+ int ny = w->top;
+
+ if (nx + w->width > _screen.width) nx -= (nx + w->width - _screen.width);
const Window *wt = FindWindowById(WC_MAIN_TOOLBAR, 0);
- w->top = max(w->top, (wt == NULL || w == wt || y == 0) ? 0 : wt->height);
- w->left = max(w->left, 0);
+ ny = max(ny, (wt == NULL || w == wt || y == 0) ? 0 : wt->height);
+ nx = max(nx, 0);
+
+ if (w->viewport != NULL) {
+ w->viewport->left += nx - w->left;
+ w->viewport->top += ny - w->top;
+ }
+ w->left = nx;
+ w->top = ny;
SetWindowDirty(w);