Store Maru display type as an enum and not as a bool
authorMateusz Majewski <m.majewski2@samsung.com>
Tue, 25 Mar 2025 10:06:02 +0000 (11:06 +0100)
committerMateusz Majewski <m.majewski2@samsung.com>
Tue, 25 Mar 2025 14:15:39 +0000 (15:15 +0100)
This will be necessary to introduce a third value.

Change-Id: I27d79cf6f647bfcd87418f7eaabc08a56aea35b8

hw/vigs/vigs_qt5.cpp
tizen/src/ui/mainwindow.cpp
tizen/src/ui/mainwindow.h
tizen/src/ui/qt5.c
tizen/src/ui/qt5.h
tizen/src/ui/qt5_supplement.cpp
tizen/src/ui/qt5_supplement.h
vl.c

index e33817a61e9a63343a32071aca0e1657166a48b5..ca8356a1f0c5d1b41ca83808e4c3671275db9b65 100644 (file)
 #include <QOpenGLContext>
 #include <qpa/qplatformnativeinterface.h>
 #include "config-host.h"
+#include "qt5_supplement.h"
 #include "vigs_qt5.h"
 
-extern bool qt5IsOnscreen;
+extern maru_display_type display_type;
 extern QApplication *qt5App;
 extern QOpenGLContext *qt5GLContext;
 
@@ -47,7 +48,7 @@ extern void qt5_update_texture(void *dpy_item);
 
 bool vigs_qt5_onscreen_enabled(void)
 {
-    if (qt5App != NULL && qt5IsOnscreen) {
+    if (qt5App != NULL && display_type == MARU_DISPLAY_TYPE_ONSCREEN) {
         return true;
     }
     return  false;
index d88f61bffe86fef992d3a179ceee8c802aa9e3d7..ce3e35b365bba4bbcff07a8c700e7f747a8b203f 100644 (file)
@@ -48,7 +48,7 @@ void qt5_graphic_hw_update(void);
 void qemu_system_graceful_shutdown_request(unsigned int sec);
 }
 
-MainWindow::MainWindow(UiInformation *uiInfo, bool useGL, QWidget *parent) :
+MainWindow::MainWindow(UiInformation *uiInfo, maru_display_type display_type, QWidget *parent) :
     QWidget(parent)
 {
     /* initialize */
@@ -105,7 +105,7 @@ MainWindow::MainWindow(UiInformation *uiInfo, bool useGL, QWidget *parent) :
 
     /* display */
     updateDisplayTransform();
-    createDisplay(useGL);
+    createDisplay(display_type);
 
     /* set HW Key shortcut */
     keyboardShortcut = new KeyboardShortcut(this);
@@ -118,19 +118,23 @@ MainWindow::MainWindow(UiInformation *uiInfo, bool useGL, QWidget *parent) :
         SLOT(slotContextMenu(const QPoint&)));
 }
 
