From: SeokYeon Hwang Date: Mon, 10 Aug 2015 03:58:35 +0000 (+0900) Subject: UI: massive refactoring about UI/Display components X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.2~40^2~211 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=933aac74b478bd50b5516c2f018669fb72c0f675;p=sdk%2Femulator%2Fqemu.git UI: massive refactoring about UI/Display components 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 --- diff --git a/include/ui/console.h b/include/ui/console.h index 28986208d6..a3ce4f9dcb 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -11,7 +11,7 @@ #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 diff --git a/tizen/src/Makefile.objs b/tizen/src/Makefile.objs index 1ff95c8b9e..404f1ac1e7 100644 --- a/tizen/src/Makefile.objs +++ b/tizen/src/Makefile.objs @@ -11,9 +11,6 @@ obj-y += util/ # ui obj-y += ui/ -# maru display -obj-y += display/ - # protobuf obj-y += distrib/protobuf/protobuf-c.o @@ -23,8 +20,11 @@ obj-y += ecs/ # 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/ diff --git a/tizen/src/display/Makefile.objs b/tizen/src/display/Makefile.objs index 4fc94161d9..92fdb9990b 100644 --- a/tizen/src/display/Makefile.objs +++ b/tizen/src/display/Makefile.objs @@ -1,13 +1,6 @@ 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) diff --git a/tizen/src/display/maru_display.c b/tizen/src/display/maru_display.c index 9f97fa665e..ca631448e8 100644 --- a/tizen/src/display/maru_display.c +++ b/tizen/src/display/maru_display.c @@ -60,10 +60,6 @@ static void maru_display_notify_exit(Notifier *notifier, void *data) 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) { diff --git a/tizen/src/display/maru_sdl.c b/tizen/src/display/maru_sdl.c index a3c30874b6..1caae288d5 100644 --- a/tizen/src/display/maru_sdl.c +++ b/tizen/src/display/maru_sdl.c @@ -78,7 +78,7 @@ static unsigned int blank_cnt; #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; diff --git a/tizen/src/display/propertykeyword.h b/tizen/src/display/propertykeyword.h deleted file mode 100644 index 8763e40a80..0000000000 --- a/tizen/src/display/propertykeyword.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Qt UI - * - * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * GiWoong Kim - * Sangho Park - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - -#ifndef 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 diff --git a/tizen/src/display/qt5.c b/tizen/src/display/qt5.c deleted file mode 100644 index 7e8a714522..0000000000 --- a/tizen/src/display/qt5.c +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Qt UI - * - * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * SeokYeon Hwang - * Sangho Park - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - -#include "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 */ -} diff --git a/tizen/src/display/qt5.h b/tizen/src/display/qt5.h deleted file mode 100644 index b1aac1c354..0000000000 --- a/tizen/src/display/qt5.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * QT5 display driver - * - * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * GiWoong Kim - * SeokYeon Hwang - * - * 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 - -#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__ diff --git a/tizen/src/display/qt5_supplement.cpp b/tizen/src/display/qt5_supplement.cpp deleted file mode 100644 index 3cd245084e..0000000000 --- a/tizen/src/display/qt5_supplement.cpp +++ /dev/null @@ -1,533 +0,0 @@ -/* - * Qt UI - * - * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * GiWoong Kim - * SeokYeon Hwang - * Sangho Park - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - -#include - -#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(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 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; - } -} diff --git a/tizen/src/display/qt5_supplement.h b/tizen/src/display/qt5_supplement.h deleted file mode 100644 index 89cbf7f34c..0000000000 --- a/tizen/src/display/qt5_supplement.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Qt UI - * - * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * GiWoong Kim - * SeokYeon Hwang - * Sangho Park - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - -#ifndef __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__ diff --git a/tizen/src/display/xmllayoutkeyword.h b/tizen/src/display/xmllayoutkeyword.h deleted file mode 100644 index dd84f762c6..0000000000 --- a/tizen/src/display/xmllayoutkeyword.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Qt UI - * - * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * GiWoong Kim - * Sangho Park - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - -#ifndef 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 diff --git a/tizen/src/display/xmllayoutparser.cpp b/tizen/src/display/xmllayoutparser.cpp deleted file mode 100644 index 82ed1dfb9b..0000000000 --- a/tizen/src/display/xmllayoutparser.cpp +++ /dev/null @@ -1,688 +0,0 @@ -/* - * Qt UI - * - * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * GiWoong Kim - * Sangho Park - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - -#include "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) /* ~ */ - { - 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) /* ~ */ - { - 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) /* ~ */ - { - 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 &list) -{ - HardwareKey *hwKey = NULL; - QXmlStreamReader::TokenType token = xml.readNext(); - - while (xml.atEnd() == false && (xml.name() == KEYLIST_KEYWORD && - token == QXmlStreamReader::EndElement) == false) /* ~ */ - { - 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) /* ~ */ - { - 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 &list) -{ - MainForm *form = NULL; - QXmlStreamReader::TokenType token = xml.readNext(); - - while (xml.atEnd() == false && (xml.name() == FORMLIST_KEYWORD && - token == QXmlStreamReader::EndElement) == false) /* ~ */ - { - 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 &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) /* ~ */ - { - 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 &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) /* ~ */ - { - 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) /* ~ */ - { - 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) /* ~ */ - { - if (token == QXmlStreamReader::StartElement) { - if (xml.name() == SHORTCUT_KEYWORD) { - parseShortcut(xml, item->getShortcutMap()); - } - } - - token = xml.readNext(); - } - - return item; -} - -int XmlLayoutParser::parseMenuList( - QXmlStreamReader &xml, QList &list) -{ - MenuItem *item = NULL; - QXmlStreamReader::TokenType token = xml.readNext(); - - while (xml.atEnd() == false && (xml.name() == MENULIST_KEYWORD && - token == QXmlStreamReader::EndElement) == false) /* ~ */ - { - 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) /* ~ */ - { - 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; -} diff --git a/tizen/src/display/xmllayoutparser.h b/tizen/src/display/xmllayoutparser.h deleted file mode 100644 index 6e01a0231f..0000000000 --- a/tizen/src/display/xmllayoutparser.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Qt UI - * - * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * GiWoong Kim - * Sangho Park - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - -#ifndef XMLLAYOUTPARSER_H -#define XMLLAYOUTPARSER_H - -#include - -#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 &list); - MainForm *parseMainForm(QXmlStreamReader &xml); - int parseMainFormList(QXmlStreamReader &xml, QList &list); - - int parseFactorList(QXmlStreamReader &xml, QMap &map, int *defaultFactor); - int parseShortcut(QXmlStreamReader &xml, QMap &map); - AdvancedMenuItem *parseAdvancedMenuItem(QXmlStreamReader &xml); - ScaleMenuItem *parseScaleMenuItem(QXmlStreamReader &xml); - MenuItem *parseGeneralMenuItem(QXmlStreamReader &xml, int menuType); - int parseMenuList(QXmlStreamReader &xml, QList &list); - - ControllerForm *parseControllerForm(QXmlStreamReader &xml); - - QString xmlPath; - UIInformation *uiInfo; -}; - -#endif // XMLLAYOUTPARSER_H diff --git a/tizen/src/ecs/ecs_msg_device.c b/tizen/src/ecs/ecs_msg_device.c index 57b921bd10..87dab3f798 100644 --- a/tizen/src/ecs/ecs_msg_device.c +++ b/tizen/src/ecs/ecs_msg_device.c @@ -37,9 +37,8 @@ #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" diff --git a/tizen/src/ecs/ecs_msg_injector.c b/tizen/src/ecs/ecs_msg_injector.c index dca573046b..6892443fd1 100644 --- a/tizen/src/ecs/ecs_msg_injector.c +++ b/tizen/src/ecs/ecs_msg_injector.c @@ -44,7 +44,7 @@ #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); @@ -519,7 +519,7 @@ static void show_error_popup(char* data) 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) diff --git a/tizen/src/emul_state.c b/tizen/src/emul_state.c index c064186692..310dea6061 100644 --- a/tizen/src/emul_state.c +++ b/tizen/src/emul_state.c @@ -52,11 +52,14 @@ extern bool hax_allowed; #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,}; diff --git a/tizen/src/emulator.c b/tizen/src/emulator.c index f6cc9724dd..4205e0cc55 100644 --- a/tizen/src/emulator.c +++ b/tizen/src/emulator.c @@ -43,12 +43,16 @@ #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 #endif diff --git a/tizen/src/emulator_legacy.c b/tizen/src/emulator_legacy.c index 42e220a74c..3c64841b35 100644 --- a/tizen/src/emulator_legacy.c +++ b/tizen/src/emulator_legacy.c @@ -45,7 +45,6 @@ #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" diff --git a/tizen/src/eventcast/encode_fb.c b/tizen/src/eventcast/encode_fb.c index 10d607c1d0..78c48527c9 100644 --- a/tizen/src/eventcast/encode_fb.c +++ b/tizen/src/eventcast/encode_fb.c @@ -32,7 +32,6 @@ #include "emulator_common.h" #include "emul_state.h" -#include "skin/maruskin_operation.h" #include "encode_fb.h" #if defined(CONFIG_LINUX) && defined(ENCODE_DEBUG) diff --git a/tizen/src/hw/pci/maru_brightness.c b/tizen/src/hw/pci/maru_brightness.c index c0004d163a..7be99fc717 100644 --- a/tizen/src/hw/pci/maru_brightness.c +++ b/tizen/src/hw/pci/maru_brightness.c @@ -36,11 +36,14 @@ #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 */ @@ -74,7 +77,9 @@ uint8_t brightness_tbl[] = {155, /* level 0 : for dimming */ /* 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) @@ -178,8 +183,10 @@ static void brightness_reg_write(void *opaque, 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: @@ -196,9 +203,11 @@ static const MemoryRegionOps brightness_mmio_ops = { 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; @@ -207,10 +216,12 @@ static void brightness_exitfn(PCIDevice *dev) 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) { @@ -225,7 +236,9 @@ 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; diff --git a/tizen/src/hw/virtio/Makefile.objs b/tizen/src/hw/virtio/Makefile.objs index adf0677b33..af51e99a49 100644 --- a/tizen/src/hw/virtio/Makefile.objs +++ b/tizen/src/hw/virtio/Makefile.objs @@ -1,6 +1,5 @@ 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 @@ -11,3 +10,4 @@ obj-y += maru_virtio_sensor.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 diff --git a/tizen/src/hw/virtio/maru_virtio_esm.c b/tizen/src/hw/virtio/maru_virtio_esm.c index 03b863dd97..80f566660d 100644 --- a/tizen/src/hw/virtio/maru_virtio_esm.c +++ b/tizen/src/hw/virtio/maru_virtio_esm.c @@ -28,12 +28,14 @@ #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 @@ -84,13 +86,17 @@ static void virtio_esm_handle(VirtIODevice *vdev, VirtQueue *vq) 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 */ diff --git a/tizen/src/skin/maruskin_operation.c b/tizen/src/skin/maruskin_operation.c index f212b7f2ab..398c4bebe8 100644 --- a/tizen/src/skin/maruskin_operation.c +++ b/tizen/src/skin/maruskin_operation.c @@ -61,16 +61,9 @@ 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; @@ -95,116 +88,6 @@ void do_grabbing_enable(bool on) 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) @@ -299,30 +182,6 @@ void do_keyboard_key_event(int event_type, } } -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); @@ -580,21 +439,6 @@ void do_open_shell(void) /* 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); @@ -635,8 +479,13 @@ void request_close(void) 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); + } } diff --git a/tizen/src/skin/maruskin_operation.h b/tizen/src/skin/maruskin_operation.h index db4cf57a00..2126e8370e 100644 --- a/tizen/src/skin/maruskin_operation.h +++ b/tizen/src/skin/maruskin_operation.h @@ -32,9 +32,10 @@ #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; @@ -56,12 +57,8 @@ void start_display(uint64_t handle_id, 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); @@ -72,12 +69,10 @@ void free_detail_info(DetailInfo *detail_info); 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_ */ diff --git a/tizen/src/ui/Makefile.objs b/tizen/src/ui/Makefile.objs index ef66fac600..1c8a6dc40b 100644 --- a/tizen/src/ui/Makefile.objs +++ b/tizen/src/ui/Makefile.objs @@ -1,6 +1,10 @@ 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 $@ diff --git a/tizen/src/ui/controller/hwkeybutton.cpp b/tizen/src/ui/controller/hwkeybutton.cpp index 66a5a986c1..c3ca9bc97e 100644 --- a/tizen/src/ui/controller/hwkeybutton.cpp +++ b/tizen/src/ui/controller/hwkeybutton.cpp @@ -32,8 +32,8 @@ #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) : diff --git a/tizen/src/ui/displaybase.cpp b/tizen/src/ui/displaybase.cpp index 2345bb8015..5468962952 100644 --- a/tizen/src/ui/displaybase.cpp +++ b/tizen/src/ui/displaybase.cpp @@ -33,6 +33,9 @@ #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); } diff --git a/tizen/src/ui/displaybase.h b/tizen/src/ui/displaybase.h index 127c8923f1..01de411841 100644 --- a/tizen/src/ui/displaybase.h +++ b/tizen/src/ui/displaybase.h @@ -40,10 +40,6 @@ #include "layout/displaytype.h" #include "input/touchscreenhelper.h" -extern "C" { -void qt5_graphic_hw_invalidate(void); -} - enum { TOUCH_PRESS = 1, TOUCH_RELEASE = 2, diff --git a/tizen/src/ui/input/keyboardhelper.cpp b/tizen/src/ui/input/keyboardhelper.cpp index c25a1af7cc..643a73f528 100644 --- a/tizen/src/ui/input/keyboardhelper.cpp +++ b/tizen/src/ui/input/keyboardhelper.cpp @@ -34,7 +34,7 @@ extern "C" { #include "emul_state.h" -#include "skin/maruskin_operation.h" +#include "util/ui_operations.h" void virtio_keyboard_event(int keycode); } diff --git a/tizen/src/ui/input/keyboardshortcut.cpp b/tizen/src/ui/input/keyboardshortcut.cpp index 1cc8da6f5f..e23a3fa1ea 100644 --- a/tizen/src/ui/input/keyboardshortcut.cpp +++ b/tizen/src/ui/input/keyboardshortcut.cpp @@ -32,6 +32,10 @@ #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; diff --git a/tizen/src/ui/input/multitouchtracker.cpp b/tizen/src/ui/input/multitouchtracker.cpp index 9d8774ed22..c3c698d392 100644 --- a/tizen/src/ui/input/multitouchtracker.cpp +++ b/tizen/src/ui/input/multitouchtracker.cpp @@ -32,6 +32,7 @@ #include #include +#include "qt5_supplement.h" #include "multitouchtracker.h" #include "displaybase.h" diff --git a/tizen/src/ui/mainwindow.cpp b/tizen/src/ui/mainwindow.cpp index e737283514..3cd69c9172 100644 --- a/tizen/src/ui/mainwindow.cpp +++ b/tizen/src/ui/mainwindow.cpp @@ -37,7 +37,9 @@ #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); } diff --git a/tizen/src/ui/menu/contextmenu.cpp b/tizen/src/ui/menu/contextmenu.cpp index ffd591efd4..c617a8430e 100644 --- a/tizen/src/ui/menu/contextmenu.cpp +++ b/tizen/src/ui/menu/contextmenu.cpp @@ -40,6 +40,9 @@ 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) @@ -577,7 +580,7 @@ void ContextMenu::slotShell() { qDebug("SDB shell"); - if (is_sdbd_initialized == 0) { + if (!is_sdb_daemon_initialized()) { showMsgBox(QMessageBox::Warning, MSG_SDB_NOT_READY); return; } @@ -699,7 +702,11 @@ void ContextMenu::slotHostKeyboard(bool on) { 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() diff --git a/tizen/src/ui/menu/contextmenu.h b/tizen/src/ui/menu/contextmenu.h index 991b4e6c0a..57fa534b2f 100644 --- a/tizen/src/ui/menu/contextmenu.h +++ b/tizen/src/ui/menu/contextmenu.h @@ -44,9 +44,8 @@ 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 */ diff --git a/tizen/src/ui/propertykeyword.h b/tizen/src/ui/propertykeyword.h new file mode 100644 index 0000000000..8763e40a80 --- /dev/null +++ b/tizen/src/ui/propertykeyword.h @@ -0,0 +1,41 @@ +/* + * Qt UI + * + * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#ifndef 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 diff --git a/tizen/src/ui/qt5.c b/tizen/src/ui/qt5.c new file mode 100644 index 0000000000..7e8a714522 --- /dev/null +++ b/tizen/src/ui/qt5.c @@ -0,0 +1,210 @@ +/* + * Qt UI + * + * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * SeokYeon Hwang + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "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 */ +} diff --git a/tizen/src/ui/qt5.h b/tizen/src/ui/qt5.h new file mode 100644 index 0000000000..b1aac1c354 --- /dev/null +++ b/tizen/src/ui/qt5.h @@ -0,0 +1,41 @@ +/* + * QT5 display driver + * + * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * SeokYeon Hwang + * + * 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 + +#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__ diff --git a/tizen/src/ui/qt5_supplement.cpp b/tizen/src/ui/qt5_supplement.cpp new file mode 100644 index 0000000000..3cd245084e --- /dev/null +++ b/tizen/src/ui/qt5_supplement.cpp @@ -0,0 +1,533 @@ +/* + * Qt UI + * + * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * SeokYeon Hwang + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include + +#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(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 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; + } +} diff --git a/tizen/src/ui/qt5_supplement.h b/tizen/src/ui/qt5_supplement.h new file mode 100644 index 0000000000..89cbf7f34c --- /dev/null +++ b/tizen/src/ui/qt5_supplement.h @@ -0,0 +1,51 @@ +/* + * Qt UI + * + * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * SeokYeon Hwang + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#ifndef __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__ diff --git a/tizen/src/ui/rotaryview.cpp b/tizen/src/ui/rotaryview.cpp index 4265b8836e..4525b3ae2c 100644 --- a/tizen/src/ui/rotaryview.cpp +++ b/tizen/src/ui/rotaryview.cpp @@ -32,6 +32,10 @@ #include "rotaryview.h" #include "mainwindow.h" +extern "C" { +#include "util/ui_operations.h" +} + #define ROTARY_DRAWING_INTERVAL 100 RotaryView::RotaryView(QWidget *parent) : diff --git a/tizen/src/ui/skinbezelitem.cpp b/tizen/src/ui/skinbezelitem.cpp index 7fa9c63228..8eef8fc7c1 100644 --- a/tizen/src/ui/skinbezelitem.cpp +++ b/tizen/src/ui/skinbezelitem.cpp @@ -32,6 +32,11 @@ #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) { diff --git a/tizen/src/ui/skinkeyitem.cpp b/tizen/src/ui/skinkeyitem.cpp index ddaf15cea1..3e7c6f8651 100644 --- a/tizen/src/ui/skinkeyitem.cpp +++ b/tizen/src/ui/skinkeyitem.cpp @@ -31,6 +31,11 @@ #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) diff --git a/tizen/src/ui/skinkeyitem.h b/tizen/src/ui/skinkeyitem.h index 85e1e0b71e..c5fec95002 100644 --- a/tizen/src/ui/skinkeyitem.h +++ b/tizen/src/ui/skinkeyitem.h @@ -38,11 +38,6 @@ #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 diff --git a/tizen/src/ui/xmllayoutkeyword.h b/tizen/src/ui/xmllayoutkeyword.h new file mode 100644 index 0000000000..dd84f762c6 --- /dev/null +++ b/tizen/src/ui/xmllayoutkeyword.h @@ -0,0 +1,84 @@ +/* + * Qt UI + * + * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#ifndef 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 diff --git a/tizen/src/ui/xmllayoutparser.cpp b/tizen/src/ui/xmllayoutparser.cpp new file mode 100644 index 0000000000..82ed1dfb9b --- /dev/null +++ b/tizen/src/ui/xmllayoutparser.cpp @@ -0,0 +1,688 @@ +/* + * Qt UI + * + * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "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) /* ~ */ + { + 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) /* ~ */ + { + 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) /* ~ */ + { + 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 &list) +{ + HardwareKey *hwKey = NULL; + QXmlStreamReader::TokenType token = xml.readNext(); + + while (xml.atEnd() == false && (xml.name() == KEYLIST_KEYWORD && + token == QXmlStreamReader::EndElement) == false) /* ~ */ + { + 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) /* ~ */ + { + 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 &list) +{ + MainForm *form = NULL; + QXmlStreamReader::TokenType token = xml.readNext(); + + while (xml.atEnd() == false && (xml.name() == FORMLIST_KEYWORD && + token == QXmlStreamReader::EndElement) == false) /* ~ */ + { + 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 &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) /* ~ */ + { + 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 &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) /* ~ */ + { + 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) /* ~ */ + { + 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) /* ~ */ + { + if (token == QXmlStreamReader::StartElement) { + if (xml.name() == SHORTCUT_KEYWORD) { + parseShortcut(xml, item->getShortcutMap()); + } + } + + token = xml.readNext(); + } + + return item; +} + +int XmlLayoutParser::parseMenuList( + QXmlStreamReader &xml, QList &list) +{ + MenuItem *item = NULL; + QXmlStreamReader::TokenType token = xml.readNext(); + + while (xml.atEnd() == false && (xml.name() == MENULIST_KEYWORD && + token == QXmlStreamReader::EndElement) == false) /* ~ */ + { + 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) /* ~ */ + { + 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; +} diff --git a/tizen/src/ui/xmllayoutparser.h b/tizen/src/ui/xmllayoutparser.h new file mode 100644 index 0000000000..6e01a0231f --- /dev/null +++ b/tizen/src/ui/xmllayoutparser.h @@ -0,0 +1,76 @@ +/* + * Qt UI + * + * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#ifndef XMLLAYOUTPARSER_H +#define XMLLAYOUTPARSER_H + +#include + +#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 &list); + MainForm *parseMainForm(QXmlStreamReader &xml); + int parseMainFormList(QXmlStreamReader &xml, QList &list); + + int parseFactorList(QXmlStreamReader &xml, QMap &map, int *defaultFactor); + int parseShortcut(QXmlStreamReader &xml, QMap &map); + AdvancedMenuItem *parseAdvancedMenuItem(QXmlStreamReader &xml); + ScaleMenuItem *parseScaleMenuItem(QXmlStreamReader &xml); + MenuItem *parseGeneralMenuItem(QXmlStreamReader &xml, int menuType); + int parseMenuList(QXmlStreamReader &xml, QList &list); + + ControllerForm *parseControllerForm(QXmlStreamReader &xml); + + QString xmlPath; + UIInformation *uiInfo; +}; + +#endif // XMLLAYOUTPARSER_H diff --git a/tizen/src/util/Makefile.objs b/tizen/src/util/Makefile.objs index 43009e8e65..ac77989bd3 100644 --- a/tizen/src/util/Makefile.objs +++ b/tizen/src/util/Makefile.objs @@ -6,6 +6,9 @@ ifdef CONFIG_DARWIN 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 diff --git a/tizen/src/util/error_handler.c b/tizen/src/util/error_handler.c index 87f36f7c2b..654230726f 100644 --- a/tizen/src/util/error_handler.c +++ b/tizen/src/util/error_handler.c @@ -50,95 +50,16 @@ 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 { @@ -254,13 +175,6 @@ static void dump_backtrace(void *ptr, int depth) 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"); @@ -305,7 +219,7 @@ static WINAPI LONG maru_unhandled_exception_filter(LPEXCEPTION_POINTERS pExcepti #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 @@ -365,7 +279,18 @@ static void report(const char *fmt, va_list ap) // 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; } diff --git a/tizen/src/util/error_handler.h b/tizen/src/util/error_handler.h index 7081672d1a..f45b05f320 100644 --- a/tizen/src/util/error_handler.h +++ b/tizen/src/util/error_handler.h @@ -31,26 +31,6 @@ #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__ */ diff --git a/tizen/src/util/sdb.c b/tizen/src/util/sdb.c index f9f5f7066b..017587cee3 100644 --- a/tizen/src/util/sdb.c +++ b/tizen/src/util/sdb.c @@ -36,16 +36,21 @@ #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" @@ -449,7 +454,10 @@ static void command_handler(char* readbuf, struct sockaddr_in* client_addr) 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); @@ -624,3 +632,7 @@ static void start_sdb_noti_server(int server_port) emulator_add_exit_notifier(&sdb_noti_server_exit); } +bool is_sdb_daemon_initialized(void) +{ + return sdb_daemon_is_initialized; +} diff --git a/tizen/src/util/sdb.h b/tizen/src/util/sdb.h index cadb6ee657..97ae0912f3 100644 --- a/tizen/src/util/sdb.h +++ b/tizen/src/util/sdb.h @@ -58,6 +58,7 @@ int inet_strtoip(const char* str, uint32_t *ip); 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 diff --git a/tizen/src/util/ui_operations.c b/tizen/src/util/ui_operations.c new file mode 100644 index 0000000000..c255481bb3 --- /dev/null +++ b/tizen/src/util/ui_operations.c @@ -0,0 +1,199 @@ +/* + * UI operations + * + * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * SeokYeon Hwang + * + * 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); + } +} diff --git a/tizen/src/util/ui_operations.h b/tizen/src/util/ui_operations.h new file mode 100644 index 0000000000..910f1fb8d1 --- /dev/null +++ b/tizen/src/util/ui_operations.h @@ -0,0 +1,44 @@ +/* + * UI operations + * + * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * SeokYeon Hwang + * + * 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___ diff --git a/vl.c b/vl.c index 8036327aa2..a1d9dcdf17 100644 --- a/vl.c +++ b/vl.c @@ -133,8 +133,8 @@ int qemu_main(int argc, char **argv, char **envp); #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"