ui: revised MRU position 91/29391/2
authorGiWoong Kim <giwoong.kim@samsung.com>
Wed, 22 Oct 2014 08:19:01 +0000 (17:19 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Tue, 28 Oct 2014 08:29:39 +0000 (01:29 -0700)
Emulator windows's first appearance should be shown at
inside of host monitor bounds.

Change-Id: I9ae38f4edead5de579a56308d72a885704915933
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/display/qt5_supplement.cpp
tizen/src/ui/Makefile.objs
tizen/src/ui/uiutil.cpp [new file with mode: 0644]
tizen/src/ui/uiutil.h [new file with mode: 0644]

index d75ab83f816a68da7c98ae449c2880a72c6e325c..b5bb7188ca2f5675ac2991147a86552c7b1f4b13 100644 (file)
@@ -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) {
index fbde158636f88d675ede2b6a5d51d3b0da67c346..417087ecd83742c99f1404969561e7c0e4c8a504 100644 (file)
@@ -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 (file)
index 0000000..ab2959a
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * 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 (file)
index 0000000..b7e20d0
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * 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 <QApplication>
+#include <QDesktopWidget>
+#include <QScreen>
+#include <QRect>
+
+class UIUtil
+{
+public:
+    UIUtil();
+
+    static QRect getHostScreenBounds();
+};
+
+#endif // UIUTIL_H