summaryrefslogtreecommitdiff
path: root/src/gui/widgets/window.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-04-12 20:17:36 +0300
committerAndrei Karas <akaras@inbox.ru>2011-04-12 20:17:36 +0300
commitda1b2d8311ca78eccd3e9875598562ce6bf05cab (patch)
treedec1e1e46e242c0cd3e1b764db31fa591629c385 /src/gui/widgets/window.cpp
parentd085ae2b90d332f145cd2bf5a0d3e39435ddba02 (diff)
downloadmanaverse-da1b2d8311ca78eccd3e9875598562ce6bf05cab.tar.gz
manaverse-da1b2d8311ca78eccd3e9875598562ce6bf05cab.tar.bz2
manaverse-da1b2d8311ca78eccd3e9875598562ce6bf05cab.tar.xz
manaverse-da1b2d8311ca78eccd3e9875598562ce6bf05cab.zip
Fix windows size if part of window showed out of screen.
Diffstat (limited to 'src/gui/widgets/window.cpp')
-rw-r--r--src/gui/widgets/window.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 14f39a4c3..72530db8f 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -665,6 +665,22 @@ void Window::loadWindowState()
// Check if the window is off screen...
checkIfIsOffScreen();
+
+ if (viewport)
+ {
+ int width = getWidth();
+ int height = getHeight();
+
+ if (getX() + width >= viewport->getWidth())
+ width = viewport->getWidth() - getX() - 1;
+ if (getY() + height >= viewport->getHeight())
+ height = viewport->getHeight() - getY() - 1;
+ if (width < 0)
+ width = 0;
+ if (height < 0)
+ height = 0;
+ setSize(width, height);
+ }
}
void Window::saveWindowState()