-void MainWindow::createDisplay(bool useGL)
+void MainWindow::createDisplay(maru_display_type display_type)
 {
     qDebug("create a display");
+    DisplaySWWidget *widget;
 
-    if (useGL) { /* on-screen rendering */
+    switch (display_type) {
+    case MARU_DISPLAY_TYPE_ONSCREEN:
         this->display = new DisplayGLWidget(this,
             uiInfo->getMainFormDpyType(), uiInfo->getResolution(), getUiState()->getScaleFactor());
-    } else { /* off-screen rendering */
-        DisplaySWWidget *widget = new DisplaySWWidget(this,
+        break;
+    case MARU_DISPLAY_TYPE_OFFSCREEN:
+        widget = new DisplaySWWidget(this,
             uiInfo->getMainFormDpyType(), uiInfo->getResolution(), getUiState()->getScaleFactor());
 
         this->screenWidget = widget;
         this->display = widget;
+        break;
     }
 }
 
index 84159c7caecb568e56a6f6e113dc6734a516e53b..f66237a184c55b86ab3bde0d7553e0b6813b62d9 100644 (file)
@@ -39,6 +39,7 @@
 #include "menu/contextmenu.h"
 #include "mainview.h"
 #include "displaybase.h"
+#include "qt5_supplement.h"
 #include "rotaryview.h"
 #include "uiinformation.h"
 #include "controller/dockingcontroller.h"
@@ -54,7 +55,7 @@ public:
     bool isMovingMode;
 
     explicit MainWindow(UiInformation *uiInfo,
-                        bool useGL,
+                        maru_display_type display_type,
                         QWidget *parent = 0);
     ~MainWindow();
 
@@ -103,7 +104,7 @@ protected:
     QLabel *screenWidget;
 
 private:
-    void createDisplay(bool useGL);
+    void createDisplay(maru_display_type display_type);
     RotaryView *createRotary();
 
     UiInformation *uiInfo;
index c6023fcef2624b118bbac45cf2c2fef8d5693a45..6007112785bfb6e7ccb39f3334f1d5ce6c2d5a41 100644 (file)
@@ -129,10 +129,10 @@ static const DisplayChangeListenerOps dcl_ops = {
     .dpy_cursor_define = qt5_mouse_define,
 };
 
-void maru_early_qt5_display_init(bool isOnscreen)
+void maru_early_qt5_display_init(enum maru_display_type display_type)
 {
 #ifdef CONFIG_DARWIN
-    ns_run_in_event_loop_with_int(&qt5_early_prepare, isOnscreen);
+    ns_run_in_event_loop_with_int(&qt5_early_prepare, display_type);
 
     /* set emulator icon */
     const int path_len = strlen(get_bin_path()) +
@@ -146,13 +146,16 @@ void maru_early_qt5_display_init(bool isOnscreen)
     set_application_icon(icon_path);
     g_free(icon_path);
 #else
-    qt5_early_prepare(isOnscreen);
+    qt5_early_prepare(display_type);
 #endif
 
-    if (isOnscreen) {
+    switch (display_type) {
+    case MARU_DISPLAY_TYPE_ONSCREEN:
         LOG_INFO("Display Type: QT5 Onscreen\n");
-    } else {
+        break;
+    case MARU_DISPLAY_TYPE_OFFSCREEN:
         LOG_INFO("Display Type: QT5 Offscreen\n");
+        break;
     }
 }
 
index 226ea3759d86d60d8f2518299046144e82b379ee..f9dfdbdecb0c2c4220019704edd6a1827730ac02 100644 (file)
@@ -33,8 +33,9 @@
 
 #include "qemu/osdep.h"
 #include "sysemu/sysemu.h"
+#include "qt5_supplement.h"
 
-void maru_early_qt5_display_init(bool isOnscreen);
+void maru_early_qt5_display_init(enum maru_display_type);
 void maru_qt5_display_init(DisplayState *ds, int full_screen);
 void maru_qt5_display_fini(void);
 
index d546ea8065fb998d747490c9730dedfc28871694..113ac3dd07b9d93f691cbaba09d11c89c839e93b 100644 (file)
@@ -53,7 +53,7 @@ bool is_display_off(void);
 }
 
 //using namespace std;
-bool qt5IsOnscreen;
+maru_display_type display_type;
 QApplication *qt5App = NULL;
 QOpenGLContext *qt5GLContext;
 bool isForceLegacy;
@@ -326,7 +326,7 @@ static void qt5_gui_init(void)
     /* GUI */
     qDebug("start!");
 
-    mainwindow = new MainWindow(uiInfo, qt5IsOnscreen);
+    mainwindow = new MainWindow(uiInfo, display_type);
     mainwindow->setCaptureRequestHandler(captureRequestListener, captureRequestHandler);
 
     /* position */
@@ -440,13 +440,13 @@ void qt5_set_force_legacy(bool isLegacy)
     isForceLegacy = isLegacy;
 }
 
-void qt5_early_prepare(bool isOnscreen)
+void qt5_early_prepare(enum maru_display_type _display_type)
 {
-    qt5IsOnscreen = isOnscreen;
+    display_type = _display_type;
 
     Q_INIT_RESOURCE(resource);
 
-    if (qt5IsOnscreen) {
+    if (display_type == MARU_DISPLAY_TYPE_ONSCREEN) {
         QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
         QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
 
@@ -481,7 +481,7 @@ void qt5_early_prepare(bool isOnscreen)
     eventFilter = new EventFilter();
     qt5App->installNativeEventFilter(eventFilter);
 #endif
-    if (qt5IsOnscreen) {
+    if (display_type == MARU_DISPLAY_TYPE_ONSCREEN) {
         qt5GLContext = QOpenGLContext::globalShareContext();
         qDebug("* Qt global share context: OpenGL %d.%d(Profile:%d)",
                qt5GLContext->format().majorVersion(),
index dbdcd06be23a5cf7508b1deb091b7f1d1b0f287e..73b82e0360cda8164c50773fe5bbfa7a04970aac 100644 (file)
 #ifdef __cplusplus
 extern "C" {
 #endif
+
+enum maru_display_type {
+    MARU_DISPLAY_TYPE_ONSCREEN,
+    MARU_DISPLAY_TYPE_OFFSCREEN,
+};
+
 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_early_prepare(enum maru_display_type);
 void qt5_prepare(void);
 void qt5_destroy(void);
 
diff --git a/vl.c b/vl.c
index 91c0f08c2c1dabc7a1a0038bc2170ac7a4d053ec..3317a1424bc7697a4baab1c134454fce86d957b1 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -4489,9 +4489,9 @@ int main(int argc, char **argv, char **envp)
 #ifdef CONFIG_MARU
 # if defined(CONFIG_QT)
     if (display_type == DT_MARU_QT_ONSCREEN) {
-        maru_early_qt5_display_init(true);
+        maru_early_qt5_display_init(MARU_DISPLAY_TYPE_ONSCREEN);
     } else if (display_type == DT_MARU_QT_OFFSCREEN) {
-        maru_early_qt5_display_init(false);
+        maru_early_qt5_display_init(MARU_DISPLAY_TYPE_OFFSCREEN);
     }
 # endif
 #endif