From f02ce95a6e99aadce48bdc608121496520639e2d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 4 Feb 2014 13:07:05 +0300 Subject: adjust windows size if main window was resized to smaller size. --- src/gui/widgets/window.cpp | 22 ++++++++++++++++++++++ src/gui/widgets/window.h | 2 ++ 2 files changed, 24 insertions(+) (limited to 'src') diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index cd00d2568..36372dcaa 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -1059,6 +1059,28 @@ void Window::adjustPositionAfterResize(const int oldScreenWidth, } ensureOnScreen(); + adjustSizeToScreen(); +} + +void Window::adjustSizeToScreen() +{ + if (!mGrip) + return; + + const int screenWidth = mainGraphics->mWidth; + const int screenHeight = mainGraphics->mHeight; + const int oldWidth = mDimension.width; + const int oldHeight = mDimension.height; + if (oldWidth + mDimension.x > screenWidth) + mDimension.x = 0; + if (oldHeight + mDimension.y > screenHeight) + mDimension.x = 0; + if (mDimension.width > screenWidth) + mDimension.width = screenWidth; + if (mDimension.height > screenHeight) + mDimension.height = screenHeight; + if (oldWidth != mDimension.width || oldHeight != mDimension.height) + widgetResized(gcn::Event(this)); } int Window::getResizeHandles(const gcn::MouseEvent &event) diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 757ec8c58..bb0f19bb3 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -465,6 +465,8 @@ class Window : public gcn::Window, */ void ensureOnScreen(); + void adjustSizeToScreen(); + /** * Determines if the mouse is in a resize area and returns appropriate * resize handles. Also initializes drag offset in case the resize -- cgit v1.2.3-60-g2f50