From 957ddddb6e0829ec23a78a841a11595a3c88b301 Mon Sep 17 00:00:00 2001 From: GiWoong Kim Date: Wed, 22 Oct 2014 17:19:01 +0900 Subject: [PATCH] ui: revised MRU position Emulator windows's first appearance should be shown at inside of host monitor bounds. Change-Id: I9ae38f4edead5de579a56308d72a885704915933 Signed-off-by: GiWoong Kim --- tizen/src/display/qt5_supplement.cpp | 24 ++++++++++++--- tizen/src/ui/Makefile.objs | 1 + tizen/src/ui/uiutil.cpp | 41 +++++++++++++++++++++++++ tizen/src/ui/uiutil.h | 46 ++++++++++++++++++++++++++++ 4 files changed, 107 insertions(+), 5 deletions(-) create mode 100644 tizen/src/ui/uiutil.cpp create mode 100644 tizen/src/ui/uiutil.h diff --git a/tizen/src/display/qt5_supplement.cpp b/tizen/src/display/qt5_supplement.cpp index d75ab83f81..b5bb7188ca 100644 --- a/tizen/src/display/qt5_supplement.cpp +++ b/tizen/src/display/qt5_supplement.cpp @@ -39,6 +39,7 @@ #include "hardwarekey.h" #include "floatingcontroller.h" #include "ui/xml/emulatoruitype.h" +#include "uiutil.h" extern "C" { #include "emul_state.h" @@ -174,14 +175,27 @@ void qt5_gui_init(void) mainwindow = new MainWindow(uiInfo); /* position */ - int xx = mruInfo.value(SKIN_PROPERTY_WINDOW_X).toInt(); - int yy = mruInfo.value(SKIN_PROPERTY_WINDOW_Y).toInt(); - qDebug("previous position value is (%d, %d)", xx, yy); + QRect hostBounds = UIUtil::getHostScreenBounds(); + qDebug() << "host geometry : " << hostBounds; - if (xx == 0 && yy == 0) { - xx = yy = 80 + (uiInfo->basePort % 100); + int defaultValueX = hostBounds.x() - 1; + int defaultValueY = hostBounds.y() - 1; + int xx = mruInfo.value(SKIN_PROPERTY_WINDOW_X, defaultValueX).toInt(); + int yy = mruInfo.value(SKIN_PROPERTY_WINDOW_Y, defaultValueY).toInt(); + + if (xx == defaultValueX || yy == defaultValueY) { + xx = yy = 80 + (uiInfo->basePort % 100); /* default position */ + } else { + qDebug("previous position value : (%d, %d)", xx, yy); + + xx = qMax(xx, hostBounds.x()); + xx = qMin(xx, hostBounds.x() + hostBounds.width() - 100); + yy = qMax(yy, hostBounds.y()); + yy = qMin(yy, hostBounds.y() + hostBounds.height() - 100); } + mainwindow->move(xx, yy); + qDebug("current position value : (%d, %d)", xx, yy); bool onTop = mruInfo.value(SKIN_PROPERTY_WINDOW_TOPMOST).toBool(); if (onTop == true) { diff --git a/tizen/src/ui/Makefile.objs b/tizen/src/ui/Makefile.objs index fbde158636..417087ecd8 100644 --- a/tizen/src/ui/Makefile.objs +++ b/tizen/src/ui/Makefile.objs @@ -22,6 +22,7 @@ obj-$(CONFIG_QT) += keyboardhelper.o obj-$(CONFIG_QT) += skinview.o obj-$(CONFIG_QT) += uiinformation.o obj-$(CONFIG_QT) += uistate.o +obj-$(CONFIG_QT) += uiutil.o obj-$(CONFIG_QT) += qrc_resource.o obj-$(CONFIG_QT) += xml/ diff --git a/tizen/src/ui/uiutil.cpp b/tizen/src/ui/uiutil.cpp new file mode 100644 index 0000000000..ab2959a149 --- /dev/null +++ b/tizen/src/ui/uiutil.cpp @@ -0,0 +1,41 @@ +/* + * Qt UI + * + * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "uiutil.h" + +UIUtil::UIUtil() +{ + /* do nothing */ +} + +QRect UIUtil::getHostScreenBounds() +{ + return QApplication::screens().at( + QApplication::desktop()->primaryScreen())->virtualGeometry(); +} diff --git a/tizen/src/ui/uiutil.h b/tizen/src/ui/uiutil.h new file mode 100644 index 0000000000..b7e20d01c1 --- /dev/null +++ b/tizen/src/ui/uiutil.h @@ -0,0 +1,46 @@ +/* + * Qt UI + * + * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#ifndef UIUTIL_H +#define UIUTIL_H + +#include +#include +#include +#include + +class UIUtil +{ +public: + UIUtil(); + + static QRect getHostScreenBounds(); +}; + +#endif // UIUTIL_H -- 2.34.1