diff --git a/src/qt/qt.c b/src/qt/qt.c
index 68b204dbc..bb6d9658d 100644
--- a/src/qt/qt.c
+++ b/src/qt/qt.c
@@ -51,6 +51,8 @@ plat_vidapi(char* api) {
return 4;
} else if (!strcasecmp(api, "qt_d3d9")) {
return 5;
+ } else if (!strcasecmp(api, "vnc")) {
+ return 6;
}
return 0;
@@ -78,6 +80,9 @@ char* plat_vidapi_name(int api) {
case 5:
name = "qt_d3d9";
break;
+ case 6:
+ name = "vnc";
+ break;
default:
fatal("Unknown renderer: %i\n", api);
break;
diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp
index 00ebb578e..f05c32ba6 100644
--- a/src/qt/qt_mainwindow.cpp
+++ b/src/qt/qt_mainwindow.cpp
@@ -46,6 +46,10 @@ extern "C" {
#include <86box/vid_ega.h>
#include <86box/version.h>
+#ifdef USE_VNC
+#include <86box/vnc.h>
+#endif
+
extern int qt_nvr_save(void);
#ifdef MTR_ENABLED
@@ -141,6 +145,8 @@ MainWindow::MainWindow(QWidget *parent) :
((BWindow*)this->winId())->AddFilter(filter);
#endif
setUnifiedTitleAndToolBarOnMac(true);
+ extern MainWindow* main_window;
+ main_window = this;
ui->setupUi(this);
ui->stackedWidget->setMouseTracking(true);
statusBar()->setVisible(!hide_status_bar);
@@ -308,6 +314,11 @@ MainWindow::MainWindow(QWidget *parent) :
if (vid_api == 5) vid_api = 0;
#endif
+#ifndef USE_VNC
+ if (vid_api == 6) vid_api = 0;
+ ui->actionVNC->setVisible(false);
+#endif
+
#if !QT_CONFIG(vulkan)
if (vid_api == 4) vid_api = 0;
ui->actionVulkan->setVisible(false);
@@ -322,10 +333,20 @@ MainWindow::MainWindow(QWidget *parent) :
actGroup->addAction(ui->actionOpenGL_3_0_Core);
actGroup->addAction(ui->actionVulkan);
actGroup->addAction(ui->actionDirect3D_9);
+ actGroup->addAction(ui->actionVNC);
actGroup->setExclusive(true);
connect(actGroup, &QActionGroup::triggered, [this](QAction* action) {
vid_api = action->property("vid_api").toInt();
+#ifdef USE_VNC
+ if (vnc_enabled && vid_api != 6) {
+ startblit();
+ vnc_enabled = 0;
+ vnc_close();
+ video_setblit(qt_blit);
+ endblit();
+ }
+#endif
RendererStack::Renderer newVidApi = RendererStack::Renderer::Software;
switch (vid_api)
{
@@ -347,6 +368,15 @@ MainWindow::MainWindow(QWidget *parent) :
case 5:
newVidApi = (RendererStack::Renderer::Direct3D9);
break;
+#ifdef USE_VNC
+ case 6:
+ {
+ newVidApi = RendererStack::Renderer::Software;
+ startblit();
+ vnc_enabled = vnc_init(nullptr);
+ endblit();
+ }
+#endif
}
ui->stackedWidget->switchRenderer(newVidApi);
if (!show_second_monitors) return;
@@ -469,7 +499,7 @@ MainWindow::MainWindow(QWidget *parent) :
ui->actionCtrl_Alt_Del->setShortcutVisibleInContextMenu(true);
ui->actionTake_screenshot->setShortcutVisibleInContextMenu(true);
#endif
- video_setblit(qt_blit);
+ if (!vnc_enabled) video_setblit(qt_blit);
if (start_in_fullscreen) {
connect(ui->stackedWidget, &RendererStack::blit, this, [this] () {
diff --git a/src/qt/qt_mainwindow.hpp b/src/qt/qt_mainwindow.hpp
index 0f8a5ecd2..c33decb44 100644
--- a/src/qt/qt_mainwindow.hpp
+++ b/src/qt/qt_mainwindow.hpp
@@ -144,6 +144,7 @@ private:
bool send_keyboard_input = true;
bool shownonce = false;
bool resizableonce = false;
+ bool vnc_enabled = false;
friend class SpecifyDimensions;
friend class ProgSettings;
diff --git a/src/qt/qt_mainwindow.ui b/src/qt/qt_mainwindow.ui
index f077f7e97..522d2f081 100644
--- a/src/qt/qt_mainwindow.ui
+++ b/src/qt/qt_mainwindow.ui
@@ -106,6 +106,7 @@
+
diff --git a/src/vnc.c b/src/vnc.c
index 46ef21c5d..27df6cb22 100644
--- a/src/vnc.c
+++ b/src/vnc.c
@@ -172,8 +172,10 @@ vnc_blit(int x, int y, int w, int h, int monitor_index)
uint32_t *p;
int yy;
- if (monitor_index || (x < 0) || (y < 0) || (w <= 0) || (h <= 0) || (w > 2048) || (h > 2048) || (buffer32 == NULL))
- return;
+ if (monitor_index || (x < 0) || (y < 0) || (w <= 0) || (h <= 0) || (w > 2048) || (h > 2048) || (buffer32 == NULL)) {
+ video_blit_complete_monitor(monitor_index);
+ return;
+ }
for (yy=0; yyframeBuffer)[yy*VNC_MAX_X]);
@@ -185,7 +187,7 @@ vnc_blit(int x, int y, int w, int h, int monitor_index)
if (screenshots)
video_screenshot((uint32_t *) rfb->frameBuffer, 0, 0, VNC_MAX_X);
- video_blit_complete();
+ video_blit_complete_monitor(monitor_index);
if (! updatingSize)
rfbMarkRectAsModified(rfb, 0,0, allowedX,allowedY);
@@ -210,7 +212,7 @@ vnc_init(UNUSED(void *arg))
32, 32, 0, 1, 255,255,255, 16, 8, 0, 0, 0
};
- cgapal_rebuild();
+ cgapal_rebuild_monitor(0);
if (rfb == NULL) {
wcstombs(title, ui_window_title(NULL), sizeof(title));