qt: Enable and make VNC work properly

This commit is contained in:
Cacodemon345
2022-08-03 13:05:21 +06:00
parent e375bc216f
commit 468ef84399
5 changed files with 55 additions and 5 deletions

View File

@@ -51,6 +51,8 @@ plat_vidapi(char* api) {
return 4; return 4;
} else if (!strcasecmp(api, "qt_d3d9")) { } else if (!strcasecmp(api, "qt_d3d9")) {
return 5; return 5;
} else if (!strcasecmp(api, "vnc")) {
return 6;
} }
return 0; return 0;
@@ -78,6 +80,9 @@ char* plat_vidapi_name(int api) {
case 5: case 5:
name = "qt_d3d9"; name = "qt_d3d9";
break; break;
case 6:
name = "vnc";
break;
default: default:
fatal("Unknown renderer: %i\n", api); fatal("Unknown renderer: %i\n", api);
break; break;

View File

@@ -46,6 +46,10 @@ extern "C" {
#include <86box/vid_ega.h> #include <86box/vid_ega.h>
#include <86box/version.h> #include <86box/version.h>
#ifdef USE_VNC
#include <86box/vnc.h>
#endif
extern int qt_nvr_save(void); extern int qt_nvr_save(void);
#ifdef MTR_ENABLED #ifdef MTR_ENABLED
@@ -141,6 +145,8 @@ MainWindow::MainWindow(QWidget *parent) :
((BWindow*)this->winId())->AddFilter(filter); ((BWindow*)this->winId())->AddFilter(filter);
#endif #endif
setUnifiedTitleAndToolBarOnMac(true); setUnifiedTitleAndToolBarOnMac(true);
extern MainWindow* main_window;
main_window = this;
ui->setupUi(this); ui->setupUi(this);
ui->stackedWidget->setMouseTracking(true); ui->stackedWidget->setMouseTracking(true);
statusBar()->setVisible(!hide_status_bar); statusBar()->setVisible(!hide_status_bar);
@@ -308,6 +314,11 @@ MainWindow::MainWindow(QWidget *parent) :
if (vid_api == 5) vid_api = 0; if (vid_api == 5) vid_api = 0;
#endif #endif
#ifndef USE_VNC
if (vid_api == 6) vid_api = 0;
ui->actionVNC->setVisible(false);
#endif
#if !QT_CONFIG(vulkan) #if !QT_CONFIG(vulkan)
if (vid_api == 4) vid_api = 0; if (vid_api == 4) vid_api = 0;
ui->actionVulkan->setVisible(false); ui->actionVulkan->setVisible(false);
@@ -322,10 +333,20 @@ MainWindow::MainWindow(QWidget *parent) :
actGroup->addAction(ui->actionOpenGL_3_0_Core); actGroup->addAction(ui->actionOpenGL_3_0_Core);
actGroup->addAction(ui->actionVulkan); actGroup->addAction(ui->actionVulkan);
actGroup->addAction(ui->actionDirect3D_9); actGroup->addAction(ui->actionDirect3D_9);
actGroup->addAction(ui->actionVNC);
actGroup->setExclusive(true); actGroup->setExclusive(true);
connect(actGroup, &QActionGroup::triggered, [this](QAction* action) { connect(actGroup, &QActionGroup::triggered, [this](QAction* action) {
vid_api = action->property("vid_api").toInt(); 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; RendererStack::Renderer newVidApi = RendererStack::Renderer::Software;
switch (vid_api) switch (vid_api)
{ {
@@ -347,6 +368,15 @@ MainWindow::MainWindow(QWidget *parent) :
case 5: case 5:
newVidApi = (RendererStack::Renderer::Direct3D9); newVidApi = (RendererStack::Renderer::Direct3D9);
break; break;
#ifdef USE_VNC
case 6:
{
newVidApi = RendererStack::Renderer::Software;
startblit();
vnc_enabled = vnc_init(nullptr);
endblit();
}
#endif
} }
ui->stackedWidget->switchRenderer(newVidApi); ui->stackedWidget->switchRenderer(newVidApi);
if (!show_second_monitors) return; if (!show_second_monitors) return;
@@ -469,7 +499,7 @@ MainWindow::MainWindow(QWidget *parent) :
ui->actionCtrl_Alt_Del->setShortcutVisibleInContextMenu(true); ui->actionCtrl_Alt_Del->setShortcutVisibleInContextMenu(true);
ui->actionTake_screenshot->setShortcutVisibleInContextMenu(true); ui->actionTake_screenshot->setShortcutVisibleInContextMenu(true);
#endif #endif
video_setblit(qt_blit); if (!vnc_enabled) video_setblit(qt_blit);
if (start_in_fullscreen) { if (start_in_fullscreen) {
connect(ui->stackedWidget, &RendererStack::blit, this, [this] () { connect(ui->stackedWidget, &RendererStack::blit, this, [this] () {

View File

@@ -144,6 +144,7 @@ private:
bool send_keyboard_input = true; bool send_keyboard_input = true;
bool shownonce = false; bool shownonce = false;
bool resizableonce = false; bool resizableonce = false;
bool vnc_enabled = false;
friend class SpecifyDimensions; friend class SpecifyDimensions;
friend class ProgSettings; friend class ProgSettings;

View File

@@ -106,6 +106,7 @@
<addaction name="actionOpenGL_3_0_Core"/> <addaction name="actionOpenGL_3_0_Core"/>
<addaction name="actionVulkan"/> <addaction name="actionVulkan"/>
<addaction name="actionDirect3D_9"/> <addaction name="actionDirect3D_9"/>
<addaction name="actionVNC"/>
</widget> </widget>
<widget class="QMenu" name="menuWindow_scale_factor"> <widget class="QMenu" name="menuWindow_scale_factor">
<property name="title"> <property name="title">
@@ -766,6 +767,17 @@
<string>Show non-primary monitors</string> <string>Show non-primary monitors</string>
</property> </property>
</action> </action>
<action name="actionVNC">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>VNC</string>
</property>
<property name="vid_api" stdset="0">
<number>6</number>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>

View File

@@ -172,8 +172,10 @@ vnc_blit(int x, int y, int w, int h, int monitor_index)
uint32_t *p; uint32_t *p;
int yy; int yy;
if (monitor_index || (x < 0) || (y < 0) || (w <= 0) || (h <= 0) || (w > 2048) || (h > 2048) || (buffer32 == NULL)) if (monitor_index || (x < 0) || (y < 0) || (w <= 0) || (h <= 0) || (w > 2048) || (h > 2048) || (buffer32 == NULL)) {
video_blit_complete_monitor(monitor_index);
return; return;
}
for (yy=0; yy<h; yy++) { for (yy=0; yy<h; yy++) {
p = (uint32_t *)&(((uint32_t *)rfb->frameBuffer)[yy*VNC_MAX_X]); p = (uint32_t *)&(((uint32_t *)rfb->frameBuffer)[yy*VNC_MAX_X]);
@@ -185,7 +187,7 @@ vnc_blit(int x, int y, int w, int h, int monitor_index)
if (screenshots) if (screenshots)
video_screenshot((uint32_t *) rfb->frameBuffer, 0, 0, VNC_MAX_X); video_screenshot((uint32_t *) rfb->frameBuffer, 0, 0, VNC_MAX_X);
video_blit_complete(); video_blit_complete_monitor(monitor_index);
if (! updatingSize) if (! updatingSize)
rfbMarkRectAsModified(rfb, 0,0, allowedX,allowedY); 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 32, 32, 0, 1, 255,255,255, 16, 8, 0, 0, 0
}; };
cgapal_rebuild(); cgapal_rebuild_monitor(0);
if (rfb == NULL) { if (rfb == NULL) {
wcstombs(title, ui_window_title(NULL), sizeof(title)); wcstombs(title, ui_window_title(NULL), sizeof(title));