From: GiWoong Kim Date: Mon, 11 Jan 2016 06:42:34 +0000 (+0900) Subject: gui: prevent moving to position out of monitor range X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.2~95 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6c519cc05f8686b7c7a6b9bdefb7acf660ca31b5;p=sdk%2Femulator%2Fqemu.git gui: prevent moving to position out of monitor range Change-Id: I755b7d8700e99fd3f4f1889159113e32a8ceb1dc Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/ui/mainwindow.cpp b/tizen/src/ui/mainwindow.cpp index aa2120eb0b..aea516a613 100644 --- a/tizen/src/ui/mainwindow.cpp +++ b/tizen/src/ui/mainwindow.cpp @@ -36,6 +36,7 @@ #include "displayglwidget.h" #include "displayswwidget.h" #include "resource/ui_strings.h" +#include "uiutil.h" extern "C" { #include "util/ui_operations.h" @@ -363,6 +364,11 @@ void MainWindow::closeController() /* override */ void MainWindow::resize(const QSize &size) { + if (size.width() <= 0 || size.height() <= 0) { + qWarning() << "Invalid scale size. Cannot be less than zero." << size; + return; + } + setFixedSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); QWidget::resize(size); } @@ -387,6 +393,17 @@ void MainWindow::resizeEvent(QResizeEvent *event) QWidget::resizeEvent(event); setFixedSize(size()); + + /* correctional position */ + int xx = pos().x(); + int yy = pos().y(); + QRect hostBounds = UiUtil::getHostScreenBounds(); + xx = qMax(xx, hostBounds.x()); + yy = qMax(yy, hostBounds.y()); + // shift a little bit from screen edge to inside of bounds + xx = qMin(xx, hostBounds.x() + hostBounds.width() - 100); + yy = qMin(yy, hostBounds.y() + hostBounds.height() - 100); + move(xx, yy); } /* override */