From 03096ca9f4bddb6e8b04cd73837e7c7c6342c14c Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Thu, 9 Dec 2021 00:01:22 +0600 Subject: [PATCH 1/4] Fix mouse support on EGLFS --- src/qt/qt_rendererstack.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/qt/qt_rendererstack.cpp b/src/qt/qt_rendererstack.cpp index bb80944de..b1c1bde5f 100644 --- a/src/qt/qt_rendererstack.cpp +++ b/src/qt/qt_rendererstack.cpp @@ -70,12 +70,14 @@ void RendererStack::mousePoll() #endif } +int ignoreNextMouseEvent = 1; void RendererStack::mouseReleaseEvent(QMouseEvent *event) { if (this->geometry().contains(event->pos()) && event->button() == Qt::LeftButton && !mouse_capture) { plat_mouse_capture(1); this->setCursor(Qt::BlankCursor); + if (!ignoreNextMouseEvent) ignoreNextMouseEvent++; // Avoid jumping cursor when moved. return; } if (mouse_capture && event->button() == Qt::MiddleButton && mouse_get_buttons() < 3) @@ -105,7 +107,6 @@ void RendererStack::wheelEvent(QWheelEvent *event) } } -int ignoreNextMouseEvent = 1; void RendererStack::mouseMoveEvent(QMouseEvent *event) { if (QApplication::platformName().contains("wayland")) @@ -122,8 +123,13 @@ void RendererStack::mouseMoveEvent(QMouseEvent *event) if (ignoreNextMouseEvent) { oldPos = event->pos(); ignoreNextMouseEvent--; event->accept(); return; } mousedata.deltax += event->pos().x() - oldPos.x(); mousedata.deltay += event->pos().y() - oldPos.y(); - if (event->globalPos().x() == 0 || event->globalPos().y() == 0) leaveEvent((QEvent*)event); - if (event->globalPos().x() == (screen()->geometry().width() - 1) || event->globalPos().y() == (screen()->geometry().height() - 1)) leaveEvent((QEvent*)event); + if (QApplication::platformName() == "eglfs") + { + leaveEvent((QEvent*)event); + ignoreNextMouseEvent--; + } + else if (event->globalPos().x() == 0 || event->globalPos().y() == 0) leaveEvent((QEvent*)event); + else if (event->globalPos().x() == (screen()->geometry().width() - 1) || event->globalPos().y() == (screen()->geometry().height() - 1)) leaveEvent((QEvent*)event); oldPos = event->pos(); #endif } From 55be576cb99fae803b9bf01edb4e288bd587d5e3 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Thu, 9 Dec 2021 16:27:53 +0600 Subject: [PATCH 2/4] Implement Help menu items --- src/qt/qt_mainwindow.cpp | 39 +++++++++++++++++++++++++++++++++++++++ src/qt/qt_mainwindow.hpp | 3 +++ src/qt/qt_mainwindow.ui | 30 ++++++++++++++++++++++++++++++ src/qt_resources.qrc | 4 ++++ 4 files changed, 76 insertions(+) diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 8d6a6b671..3ca336ad4 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -16,6 +16,10 @@ extern "C" { #include #include #include +#include +#include +#include +#include #include #include @@ -48,6 +52,8 @@ MainWindow::MainWindow(QWidget *parent) : ui->ogl->setRenderType(HardwareRenderer::RenderType::OpenGL); ui->gles->setRenderType(HardwareRenderer::RenderType::OpenGLES); + this->setWindowIcon(QIcon(":/settings/win/icons/86Box-yellow.ico")); + connect(this, &MainWindow::showMessageForNonQtThread, this, &MainWindow::showMessage_, Qt::BlockingQueuedConnection); connect(this, &MainWindow::setTitleForNonQtThread, this, &MainWindow::setTitle_, Qt::BlockingQueuedConnection); @@ -1071,3 +1077,36 @@ void MainWindow::on_actionBT709_HDTV_triggered() { void MainWindow::on_actionAverage_triggered() { update_greyscale_type_checkboxes(ui, ui->actionAverage, 2); } + +void MainWindow::on_actionAbout_Qt_triggered() +{ + QApplication::aboutQt(); +} + +void MainWindow::on_actionAbout_86Box_triggered() +{ + QMessageBox msgBox; + msgBox.setTextFormat(Qt::RichText); + msgBox.setText("About 86Box"); + msgBox.setInformativeText(R"( +An emulator of old computers + +Authors: Sarah Walker, Miran Grca, Fred N. van Kempen (waltje), SA1988, Tiseno100, reenigne, leilei, JohnElliott, greatpsycho, and others. + +Released under the GNU General Public License version 2 or later. See LICENSE for more information. +)"); + msgBox.setWindowTitle("About 86Box"); + msgBox.addButton("OK", QMessageBox::ButtonRole::AcceptRole); + auto webSiteButton = msgBox.addButton("86box.net", QMessageBox::ButtonRole::HelpRole); + webSiteButton->connect(webSiteButton, &QPushButton::released, []() + { + QDesktopServices::openUrl(QUrl("https://86box.net/")); + }); + msgBox.setIconPixmap(QIcon(":/settings/win/icons/86Box-yellow.ico").pixmap(32, 32)); + msgBox.exec(); +} + +void MainWindow::on_actionDocumentation_triggered() +{ + QDesktopServices::openUrl(QUrl("https://86box.readthedocs.io")); +} diff --git a/src/qt/qt_mainwindow.hpp b/src/qt/qt_mainwindow.hpp index 972b2a161..c84f65484 100644 --- a/src/qt/qt_mainwindow.hpp +++ b/src/qt/qt_mainwindow.hpp @@ -76,6 +76,9 @@ private slots: void on_actionAverage_triggered(); void on_actionBT709_HDTV_triggered(); void on_actionBT601_NTSC_PAL_triggered(); + void on_actionDocumentation_triggered(); + void on_actionAbout_86Box_triggered(); + void on_actionAbout_Qt_triggered(); void refreshMediaMenu(); void showMessage_(const QString& header, const QString& message); diff --git a/src/qt/qt_mainwindow.ui b/src/qt/qt_mainwindow.ui index af8a8a2bd..fafb6b3f2 100644 --- a/src/qt/qt_mainwindow.ui +++ b/src/qt/qt_mainwindow.ui @@ -166,10 +166,19 @@ Media + + + Help + + + + + + @@ -466,6 +475,27 @@ Average + + + About Qt... + + + QAction::AboutQtRole + + + + + About 86Box... + + + QAction::AboutRole + + + + + Documentation... + + diff --git a/src/qt_resources.qrc b/src/qt_resources.qrc index 8c66e5ca2..0db4552e9 100644 --- a/src/qt_resources.qrc +++ b/src/qt_resources.qrc @@ -43,5 +43,9 @@ win/icons/zip_disabled.ico win/icons/zip_empty.ico win/icons/zip_empty_active.ico + win/icons/86Box-gray.ico + win/icons/86Box-green.ico + win/icons/86Box-red.ico + win/icons/86Box-yellow.ico From 13b18c9d8d2f8254447772ec4a12a6908d95633b Mon Sep 17 00:00:00 2001 From: "Joakim L. Gilje" Date: Thu, 9 Dec 2021 11:55:28 +0100 Subject: [PATCH 3/4] added handler for force 4:3, monochrome contrast and overscan --- src/qt/qt_mainwindow.cpp | 27 +++++++++++++++++++++++++++ src/qt/qt_mainwindow.hpp | 3 +++ 2 files changed, 30 insertions(+) diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 8d6a6b671..b86127997 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -7,6 +7,7 @@ extern "C" { #include <86box/keyboard.h> #include <86box/plat.h> #include <86box/video.h> +#include <86box/vid_ega.h> }; #include @@ -181,6 +182,15 @@ MainWindow::MainWindow(QWidget *parent) : ui->actionAverage->setChecked(true); break; } + if (force_43 > 0) { + ui->actionForce_4_3_display_ratio->setChecked(true); + } + if (enable_overscan > 0) { + ui->actionCGA_PCjr_Tandy_EGA_S_VGA_overscan->setChecked(true); + } + if (vid_cga_contrast > 0) { + ui->actionChange_contrast_for_monochrome_display->setChecked(true); + } setFocusPolicy(Qt::StrongFocus); ui->gles->setFocusPolicy(Qt::NoFocus); @@ -1071,3 +1081,20 @@ void MainWindow::on_actionBT709_HDTV_triggered() { void MainWindow::on_actionAverage_triggered() { update_greyscale_type_checkboxes(ui, ui->actionAverage, 2); } + +void MainWindow::on_actionCGA_PCjr_Tandy_EGA_S_VGA_overscan_triggered() { + update_overscan = 1; + video_toggle_option(ui->actionCGA_PCjr_Tandy_EGA_S_VGA_overscan, &enable_overscan); +} + +void MainWindow::on_actionChange_contrast_for_monochrome_display_triggered() { + vid_cga_contrast ^= 1; + cgapal_rebuild(); + config_save(); +} + +void MainWindow::on_actionForce_4_3_display_ratio_triggered() { + video_toggle_option(ui->actionForce_4_3_display_ratio, &force_43); + video_force_resize_set(1); +} + diff --git a/src/qt/qt_mainwindow.hpp b/src/qt/qt_mainwindow.hpp index 972b2a161..148de615b 100644 --- a/src/qt/qt_mainwindow.hpp +++ b/src/qt/qt_mainwindow.hpp @@ -76,6 +76,9 @@ private slots: void on_actionAverage_triggered(); void on_actionBT709_HDTV_triggered(); void on_actionBT601_NTSC_PAL_triggered(); + void on_actionForce_4_3_display_ratio_triggered(); + void on_actionChange_contrast_for_monochrome_display_triggered(); + void on_actionCGA_PCjr_Tandy_EGA_S_VGA_overscan_triggered(); void refreshMediaMenu(); void showMessage_(const QString& header, const QString& message); From 05943477a6a923b36415a3ded2e93af7f0b567a1 Mon Sep 17 00:00:00 2001 From: "Joakim L. Gilje" Date: Thu, 9 Dec 2021 19:48:56 +0100 Subject: [PATCH 4/4] hide statusbar and menubar when fullscreen. prevent exit-fullscreen from triggering 'enter fullscreen' --- src/qt/qt_mainwindow.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 148d59fdf..5844e7765 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -787,9 +787,13 @@ uint16_t x11_keycode_to_keysym(uint32_t keycode) void MainWindow::on_actionFullscreen_triggered() { if (video_fullscreen > 0) { + ui->menubar->show(); + ui->statusbar->show(); showNormal(); video_fullscreen = 0; } else { + ui->menubar->hide(); + ui->statusbar->hide(); showFullScreen(); video_fullscreen = 1; } @@ -870,7 +874,7 @@ void MainWindow::keyPressEvent(QKeyEvent* event) keyboard_input(1, x11_keycode_to_keysym(event->nativeScanCode())); #endif - if (keyboard_isfsexit()) { + if ((video_fullscreen > 0) && keyboard_isfsexit()) { ui->actionFullscreen->trigger(); }