diff options
author | rubidium <rubidium@openttd.org> | 2011-12-04 14:00:23 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2011-12-04 14:00:23 +0000 |
commit | 8b5d315d2a89f36dd06ec2f5c9b1c600767039ee (patch) | |
tree | d899a34dd95617e275bc68448336ab92a8c71aa4 | |
parent | 6711026011384817d6b9c9445490bf1c81f968f8 (diff) | |
download | openttd-8b5d315d2a89f36dd06ec2f5c9b1c600767039ee.tar.xz |
(svn r23429) -Fix [FS#4842]: prevent windows to be resized beyond the bounds of the (main) window
-rw-r--r-- | src/window.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/window.cpp b/src/window.cpp index 390777fae..285a18711 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1671,6 +1671,13 @@ static void EnsureVisibleCaption(Window *w, int nx, int ny) void ResizeWindow(Window *w, int delta_x, int delta_y) { if (delta_x != 0 || delta_y != 0) { + /* Determine the new right/bottom position. If that is outside of the bounds of + * the resolution clamp it in such a manner that it stays within the bounts. */ + int new_right = w->left + w->width + delta_x; + int new_bottom = w->top + w->height + delta_y; + if (new_right >= (int)_cur_resolution.width) delta_x -= new_right - _cur_resolution.width; + if (new_bottom >= (int)_cur_resolution.height) delta_y -= new_bottom - _cur_resolution.height; + w->SetDirty(); uint new_xinc = max(0, (w->nested_root->resize_x == 0) ? 0 : (int)(w->nested_root->current_x - w->nested_root->smallest_x) + delta_x); |