Detached QT UI from skin/display completely.
Did not built skin/display when JAVA UI is disabled.
Fixed some of badly header inclusion chains.
Change-Id: I260876aadbed75154055ec19d5f384c884854ef5
Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
#include "qapi-types.h"
#include "qapi/error.h"
-#if defined(CONFIG_MARU) && defined(CONFIG_SDL)
+#if defined(CONFIG_MARU) && defined(CONFIG_SDL) && defined(CONFIG_JAVA_UI)
#define SDL_THREAD
#endif
# ui
obj-y += ui/
-# maru display
-obj-y += display/
-
# protobuf
obj-y += distrib/protobuf/protobuf-c.o
# tethering
obj-y += eventcast/
+# maru display
+obj-$(CONFIG_JAVA_UI) += display/
+
# maru skin
-obj-y += skin/
+obj-$(CONFIG_JAVA_UI) += skin/
# maru hardware
obj-y += hw/
obj-y += maru_display.o maru_display_processing.o
-
-ifdef CONFIG_JAVA_UI
obj-$(CONFIG_USE_SHM) += maru_shm.o
obj-$(CONFIG_SDL) += maru_sdl.o maru_sdl_processing.o maru_finger.o
-endif
-
-obj-$(CONFIG_QT) += qt5.o
-obj-$(CONFIG_QT) += qt5_supplement.o
-obj-$(CONFIG_QT) += xmllayoutparser.o
$(obj)/maru_display.o $(obj)/maru_sdl.o $(obj)/maru_sdl_processing.o $(obj)/maru_finger.o: QEMU_CFLAGS += $(SDL_CFLAGS)
static Notifier maru_display_exit = { .notify = maru_display_notify_exit };
-// FIXME
-#ifdef SDL_THREAD
-QemuMutex sdl_mutex;
-#endif
void maru_display_init(DisplayState *ds, DisplayType display_type,
int full_screen)
{
#define BLANK_GUIDE_IMAGE_NAME "display_off_guide.png"
#ifdef SDL_THREAD
-extern QemuMutex sdl_mutex;
+QemuMutex sdl_mutex;
QemuCond sdl_cond;
static int sdl_thread_initialized;
+++ /dev/null
-/*
- * Qt UI
- *
- * Copyright (C) 2015 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 PROPERTYKEYWORD_H
-#define PROPERTYKEYWORD_H
-
-#define SKIN_PROPERTY_NAME "skin.name"
-#define SKIN_PROPERTY_WINDOW_X "window.x"
-#define SKIN_PROPERTY_WINDOW_Y "window.y"
-#define SKIN_PROPERTY_WINDOW_SCALE "window.scale"
-#define SKIN_PROPERTY_WINDOW_TOPMOST "window.ontop"
-#define SKIN_PROPERTY_CONTROLLER_INDEX "controller.index"
-#define SKIN_PROPERTY_CONTROLLER_DOCK "controller.dock"
-
-#endif // PROPERTYKEYWORD_H
+++ /dev/null
-/*
- * Qt UI
- *
- * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * SeokYeon Hwang <syeon.hwang@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 "ui/console.h"
-
-#include "qt5.h"
-#include "emul_state.h"
-#include "qt5_supplement.h"
-#include "hw/pci/maru_brightness.h"
-#ifdef CONFIG_DARWIN
-#include "ns_event.h"
-#endif
-
-
-#include "util/new_debug_ch.h"
-
-DECLARE_DEBUG_CHANNEL(qt5_console);
-
-static int qt5_num_outputs;
-
-// only for informing HW specification
-static int pixel_density_dpi;
-
-static struct qt5_state {
- DisplayChangeListener dcl;
- DisplaySurface *surface;
-
- int idx;
-} *qt5_console;
-
-void qt5_graphic_hw_invalidate(void)
-{
- graphic_hw_invalidate(NULL);
-}
-
-void qt5_graphic_hw_update(void)
-{
- graphic_hw_update(NULL);
-}
-
-int qt5_graphic_hw_display(void)
-{
- console_ch_t displayed = 0;
- graphic_hw_text_update(NULL, &displayed);
- return displayed;
-}
-
-static void qt5_update(DisplayChangeListener *dcl,
- int x, int y, int w, int h)
-{
- struct qt5_state *con = container_of(dcl, struct qt5_state, dcl);
-
- assert(con->surface);
-
- composite_brightness_image(con->surface->image);
-
- qt5_update_internal(surface_data(con->surface),
- surface_width(con->surface),
- surface_height(con->surface));
-}
-
-static void qt5_switch(DisplayChangeListener *dcl,
- DisplaySurface *new_surface)
-{
- struct qt5_state *con = container_of(dcl, struct qt5_state, dcl);
-
- if (con->surface &&
- (surface_width(con->surface) != surface_width(new_surface) ||
- surface_height(con->surface) != surface_height(new_surface))) {
- // TODO: we should adjust display size.
- // We should warn to user since we can not adjust display size now.
- LOG_WARNING("display size is changed.\n");
- }
-
- con->surface = new_surface;
-
-}
-
-static void qt5_refresh(DisplayChangeListener *dcl)
-{
- graphic_hw_update(dcl->con);
- qt5_refresh_internal();
-}
-
-static void qt5_mouse_warp(DisplayChangeListener *dcl,
- int x, int y, int on)
-{
-}
-
-static void qt5_mouse_define(DisplayChangeListener *dcl,
- QEMUCursor *c)
-{
-}
-
-static const DisplayChangeListenerOps dcl_ops = {
- .dpy_name = "qt5",
- .dpy_gfx_update = qt5_update,
- .dpy_gfx_switch = qt5_switch,
- .dpy_refresh = qt5_refresh,
- .dpy_mouse_set = qt5_mouse_warp,
- .dpy_cursor_define = qt5_mouse_define,
-};
-
-void maru_early_qt5_display_init(bool isOnscreen)
-{
-#ifdef CONFIG_DARWIN
- ns_run_in_event_loop_with_bool(&qt5_early_prepare, isOnscreen);
-
- /* set emulator icon */
-#define ICON_RESOURCE_PATH "../icons/"
-#define ICON_FILE_NAME "emulator_icon.ico"
- const int path_len = strlen(get_bin_path()) +
- strlen(ICON_RESOURCE_PATH) + strlen(ICON_FILE_NAME) + 1;
-
- char *icon_path = g_malloc0(sizeof(char) * path_len);
- snprintf(icon_path, path_len, "%s%s%s",
- get_bin_path(), ICON_RESOURCE_PATH, ICON_FILE_NAME);
- fprintf(stdout, "application icon path : %s\n", icon_path);
-
- set_application_icon(icon_path);
- g_free(icon_path);
-#else
- qt5_early_prepare(isOnscreen);
-#endif
- if (isOnscreen) {
- LOG_INFO("Display Type: QT5 Onscreen\n");
- } else {
- LOG_INFO("Display Type: QT5 Offscreen\n");
- }
-}
-
-static void maru_qt5_display_fini(void)
-{
- if (qt5_console) {
- g_free(qt5_console);
- qt5_console = NULL;
- }
- qt5_destroy();
-}
-
-void set_display_pixel_density(int dpi)
-{
- pixel_density_dpi = dpi;
-}
-
-void maru_qt5_display_init(DisplayState *ds, int full_screen)
-{
- int i;
-
- /* prepare gui */
-#ifdef CONFIG_DARWIN
- ns_run_in_event_loop(&qt5_prepare);
-#else
- qt5_prepare();
-#endif
-
- for (i = 0;; i++) {
- QemuConsole *con = qemu_console_lookup_by_index(i);
- if (!con || !qemu_console_is_graphic(con)) {
- break;
- }
- }
- qt5_num_outputs = i;
- qt5_console = g_new0(struct qt5_state, qt5_num_outputs);
- for (i = 0; i < qt5_num_outputs; i++) {
- QemuConsole *con = qemu_console_lookup_by_index(i);
- qt5_console[i].dcl.ops = &dcl_ops;
- qt5_console[i].dcl.con = con;
- register_displaychangelistener(&qt5_console[i].dcl);
- qt5_console[i].idx = i;
- }
-
- if (full_screen) {
- /* TODO */
- }
- atexit(maru_qt5_display_fini);
-
- /* TODO
- mouse_mode_notifier.notify = qt2_mouse_mode_change;
- qemu_add_mouse_mode_change_notifier(&mouse_mode_notifier);
- */
-
- /* TODO: cursor control */
-}
+++ /dev/null
-/*
- * QT5 display driver
- *
- * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * GiWoong Kim <giwoong.kim@samsung.com>
- * SeokYeon Hwang <syeon.hwang@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 __QT5_H__
-#define __QT5_H__
-
-#include <stdbool.h>
-
-#include "sysemu/sysemu.h"
-
-void maru_early_qt5_display_init(bool isOnscreen);
-void maru_qt5_display_init(DisplayState *ds, int full_screen);
-
-void set_display_pixel_density(int dpi);
-
-#endif // __QT5_H__
+++ /dev/null
-/*
- * Qt UI
- *
- * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * GiWoong Kim <giwoong.kim@samsung.com>
- * SeokYeon Hwang <syeon.hwang@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 <QApplication>
-
-#include "qt5_supplement.h"
-#include "propertykeyword.h"
-#include "mainwindow.h"
-#include "layout/hardwarekey.h"
-#include "xmllayoutparser.h"
-#include "uiutil.h"
-#include "resource/ui_strings.h"
-#include "displaybase.h"
-
-extern "C" {
-#include "emul_state.h"
-int qemu_get_thread_id(void);
-bool is_display_off(void);
-}
-
-//using namespace std;
-void qMessageOutput(QtMsgType, const QMessageLogContext &, const QString &);
-void loadMainFormFromXML(QFile *, UIInformation *);
-void loadConFormFromXML(QFile *, UIInformation *);
-
-bool qt5IsOnscreen;
-QApplication *qt5App = NULL;
-
-static int argc = 0;
-static char *argv[0];
-
-#define MAX_BLANK_FRAME_CNT 10
-static unsigned int blank_cnt;
-
-static void *captureRequestListener;
-static void (*captureRequestHandler)(void *);
-
-static MainWindow *mainwindow;
-static UIInformation *uiInfo;
-
-#define GUI_PROPERTIES_FILE_NAME "gui.property"
-#define SKIN_INFO_FILE_NAME "info.ini"
-#define FORM_FILE_NAME "layout.xml"
-#define CON_FORM_SUBPATH "controller"
-
-class ConFile {
-public:
- QFile *formFile;
- int priority;
-};
-
-#ifdef CONFIG_WIN32
-class EventFilter : public QAbstractNativeEventFilter
-{
-public:
- virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *res) Q_DECL_OVERRIDE;
-};
-
-EventFilter *eventFilter = NULL;
-
-bool EventFilter::nativeEventFilter(const QByteArray &eventType, void *message, long *res)
-{
- if (eventType == "windows_generic_MSG") {
- MSG *msg = static_cast<MSG *>(message);
- if (msg->message == WM_ERASEBKGND) {
- qt5_graphic_hw_invalidate();
- }
- }
-
- return false;
-}
-#endif
-
-void qt5_gui_init(void)
-{
- QCoreApplication::setApplicationName("Tizen Emulator");
-
- qDebug() << "* Qt version :" << QT_VERSION_STR;
- qDebug() << "* working path :" << QDir::currentPath();
- qDebug() << "* binary path :" << QCoreApplication::applicationDirPath();
-
- uiInfo = new UIInformation();
-
- /* parameter parsing */
- // TODO:
-
- uiInfo->vmName = QString(get_vm_name()).trimmed();
- qDebug() << "VM name :" << uiInfo->vmName;
-
- uiInfo->resolution.setWidth(get_display_resolution_width());
- uiInfo->resolution.setHeight(get_display_resolution_height());
- uiInfo->basePort = get_emul_vm_base_port();
-
- uiInfo->vmDataPath = QDir(get_vm_data_path()).canonicalPath();
- if (uiInfo->vmDataPath.endsWith(QDir::separator()) == false) {
- uiInfo->vmDataPath += QDir::separator();
- }
- qDebug() << "VM path :" << uiInfo->vmDataPath;
-
- uiInfo->skinPath = QDir(get_emul_skin_path()).canonicalPath();
- if (uiInfo->skinPath.endsWith(QDir::separator()) == false) {
- uiInfo->skinPath += QDir::separator();
- }
- qDebug() << "skin path :" << uiInfo->skinPath;
-
- /* read skin information */
- QSettings skinInfo(uiInfo->skinPath + SKIN_INFO_FILE_NAME,
- QSettings::IniFormat);
- QString skinName = skinInfo.value(SKIN_PROPERTY_NAME).toString();
- if (skinName.isEmpty() == true) {
- skinName = "Undefined";
- }
- uiInfo->skinName = skinName;
-
- /* open most recently used data information file */
- QFile::remove(uiInfo->vmDataPath + GUI_PROPERTIES_FILE_NAME + ".lock");
- const QSettings mruInfo(
- uiInfo->vmDataPath + GUI_PROPERTIES_FILE_NAME, QSettings::IniFormat);
-
- /* XML layout */
- QFile mainXMLFile(uiInfo->skinPath + FORM_FILE_NAME);
- /* load main form */
- loadMainFormFromXML(&mainXMLFile, uiInfo);
-
- QDir skinDir(uiInfo->skinPath + CON_FORM_SUBPATH);
- /* load controller forms */
- QFileInfoList entries = skinDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
-
- if (entries.isEmpty() == false) {
- /* sort by priority */
- QList<ConFile *> conFileList;
-
- for (int i = 0; i < entries.size(); i++) {
- ConFile *conFile = new ConFile();
-
- QString conPath = entries.at(i).filePath() + QDir::separator();
- conFile->formFile = new QFile(conPath + FORM_FILE_NAME);
- QSettings conInfo(conPath + SKIN_INFO_FILE_NAME, QSettings::IniFormat);
- conFile->priority = conInfo.value("priority").toInt();
-
- int j = 0;
- for ( ; j < conFileList.size(); j++) {
- if (conFileList.at(j)->priority > conFile->priority) {
- break;
- }
- }
- conFileList.insert(j, conFile);
- }
-
- /* loading */
- for (int i = 0; i < conFileList.size(); i++) {
- loadConFormFromXML(conFileList.at(i)->formFile, uiInfo);
- delete conFileList.at(i)->formFile;
- delete conFileList.at(i);
- }
- }
-
- /* default scale */
- int scale = mruInfo.value(SKIN_PROPERTY_WINDOW_SCALE).toInt();
- qDebug("previous scale value is %d", scale);
-
- if (scale <= 0) {
- scale = 100;
-
- MenuItem *item = NULL;
- for (int i = 0; i < uiInfo->menuList.count(); i++) {
- item = uiInfo->menuList.at(i);
- if (item->getType() == MenuItemType::scaleItem) {
- ScaleMenuItem *scaleItem = (ScaleMenuItem *)item;
- if (scaleItem->getDefaultScaleFactor() > 0) {
- scale = scaleItem->getDefaultScaleFactor();
- }
- }
- }
- }
- uiInfo->uiState.mainFormScale = scale;
- qDebug("default scale value is %d", uiInfo->uiState.mainFormScale);
-
- /* GUI */
- qDebug("start!");
-
- mainwindow = new MainWindow(uiInfo);
- mainwindow->setCaptureRequestHandler(captureRequestListener, captureRequestHandler);
-
- /* position */
- QRect hostBounds = UIUtil::getHostScreenBounds();
- qDebug() << "host geometry :" << hostBounds;
-
- 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) {
- mainwindow->setTopMost(true);
- }
-
- /* controller */
- const int defaultDockPos = Qt::AlignRight | Qt::AlignCenter;
- mainwindow->getUIState()->conState.recentlyDockPos = defaultDockPos;
-
- int conIndex = mruInfo.value(SKIN_PROPERTY_CONTROLLER_INDEX).toInt();
- if (conIndex >= 0 && conIndex < uiInfo->conFormList.count()) {
- int conDockPos = mruInfo.value(SKIN_PROPERTY_CONTROLLER_DOCK).toInt();
- if (conDockPos <= 0) {
- conDockPos = defaultDockPos;
- }
-
- mainwindow->openController(conIndex, conDockPos);
- }
-
- mainwindow->show();
-
-#ifdef CONFIG_WIN32
- /* W/A: Sometimes, QGrahpicsItem's update() does not work with QGLWidget
- * on Windows Aero theme. We need to indirectly repaint the items
- * through these lines. */
- const QSize viewSize = uiInfo->getUiSize();
- mainwindow->getSkinView()->resize(viewSize / 2);
- mainwindow->getSkinView()->resize(viewSize);
-#endif
-
- mainwindow->startDisplaySwapper();
-}
-
-void qt5_destroy()
-{
- qDebug("qt5 destroy");
-
- /* write most recently used data information */
- QString path(uiInfo->vmDataPath + GUI_PROPERTIES_FILE_NAME);
- qDebug() << "save MRU data:" << path;
-
- QSettings mruInfo(path, QSettings::IniFormat);
- mruInfo.setValue(SKIN_PROPERTY_WINDOW_X, mainwindow->pos().x());
- mruInfo.setValue(SKIN_PROPERTY_WINDOW_Y, mainwindow->pos().y());
- mruInfo.setValue(SKIN_PROPERTY_WINDOW_SCALE, uiInfo->uiState.mainFormScale);
- mruInfo.setValue(SKIN_PROPERTY_WINDOW_TOPMOST, uiInfo->uiState.isOnTop());
- mruInfo.setValue(SKIN_PROPERTY_CONTROLLER_INDEX, uiInfo->uiState.conState.conFormIndex);
-
- DockingController *con = uiInfo->uiState.conState.dockingCon;
- if (con != NULL) {
- mruInfo.setValue(SKIN_PROPERTY_CONTROLLER_DOCK, con->getDockPos());
- } else {
- mruInfo.setValue(SKIN_PROPERTY_CONTROLLER_DOCK, 0);
- }
-
- mruInfo.sync();
-
- /* clean up */
-#ifdef CONFIG_WIN32
- delete eventFilter;
-#endif
- qt5App->flush();
-
- mainwindow->closeController();
- mainwindow->terminateDisplaySwapper();
-
- qt5App->processEvents(QEventLoop::ExcludeUserInputEvents);
- qt5App->quit();
-
- //TODO: fix me
- //delete mainwindow;
-
- if (uiInfo) {
- delete uiInfo;
- uiInfo = NULL;
- }
-}
-
-void qt5_early_prepare(bool isOnscreen)
-{
- qt5IsOnscreen = isOnscreen;
-
- Q_INIT_RESOURCE(resource);
-
-#ifdef CONFIG_LINUX
- /* QGLWidget threading: Note that under X11 it is necessary to set the
- * Qt::AA_X11InitThreads application attribute to make the X11 library
- * and GLX calls thread safe, otherwise the above scenarios will fail. */
-
- /* Calls XInitThreads() as part of the QApplication construction in order
- * to make Xlib calls thread-safe. This attribute must be set before
- * QApplication is constructed. */
- QCoreApplication::setAttribute(Qt::AA_X11InitThreads);
-#endif
-
- qt5App = new QApplication(argc, argv);
-
- /* add the path in the application's main() function, right after the
- * QApplication object is created */
- qt5App->addLibraryPath(QDir::currentPath()); //TODO: consider a symbolic link
-
- qInstallMessageHandler(qMessageOutput);
-
- qDebug() << "* Qt plugin library path:" << QCoreApplication::libraryPaths();
-
-#ifdef CONFIG_WIN32
- eventFilter = new EventFilter();
- qt5App->installNativeEventFilter(eventFilter);
-#endif
-}
-
-void qt5_prepare(void)
-{
- qt5_gui_init();
-}
-
-void qt5_update_internal(void *data, int width, int height)
-{
- QImage image((uchar *)data, width, height, QImage::Format_RGB32);
-
- mainwindow->getScreenWidget()->setPixmap(
- QPixmap::fromImage(image.transformed(
- mainwindow->getDisplayMatrix(), Qt::SmoothTransformation)));
-}
-
-void qt5_switch_internal(void)
-{
- /* do nothing */
-}
-
-void qt5_refresh_internal(void)
-{
- qt5App->processEvents();
-
- DisplayBase *db = mainwindow->getDisplay();
- if (db) {
- if (db->getIsGimgReady()) {
- if (is_display_off()) {
- if (db->getGimgState() == false) {
- if (blank_cnt > MAX_BLANK_FRAME_CNT) {
- db->startGuideImg();
- blank_cnt = 0;
- } else {
- blank_cnt++;
- }
- }
- } else {
- if (db->getGimgState() == true) {
- db->stopGuideImg();
- }
-
- blank_cnt = 0;
- }
- }
- } else {
- qDebug() << "Display is not ready.";
- }
-}
-
-void qt5_register_capture_request_listener(void *listener, void (*handler)(void *))
-{
- if (mainwindow) {
- mainwindow->setCaptureRequestHandler(listener, handler);
- }
-
- captureRequestListener = listener;
- captureRequestHandler = handler;
-}
-
-void qt5_unregister_capture_request_listener(void *listener)
-{
- if (mainwindow) {
- mainwindow->unsetCaptureRequestHandler(listener);
- }
-
- captureRequestListener = NULL;
- captureRequestHandler = NULL;
-}
-
-void qt5_process_captured(bool captured, void *pixels, int width, int height)
-{
- if (mainwindow) {
- mainwindow->processCaptured(captured, pixels, width, height);
- }
-}
-
-void qMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
-{
- QByteArray localMsg = msg.toLocal8Bit();
- QByteArray dateMsg = QDateTime::currentDateTime().toString("hh:mm:ss.zzz").toLocal8Bit();
-
- QString path = context.file;
- char *fname = NULL;
- int posFname = path.lastIndexOf('/') + 1;
- int posDot = path.lastIndexOf('.');
-
- if (( posFname != 0 ) && ( posDot != -1)) {
- int fnameLen = path.length() - posFname;
- path = path.right(fnameLen);
- fnameLen = posDot - posFname;
- path.truncate(fnameLen);
- }
- fname = path.toLocal8Bit().data();
-
- switch (type) {
- case QtDebugMsg:
- fprintf(stdout, "%s|%5d|I|%10.10s|%4u|%s\n", dateMsg.constData(),
- qemu_get_thread_id(), fname, context.line,
- localMsg.trimmed().constData());
- break;
- case QtWarningMsg:
- fprintf(stdout, "%s|%5d|W|%10.10s|%4u|%s\n", dateMsg.constData(),
- qemu_get_thread_id(), fname, context.line,
- localMsg.trimmed().constData());
- break;
- case QtCriticalMsg:
- fprintf(stderr, "%s|%5d|S|%10.10s|%4u|%s\n", dateMsg.constData(),
- qemu_get_thread_id(), fname, context.line,
- localMsg.trimmed().constData());
- break;
- case QtFatalMsg:
- fprintf(stderr, "%s|%5d|S|%10.10s|%4u|%s\n", dateMsg.constData(),
- qemu_get_thread_id(), fname, context.line,
- localMsg.trimmed().constData());
-
- QString err;
- QMessageBox::critical(0, EMULATOR_TITLE,
- QString(MSG_INTERNAL_ERR) +
- err.sprintf("%s", (localMsg.trimmed()).constData()) +
- MSG_EMULATOR_EXIT);
- abort();
- }
-}
-
-void loadMainFormFromXML(QFile *file, UIInformation *uiInfo/* out */)
-{
- if (file->exists() == false) {
- qFatal("%s %s", qPrintable(file->fileName()), MSG_NOT_FOUND);
- return;
- }
-
- if (!file->open(QIODevice::ReadOnly | QIODevice::Text)) {
- qFatal("%s %s %s", MSG_NOT_OPEN_1, qPrintable(file->fileName()), MSG_NOT_OPEN_2);
- return;
- }
-
- qDebug("main form is loaded from %s", qPrintable(file->fileName()));
-
- /* read xml */
- QFileInfo fileInfo(*file);
- QXmlStreamReader xml(file);
-
- /* parse xml */
- XmlLayoutParser parser(fileInfo.absolutePath(), uiInfo);
- QString version = parser.parseEmulatorUI(xml);
- qDebug() << "layout version :" << version;
-
- const bool hasError = xml.hasError();
- xml.clear();
- file->close();
-
- if (hasError == true) {
- qFatal(MSG_INVALID_XML_FORMAT);
- return;
- }
-}
-
-void loadConFormFromXML(QFile *file, UIInformation *uiInfo/* out */)
-{
- if (file->exists() == false) {
- qWarning("%s is not found", qPrintable(file->fileName()));
- return;
- }
-
- if (!file->open(QIODevice::ReadOnly | QIODevice::Text)) {
- qFatal("%s %s %s", MSG_NOT_OPEN_1, qPrintable(file->fileName()), MSG_NOT_OPEN_2);
- return;
- }
-
- qDebug("controller form is loaded from %s", qPrintable(file->fileName()));
-
- /* read xml */
- QFileInfo fileInfo(*file);
- QXmlStreamReader xml(file);
-
- /* parse xml */
- XmlLayoutParser parser(fileInfo.absolutePath(), uiInfo);
- QString version = parser.parseControllerUI(xml);
- qDebug() << "layout version :" << version;
-
- const bool hasError = xml.hasError();
- xml.clear();
- file->close();
-
- if (hasError == true) {
- qFatal(MSG_INVALID_XML_FORMAT);
- return;
- }
-}
+++ /dev/null
-/*
- * Qt UI
- *
- * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * GiWoong Kim <giwoong.kim@samsung.com>
- * SeokYeon Hwang <syeon.hwang@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 __QT5_INTERNAL_H__
-#define __QT5_INTERNAL_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-void qt5_graphic_hw_invalidate(void);
-void qt5_graphic_hw_update(void);
-int qt5_graphic_hw_display(void);
-void qt5_early_prepare(bool isOnscreen);
-void qt5_prepare(void);
-void qt5_destroy(void);
-
-void qt5_update_internal(void *data, int width, int height);
-void qt5_switch_internal(void);
-void qt5_refresh_internal(void);
-#ifdef __cplusplus
-}
-#endif
-
-#endif // __QT5_INTERNAL_H__
+++ /dev/null
-/*
- * 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 XMLLAYOUTKEYWORD_H
-#define XMLLAYOUTKEYWORD_H
-
-#define NAME_ATTR_KEYWORD "name"
-#define PROP_ATTR_KEYWORD "property"
-#define DEFAULT_ATTR_KEYWORD "default"
-#define COLOR_RED_ATTR_KEYWORD "R"
-#define COLOR_GREEN_ATTR_KEYWORD "G"
-#define COLOR_BLUE_ATTR_KEYWORD "B"
-#define REGION_LEFT_ATTR_KEYWORD "left"
-#define REGION_TOP_ATTR_KEYWORD "top"
-#define REGION_WIDTH_ATTR_KEYWORD "width"
-#define REGION_HEIGHT_ATTR_KEYWORD "height"
-#define KEYCODE_LONGPRESS_ATTR_KEYWORD "longPress"
-
-#define EMULATOR_UI_KEYWORD "EmulatorUI"
-#define CONTROLLER_UI_KEYWORD "ControllerUI"
-#define LAYOUTVER_KEYWORD "layoutVersion"
-#define COLOR_KEYWORD "color"
-#define REGION_KEYWORD "region"
-#define ANGLE_KEYWORD "angle"
-#define DISPLAY_KEYWORD "display"
-#define NORMAL_IMG_KEYWORD "normalImage"
-#define PRESSED_IMG_KEYWORD "pressedImage"
-#define MASK_IMG_KEYWORD "maskImage"
-#define ROTARY_IMG_KEYWORD "rotaryImage"
-#define KEYLIST_KEYWORD "keyList"
-#define KEY_KEYWORD "key"
-#define KEYCODE_KEYWORD "keycode"
-#define TOOLTIP_KEYWORD "tooltip"
-#define SHORTCUT_KEYWORD "shortcut"
-#define HOVER_KEYWORD "hover"
-#define FACTORLIST_KEYWORD "factorList"
-#define FACTOR_KEYWORD "factor"
-#define FORM_KEYWORD "form"
-#define FORMLIST_KEYWORD "formList"
-#define SHORTCUT_KEYWORD "shortcut"
-#define MENULIST_KEYWORD "menuList"
-
-#define SEPARATOR_MENU_KEYWORD "separator"
-#define ADVANCED_MENU_KEYWORD "advancedItem"
-#define INFO_MENU_KEYWORD "infoItem"
-#define ONTOP_MENU_KEYWORD "onTopItem"
-#define SWITCH_MENU_KEYWORD "switchItem"
-#define SCALE_MENU_KEYWORD "scaleItem"
-#define CONTROLLER_MENU_KEYWORD "controllerItem"
-#define HOSTKBD_MENU_KEYWORD "hostKeyboardItem"
-#define SHELL_MENU_KEYWORD "shellItem"
-#define ECP_MENU_KEYWORD "controlPanelItem"
-#define SCREENSHOT_MENU_KEYWORD "screenShotItem"
-#define ABOUT_MENU_KEYWORD "aboutItem"
-#define FORCECLOSE_MENU_KEYWORD "forceCloseItem"
-#define CLOSE_MENU_KEYWORD "closeItem"
-
-#endif // XMLLAYOUTKEYWORD_H
+++ /dev/null
-/*
- * 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 "xmllayoutparser.h"
-#include "xmllayoutkeyword.h"
-#include "skinpainter.h"
-#include "layout/keycodetype.h"
-#include "controller/generalpurposecon.h"
-
-/* Qt Qlayout has a minimum size */
-#define QT_LAYOUT_MINIMUM (73)
-
-XmlLayoutParser::XmlLayoutParser(QString path, UIInformation *uiInfo)
-{
- this->xmlPath = path;
- this->uiInfo = uiInfo;
-}
-
-QColor XmlLayoutParser::parseColor(QXmlStreamReader &xml)
-{
- int red = 0, green = 0, blue = 0;
-
- if (xml.name() == COLOR_KEYWORD &&
- xml.tokenType() == QXmlStreamReader::StartElement) {
- QXmlStreamAttributes attributes = xml.attributes();
-
- if (attributes.hasAttribute(COLOR_RED_ATTR_KEYWORD)) {
- red = attributes.value(COLOR_RED_ATTR_KEYWORD).toString().toInt();
- qDebug() << red;
- }
- if (attributes.hasAttribute(COLOR_GREEN_ATTR_KEYWORD)) {
- green = attributes.value(COLOR_GREEN_ATTR_KEYWORD).toString().toInt();
- qDebug() << green;
- }
- if (attributes.hasAttribute(COLOR_BLUE_ATTR_KEYWORD)) {
- blue = attributes.value(COLOR_BLUE_ATTR_KEYWORD).toString().toUInt();
- qDebug() << blue;
- }
- }
-
- return QColor(red, green, blue, 255);
-}
-
-HoverType *XmlLayoutParser::parseHover(QXmlStreamReader &xml)
-{
- QColor color;
-
- QXmlStreamReader::TokenType token = xml.readNext();
-
- while (xml.atEnd() == false && (xml.name() == HOVER_KEYWORD &&
- token == QXmlStreamReader::EndElement) == false) /* ~ </hover> */
- {
- if (token == QXmlStreamReader::StartElement) {
- if (xml.name() == COLOR_KEYWORD) {
- /* color */
- color = parseColor(xml);
- qDebug() << "hover color :" << color;
- }
- }
-
- token = xml.readNext();
- }
-
- return new HoverType(color);
-}
-
-QRect XmlLayoutParser::parseRegion(QXmlStreamReader &xml)
-{
- int left = 0, top = 0;
- unsigned int width = 0, height = 0;
-
- if (xml.name() == REGION_KEYWORD &&
- xml.tokenType() == QXmlStreamReader::StartElement) {
- QXmlStreamAttributes attributes = xml.attributes();
-
- if (attributes.hasAttribute(REGION_LEFT_ATTR_KEYWORD)) {
- left = attributes.value(REGION_LEFT_ATTR_KEYWORD).toString().toInt();
- }
- if (attributes.hasAttribute(REGION_TOP_ATTR_KEYWORD)) {
- top = attributes.value(REGION_TOP_ATTR_KEYWORD).toString().toInt();
- }
- if (attributes.hasAttribute(REGION_WIDTH_ATTR_KEYWORD)) {
- width = attributes.value(REGION_WIDTH_ATTR_KEYWORD).toString().toUInt();
- }
- if (attributes.hasAttribute(REGION_HEIGHT_ATTR_KEYWORD)) {
- height = attributes.value(REGION_HEIGHT_ATTR_KEYWORD).toString().toUInt();
- }
- }
-
- return QRect(left, top, width, height);
-}
-
-DisplayType *XmlLayoutParser::parseDisplay(QXmlStreamReader &xml)
-{
- QRect displayRect;
- int angle = 0;
- QPixmap maskImage;
-
- qDebug() << "**" << DISPLAY_KEYWORD << "{";
-
- QXmlStreamReader::TokenType token = xml.readNext();
-
- while (xml.atEnd() == false && (xml.name() == DISPLAY_KEYWORD &&
- token == QXmlStreamReader::EndElement) == false) /* ~ </display> */
- {
- if (token == QXmlStreamReader::StartElement) {
- if (xml.name() == REGION_KEYWORD) {
- /* region */
- displayRect = parseRegion(xml);
- qDebug("- rect : (%d,%d %dx%d)",
- displayRect.x(), displayRect.y(),
- displayRect.width(), displayRect.height());
- } else if (xml.name() == ANGLE_KEYWORD) {
- /* angle */
- angle = xml.readElementText().toInt();
- } else if (xml.name() == MASK_IMG_KEYWORD) {
- /* display mask */
- QString maskImageFileName = xml.readElementText();
- qDebug() << "-" << MASK_IMG_KEYWORD << ":" << maskImageFileName;
-
- if (maskImage.load(
- xmlPath + QDir::separator() + maskImageFileName) == false) {
- qWarning() << "failed to load mask image";
- }
- }
- }
-
- token = xml.readNext();
- }
-
- qDebug("** }");
-
- return new DisplayType(displayRect, angle, maskImage);
-}
-
-KeycodeType *XmlLayoutParser::parseKeycode(QXmlStreamReader &xml)
-{
- int longPress = -1, shortPress = 0;
-
- /* attribute */
- longPress = xml.attributes().value(KEYCODE_LONGPRESS_ATTR_KEYWORD).toString().toInt();
-
- shortPress = xml.readElementText().toInt();
-
- return new KeycodeType(shortPress, longPress);
-}
-
-HardwareKey *XmlLayoutParser::parseKey(QXmlStreamReader &xml)
-{
- QRect keyRegion;
- KeycodeType *keycodeType = NULL;
- QString keyTooptip;
- QString keySequence;
-
- /* attribute */
- QString keyName = xml.attributes().value(NAME_ATTR_KEYWORD).toString();
-
- QXmlStreamReader::TokenType token = xml.readNext();
-
- while (xml.atEnd() == false && (xml.name() == KEY_KEYWORD &&
- token == QXmlStreamReader::EndElement) == false) /* ~ </key> */
- {
- if (token == QXmlStreamReader::StartElement) {
- if (xml.name() == REGION_KEYWORD) {
- /* region */
- keyRegion = parseRegion(xml);
- } else if (xml.name() == KEYCODE_KEYWORD) {
- /* keycode */
- keycodeType = parseKeycode(xml);
- } else if (xml.name() == TOOLTIP_KEYWORD) {
- /* tooltip */
- keyTooptip = xml.readElementText();
- } else if (xml.name() == SHORTCUT_KEYWORD) {
- /* shortcut */
- keySequence = xml.readElementText();
- }
- }
-
- token = xml.readNext();
- }
-
- return new HardwareKey(keyName, keycodeType, keyRegion, keyTooptip, keySequence);
-}
-
-int XmlLayoutParser::parseKeyList(
- QXmlStreamReader &xml, QList<HardwareKey *> &list)
-{
- HardwareKey *hwKey = NULL;
- QXmlStreamReader::TokenType token = xml.readNext();
-
- while (xml.atEnd() == false && (xml.name() == KEYLIST_KEYWORD &&
- token == QXmlStreamReader::EndElement) == false) /* ~ </keyList> */
- {
- if (token == QXmlStreamReader::StartElement) {
- if (xml.name() == KEY_KEYWORD) {
- hwKey = parseKey(xml);
- if (hwKey != NULL) {
- list.append(hwKey);
- }
- }
- }
-
- token = xml.readNext();
- }
-
- return list.count();
-}
-
-MainForm *XmlLayoutParser::parseMainForm(QXmlStreamReader &xml)
-{
- /* attribute */
- QString formName = xml.attributes().value(NAME_ATTR_KEYWORD).toString();
- MainForm *form = new MainForm(formName);
-
- qDebug() << '*' << form->getName() << '{';
-
- QXmlStreamReader::TokenType token = xml.readNext();
-
- while (xml.atEnd() == false && (xml.name() == FORM_KEYWORD &&
- token == QXmlStreamReader::EndElement) == false) /* ~ </form> */
- {
- if (token == QXmlStreamReader::StartElement) {
- if (xml.name() == DISPLAY_KEYWORD) {
- /* display */
- form->displayType = parseDisplay(xml);
- } else if (xml.name() == NORMAL_IMG_KEYWORD) {
- /* normal image */
- QString normalImageFileName = xml.readElementText();
- qDebug() << "-" << NORMAL_IMG_KEYWORD << ":" << normalImageFileName;
-
- if (form->skinImg[MainForm::normal].load(
- xmlPath + QDir::separator() + normalImageFileName) == false) {
- qWarning() << "failed to load normal image";
- }
- } else if (xml.name() == PRESSED_IMG_KEYWORD) {
- /* key pressed image */
- QString pressedImageFileName = xml.readElementText();
- qDebug() << "-" << PRESSED_IMG_KEYWORD << ":" << pressedImageFileName;
-
- if (form->skinImg[MainForm::pressed].load(
- xmlPath + QDir::separator() + pressedImageFileName) == false) {
- qWarning() << "failed to load pressed image";
- }
- } else if (xml.name() == ROTARY_IMG_KEYWORD) {
- /* rotary image */
- QString rotaryImageFileName = xml.readElementText();
- qDebug() << "-" << ROTARY_IMG_KEYWORD << ":" << rotaryImageFileName;
-
- form->setRotaryImage(new QPixmap(
- xmlPath + QDir::separator() + rotaryImageFileName));
- if (form->getRotaryImage()->isNull() == true) {
- qWarning() << "failed to load rotary image";
- }
- } else if (xml.name() == KEYLIST_KEYWORD) {
- /* HW keys */
- int cnt = parseKeyList(xml, form->keyList);
- qDebug() << "-" << KEYLIST_KEYWORD << ":" << cnt;
- } else {
- qWarning() << "undefined element :" << xml.name();
- }
- }
-
- token = xml.readNext();
- }
-
- qDebug("}");
-
- return form;
-}
-
-int XmlLayoutParser::parseMainFormList(
- QXmlStreamReader &xml, QList<MainForm *> &list)
-{
- MainForm *form = NULL;
- QXmlStreamReader::TokenType token = xml.readNext();
-
- while (xml.atEnd() == false && (xml.name() == FORMLIST_KEYWORD &&
- token == QXmlStreamReader::EndElement) == false) /* ~ </formList> */
- {
- if (token == QXmlStreamReader::StartElement) {
- if (xml.name() == FORM_KEYWORD) {
- form = parseMainForm(xml);
- if (form != NULL) {
- /* image validation */
- if (form->skinImg[MainForm::normal].size() == QSize(0, 0)) {
- qDebug("- general purpose skin form");
-
- SkinPainter painter("main-skin",
- uiInfo->resolution, form->displayType->getAngle(),
- QPoint(30, 16), uiInfo->getVMColor());
- form->setGeneralPurpose(true);
-
- form->skinImg[MainForm::normal] = painter.getSkinImage();
- form->displayType->setRect(painter.getCenterRect());
- }
-
- list.append(form);
- }
- }
- }
-
- token = xml.readNext();
- }
-
- return list.count();
-}
-
-/* menu */
-int XmlLayoutParser::parseFactorList(
- QXmlStreamReader &xml, QMap<int, QString> &map, int *defaultFactor)
-{
- QString defaultValue = xml.attributes().value(DEFAULT_ATTR_KEYWORD).toString();
- *defaultFactor = defaultValue.toInt();
-
- QXmlStreamReader::TokenType token = xml.readNext();
-
- while (xml.atEnd() == false && (xml.name() == "factorList" &&
- token == QXmlStreamReader::EndElement) == false) /* ~ </factorList> */
- {
- if (token == QXmlStreamReader::StartElement) {
- if (xml.name() == FACTOR_KEYWORD) {
- QString value = xml.attributes().value(NAME_ATTR_KEYWORD).toString();
- map.insert(xml.readElementText().toInt(), value);
- }
- }
-
- token = xml.readNext();
- }
-
- return map.count();
-}
-
-int XmlLayoutParser::parseShortcut(
- QXmlStreamReader &xml, QMap<QString, QString> &map)
-{
- QString key = xml.attributes().value(PROP_ATTR_KEYWORD).toString();
- map.insert(key, xml.readElementText());
-
- return map.count();
-}
-
-AdvancedMenuItem *XmlLayoutParser::parseAdvancedMenuItem(QXmlStreamReader &xml)
-{
- /* attribute */
- QString menuName = xml.attributes().value(NAME_ATTR_KEYWORD).toString();
- AdvancedMenuItem *item = new AdvancedMenuItem(menuName);
-
- QXmlStreamReader::TokenType token = xml.readNext();
-
- while (xml.atEnd() == false && (xml.name() == "advancedItem" &&
- token == QXmlStreamReader::EndElement) == false) /* ~ </advancedItem> */
- {
- if (token == QXmlStreamReader::StartElement) {
- if (xml.name() == SHORTCUT_KEYWORD) {
- parseShortcut(xml, item->getShortcutMap());
- } else if (xml.name() == MENULIST_KEYWORD) {
- int cnt = parseMenuList(xml, item->getMenuList());
- qDebug("- advanced menuList : %d", cnt);
- }
- }
-
- token = xml.readNext();
- }
-
- return item;
-}
-
-ScaleMenuItem *XmlLayoutParser::parseScaleMenuItem(QXmlStreamReader &xml)
-{
- /* attribute */
- QString menuName = xml.attributes().value(NAME_ATTR_KEYWORD).toString();
- ScaleMenuItem *item = new ScaleMenuItem(menuName);
-
- QXmlStreamReader::TokenType token = xml.readNext();
-
- while (xml.atEnd() == false && (xml.name() == "scaleItem" &&
- token == QXmlStreamReader::EndElement) == false) /* ~ </scaleItem> */
- {
- if (token == QXmlStreamReader::StartElement) {
- if (xml.name() == SHORTCUT_KEYWORD) {
- parseShortcut(xml, item->getShortcutMap());
- } else if (xml.name() == FACTORLIST_KEYWORD) {
- int defaultFactor = 0;
- int cnt = parseFactorList(xml, item->getFactorMap(), &defaultFactor);
- qDebug("- scale factorList : %d", cnt);
-
- item->setDefaultScaleFactor(defaultFactor);
- }
- }
-
- token = xml.readNext();
- }
-
- return item;
-}
-
-MenuItem *XmlLayoutParser::parseGeneralMenuItem(
- QXmlStreamReader &xml, int menuType)
-{
- QString itemKeyword = xml.name().toString();
-
- /* attribute */
- QString menuName = xml.attributes().value(NAME_ATTR_KEYWORD).toString();
- MenuItem *item = new MenuItem(menuType, menuName);
-
- QString shortcut;
- QXmlStreamReader::TokenType token = xml.readNext();
-
- while (xml.atEnd() == false && (xml.name().compare(itemKeyword) == 0 &&
- token == QXmlStreamReader::EndElement) == false) /* ~ </xxItem> */
- {
- if (token == QXmlStreamReader::StartElement) {
- if (xml.name() == SHORTCUT_KEYWORD) {
- parseShortcut(xml, item->getShortcutMap());
- }
- }
-
- token = xml.readNext();
- }
-
- return item;
-}
-
-int XmlLayoutParser::parseMenuList(
- QXmlStreamReader &xml, QList<MenuItem *> &list)
-{
- MenuItem *item = NULL;
- QXmlStreamReader::TokenType token = xml.readNext();
-
- while (xml.atEnd() == false && (xml.name() == MENULIST_KEYWORD &&
- token == QXmlStreamReader::EndElement) == false) /* ~ </menuList> */
- {
- if (token == QXmlStreamReader::StartElement) {
- if (xml.name() == SEPARATOR_MENU_KEYWORD) {
- item = new MenuItem(MenuItemType::separator, NULL);
- if (item != NULL) {
- list.append(item);
- }
- } else if (xml.name() == ADVANCED_MENU_KEYWORD) {
- item = (MenuItem *)parseAdvancedMenuItem(xml);
- if (item != NULL) {
- list.append(item);
- }
- } else if (xml.name() == INFO_MENU_KEYWORD) {
- item = parseGeneralMenuItem(xml, MenuItemType::infoItem);
- if (item != NULL) {
- list.append(item);
- }
- } else if (xml.name() == ONTOP_MENU_KEYWORD) {
- item = parseGeneralMenuItem(xml, MenuItemType::onTopItem);
- if (item != NULL) {
- list.append(item);
- }
- } else if (xml.name() == SWITCH_MENU_KEYWORD) {
- item = parseGeneralMenuItem(xml, MenuItemType::switchItem);
- if (item != NULL) {
- list.append(item);
- }
- } else if (xml.name() == SCALE_MENU_KEYWORD) {
- item = (MenuItem *)parseScaleMenuItem(xml);
- if (item != NULL) {
- list.append(item);
- }
- } else if (xml.name() == CONTROLLER_MENU_KEYWORD) {
- item = parseGeneralMenuItem(xml, MenuItemType::controllerItem);
- if (item != NULL) {
- list.append(item);
- }
- } else if (xml.name() == HOSTKBD_MENU_KEYWORD) {
- item = parseGeneralMenuItem(xml, MenuItemType::hostKeyboardItem);
- if (item != NULL) {
- list.append(item);
- }
- } else if (xml.name() == SHELL_MENU_KEYWORD) {
- item = parseGeneralMenuItem(xml, MenuItemType::shellItem);
- if (item != NULL) {
- list.append(item);
- }
- } else if (xml.name() == ECP_MENU_KEYWORD) {
- item = parseGeneralMenuItem(xml, MenuItemType::controlPanelItem);
- if (item != NULL) {
- list.append(item);
- }
- } else if (xml.name() == SCREENSHOT_MENU_KEYWORD) {
- item = parseGeneralMenuItem(xml, MenuItemType::screenShotItem);
- if (item != NULL) {
- list.append(item);
- }
- } else if (xml.name() == ABOUT_MENU_KEYWORD) {
- item = parseGeneralMenuItem(xml, MenuItemType::aboutItem);
- if (item != NULL) {
- list.append(item);
- }
- } else if (xml.name() == FORCECLOSE_MENU_KEYWORD) {
- item = parseGeneralMenuItem(xml, MenuItemType::forceCloseItem);
- if (item != NULL) {
- list.append(item);
- }
- } else if (xml.name() == CLOSE_MENU_KEYWORD) {
- item = parseGeneralMenuItem(xml, MenuItemType::closeItem);
- if (item != NULL) {
- list.append(item);
- }
- }
- }
-
- token = xml.readNext();
- }
-
- return list.count();
-}
-
-QString XmlLayoutParser::parseEmulatorUI(QXmlStreamReader &xml)
-{
- QString layoutVersion = "undefined";
-
- QXmlStreamReader::TokenType token;
-
- while (xml.atEnd() == false && xml.hasError() == false) {
- token = xml.readNext();
- /* If token is just StartDocument, go to next.*/
- if (token == QXmlStreamReader::StartDocument) {
- continue;
- }
-
- if (token == QXmlStreamReader::StartElement) {
- if (xml.name() == EMULATOR_UI_KEYWORD) {
- continue;
- }
-
- if (xml.name() == LAYOUTVER_KEYWORD) {
- layoutVersion = xml.readElementText();
- continue;
- } else if (xml.name() == FORMLIST_KEYWORD) {
- int cnt = parseMainFormList(xml, uiInfo->mainFormList);
- qDebug() << FORMLIST_KEYWORD << ":" << cnt;
- } else if (xml.name() == MENULIST_KEYWORD) {
- int cnt = parseMenuList(xml, uiInfo->menuList);
- qDebug() << MENULIST_KEYWORD << ":" << cnt;
- }
- }
- }
-
- return layoutVersion;
-}
-
-/* controller */
-ControllerForm *XmlLayoutParser::parseControllerForm(QXmlStreamReader &xml)
-{
- /* attribute */
- QString formName = xml.attributes().value(NAME_ATTR_KEYWORD).toString();
- ControllerForm *form = new ControllerForm(
- formName.isEmpty() ? xmlPath.section(QDir::separator(), -1) : formName);
-
- qDebug() << '*' << form->getName() << "{";
-
- QXmlStreamReader::TokenType token = xml.readNext();
-
- while (xml.atEnd() == false && (xml.name() == FORM_KEYWORD &&
- token == QXmlStreamReader::EndElement) == false) /* ~ </form> */
- {
- if (token == QXmlStreamReader::StartElement) {
- if (xml.name() == NORMAL_IMG_KEYWORD) {
- /* normal image */
- QString normalImageFileName = xml.readElementText();
- qDebug() << "-" << NORMAL_IMG_KEYWORD << ":" << normalImageFileName;
-
- if (form->conImg[ControllerForm::normal].load(
- xmlPath + QDir::separator() + normalImageFileName) == false) {
- qWarning() << "failed to load normal image";
- }
- } else if (xml.name() == PRESSED_IMG_KEYWORD) {
- /* key pressed image */
- QString pressedImageFileName = xml.readElementText();
- qDebug() << "-" << PRESSED_IMG_KEYWORD << ":" << pressedImageFileName;
-
- if (form->conImg[ControllerForm::pressed].load(
- xmlPath + QDir::separator() + pressedImageFileName) == false) {
- qWarning() << "failed to load pressed image";
- }
- } else if (xml.name() == KEYLIST_KEYWORD) {
- /* HW keys */
- int cnt = parseKeyList(xml, form->keyList);
- qDebug() << "-" << KEYLIST_KEYWORD << ":" << cnt;
- } else if (xml.name() == HOVER_KEYWORD) {
- /* hover */
- form->setHoverType(parseHover(xml));
- } else {
- qWarning() << "undefined element :" << xml.name();
- }
- }
-
- token = xml.readNext();
- }
-
- qDebug("}");
-
- return form;
-}
-
-QString XmlLayoutParser::parseControllerUI(QXmlStreamReader &xml)
-{
- QString layoutVersion = "undefined";
-
- ControllerForm *form = NULL;
- QXmlStreamReader::TokenType token;
-
- while (xml.atEnd() == false && xml.hasError() == false) {
- token = xml.readNext();
- /* If token is just StartDocument, go to next.*/
- if (token == QXmlStreamReader::StartDocument) {
- continue;
- }
-
- if (token == QXmlStreamReader::StartElement) {
- if (xml.name() == CONTROLLER_UI_KEYWORD) {
- continue;
- }
-
- if (xml.name() == LAYOUTVER_KEYWORD) {
- layoutVersion = xml.readElementText();
- continue;
- } else if (xml.name() == FORM_KEYWORD) {
- form = parseControllerForm(xml);
- if (form != NULL) {
- /* image validation */
- if (form->conImg[ControllerForm::normal].size() == QSize(0, 0)) {
- qDebug("- general purpose con form");
-
- int keyCount = form->keyList.count();
-
- int width = GPC_KEYBUTTON_WIDTH;
- int height = GPC_HEAD_SPACING;
- if (keyCount < GPC_KEYBUTTON_DEFAULT_CNT) {
- height += (GPC_KEYBUTTON_HEIGHT * keyCount) +
- (GPC_KEYBUTTON_VSPACING * (keyCount - 1)) +
- GPC_TAIL_SPACING;
- } else {
- width += (GPC_SCROLLBAR_WIDTH + GPC_SCROLLBAR_HSPACING);
- height += (GPC_KEYBUTTON_HEIGHT * GPC_KEYBUTTON_DEFAULT_CNT) +
- (GPC_KEYBUTTON_VSPACING * (GPC_KEYBUTTON_DEFAULT_CNT - 1)) +
- GPC_TAIL_SPACING;
- }
-
- SkinPainter painter("controller-skin",
- QSize(width, qMax(height, QT_LAYOUT_MINIMUM - 20)),
- 0, QPoint(14, GPC_HEAD_SPACING - 1),
- uiInfo->getVMColor());
- form->setGeneralPurpose(true);
-
- form->conImg[ControllerForm::normal] = painter.getSkinImage();
- form->centerRect = painter.getCenterRect();
- }
-
- uiInfo->conFormList.append(form);
- }
- }
- }
- }
-
- return layoutVersion;
-}
+++ /dev/null
-/*
- * 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 XMLLAYOUTPARSER_H
-#define XMLLAYOUTPARSER_H
-
-#include <QXmlStreamReader>
-
-#include "uiinformation.h"
-#include "layout/keycodetype.h"
-#include "layout/mainform.h"
-#include "layout/controllerform.h"
-#include "menu/menuitem.h"
-#include "menu/advancedmenuitem.h"
-#include "menu/scalemenuitem.h"
-
-
-class XmlLayoutParser
-{
-public:
- XmlLayoutParser(QString path, UIInformation *uiInfo /* out */);
-
- QString parseEmulatorUI(QXmlStreamReader &xml);
- QString parseControllerUI(QXmlStreamReader &xml);
-
-private:
- QColor parseColor(QXmlStreamReader &xml);
- HoverType *parseHover(QXmlStreamReader &xml);
- QRect parseRegion(QXmlStreamReader &xml);
- DisplayType *parseDisplay(QXmlStreamReader &xml);
- KeycodeType *parseKeycode(QXmlStreamReader &xml);
- HardwareKey *parseKey(QXmlStreamReader &xml);
- int parseKeyList(QXmlStreamReader &xml, QList<HardwareKey *> &list);
- MainForm *parseMainForm(QXmlStreamReader &xml);
- int parseMainFormList(QXmlStreamReader &xml, QList<MainForm *> &list);
-
- int parseFactorList(QXmlStreamReader &xml, QMap<int, QString> &map, int *defaultFactor);
- int parseShortcut(QXmlStreamReader &xml, QMap<QString, QString> &map);
- AdvancedMenuItem *parseAdvancedMenuItem(QXmlStreamReader &xml);
- ScaleMenuItem *parseScaleMenuItem(QXmlStreamReader &xml);
- MenuItem *parseGeneralMenuItem(QXmlStreamReader &xml, int menuType);
- int parseMenuList(QXmlStreamReader &xml, QList<MenuItem *> &list);
-
- ControllerForm *parseControllerForm(QXmlStreamReader &xml);
-
- QString xmlPath;
- UIInformation *uiInfo;
-};
-
-#endif // XMLLAYOUTPARSER_H
#include "monitor/qdev.h"
#include "hw/virtio/maru_virtio_sensor.h"
#include "hw/virtio/maru_virtio_nfc.h"
-#include "skin/maruskin_operation.h"
-#include "skin/maruskin_server.h"
+#include "util/ui_operations.h"
#include "util/device_hotplug.h"
#include "util/hds.h"
#include "emul_state.h"
#include "ecs.h"
#include "debug_ch.h"
#include "util/osutil.h"
-#include "skin/maruskin_client.h"
+#include "util/exported_strings.h"
MULTI_DEBUG_CHANNEL(qemu, ecs);
strcat(fail_msg, addon);
strcat(fail_msg, FAILED_TO_INSTALL_EXTRAPACKAGE_2);
- start_simple_client(fail_msg);
+ error_report("%s", fail_msg);
}
static void* push_pkgs_thread(void* args)
#include "qmp-commands.h"
#include "emulator_options.h"
-#include "skin/maruskin_server.h"
#include "hw/virtio/maru_virtio_touchscreen.h"
#include "hw/virtio/maru_virtio_evdi.h"
#include "util/new_debug_ch.h"
+#ifdef CONFIG_JAVA_UI
+#include "skin/maruskin_server.h"
+#endif
+
DECLARE_DEBUG_CHANNEL(emul_state);
static EmulatorConfigInfo _emul_info = {0,};
#include "util/error_handler.h"
#include "util/osutil.h"
#include "util/sdb.h"
-#include "skin/maruskin_server.h"
#include "util/new_debug_ch.h"
#include "ecs/ecs.h"
#include "util/device_hotplug.h"
#include "util/exported_strings.h"
+#ifdef CONFIG_JAVA_UI
+#include "skin/maruskin_server.h"
+#include "skin/maruskin_client.h"
+#endif
+
#ifdef CONFIG_SDL
#include <SDL.h>
#endif
#include "display/maru_display.h"
#include "util/osutil.h"
#include "util/sdb.h"
-#include "skin/maruskin_server.h"
#include "debug_ch.h"
#include "ecs/ecs.h"
#include "emulator_common.h"
#include "emul_state.h"
-#include "skin/maruskin_operation.h"
#include "encode_fb.h"
#if defined(CONFIG_LINUX) && defined(ENCODE_DEBUG)
#include "hw/pci/pci.h"
#include "hw/maru_device_ids.h"
#include "maru_brightness.h"
-#include "skin/maruskin_server.h"
#include "debug_ch.h"
MULTI_DEBUG_CHANNEL(tizen, brightness);
+#ifdef CONFIG_JAVA_UI
+#include "skin/maruskin_server.h"
+#endif
+
#define QEMU_DEV_NAME "maru-brightness"
#define BRIGHTNESS_MEM_SIZE (4 * 1024) /* 4KB */
/* level 81 ~ 90 */ 29, 27, 26, 24, 23, 21, 20, 18, 17, 15,
/* level 91 ~ 99 */ 14, 12, 11, 9, 8, 6, 5, 3, 2, 0};
-QEMUBH *display_bh;
+#ifdef CONFIG_JAVA_UI
+QEMUBH *display_bh = NULL;
+#endif
/* Image processing functions using the pixman library */
void composite_brightness_image(pixman_image_t *dst_image)
maru_pixman_image_set_alpha(brightness_tbl[brightness_level]);
}
+#ifdef CONFIG_JAVA_UI
/* notify to skin process */
qemu_bh_schedule(display_bh);
+#endif
return;
default:
static void brightness_exitfn(PCIDevice *dev)
{
+#ifdef CONFIG_JAVA_UI
if (display_bh) {
qemu_bh_delete(display_bh);
}
+#endif
if (brightness_image) {
pixman_image_unref(brightness_image);
brightness_image = NULL;
INFO("finalize maru-brightness device\n");
}
+#ifdef CONFIG_JAVA_UI
static void maru_display_bh(void *opaque)
{
notify_display_power(!display_off);
}
+#endif
static int brightness_initfn(PCIDevice *dev)
{
"maru-brightness-mmio", BRIGHTNESS_REG_SIZE);
pci_register_bar(&s->dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mmio_addr);
+#ifdef CONFIG_JAVA_UI
display_bh = qemu_bh_new(maru_display_bh, s);
+#endif
brightness_level = BRIGHTNESS_MAX;
level_color.alpha = 0x0000;
level_color.red = 0x0000;
obj-y += maru_virtio_pci.o
obj-y += maru_virtio_touchscreen.o
-obj-y += maru_virtio_esm.o
obj-y += maru_virtio_evdi.o
obj-y += maru_virtio_hwkey.o
obj-y += maru_virtio_jack.o
obj-y += maru_virtio_vmodem.o
obj-y += maru_virtio_rotary.o
obj-y += maru_virtio_tablet.o
+obj-y += maru_virtio_esm.o
#include "hw/maru_device_ids.h"
#include "maru_virtio_esm.h"
-#include "skin/maruskin_server.h"
#include "emul_state.h"
#include "debug_ch.h"
MULTI_DEBUG_CHANNEL(qemu, esm);
+#ifdef CONFIG_JAVA_UI
+#include "skin/maruskin_server.h"
+#endif
#define SYSTEM_MODE_LAYER 1
#define USER_MODE_LAYER 0
boot_complete |= (1 << SYSTEM_MODE_LAYER);
}
+#ifdef CONFIG_JAVA_UI
notify_booting_progress(SYSTEM_MODE_LAYER, progress.percentage);
+#endif
} else {
if (progress.percentage >= 100) {
boot_complete |= (1 << USER_MODE_LAYER);
}
+#ifdef CONFIG_JAVA_UI
notify_booting_progress(USER_MODE_LAYER, progress.percentage);
+#endif
}
/* booting complete check */
MULTI_DEBUG_CHANNEL(qemu, skin_op);
-
-#define RESUME_KEY_SEND_INTERVAL 500 /* milli-seconds */
#define CLOSE_POWER_KEY_INTERVAL 1200 /* milli-seconds */
#define DATA_DELIMITER "#" /* in detail info data */
-/* touch values */
-static int guest_x, guest_y;
-static int pressing_x = -1, pressing_y = -1;
-static int pressing_origin_x = -1, pressing_origin_y = -1;
-
extern pthread_mutex_t mutex_screenshot;
extern pthread_cond_t cond_screenshot;
maru_display_set_invalidate(on);
}
-void do_mouse_event(int button_type, int event_type,
- int origin_x, int origin_y, int x, int y, int z)
-{
- if (display_off) {
- if (button_type == 0) {
- INFO("auto mouse release\n");
- // TODO:
- virtio_touchscreen_event(0, 0, 0, 0);
-
- return;
- } else {
- TRACE("reject mouse touch in display off : "
- "button=%d, type=%d, x=%d, y=%d, z=%d\n",
- button_type, event_type, x, y, z);
- return;
- }
- }
-
- TRACE("mouse event : button=%d, type=%d, "
- "host=(%d, %d), x=%d, y=%d, z=%d\n",
- button_type, event_type, origin_x, origin_y, x, y, z);
-
-#if defined(CONFIG_JAVA_UI) && !defined(CONFIG_USE_SHM)
- /* draw multi-touch points */
- if (get_multi_touch_enable() != 0) {
- if (event_type == MOUSE_DOWN || event_type == MOUSE_DRAG) {
- update_finger_point(z, origin_x, origin_y, x, y);
- } else if (event_type == MOUSE_UP) {
- remove_finger_point(z);
- }
-
- maru_display_update();
- }
-#endif
-
- /* single touch */
- switch(event_type) {
- case MOUSE_DOWN:
- case MOUSE_DRAG:
- pressing_x = guest_x = x;
- pressing_y = guest_y = y;
- pressing_origin_x = origin_x;
- pressing_origin_y = origin_y;
-
- virtio_touchscreen_event(x, y, z, 1);
-
- break;
- case MOUSE_UP:
- guest_x = x;
- guest_y = y;
- pressing_x = pressing_y = -1;
- pressing_origin_x = pressing_origin_y = -1;
-
- virtio_touchscreen_event(x, y, z, 0);
-
- break;
- case MOUSE_WHEELUP:
- case MOUSE_WHEELDOWN:
- if (is_emul_input_touch_enable() == true) {
- x -= guest_x;
- y -= guest_y;
- guest_x += x;
- guest_y += y;
- } else {
- guest_x = x;
- guest_y = y;
- }
-
- virtio_touchscreen_event(x, y, -z, event_type);
-
- break;
- case MOUSE_MOVE:
- guest_x = x;
- guest_y = y;
-
- if (x != 0) {
- qemu_input_queue_rel(NULL, INPUT_AXIS_X, x);
- }
- if (y != 0) {
- qemu_input_queue_rel(NULL, INPUT_AXIS_Y, y);
- }
- qemu_input_event_sync();
-
- break;
- case PS2_DOWN:
- qemu_input_queue_btn(NULL, INPUT_BUTTON_LEFT, 1);
- qemu_input_event_sync();
-
- break;
- case PS2_UP:
- qemu_input_queue_btn(NULL, INPUT_BUTTON_LEFT, 0);
- qemu_input_event_sync();
-
- break;
- default:
- ERR("undefined mouse event type passed : %d\n", event_type);
- break;
- }
-}
-
-void do_qt_keyboard_key_event(int event_type, int keycode) {
- if (KEY_PRESSED == event_type) {
- TRACE("key pressed: %d\n", keycode);
- virtio_keyboard_event(keycode);
- } else if (KEY_RELEASED == event_type) {
- TRACE("key released: %d\n", keycode);
- virtio_keyboard_event(keycode | 0x80);
- }
-}
-
#if defined(CONFIG_JAVA_UI) && !defined(CONFIG_USE_SHM)
static void multitouch_toggle_key_checking(int event_type,
int keycode, int state_mask, int key_location)
}
}
-void do_hw_key_event(int event_type, int keycode)
-{
- TRACE("HW Key : event_type=%d, keycode=%d\n", event_type, keycode);
-
- // TODO: remove workaround
- if (runstate_check(RUN_STATE_SUSPENDED)) {
- if (KEY_PRESSED == event_type) {
- /* home key or power key is used for resume */
- if ((HARD_KEY_HOME == keycode) || (HARD_KEY_POWER == keycode)) {
- INFO("user requests system resume\n");
- resume();
-
-#ifdef CONFIG_WIN32
- Sleep(RESUME_KEY_SEND_INTERVAL);
-#else
- usleep(RESUME_KEY_SEND_INTERVAL * 1000);
-#endif
- }
- }
- }
-
- maru_hwkey_event(event_type, keycode);
-}
-
void do_scale_event(double scale_factor)
{
INFO("do_scale_event scale_factor : %lf\n", scale_factor);
/* do nothing */
}
-void do_host_kbd_enable(bool on)
-{
- INFO("host kbd enable : %d\n", on);
-
-#if defined(TARGET_ARM)
- mloop_evcmd_usbkbd(on);
-#elif defined(TARGET_I386)
- if (on) {
- do_hotplug(ATTACH_HOST_KEYBOARD, NULL, 0);
- } else {
- do_hotplug(DETACH_HOST_KEYBOARD, NULL, 0);
- }
-#endif
-}
-
void do_interpolation_enable(bool on)
{
INFO("interpolation enable : %d\n", on);
maru_display_update();
}
-void do_rotary_event(int32_t delta, int32_t type)
+void do_host_kbd_enable(bool on)
{
- TRACE("rotaty event: delta(%d), type(%d)\n", delta, type);
- maru_rotary_event(delta, type);
+ LOG_INFO("host kbd enable : %d\n", on);
+
+ if (on) {
+ do_hotplug(ATTACH_HOST_KEYBOARD, NULL, 0);
+ } else {
+ do_hotplug(DETACH_HOST_KEYBOARD, NULL, 0);
+ }
}
#include "stdint.h"
-extern int ret_hax_init;
+// HACK: for common operations
+#include "util/ui_operations.h"
-#define TIMEOUT_FOR_SHUTDOWN 10 /* seconds */
+extern int ret_hax_init;
typedef struct Framebuffer {
unsigned char* data;
double scale_factor, short rotation_type, bool blank_guide);
void do_grabbing_enable(bool on);
-void do_mouse_event(int button_type, int event_type,
- int origin_x, int origin_y, int x, int y, int z);
-void do_qt_keyboard_key_event(int event_type, int keycode);
void do_keyboard_key_event(int event_type,
int keycode, int state_mask, int key_location);
-void do_hw_key_event(int event_type, int keycode);
void do_scale_event(double scale_factor);
void do_rotation_event(int rotation_type);
void free_screenshot(Framebuffer *);
void do_open_shell(void);
-void do_host_kbd_enable(bool on);
void do_interpolation_enable(bool on);
void do_ram_dump(void);
void do_guestmemory_dump(void);
+void do_host_kbd_enable(bool on);
void request_close(void);
-
-void do_rotary_event(int32_t delta, int32_t type);
#endif /* MARUSKIN_OPERATION_H_ */
TIZEN_UI = $(SRC_PATH)/tizen/src/ui
QEMU_CFLAGS += $(QT_CFLAGS) -I$(TIZEN_UI)
+obj-$(CONFIG_QT) += qt5.o
+obj-$(CONFIG_QT) += qt5_supplement.o
+obj-$(CONFIG_QT) += xmllayoutparser.o
+
$(obj)/qrc_resource.o: $(obj)/qrc_resource.cpp
$(obj)/qrc_resource.cpp: $(TIZEN_UI)/resource/resource.qrc
rcc -name resource $< -o $@
#include "hwkeybutton.h"
extern "C" {
-#include "skin/maruskin_operation.h"
#include "emul_state.h"
+#include "util/ui_operations.h"
}
HWKeyButton::HWKeyButton(QWidget *parent, HardwareKey *hwKey, QSize size) :
#include "mainwindow.h"
extern "C" {
+#include "util/ui_operations.h"
+
+void qt5_graphic_hw_invalidate(void);
void req_set_sensor_accel_angle(int angle);
void maru_tablet_event(int event_type, int x, int y, int btn, int btn_status);
}
#include "layout/displaytype.h"
#include "input/touchscreenhelper.h"
-extern "C" {
-void qt5_graphic_hw_invalidate(void);
-}
-
enum {
TOUCH_PRESS = 1,
TOUCH_RELEASE = 2,
extern "C" {
#include "emul_state.h"
-#include "skin/maruskin_operation.h"
+#include "util/ui_operations.h"
void virtio_keyboard_event(int keycode);
}
#include "resource/ui_strings.h"
#include "mainwindow.h"
+extern "C" {
+#include "util/ui_operations.h"
+}
+
KeyboardShortcut::KeyboardShortcut(QWidget *parent) : QWidget(parent)
{
this->parent = (MainWindow *)parent;
#include <QImage>
#include <QDebug>
+#include "qt5_supplement.h"
#include "multitouchtracker.h"
#include "displaybase.h"
#include "resource/ui_strings.h"
extern "C" {
-extern void qt5_graphic_hw_update(void);
+#include "util/ui_operations.h"
+
+void qt5_graphic_hw_update(void);
// FIXME: To avoid very complex header inclusion chains
void qemu_system_graceful_shutdown_request(unsigned int sec);
}
extern "C" {
// FIXME: To avoid very complex header inclusion chains
void qemu_system_graceful_shutdown_request(unsigned int sec);
+
+#include "util/device_hotplug.h"
+#include "util/ui_operations.h"
}
ContextMenu::ContextMenu(QWidget *parent) : QMenu(parent)
{
qDebug("SDB shell");
- if (is_sdbd_initialized == 0) {
+ if (!is_sdb_daemon_initialized()) {
showMsgBox(QMessageBox::Warning, MSG_SDB_NOT_READY);
return;
}
{
qDebug("host keyboard : %s", on? "on" : "off");
- do_host_kbd_enable(on);
+ if (on) {
+ do_hotplug(ATTACH_HOST_KEYBOARD, NULL, 0);
+ } else {
+ do_hotplug(DETACH_HOST_KEYBOARD, NULL, 0);
+ }
}
void ContextMenu::slotAbout()
class MainWindow;
extern "C" {
-#include "skin/maruskin_operation.h"
-#include "skin/maruskin_server.h"
#include "emul_state.h"
+#include "util/sdb.h"
}
#define CLOSE_POWER_KEY_INTERVAL 1200 /* milli-seconds */
--- /dev/null
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2015 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 PROPERTYKEYWORD_H
+#define PROPERTYKEYWORD_H
+
+#define SKIN_PROPERTY_NAME "skin.name"
+#define SKIN_PROPERTY_WINDOW_X "window.x"
+#define SKIN_PROPERTY_WINDOW_Y "window.y"
+#define SKIN_PROPERTY_WINDOW_SCALE "window.scale"
+#define SKIN_PROPERTY_WINDOW_TOPMOST "window.ontop"
+#define SKIN_PROPERTY_CONTROLLER_INDEX "controller.index"
+#define SKIN_PROPERTY_CONTROLLER_DOCK "controller.dock"
+
+#endif // PROPERTYKEYWORD_H
--- /dev/null
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * SeokYeon Hwang <syeon.hwang@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 "ui/console.h"
+
+#include "qt5.h"
+#include "emul_state.h"
+#include "qt5_supplement.h"
+#include "hw/pci/maru_brightness.h"
+#ifdef CONFIG_DARWIN
+#include "ns_event.h"
+#endif
+
+
+#include "util/new_debug_ch.h"
+
+DECLARE_DEBUG_CHANNEL(qt5_console);
+
+static int qt5_num_outputs;
+
+// only for informing HW specification
+static int pixel_density_dpi;
+
+static struct qt5_state {
+ DisplayChangeListener dcl;
+ DisplaySurface *surface;
+
+ int idx;
+} *qt5_console;
+
+void qt5_graphic_hw_invalidate(void)
+{
+ graphic_hw_invalidate(NULL);
+}
+
+void qt5_graphic_hw_update(void)
+{
+ graphic_hw_update(NULL);
+}
+
+int qt5_graphic_hw_display(void)
+{
+ console_ch_t displayed = 0;
+ graphic_hw_text_update(NULL, &displayed);
+ return displayed;
+}
+
+static void qt5_update(DisplayChangeListener *dcl,
+ int x, int y, int w, int h)
+{
+ struct qt5_state *con = container_of(dcl, struct qt5_state, dcl);
+
+ assert(con->surface);
+
+ composite_brightness_image(con->surface->image);
+
+ qt5_update_internal(surface_data(con->surface),
+ surface_width(con->surface),
+ surface_height(con->surface));
+}
+
+static void qt5_switch(DisplayChangeListener *dcl,
+ DisplaySurface *new_surface)
+{
+ struct qt5_state *con = container_of(dcl, struct qt5_state, dcl);
+
+ if (con->surface &&
+ (surface_width(con->surface) != surface_width(new_surface) ||
+ surface_height(con->surface) != surface_height(new_surface))) {
+ // TODO: we should adjust display size.
+ // We should warn to user since we can not adjust display size now.
+ LOG_WARNING("display size is changed.\n");
+ }
+
+ con->surface = new_surface;
+
+}
+
+static void qt5_refresh(DisplayChangeListener *dcl)
+{
+ graphic_hw_update(dcl->con);
+ qt5_refresh_internal();
+}
+
+static void qt5_mouse_warp(DisplayChangeListener *dcl,
+ int x, int y, int on)
+{
+}
+
+static void qt5_mouse_define(DisplayChangeListener *dcl,
+ QEMUCursor *c)
+{
+}
+
+static const DisplayChangeListenerOps dcl_ops = {
+ .dpy_name = "qt5",
+ .dpy_gfx_update = qt5_update,
+ .dpy_gfx_switch = qt5_switch,
+ .dpy_refresh = qt5_refresh,
+ .dpy_mouse_set = qt5_mouse_warp,
+ .dpy_cursor_define = qt5_mouse_define,
+};
+
+void maru_early_qt5_display_init(bool isOnscreen)
+{
+#ifdef CONFIG_DARWIN
+ ns_run_in_event_loop_with_bool(&qt5_early_prepare, isOnscreen);
+
+ /* set emulator icon */
+#define ICON_RESOURCE_PATH "../icons/"
+#define ICON_FILE_NAME "emulator_icon.ico"
+ const int path_len = strlen(get_bin_path()) +
+ strlen(ICON_RESOURCE_PATH) + strlen(ICON_FILE_NAME) + 1;
+
+ char *icon_path = g_malloc0(sizeof(char) * path_len);
+ snprintf(icon_path, path_len, "%s%s%s",
+ get_bin_path(), ICON_RESOURCE_PATH, ICON_FILE_NAME);
+ fprintf(stdout, "application icon path : %s\n", icon_path);
+
+ set_application_icon(icon_path);
+ g_free(icon_path);
+#else
+ qt5_early_prepare(isOnscreen);
+#endif
+ if (isOnscreen) {
+ LOG_INFO("Display Type: QT5 Onscreen\n");
+ } else {
+ LOG_INFO("Display Type: QT5 Offscreen\n");
+ }
+}
+
+static void maru_qt5_display_fini(void)
+{
+ if (qt5_console) {
+ g_free(qt5_console);
+ qt5_console = NULL;
+ }
+ qt5_destroy();
+}
+
+void set_display_pixel_density(int dpi)
+{
+ pixel_density_dpi = dpi;
+}
+
+void maru_qt5_display_init(DisplayState *ds, int full_screen)
+{
+ int i;
+
+ /* prepare gui */
+#ifdef CONFIG_DARWIN
+ ns_run_in_event_loop(&qt5_prepare);
+#else
+ qt5_prepare();
+#endif
+
+ for (i = 0;; i++) {
+ QemuConsole *con = qemu_console_lookup_by_index(i);
+ if (!con || !qemu_console_is_graphic(con)) {
+ break;
+ }
+ }
+ qt5_num_outputs = i;
+ qt5_console = g_new0(struct qt5_state, qt5_num_outputs);
+ for (i = 0; i < qt5_num_outputs; i++) {
+ QemuConsole *con = qemu_console_lookup_by_index(i);
+ qt5_console[i].dcl.ops = &dcl_ops;
+ qt5_console[i].dcl.con = con;
+ register_displaychangelistener(&qt5_console[i].dcl);
+ qt5_console[i].idx = i;
+ }
+
+ if (full_screen) {
+ /* TODO */
+ }
+ atexit(maru_qt5_display_fini);
+
+ /* TODO
+ mouse_mode_notifier.notify = qt2_mouse_mode_change;
+ qemu_add_mouse_mode_change_notifier(&mouse_mode_notifier);
+ */
+
+ /* TODO: cursor control */
+}
--- /dev/null
+/*
+ * QT5 display driver
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@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 __QT5_H__
+#define __QT5_H__
+
+#include <stdbool.h>
+
+#include "sysemu/sysemu.h"
+
+void maru_early_qt5_display_init(bool isOnscreen);
+void maru_qt5_display_init(DisplayState *ds, int full_screen);
+
+void set_display_pixel_density(int dpi);
+
+#endif // __QT5_H__
--- /dev/null
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@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 <QApplication>
+
+#include "qt5_supplement.h"
+#include "propertykeyword.h"
+#include "mainwindow.h"
+#include "layout/hardwarekey.h"
+#include "xmllayoutparser.h"
+#include "uiutil.h"
+#include "resource/ui_strings.h"
+#include "displaybase.h"
+
+extern "C" {
+#include "emul_state.h"
+int qemu_get_thread_id(void);
+bool is_display_off(void);
+}
+
+//using namespace std;
+void qMessageOutput(QtMsgType, const QMessageLogContext &, const QString &);
+void loadMainFormFromXML(QFile *, UIInformation *);
+void loadConFormFromXML(QFile *, UIInformation *);
+
+bool qt5IsOnscreen;
+QApplication *qt5App = NULL;
+
+static int argc = 0;
+static char *argv[0];
+
+#define MAX_BLANK_FRAME_CNT 10
+static unsigned int blank_cnt;
+
+static void *captureRequestListener;
+static void (*captureRequestHandler)(void *);
+
+static MainWindow *mainwindow;
+static UIInformation *uiInfo;
+
+#define GUI_PROPERTIES_FILE_NAME "gui.property"
+#define SKIN_INFO_FILE_NAME "info.ini"
+#define FORM_FILE_NAME "layout.xml"
+#define CON_FORM_SUBPATH "controller"
+
+class ConFile {
+public:
+ QFile *formFile;
+ int priority;
+};
+
+#ifdef CONFIG_WIN32
+class EventFilter : public QAbstractNativeEventFilter
+{
+public:
+ virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *res) Q_DECL_OVERRIDE;
+};
+
+EventFilter *eventFilter = NULL;
+
+bool EventFilter::nativeEventFilter(const QByteArray &eventType, void *message, long *res)
+{
+ if (eventType == "windows_generic_MSG") {
+ MSG *msg = static_cast<MSG *>(message);
+ if (msg->message == WM_ERASEBKGND) {
+ qt5_graphic_hw_invalidate();
+ }
+ }
+
+ return false;
+}
+#endif
+
+void qt5_gui_init(void)
+{
+ QCoreApplication::setApplicationName("Tizen Emulator");
+
+ qDebug() << "* Qt version :" << QT_VERSION_STR;
+ qDebug() << "* working path :" << QDir::currentPath();
+ qDebug() << "* binary path :" << QCoreApplication::applicationDirPath();
+
+ uiInfo = new UIInformation();
+
+ /* parameter parsing */
+ // TODO:
+
+ uiInfo->vmName = QString(get_vm_name()).trimmed();
+ qDebug() << "VM name :" << uiInfo->vmName;
+
+ uiInfo->resolution.setWidth(get_display_resolution_width());
+ uiInfo->resolution.setHeight(get_display_resolution_height());
+ uiInfo->basePort = get_emul_vm_base_port();
+
+ uiInfo->vmDataPath = QDir(get_vm_data_path()).canonicalPath();
+ if (uiInfo->vmDataPath.endsWith(QDir::separator()) == false) {
+ uiInfo->vmDataPath += QDir::separator();
+ }
+ qDebug() << "VM path :" << uiInfo->vmDataPath;
+
+ uiInfo->skinPath = QDir(get_emul_skin_path()).canonicalPath();
+ if (uiInfo->skinPath.endsWith(QDir::separator()) == false) {
+ uiInfo->skinPath += QDir::separator();
+ }
+ qDebug() << "skin path :" << uiInfo->skinPath;
+
+ /* read skin information */
+ QSettings skinInfo(uiInfo->skinPath + SKIN_INFO_FILE_NAME,
+ QSettings::IniFormat);
+ QString skinName = skinInfo.value(SKIN_PROPERTY_NAME).toString();
+ if (skinName.isEmpty() == true) {
+ skinName = "Undefined";
+ }
+ uiInfo->skinName = skinName;
+
+ /* open most recently used data information file */
+ QFile::remove(uiInfo->vmDataPath + GUI_PROPERTIES_FILE_NAME + ".lock");
+ const QSettings mruInfo(
+ uiInfo->vmDataPath + GUI_PROPERTIES_FILE_NAME, QSettings::IniFormat);
+
+ /* XML layout */
+ QFile mainXMLFile(uiInfo->skinPath + FORM_FILE_NAME);
+ /* load main form */
+ loadMainFormFromXML(&mainXMLFile, uiInfo);
+
+ QDir skinDir(uiInfo->skinPath + CON_FORM_SUBPATH);
+ /* load controller forms */
+ QFileInfoList entries = skinDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
+
+ if (entries.isEmpty() == false) {
+ /* sort by priority */
+ QList<ConFile *> conFileList;
+
+ for (int i = 0; i < entries.size(); i++) {
+ ConFile *conFile = new ConFile();
+
+ QString conPath = entries.at(i).filePath() + QDir::separator();
+ conFile->formFile = new QFile(conPath + FORM_FILE_NAME);
+ QSettings conInfo(conPath + SKIN_INFO_FILE_NAME, QSettings::IniFormat);
+ conFile->priority = conInfo.value("priority").toInt();
+
+ int j = 0;
+ for ( ; j < conFileList.size(); j++) {
+ if (conFileList.at(j)->priority > conFile->priority) {
+ break;
+ }
+ }
+ conFileList.insert(j, conFile);
+ }
+
+ /* loading */
+ for (int i = 0; i < conFileList.size(); i++) {
+ loadConFormFromXML(conFileList.at(i)->formFile, uiInfo);
+ delete conFileList.at(i)->formFile;
+ delete conFileList.at(i);
+ }
+ }
+
+ /* default scale */
+ int scale = mruInfo.value(SKIN_PROPERTY_WINDOW_SCALE).toInt();
+ qDebug("previous scale value is %d", scale);
+
+ if (scale <= 0) {
+ scale = 100;
+
+ MenuItem *item = NULL;
+ for (int i = 0; i < uiInfo->menuList.count(); i++) {
+ item = uiInfo->menuList.at(i);
+ if (item->getType() == MenuItemType::scaleItem) {
+ ScaleMenuItem *scaleItem = (ScaleMenuItem *)item;
+ if (scaleItem->getDefaultScaleFactor() > 0) {
+ scale = scaleItem->getDefaultScaleFactor();
+ }
+ }
+ }
+ }
+ uiInfo->uiState.mainFormScale = scale;
+ qDebug("default scale value is %d", uiInfo->uiState.mainFormScale);
+
+ /* GUI */
+ qDebug("start!");
+
+ mainwindow = new MainWindow(uiInfo);
+ mainwindow->setCaptureRequestHandler(captureRequestListener, captureRequestHandler);
+
+ /* position */
+ QRect hostBounds = UIUtil::getHostScreenBounds();
+ qDebug() << "host geometry :" << hostBounds;
+
+ 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) {
+ mainwindow->setTopMost(true);
+ }
+
+ /* controller */
+ const int defaultDockPos = Qt::AlignRight | Qt::AlignCenter;
+ mainwindow->getUIState()->conState.recentlyDockPos = defaultDockPos;
+
+ int conIndex = mruInfo.value(SKIN_PROPERTY_CONTROLLER_INDEX).toInt();
+ if (conIndex >= 0 && conIndex < uiInfo->conFormList.count()) {
+ int conDockPos = mruInfo.value(SKIN_PROPERTY_CONTROLLER_DOCK).toInt();
+ if (conDockPos <= 0) {
+ conDockPos = defaultDockPos;
+ }
+
+ mainwindow->openController(conIndex, conDockPos);
+ }
+
+ mainwindow->show();
+
+#ifdef CONFIG_WIN32
+ /* W/A: Sometimes, QGrahpicsItem's update() does not work with QGLWidget
+ * on Windows Aero theme. We need to indirectly repaint the items
+ * through these lines. */
+ const QSize viewSize = uiInfo->getUiSize();
+ mainwindow->getSkinView()->resize(viewSize / 2);
+ mainwindow->getSkinView()->resize(viewSize);
+#endif
+
+ mainwindow->startDisplaySwapper();
+}
+
+void qt5_destroy()
+{
+ qDebug("qt5 destroy");
+
+ /* write most recently used data information */
+ QString path(uiInfo->vmDataPath + GUI_PROPERTIES_FILE_NAME);
+ qDebug() << "save MRU data:" << path;
+
+ QSettings mruInfo(path, QSettings::IniFormat);
+ mruInfo.setValue(SKIN_PROPERTY_WINDOW_X, mainwindow->pos().x());
+ mruInfo.setValue(SKIN_PROPERTY_WINDOW_Y, mainwindow->pos().y());
+ mruInfo.setValue(SKIN_PROPERTY_WINDOW_SCALE, uiInfo->uiState.mainFormScale);
+ mruInfo.setValue(SKIN_PROPERTY_WINDOW_TOPMOST, uiInfo->uiState.isOnTop());
+ mruInfo.setValue(SKIN_PROPERTY_CONTROLLER_INDEX, uiInfo->uiState.conState.conFormIndex);
+
+ DockingController *con = uiInfo->uiState.conState.dockingCon;
+ if (con != NULL) {
+ mruInfo.setValue(SKIN_PROPERTY_CONTROLLER_DOCK, con->getDockPos());
+ } else {
+ mruInfo.setValue(SKIN_PROPERTY_CONTROLLER_DOCK, 0);
+ }
+
+ mruInfo.sync();
+
+ /* clean up */
+#ifdef CONFIG_WIN32
+ delete eventFilter;
+#endif
+ qt5App->flush();
+
+ mainwindow->closeController();
+ mainwindow->terminateDisplaySwapper();
+
+ qt5App->processEvents(QEventLoop::ExcludeUserInputEvents);
+ qt5App->quit();
+
+ //TODO: fix me
+ //delete mainwindow;
+
+ if (uiInfo) {
+ delete uiInfo;
+ uiInfo = NULL;
+ }
+}
+
+void qt5_early_prepare(bool isOnscreen)
+{
+ qt5IsOnscreen = isOnscreen;
+
+ Q_INIT_RESOURCE(resource);
+
+#ifdef CONFIG_LINUX
+ /* QGLWidget threading: Note that under X11 it is necessary to set the
+ * Qt::AA_X11InitThreads application attribute to make the X11 library
+ * and GLX calls thread safe, otherwise the above scenarios will fail. */
+
+ /* Calls XInitThreads() as part of the QApplication construction in order
+ * to make Xlib calls thread-safe. This attribute must be set before
+ * QApplication is constructed. */
+ QCoreApplication::setAttribute(Qt::AA_X11InitThreads);
+#endif
+
+ qt5App = new QApplication(argc, argv);
+
+ /* add the path in the application's main() function, right after the
+ * QApplication object is created */
+ qt5App->addLibraryPath(QDir::currentPath()); //TODO: consider a symbolic link
+
+ qInstallMessageHandler(qMessageOutput);
+
+ qDebug() << "* Qt plugin library path:" << QCoreApplication::libraryPaths();
+
+#ifdef CONFIG_WIN32
+ eventFilter = new EventFilter();
+ qt5App->installNativeEventFilter(eventFilter);
+#endif
+}
+
+void qt5_prepare(void)
+{
+ qt5_gui_init();
+}
+
+void qt5_update_internal(void *data, int width, int height)
+{
+ QImage image((uchar *)data, width, height, QImage::Format_RGB32);
+
+ mainwindow->getScreenWidget()->setPixmap(
+ QPixmap::fromImage(image.transformed(
+ mainwindow->getDisplayMatrix(), Qt::SmoothTransformation)));
+}
+
+void qt5_switch_internal(void)
+{
+ /* do nothing */
+}
+
+void qt5_refresh_internal(void)
+{
+ qt5App->processEvents();
+
+ DisplayBase *db = mainwindow->getDisplay();
+ if (db) {
+ if (db->getIsGimgReady()) {
+ if (is_display_off()) {
+ if (db->getGimgState() == false) {
+ if (blank_cnt > MAX_BLANK_FRAME_CNT) {
+ db->startGuideImg();
+ blank_cnt = 0;
+ } else {
+ blank_cnt++;
+ }
+ }
+ } else {
+ if (db->getGimgState() == true) {
+ db->stopGuideImg();
+ }
+
+ blank_cnt = 0;
+ }
+ }
+ } else {
+ qDebug() << "Display is not ready.";
+ }
+}
+
+void qt5_register_capture_request_listener(void *listener, void (*handler)(void *))
+{
+ if (mainwindow) {
+ mainwindow->setCaptureRequestHandler(listener, handler);
+ }
+
+ captureRequestListener = listener;
+ captureRequestHandler = handler;
+}
+
+void qt5_unregister_capture_request_listener(void *listener)
+{
+ if (mainwindow) {
+ mainwindow->unsetCaptureRequestHandler(listener);
+ }
+
+ captureRequestListener = NULL;
+ captureRequestHandler = NULL;
+}
+
+void qt5_process_captured(bool captured, void *pixels, int width, int height)
+{
+ if (mainwindow) {
+ mainwindow->processCaptured(captured, pixels, width, height);
+ }
+}
+
+void qMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
+{
+ QByteArray localMsg = msg.toLocal8Bit();
+ QByteArray dateMsg = QDateTime::currentDateTime().toString("hh:mm:ss.zzz").toLocal8Bit();
+
+ QString path = context.file;
+ char *fname = NULL;
+ int posFname = path.lastIndexOf('/') + 1;
+ int posDot = path.lastIndexOf('.');
+
+ if (( posFname != 0 ) && ( posDot != -1)) {
+ int fnameLen = path.length() - posFname;
+ path = path.right(fnameLen);
+ fnameLen = posDot - posFname;
+ path.truncate(fnameLen);
+ }
+ fname = path.toLocal8Bit().data();
+
+ switch (type) {
+ case QtDebugMsg:
+ fprintf(stdout, "%s|%5d|I|%10.10s|%4u|%s\n", dateMsg.constData(),
+ qemu_get_thread_id(), fname, context.line,
+ localMsg.trimmed().constData());
+ break;
+ case QtWarningMsg:
+ fprintf(stdout, "%s|%5d|W|%10.10s|%4u|%s\n", dateMsg.constData(),
+ qemu_get_thread_id(), fname, context.line,
+ localMsg.trimmed().constData());
+ break;
+ case QtCriticalMsg:
+ fprintf(stderr, "%s|%5d|S|%10.10s|%4u|%s\n", dateMsg.constData(),
+ qemu_get_thread_id(), fname, context.line,
+ localMsg.trimmed().constData());
+ break;
+ case QtFatalMsg:
+ fprintf(stderr, "%s|%5d|S|%10.10s|%4u|%s\n", dateMsg.constData(),
+ qemu_get_thread_id(), fname, context.line,
+ localMsg.trimmed().constData());
+
+ QString err;
+ QMessageBox::critical(0, EMULATOR_TITLE,
+ QString(MSG_INTERNAL_ERR) +
+ err.sprintf("%s", (localMsg.trimmed()).constData()) +
+ MSG_EMULATOR_EXIT);
+ abort();
+ }
+}
+
+void loadMainFormFromXML(QFile *file, UIInformation *uiInfo/* out */)
+{
+ if (file->exists() == false) {
+ qFatal("%s %s", qPrintable(file->fileName()), MSG_NOT_FOUND);
+ return;
+ }
+
+ if (!file->open(QIODevice::ReadOnly | QIODevice::Text)) {
+ qFatal("%s %s %s", MSG_NOT_OPEN_1, qPrintable(file->fileName()), MSG_NOT_OPEN_2);
+ return;
+ }
+
+ qDebug("main form is loaded from %s", qPrintable(file->fileName()));
+
+ /* read xml */
+ QFileInfo fileInfo(*file);
+ QXmlStreamReader xml(file);
+
+ /* parse xml */
+ XmlLayoutParser parser(fileInfo.absolutePath(), uiInfo);
+ QString version = parser.parseEmulatorUI(xml);
+ qDebug() << "layout version :" << version;
+
+ const bool hasError = xml.hasError();
+ xml.clear();
+ file->close();
+
+ if (hasError == true) {
+ qFatal(MSG_INVALID_XML_FORMAT);
+ return;
+ }
+}
+
+void loadConFormFromXML(QFile *file, UIInformation *uiInfo/* out */)
+{
+ if (file->exists() == false) {
+ qWarning("%s is not found", qPrintable(file->fileName()));
+ return;
+ }
+
+ if (!file->open(QIODevice::ReadOnly | QIODevice::Text)) {
+ qFatal("%s %s %s", MSG_NOT_OPEN_1, qPrintable(file->fileName()), MSG_NOT_OPEN_2);
+ return;
+ }
+
+ qDebug("controller form is loaded from %s", qPrintable(file->fileName()));
+
+ /* read xml */
+ QFileInfo fileInfo(*file);
+ QXmlStreamReader xml(file);
+
+ /* parse xml */
+ XmlLayoutParser parser(fileInfo.absolutePath(), uiInfo);
+ QString version = parser.parseControllerUI(xml);
+ qDebug() << "layout version :" << version;
+
+ const bool hasError = xml.hasError();
+ xml.clear();
+ file->close();
+
+ if (hasError == true) {
+ qFatal(MSG_INVALID_XML_FORMAT);
+ return;
+ }
+}
--- /dev/null
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@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 __QT5_INTERNAL_H__
+#define __QT5_INTERNAL_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+void qt5_graphic_hw_invalidate(void);
+void qt5_graphic_hw_update(void);
+int qt5_graphic_hw_display(void);
+void qt5_early_prepare(bool isOnscreen);
+void qt5_prepare(void);
+void qt5_destroy(void);
+
+void qt5_update_internal(void *data, int width, int height);
+void qt5_switch_internal(void);
+void qt5_refresh_internal(void);
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __QT5_INTERNAL_H__
#include "rotaryview.h"
#include "mainwindow.h"
+extern "C" {
+#include "util/ui_operations.h"
+}
+
#define ROTARY_DRAWING_INTERVAL 100
RotaryView::RotaryView(QWidget *parent) :
#include "skinbezelitem.h"
+extern "C" {
+#include "util/ui_operations.h"
+#include "emul_state.h"
+}
+
SkinBezelItem::SkinBezelItem(QImage bezelImg, QGraphicsItem *parent) :
QGraphicsPixmapItem(QPixmap::fromImage(bezelImg), parent)
{
#include "skinkeyitem.h"
+extern "C" {
+#include "emul_state.h"
+#include "util/ui_operations.h"
+}
+
SkinKeyItem::SkinKeyItem(SkinBezelItem *parent,
HardwareKey *hwKey, QImage pressedImg, HoverType *hover) :
QGraphicsRectItem(hwKey->getRegion(), (QGraphicsItem *)parent)
#include "layout/hardwarekey.h"
#include "layout/hovertype.h"
-extern "C" {
-#include "skin/maruskin_operation.h"
-#include "emul_state.h"
-}
-
class SkinKeyItem : public QObject, public QGraphicsRectItem
{
Q_OBJECT
--- /dev/null
+/*
+ * 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 XMLLAYOUTKEYWORD_H
+#define XMLLAYOUTKEYWORD_H
+
+#define NAME_ATTR_KEYWORD "name"
+#define PROP_ATTR_KEYWORD "property"
+#define DEFAULT_ATTR_KEYWORD "default"
+#define COLOR_RED_ATTR_KEYWORD "R"
+#define COLOR_GREEN_ATTR_KEYWORD "G"
+#define COLOR_BLUE_ATTR_KEYWORD "B"
+#define REGION_LEFT_ATTR_KEYWORD "left"
+#define REGION_TOP_ATTR_KEYWORD "top"
+#define REGION_WIDTH_ATTR_KEYWORD "width"
+#define REGION_HEIGHT_ATTR_KEYWORD "height"
+#define KEYCODE_LONGPRESS_ATTR_KEYWORD "longPress"
+
+#define EMULATOR_UI_KEYWORD "EmulatorUI"
+#define CONTROLLER_UI_KEYWORD "ControllerUI"
+#define LAYOUTVER_KEYWORD "layoutVersion"
+#define COLOR_KEYWORD "color"
+#define REGION_KEYWORD "region"
+#define ANGLE_KEYWORD "angle"
+#define DISPLAY_KEYWORD "display"
+#define NORMAL_IMG_KEYWORD "normalImage"
+#define PRESSED_IMG_KEYWORD "pressedImage"
+#define MASK_IMG_KEYWORD "maskImage"
+#define ROTARY_IMG_KEYWORD "rotaryImage"
+#define KEYLIST_KEYWORD "keyList"
+#define KEY_KEYWORD "key"
+#define KEYCODE_KEYWORD "keycode"
+#define TOOLTIP_KEYWORD "tooltip"
+#define SHORTCUT_KEYWORD "shortcut"
+#define HOVER_KEYWORD "hover"
+#define FACTORLIST_KEYWORD "factorList"
+#define FACTOR_KEYWORD "factor"
+#define FORM_KEYWORD "form"
+#define FORMLIST_KEYWORD "formList"
+#define SHORTCUT_KEYWORD "shortcut"
+#define MENULIST_KEYWORD "menuList"
+
+#define SEPARATOR_MENU_KEYWORD "separator"
+#define ADVANCED_MENU_KEYWORD "advancedItem"
+#define INFO_MENU_KEYWORD "infoItem"
+#define ONTOP_MENU_KEYWORD "onTopItem"
+#define SWITCH_MENU_KEYWORD "switchItem"
+#define SCALE_MENU_KEYWORD "scaleItem"
+#define CONTROLLER_MENU_KEYWORD "controllerItem"
+#define HOSTKBD_MENU_KEYWORD "hostKeyboardItem"
+#define SHELL_MENU_KEYWORD "shellItem"
+#define ECP_MENU_KEYWORD "controlPanelItem"
+#define SCREENSHOT_MENU_KEYWORD "screenShotItem"
+#define ABOUT_MENU_KEYWORD "aboutItem"
+#define FORCECLOSE_MENU_KEYWORD "forceCloseItem"
+#define CLOSE_MENU_KEYWORD "closeItem"
+
+#endif // XMLLAYOUTKEYWORD_H
--- /dev/null
+/*
+ * 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 "xmllayoutparser.h"
+#include "xmllayoutkeyword.h"
+#include "skinpainter.h"
+#include "layout/keycodetype.h"
+#include "controller/generalpurposecon.h"
+
+/* Qt Qlayout has a minimum size */
+#define QT_LAYOUT_MINIMUM (73)
+
+XmlLayoutParser::XmlLayoutParser(QString path, UIInformation *uiInfo)
+{
+ this->xmlPath = path;
+ this->uiInfo = uiInfo;
+}
+
+QColor XmlLayoutParser::parseColor(QXmlStreamReader &xml)
+{
+ int red = 0, green = 0, blue = 0;
+
+ if (xml.name() == COLOR_KEYWORD &&
+ xml.tokenType() == QXmlStreamReader::StartElement) {
+ QXmlStreamAttributes attributes = xml.attributes();
+
+ if (attributes.hasAttribute(COLOR_RED_ATTR_KEYWORD)) {
+ red = attributes.value(COLOR_RED_ATTR_KEYWORD).toString().toInt();
+ qDebug() << red;
+ }
+ if (attributes.hasAttribute(COLOR_GREEN_ATTR_KEYWORD)) {
+ green = attributes.value(COLOR_GREEN_ATTR_KEYWORD).toString().toInt();
+ qDebug() << green;
+ }
+ if (attributes.hasAttribute(COLOR_BLUE_ATTR_KEYWORD)) {
+ blue = attributes.value(COLOR_BLUE_ATTR_KEYWORD).toString().toUInt();
+ qDebug() << blue;
+ }
+ }
+
+ return QColor(red, green, blue, 255);
+}
+
+HoverType *XmlLayoutParser::parseHover(QXmlStreamReader &xml)
+{
+ QColor color;
+
+ QXmlStreamReader::TokenType token = xml.readNext();
+
+ while (xml.atEnd() == false && (xml.name() == HOVER_KEYWORD &&
+ token == QXmlStreamReader::EndElement) == false) /* ~ </hover> */
+ {
+ if (token == QXmlStreamReader::StartElement) {
+ if (xml.name() == COLOR_KEYWORD) {
+ /* color */
+ color = parseColor(xml);
+ qDebug() << "hover color :" << color;
+ }
+ }
+
+ token = xml.readNext();
+ }
+
+ return new HoverType(color);
+}
+
+QRect XmlLayoutParser::parseRegion(QXmlStreamReader &xml)
+{
+ int left = 0, top = 0;
+ unsigned int width = 0, height = 0;
+
+ if (xml.name() == REGION_KEYWORD &&
+ xml.tokenType() == QXmlStreamReader::StartElement) {
+ QXmlStreamAttributes attributes = xml.attributes();
+
+ if (attributes.hasAttribute(REGION_LEFT_ATTR_KEYWORD)) {
+ left = attributes.value(REGION_LEFT_ATTR_KEYWORD).toString().toInt();
+ }
+ if (attributes.hasAttribute(REGION_TOP_ATTR_KEYWORD)) {
+ top = attributes.value(REGION_TOP_ATTR_KEYWORD).toString().toInt();
+ }
+ if (attributes.hasAttribute(REGION_WIDTH_ATTR_KEYWORD)) {
+ width = attributes.value(REGION_WIDTH_ATTR_KEYWORD).toString().toUInt();
+ }
+ if (attributes.hasAttribute(REGION_HEIGHT_ATTR_KEYWORD)) {
+ height = attributes.value(REGION_HEIGHT_ATTR_KEYWORD).toString().toUInt();
+ }
+ }
+
+ return QRect(left, top, width, height);
+}
+
+DisplayType *XmlLayoutParser::parseDisplay(QXmlStreamReader &xml)
+{
+ QRect displayRect;
+ int angle = 0;
+ QPixmap maskImage;
+
+ qDebug() << "**" << DISPLAY_KEYWORD << "{";
+
+ QXmlStreamReader::TokenType token = xml.readNext();
+
+ while (xml.atEnd() == false && (xml.name() == DISPLAY_KEYWORD &&
+ token == QXmlStreamReader::EndElement) == false) /* ~ </display> */
+ {
+ if (token == QXmlStreamReader::StartElement) {
+ if (xml.name() == REGION_KEYWORD) {
+ /* region */
+ displayRect = parseRegion(xml);
+ qDebug("- rect : (%d,%d %dx%d)",
+ displayRect.x(), displayRect.y(),
+ displayRect.width(), displayRect.height());
+ } else if (xml.name() == ANGLE_KEYWORD) {
+ /* angle */
+ angle = xml.readElementText().toInt();
+ } else if (xml.name() == MASK_IMG_KEYWORD) {
+ /* display mask */
+ QString maskImageFileName = xml.readElementText();
+ qDebug() << "-" << MASK_IMG_KEYWORD << ":" << maskImageFileName;
+
+ if (maskImage.load(
+ xmlPath + QDir::separator() + maskImageFileName) == false) {
+ qWarning() << "failed to load mask image";
+ }
+ }
+ }
+
+ token = xml.readNext();
+ }
+
+ qDebug("** }");
+
+ return new DisplayType(displayRect, angle, maskImage);
+}
+
+KeycodeType *XmlLayoutParser::parseKeycode(QXmlStreamReader &xml)
+{
+ int longPress = -1, shortPress = 0;
+
+ /* attribute */
+ longPress = xml.attributes().value(KEYCODE_LONGPRESS_ATTR_KEYWORD).toString().toInt();
+
+ shortPress = xml.readElementText().toInt();
+
+ return new KeycodeType(shortPress, longPress);
+}
+
+HardwareKey *XmlLayoutParser::parseKey(QXmlStreamReader &xml)
+{
+ QRect keyRegion;
+ KeycodeType *keycodeType = NULL;
+ QString keyTooptip;
+ QString keySequence;
+
+ /* attribute */
+ QString keyName = xml.attributes().value(NAME_ATTR_KEYWORD).toString();
+
+ QXmlStreamReader::TokenType token = xml.readNext();
+
+ while (xml.atEnd() == false && (xml.name() == KEY_KEYWORD &&
+ token == QXmlStreamReader::EndElement) == false) /* ~ </key> */
+ {
+ if (token == QXmlStreamReader::StartElement) {
+ if (xml.name() == REGION_KEYWORD) {
+ /* region */
+ keyRegion = parseRegion(xml);
+ } else if (xml.name() == KEYCODE_KEYWORD) {
+ /* keycode */
+ keycodeType = parseKeycode(xml);
+ } else if (xml.name() == TOOLTIP_KEYWORD) {
+ /* tooltip */
+ keyTooptip = xml.readElementText();
+ } else if (xml.name() == SHORTCUT_KEYWORD) {
+ /* shortcut */
+ keySequence = xml.readElementText();
+ }
+ }
+
+ token = xml.readNext();
+ }
+
+ return new HardwareKey(keyName, keycodeType, keyRegion, keyTooptip, keySequence);
+}
+
+int XmlLayoutParser::parseKeyList(
+ QXmlStreamReader &xml, QList<HardwareKey *> &list)
+{
+ HardwareKey *hwKey = NULL;
+ QXmlStreamReader::TokenType token = xml.readNext();
+
+ while (xml.atEnd() == false && (xml.name() == KEYLIST_KEYWORD &&
+ token == QXmlStreamReader::EndElement) == false) /* ~ </keyList> */
+ {
+ if (token == QXmlStreamReader::StartElement) {
+ if (xml.name() == KEY_KEYWORD) {
+ hwKey = parseKey(xml);
+ if (hwKey != NULL) {
+ list.append(hwKey);
+ }
+ }
+ }
+
+ token = xml.readNext();
+ }
+
+ return list.count();
+}
+
+MainForm *XmlLayoutParser::parseMainForm(QXmlStreamReader &xml)
+{
+ /* attribute */
+ QString formName = xml.attributes().value(NAME_ATTR_KEYWORD).toString();
+ MainForm *form = new MainForm(formName);
+
+ qDebug() << '*' << form->getName() << '{';
+
+ QXmlStreamReader::TokenType token = xml.readNext();
+
+ while (xml.atEnd() == false && (xml.name() == FORM_KEYWORD &&
+ token == QXmlStreamReader::EndElement) == false) /* ~ </form> */
+ {
+ if (token == QXmlStreamReader::StartElement) {
+ if (xml.name() == DISPLAY_KEYWORD) {
+ /* display */
+ form->displayType = parseDisplay(xml);
+ } else if (xml.name() == NORMAL_IMG_KEYWORD) {
+ /* normal image */
+ QString normalImageFileName = xml.readElementText();
+ qDebug() << "-" << NORMAL_IMG_KEYWORD << ":" << normalImageFileName;
+
+ if (form->skinImg[MainForm::normal].load(
+ xmlPath + QDir::separator() + normalImageFileName) == false) {
+ qWarning() << "failed to load normal image";
+ }
+ } else if (xml.name() == PRESSED_IMG_KEYWORD) {
+ /* key pressed image */
+ QString pressedImageFileName = xml.readElementText();
+ qDebug() << "-" << PRESSED_IMG_KEYWORD << ":" << pressedImageFileName;
+
+ if (form->skinImg[MainForm::pressed].load(
+ xmlPath + QDir::separator() + pressedImageFileName) == false) {
+ qWarning() << "failed to load pressed image";
+ }
+ } else if (xml.name() == ROTARY_IMG_KEYWORD) {
+ /* rotary image */
+ QString rotaryImageFileName = xml.readElementText();
+ qDebug() << "-" << ROTARY_IMG_KEYWORD << ":" << rotaryImageFileName;
+
+ form->setRotaryImage(new QPixmap(
+ xmlPath + QDir::separator() + rotaryImageFileName));
+ if (form->getRotaryImage()->isNull() == true) {
+ qWarning() << "failed to load rotary image";
+ }
+ } else if (xml.name() == KEYLIST_KEYWORD) {
+ /* HW keys */
+ int cnt = parseKeyList(xml, form->keyList);
+ qDebug() << "-" << KEYLIST_KEYWORD << ":" << cnt;
+ } else {
+ qWarning() << "undefined element :" << xml.name();
+ }
+ }
+
+ token = xml.readNext();
+ }
+
+ qDebug("}");
+
+ return form;
+}
+
+int XmlLayoutParser::parseMainFormList(
+ QXmlStreamReader &xml, QList<MainForm *> &list)
+{
+ MainForm *form = NULL;
+ QXmlStreamReader::TokenType token = xml.readNext();
+
+ while (xml.atEnd() == false && (xml.name() == FORMLIST_KEYWORD &&
+ token == QXmlStreamReader::EndElement) == false) /* ~ </formList> */
+ {
+ if (token == QXmlStreamReader::StartElement) {
+ if (xml.name() == FORM_KEYWORD) {
+ form = parseMainForm(xml);
+ if (form != NULL) {
+ /* image validation */
+ if (form->skinImg[MainForm::normal].size() == QSize(0, 0)) {
+ qDebug("- general purpose skin form");
+
+ SkinPainter painter("main-skin",
+ uiInfo->resolution, form->displayType->getAngle(),
+ QPoint(30, 16), uiInfo->getVMColor());
+ form->setGeneralPurpose(true);
+
+ form->skinImg[MainForm::normal] = painter.getSkinImage();
+ form->displayType->setRect(painter.getCenterRect());
+ }
+
+ list.append(form);
+ }
+ }
+ }
+
+ token = xml.readNext();
+ }
+
+ return list.count();
+}
+
+/* menu */
+int XmlLayoutParser::parseFactorList(
+ QXmlStreamReader &xml, QMap<int, QString> &map, int *defaultFactor)
+{
+ QString defaultValue = xml.attributes().value(DEFAULT_ATTR_KEYWORD).toString();
+ *defaultFactor = defaultValue.toInt();
+
+ QXmlStreamReader::TokenType token = xml.readNext();
+
+ while (xml.atEnd() == false && (xml.name() == "factorList" &&
+ token == QXmlStreamReader::EndElement) == false) /* ~ </factorList> */
+ {
+ if (token == QXmlStreamReader::StartElement) {
+ if (xml.name() == FACTOR_KEYWORD) {
+ QString value = xml.attributes().value(NAME_ATTR_KEYWORD).toString();
+ map.insert(xml.readElementText().toInt(), value);
+ }
+ }
+
+ token = xml.readNext();
+ }
+
+ return map.count();
+}
+
+int XmlLayoutParser::parseShortcut(
+ QXmlStreamReader &xml, QMap<QString, QString> &map)
+{
+ QString key = xml.attributes().value(PROP_ATTR_KEYWORD).toString();
+ map.insert(key, xml.readElementText());
+
+ return map.count();
+}
+
+AdvancedMenuItem *XmlLayoutParser::parseAdvancedMenuItem(QXmlStreamReader &xml)
+{
+ /* attribute */
+ QString menuName = xml.attributes().value(NAME_ATTR_KEYWORD).toString();
+ AdvancedMenuItem *item = new AdvancedMenuItem(menuName);
+
+ QXmlStreamReader::TokenType token = xml.readNext();
+
+ while (xml.atEnd() == false && (xml.name() == "advancedItem" &&
+ token == QXmlStreamReader::EndElement) == false) /* ~ </advancedItem> */
+ {
+ if (token == QXmlStreamReader::StartElement) {
+ if (xml.name() == SHORTCUT_KEYWORD) {
+ parseShortcut(xml, item->getShortcutMap());
+ } else if (xml.name() == MENULIST_KEYWORD) {
+ int cnt = parseMenuList(xml, item->getMenuList());
+ qDebug("- advanced menuList : %d", cnt);
+ }
+ }
+
+ token = xml.readNext();
+ }
+
+ return item;
+}
+
+ScaleMenuItem *XmlLayoutParser::parseScaleMenuItem(QXmlStreamReader &xml)
+{
+ /* attribute */
+ QString menuName = xml.attributes().value(NAME_ATTR_KEYWORD).toString();
+ ScaleMenuItem *item = new ScaleMenuItem(menuName);
+
+ QXmlStreamReader::TokenType token = xml.readNext();
+
+ while (xml.atEnd() == false && (xml.name() == "scaleItem" &&
+ token == QXmlStreamReader::EndElement) == false) /* ~ </scaleItem> */
+ {
+ if (token == QXmlStreamReader::StartElement) {
+ if (xml.name() == SHORTCUT_KEYWORD) {
+ parseShortcut(xml, item->getShortcutMap());
+ } else if (xml.name() == FACTORLIST_KEYWORD) {
+ int defaultFactor = 0;
+ int cnt = parseFactorList(xml, item->getFactorMap(), &defaultFactor);
+ qDebug("- scale factorList : %d", cnt);
+
+ item->setDefaultScaleFactor(defaultFactor);
+ }
+ }
+
+ token = xml.readNext();
+ }
+
+ return item;
+}
+
+MenuItem *XmlLayoutParser::parseGeneralMenuItem(
+ QXmlStreamReader &xml, int menuType)
+{
+ QString itemKeyword = xml.name().toString();
+
+ /* attribute */
+ QString menuName = xml.attributes().value(NAME_ATTR_KEYWORD).toString();
+ MenuItem *item = new MenuItem(menuType, menuName);
+
+ QString shortcut;
+ QXmlStreamReader::TokenType token = xml.readNext();
+
+ while (xml.atEnd() == false && (xml.name().compare(itemKeyword) == 0 &&
+ token == QXmlStreamReader::EndElement) == false) /* ~ </xxItem> */
+ {
+ if (token == QXmlStreamReader::StartElement) {
+ if (xml.name() == SHORTCUT_KEYWORD) {
+ parseShortcut(xml, item->getShortcutMap());
+ }
+ }
+
+ token = xml.readNext();
+ }
+
+ return item;
+}
+
+int XmlLayoutParser::parseMenuList(
+ QXmlStreamReader &xml, QList<MenuItem *> &list)
+{
+ MenuItem *item = NULL;
+ QXmlStreamReader::TokenType token = xml.readNext();
+
+ while (xml.atEnd() == false && (xml.name() == MENULIST_KEYWORD &&
+ token == QXmlStreamReader::EndElement) == false) /* ~ </menuList> */
+ {
+ if (token == QXmlStreamReader::StartElement) {
+ if (xml.name() == SEPARATOR_MENU_KEYWORD) {
+ item = new MenuItem(MenuItemType::separator, NULL);
+ if (item != NULL) {
+ list.append(item);
+ }
+ } else if (xml.name() == ADVANCED_MENU_KEYWORD) {
+ item = (MenuItem *)parseAdvancedMenuItem(xml);
+ if (item != NULL) {
+ list.append(item);
+ }
+ } else if (xml.name() == INFO_MENU_KEYWORD) {
+ item = parseGeneralMenuItem(xml, MenuItemType::infoItem);
+ if (item != NULL) {
+ list.append(item);
+ }
+ } else if (xml.name() == ONTOP_MENU_KEYWORD) {
+ item = parseGeneralMenuItem(xml, MenuItemType::onTopItem);
+ if (item != NULL) {
+ list.append(item);
+ }
+ } else if (xml.name() == SWITCH_MENU_KEYWORD) {
+ item = parseGeneralMenuItem(xml, MenuItemType::switchItem);
+ if (item != NULL) {
+ list.append(item);
+ }
+ } else if (xml.name() == SCALE_MENU_KEYWORD) {
+ item = (MenuItem *)parseScaleMenuItem(xml);
+ if (item != NULL) {
+ list.append(item);
+ }
+ } else if (xml.name() == CONTROLLER_MENU_KEYWORD) {
+ item = parseGeneralMenuItem(xml, MenuItemType::controllerItem);
+ if (item != NULL) {
+ list.append(item);
+ }
+ } else if (xml.name() == HOSTKBD_MENU_KEYWORD) {
+ item = parseGeneralMenuItem(xml, MenuItemType::hostKeyboardItem);
+ if (item != NULL) {
+ list.append(item);
+ }
+ } else if (xml.name() == SHELL_MENU_KEYWORD) {
+ item = parseGeneralMenuItem(xml, MenuItemType::shellItem);
+ if (item != NULL) {
+ list.append(item);
+ }
+ } else if (xml.name() == ECP_MENU_KEYWORD) {
+ item = parseGeneralMenuItem(xml, MenuItemType::controlPanelItem);
+ if (item != NULL) {
+ list.append(item);
+ }
+ } else if (xml.name() == SCREENSHOT_MENU_KEYWORD) {
+ item = parseGeneralMenuItem(xml, MenuItemType::screenShotItem);
+ if (item != NULL) {
+ list.append(item);
+ }
+ } else if (xml.name() == ABOUT_MENU_KEYWORD) {
+ item = parseGeneralMenuItem(xml, MenuItemType::aboutItem);
+ if (item != NULL) {
+ list.append(item);
+ }
+ } else if (xml.name() == FORCECLOSE_MENU_KEYWORD) {
+ item = parseGeneralMenuItem(xml, MenuItemType::forceCloseItem);
+ if (item != NULL) {
+ list.append(item);
+ }
+ } else if (xml.name() == CLOSE_MENU_KEYWORD) {
+ item = parseGeneralMenuItem(xml, MenuItemType::closeItem);
+ if (item != NULL) {
+ list.append(item);
+ }
+ }
+ }
+
+ token = xml.readNext();
+ }
+
+ return list.count();
+}
+
+QString XmlLayoutParser::parseEmulatorUI(QXmlStreamReader &xml)
+{
+ QString layoutVersion = "undefined";
+
+ QXmlStreamReader::TokenType token;
+
+ while (xml.atEnd() == false && xml.hasError() == false) {
+ token = xml.readNext();
+ /* If token is just StartDocument, go to next.*/
+ if (token == QXmlStreamReader::StartDocument) {
+ continue;
+ }
+
+ if (token == QXmlStreamReader::StartElement) {
+ if (xml.name() == EMULATOR_UI_KEYWORD) {
+ continue;
+ }
+
+ if (xml.name() == LAYOUTVER_KEYWORD) {
+ layoutVersion = xml.readElementText();
+ continue;
+ } else if (xml.name() == FORMLIST_KEYWORD) {
+ int cnt = parseMainFormList(xml, uiInfo->mainFormList);
+ qDebug() << FORMLIST_KEYWORD << ":" << cnt;
+ } else if (xml.name() == MENULIST_KEYWORD) {
+ int cnt = parseMenuList(xml, uiInfo->menuList);
+ qDebug() << MENULIST_KEYWORD << ":" << cnt;
+ }
+ }
+ }
+
+ return layoutVersion;
+}
+
+/* controller */
+ControllerForm *XmlLayoutParser::parseControllerForm(QXmlStreamReader &xml)
+{
+ /* attribute */
+ QString formName = xml.attributes().value(NAME_ATTR_KEYWORD).toString();
+ ControllerForm *form = new ControllerForm(
+ formName.isEmpty() ? xmlPath.section(QDir::separator(), -1) : formName);
+
+ qDebug() << '*' << form->getName() << "{";
+
+ QXmlStreamReader::TokenType token = xml.readNext();
+
+ while (xml.atEnd() == false && (xml.name() == FORM_KEYWORD &&
+ token == QXmlStreamReader::EndElement) == false) /* ~ </form> */
+ {
+ if (token == QXmlStreamReader::StartElement) {
+ if (xml.name() == NORMAL_IMG_KEYWORD) {
+ /* normal image */
+ QString normalImageFileName = xml.readElementText();
+ qDebug() << "-" << NORMAL_IMG_KEYWORD << ":" << normalImageFileName;
+
+ if (form->conImg[ControllerForm::normal].load(
+ xmlPath + QDir::separator() + normalImageFileName) == false) {
+ qWarning() << "failed to load normal image";
+ }
+ } else if (xml.name() == PRESSED_IMG_KEYWORD) {
+ /* key pressed image */
+ QString pressedImageFileName = xml.readElementText();
+ qDebug() << "-" << PRESSED_IMG_KEYWORD << ":" << pressedImageFileName;
+
+ if (form->conImg[ControllerForm::pressed].load(
+ xmlPath + QDir::separator() + pressedImageFileName) == false) {
+ qWarning() << "failed to load pressed image";
+ }
+ } else if (xml.name() == KEYLIST_KEYWORD) {
+ /* HW keys */
+ int cnt = parseKeyList(xml, form->keyList);
+ qDebug() << "-" << KEYLIST_KEYWORD << ":" << cnt;
+ } else if (xml.name() == HOVER_KEYWORD) {
+ /* hover */
+ form->setHoverType(parseHover(xml));
+ } else {
+ qWarning() << "undefined element :" << xml.name();
+ }
+ }
+
+ token = xml.readNext();
+ }
+
+ qDebug("}");
+
+ return form;
+}
+
+QString XmlLayoutParser::parseControllerUI(QXmlStreamReader &xml)
+{
+ QString layoutVersion = "undefined";
+
+ ControllerForm *form = NULL;
+ QXmlStreamReader::TokenType token;
+
+ while (xml.atEnd() == false && xml.hasError() == false) {
+ token = xml.readNext();
+ /* If token is just StartDocument, go to next.*/
+ if (token == QXmlStreamReader::StartDocument) {
+ continue;
+ }
+
+ if (token == QXmlStreamReader::StartElement) {
+ if (xml.name() == CONTROLLER_UI_KEYWORD) {
+ continue;
+ }
+
+ if (xml.name() == LAYOUTVER_KEYWORD) {
+ layoutVersion = xml.readElementText();
+ continue;
+ } else if (xml.name() == FORM_KEYWORD) {
+ form = parseControllerForm(xml);
+ if (form != NULL) {
+ /* image validation */
+ if (form->conImg[ControllerForm::normal].size() == QSize(0, 0)) {
+ qDebug("- general purpose con form");
+
+ int keyCount = form->keyList.count();
+
+ int width = GPC_KEYBUTTON_WIDTH;
+ int height = GPC_HEAD_SPACING;
+ if (keyCount < GPC_KEYBUTTON_DEFAULT_CNT) {
+ height += (GPC_KEYBUTTON_HEIGHT * keyCount) +
+ (GPC_KEYBUTTON_VSPACING * (keyCount - 1)) +
+ GPC_TAIL_SPACING;
+ } else {
+ width += (GPC_SCROLLBAR_WIDTH + GPC_SCROLLBAR_HSPACING);
+ height += (GPC_KEYBUTTON_HEIGHT * GPC_KEYBUTTON_DEFAULT_CNT) +
+ (GPC_KEYBUTTON_VSPACING * (GPC_KEYBUTTON_DEFAULT_CNT - 1)) +
+ GPC_TAIL_SPACING;
+ }
+
+ SkinPainter painter("controller-skin",
+ QSize(width, qMax(height, QT_LAYOUT_MINIMUM - 20)),
+ 0, QPoint(14, GPC_HEAD_SPACING - 1),
+ uiInfo->getVMColor());
+ form->setGeneralPurpose(true);
+
+ form->conImg[ControllerForm::normal] = painter.getSkinImage();
+ form->centerRect = painter.getCenterRect();
+ }
+
+ uiInfo->conFormList.append(form);
+ }
+ }
+ }
+ }
+
+ return layoutVersion;
+}
--- /dev/null
+/*
+ * 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 XMLLAYOUTPARSER_H
+#define XMLLAYOUTPARSER_H
+
+#include <QXmlStreamReader>
+
+#include "uiinformation.h"
+#include "layout/keycodetype.h"
+#include "layout/mainform.h"
+#include "layout/controllerform.h"
+#include "menu/menuitem.h"
+#include "menu/advancedmenuitem.h"
+#include "menu/scalemenuitem.h"
+
+
+class XmlLayoutParser
+{
+public:
+ XmlLayoutParser(QString path, UIInformation *uiInfo /* out */);
+
+ QString parseEmulatorUI(QXmlStreamReader &xml);
+ QString parseControllerUI(QXmlStreamReader &xml);
+
+private:
+ QColor parseColor(QXmlStreamReader &xml);
+ HoverType *parseHover(QXmlStreamReader &xml);
+ QRect parseRegion(QXmlStreamReader &xml);
+ DisplayType *parseDisplay(QXmlStreamReader &xml);
+ KeycodeType *parseKeycode(QXmlStreamReader &xml);
+ HardwareKey *parseKey(QXmlStreamReader &xml);
+ int parseKeyList(QXmlStreamReader &xml, QList<HardwareKey *> &list);
+ MainForm *parseMainForm(QXmlStreamReader &xml);
+ int parseMainFormList(QXmlStreamReader &xml, QList<MainForm *> &list);
+
+ int parseFactorList(QXmlStreamReader &xml, QMap<int, QString> &map, int *defaultFactor);
+ int parseShortcut(QXmlStreamReader &xml, QMap<QString, QString> &map);
+ AdvancedMenuItem *parseAdvancedMenuItem(QXmlStreamReader &xml);
+ ScaleMenuItem *parseScaleMenuItem(QXmlStreamReader &xml);
+ MenuItem *parseGeneralMenuItem(QXmlStreamReader &xml, int menuType);
+ int parseMenuList(QXmlStreamReader &xml, QList<MenuItem *> &list);
+
+ ControllerForm *parseControllerForm(QXmlStreamReader &xml);
+
+ QString xmlPath;
+ UIInformation *uiInfo;
+};
+
+#endif // XMLLAYOUTPARSER_H
QEMU_CFLAGS += -I$(SRC_PATH)/hw/vigs/vigs_inc
endif
+# ui operations
+obj-y += ui_operations.o
+
# osutil
LIBS += $(CURL_LIBS)
obj-y += osutil.o
MULTI_DEBUG_CHANNEL(qemu, backtrace);
-// deprecated
-/* This table must match the enum definition */
-static char _maru_string_table[][JAVA_MAX_COMMAND_LENGTH] = {
- /* 0 */ "",
- /* 1 */ FAILED_TO_ALLOCATE_MEMORY,
- /* 2 */ FAILED_TO_LOAD_KERNEL CHECK_FILE_VALID,
- /* 3 */ FAILED_TO_LOAD_BIOS CHECK_FILE_VALID,
- /* 4 */ FAILED_TO_INITIALIZE_SKIN,
- /* 5 */ EMULATOR_HAS_STOPPED,
- /* add here.. */
- ""
-};
-
-static int maru_exit_status = MARU_EXIT_NORMAL;
-static char *maru_exit_msg;
-
-#ifdef CONFIG_WIN32
-static LPTOP_LEVEL_EXCEPTION_FILTER prevExceptionFilter;
+#ifdef CONFIG_JAVA_UI
+#include "skin/maruskin_client.h"
#endif
-#ifdef CONFIG_LINUX
+#if defined(CONFIG_WIN32)
+static LPTOP_LEVEL_EXCEPTION_FILTER prevExceptionFilter;
+#elif defined(CONFIG_LINUX)
static pthread_spinlock_t siglock;
-void maru_sighandler(int sig);
#endif
-// deprecated
-char *get_canonical_path(char const *const path)
-{
- if ((int)g_path_is_absolute(path)) {
- return (char *)g_strdup(path);
- }
-
- char *canonical_path;
-
-#ifndef _WIN32
- char *current_dir = g_get_current_dir();
- canonical_path = g_strdup_printf("%s/%s", current_dir, path);
- g_free(current_dir);
-#else
- canonical_path = g_malloc(MAX_PATH);
- GetFullPathName(path, MAX_PATH, canonical_path, NULL);
-#endif
-
- return canonical_path;
-}
-
-// deprecated
-// Use error_report() instead
-void register_exit_message(int status, char const *format, ...)
-{
- va_list args;
-
- if (status >= MARU_EXIT_NORMAL) {
- fprintf(stderr, "Invalid error message index = %d\n",
- status);
- return;
- }
- if (maru_exit_status != MARU_EXIT_NORMAL) {
- fprintf(stderr, "The error message is already registered = %d\n",
- maru_exit_status);
- return;
- }
-
- maru_exit_status = status;
-
- if (maru_exit_status == MARU_EXIT_HB_TIME_EXPIRED) {
- fprintf(stderr, "Skin client could not connect to Skin server."
- " The time of internal heartbeat has expired.\n");
- }
-
- if (!format) {
- format = "";
- }
-
- va_start(args, format);
- char *additional = g_strdup_vprintf(format, args);
- va_end(args);
- maru_exit_msg = g_strdup_printf("%s%s", _maru_string_table[maru_exit_status],
- additional);
- g_free(additional);
-
- if (strlen(maru_exit_msg) >= JAVA_MAX_COMMAND_LENGTH) {
- maru_exit_msg[JAVA_MAX_COMMAND_LENGTH - 1] = '\0';
- }
-
- fprintf(stdout, "The error message is registered = %d : %s\n",
- maru_exit_status, maru_exit_msg);
-}
-
/* Print 'backtrace' */
#ifdef _WIN32
struct frame_layout {
static void handle_error_at_exit(void)
{
-
- // deprecated
- if (maru_exit_status != MARU_EXIT_NORMAL || maru_exit_msg) {
- start_simple_client(maru_exit_msg);
- }
- g_free(maru_exit_msg);
-
// dump backtrace log no matter what
INFO("Stack backtrace for tracing...\n");
INFO("This is not an error.\n");
#endif
#ifdef CONFIG_LINUX
-void maru_sighandler(int sig)
+static void maru_sighandler(int sig)
{
ERR("Got signal %d\n", sig);
// print system information again
// We are wating for '\n'
if (message[message_len - 1] == '\n') {
fprintf(stderr, "%s", message);
- start_simple_client(message);
+#ifdef CONFIG_QT
+ if (display_type == DT_MARU_QT_ONSCREEN ||
+ display_type == DT_MARU_QT_OFFSCREEN) {
+ // TODO: new pop-up dialog is needed
+ }
+#endif
+#ifdef CONFIG_JAVA_UI
+ if (display_type == DT_MARU_SDL ||
+ display_type == DT_MARU_SHM) {
+ start_simple_client(message);
+ }
+#endif
message[0] = '\0';
message_len = 0;
}
#ifndef __ERROR_HANDLER_H__
#define __ERROR_HANDLER_H__
-#include "tizen/src/skin/maruskin_client.h"
-
-// deprecated
-/* TODO: define macro for fair of definition */
-/* This enum must match the table definition */
-enum {
- /* 0 */ MARU_EXIT_UNKNOWN = 0,
- /* 1 */ MARU_EXIT_MEMORY_EXCEPTION,
- /* 2 */ MARU_EXIT_KERNEL_FILE_EXCEPTION,
- /* 3 */ MARU_EXIT_BIOS_FILE_EXCEPTION,
- /* 4 */ MARU_EXIT_SKIN_SERVER_FAILED,
- /* 5 */ MARU_EXIT_HB_TIME_EXPIRED,
- /* add here.. */
- MARU_EXIT_NORMAL
-};
-
void init_error_handler(void);
-// deprecated
-void register_exit_message(int status, char const *format, ...);
-// deprecated
-char *get_canonical_path(char const *const path);
#endif /* __ERROR_HANDLER_H__ */
#include "emulator.h"
#include "emulator_common.h"
-#include "debug_ch.h"
#include "emul_state.h"
#include "hw/virtio/maru_virtio_hwkey.h"
-#include "skin/maruskin_server.h"
#include "hw/maru_pm.h"
#include "ecs/ecs.h"
+#include "debug_ch.h"
MULTI_DEBUG_CHANNEL(qemu, sdb);
+#ifdef CONFIG_JAVA_UI
+#include "skin/maruskin_server.h"
+#endif
+
+static bool sdb_daemon_is_initialized = false;
+
#ifdef _WIN32
#include "qemu/main-loop.h"
TRACE("----------------------------------------\n");
TRACE("command:%s\n", command);
if (strcmp(command, "2\n" ) == 0) {
+#ifdef CONFIG_JAVA_UI
notify_sdb_daemon_start();
+#endif
+ sdb_daemon_is_initialized = true;
} else if (strcmp(command, "5\n") == 0) {
register_sdb_server(readbuf, client_addr);
set_sdb_connection(true);
emulator_add_exit_notifier(&sdb_noti_server_exit);
}
+bool is_sdb_daemon_initialized(void)
+{
+ return sdb_daemon_is_initialized;
+}
int socket_send(int fd, const void* buf, int buflen);
void socket_close(int fd);
int check_port_bind_listen(uint32_t port);
+bool is_sdb_daemon_initialized(void);
#define STATE_RUNNING 0
#define STATE_SUSPEND 1
--- /dev/null
+/*
+ * UI operations
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@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 "ui_operations.h"
+
+#include "sysemu/sysemu.h"
+#include "ui/input.h"
+
+#include "emul_state.h"
+#include "hw/maru_pm.h"
+#include "util/new_debug_ch.h"
+#include "hw/virtio/maru_virtio_hwkey.h"
+#include "hw/virtio/maru_virtio_touchscreen.h"
+#include "hw/virtio/maru_virtio_rotary.h"
+#include "hw/virtio/maru_virtio_keyboard.h"
+#include "hw/pci/maru_brightness.h"
+#include "util/device_hotplug.h"
+
+#if defined(CONFIG_JAVA_UI) && !defined(CONFIG_USE_SHM)
+#include "display/maru_finger.h"
+#include "display/maru_display.h"
+#endif
+
+DECLARE_DEBUG_CHANNEL(op_stub);
+
+#define RESUME_KEY_SEND_INTERVAL 500 /* milli-seconds */
+
+void do_hw_key_event(int event_type, int keycode)
+{
+ LOG_TRACE("HW Key : event_type=%d, keycode=%d\n", event_type, keycode);
+
+ // FIXME: remove workaround
+ if (runstate_check(RUN_STATE_SUSPENDED)) {
+ if (KEY_PRESSED == event_type) {
+ /* home key or power key is used for resume */
+ if ((HARD_KEY_HOME == keycode) || (HARD_KEY_POWER == keycode)) {
+ LOG_INFO("user requests system resume\n");
+ resume();
+
+#ifdef CONFIG_WIN32
+ Sleep(RESUME_KEY_SEND_INTERVAL);
+#else
+ usleep(RESUME_KEY_SEND_INTERVAL * 1000);
+#endif
+ }
+ }
+ }
+
+ maru_hwkey_event(event_type, keycode);
+}
+
+void do_mouse_event(int button_type, int event_type,
+ int origin_x, int origin_y, int x, int y, int z)
+{
+ static int guest_x, guest_y;
+// static int pressing_x = -1, pressing_y = -1;
+// static int pressing_origin_x = -1, pressing_origin_y = -1;
+
+ if (is_display_off()) {
+ if (button_type == 0) {
+ LOG_INFO("auto mouse release\n");
+ // TODO:
+ virtio_touchscreen_event(0, 0, 0, 0);
+
+ return;
+ } else {
+ LOG_TRACE("reject mouse touch in display off : "
+ "button=%d, type=%d, x=%d, y=%d, z=%d\n",
+ button_type, event_type, x, y, z);
+ return;
+ }
+ }
+
+ LOG_TRACE("mouse event : button=%d, type=%d, "
+ "host=(%d, %d), x=%d, y=%d, z=%d\n",
+ button_type, event_type, origin_x, origin_y, x, y, z);
+
+#if defined(CONFIG_JAVA_UI) && !defined(CONFIG_USE_SHM)
+ /* draw multi-touch points */
+ if (get_multi_touch_enable() != 0) {
+ if (event_type == MOUSE_DOWN || event_type == MOUSE_DRAG) {
+ update_finger_point(z, origin_x, origin_y, x, y);
+ } else if (event_type == MOUSE_UP) {
+ remove_finger_point(z);
+ }
+
+ maru_display_update();
+ }
+#endif
+
+ /* single touch */
+ switch(event_type) {
+ case MOUSE_DOWN:
+ case MOUSE_DRAG:
+// pressing_x = x;
+// pressing_y = y;
+ guest_x = x;
+ guest_y = y;
+// pressing_origin_x = origin_x;
+// pressing_origin_y = origin_y;
+
+ virtio_touchscreen_event(x, y, z, 1);
+
+ break;
+ case MOUSE_UP:
+ guest_x = x;
+ guest_y = y;
+// pressing_x = pressing_y = -1;
+// pressing_origin_x = pressing_origin_y = -1;
+
+ virtio_touchscreen_event(x, y, z, 0);
+
+ break;
+ case MOUSE_WHEELUP:
+ case MOUSE_WHEELDOWN:
+ if (is_emul_input_touch_enable() == true) {
+ x -= guest_x;
+ y -= guest_y;
+ guest_x += x;
+ guest_y += y;
+ } else {
+ guest_x = x;
+ guest_y = y;
+ }
+
+ virtio_touchscreen_event(x, y, -z, event_type);
+
+ break;
+ case MOUSE_MOVE:
+ guest_x = x;
+ guest_y = y;
+
+ if (x != 0) {
+ qemu_input_queue_rel(NULL, INPUT_AXIS_X, x);
+ }
+ if (y != 0) {
+ qemu_input_queue_rel(NULL, INPUT_AXIS_Y, y);
+ }
+ qemu_input_event_sync();
+
+ break;
+ case PS2_DOWN:
+ qemu_input_queue_btn(NULL, INPUT_BUTTON_LEFT, 1);
+ qemu_input_event_sync();
+
+ break;
+ case PS2_UP:
+ qemu_input_queue_btn(NULL, INPUT_BUTTON_LEFT, 0);
+ qemu_input_event_sync();
+
+ break;
+ default:
+ LOG_SEVERE("undefined mouse event type passed : %d\n", event_type);
+ break;
+ }
+}
+
+void do_rotary_event(int32_t delta, int32_t type)
+{
+ LOG_TRACE("rotaty event: delta(%d), type(%d)\n", delta, type);
+ maru_rotary_event(delta, type);
+}
+
+void do_qt_keyboard_key_event(int event_type, int keycode)
+{
+ if (KEY_PRESSED == event_type) {
+ LOG_TRACE("key pressed: %d\n", keycode);
+ virtio_keyboard_event(keycode);
+ } else if (KEY_RELEASED == event_type) {
+ LOG_TRACE("key released: %d\n", keycode);
+ virtio_keyboard_event(keycode | 0x80);
+ }
+}
--- /dev/null
+/*
+ * UI operations
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@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 __UI_OPERATIONS_H__
+#define __UI_OPERATIONS_H__
+
+#include "tizen/src/emulator_common.h"
+
+#define TIMEOUT_FOR_SHUTDOWN 10 /* seconds */
+
+void do_hw_key_event(int event_type, int keycode);
+void do_mouse_event(int button_type, int event_type,
+ int origin_x, int origin_y, int x, int y, int z);
+void do_rotary_event(int32_t delta, int32_t type);
+void do_qt_keyboard_key_event(int event_type, int keycode);
+
+#endif // __UI_OPERATIONS_H___
#ifdef CONFIG_MARU
#include "tizen/src/emulator.h"
#include "tizen/src/emul_state.h"
-#include "tizen/src/display/qt5.h"
-#include "tizen/src/skin/maruskin_operation.h"
+#include "tizen/src/ui/qt5.h"
+#include "tizen/src/util/ui_operations.h"
#include "tizen/src/ecs/ecs.h"
# ifdef CONFIG_JAVA_UI
#include "tizen/src/display/maru_display.h"