Merge pull request #2467 from Cacodemon345/multimonitor-take2-ui

qt: Make renderer widget resizable only once
This commit is contained in:
Miran Grča
2022-07-16 22:13:50 +02:00
committed by GitHub
3 changed files with 12 additions and 6 deletions

View File

@@ -229,7 +229,10 @@ MainWindow::MainWindow(QWidget *parent) :
}); });
connect(this, &MainWindow::resizeContents, this, [this](int w, int h) { connect(this, &MainWindow::resizeContents, this, [this](int w, int h) {
ui->stackedWidget->setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); if (shownonce) {
if (resizableonce == false) ui->stackedWidget->setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
resizableonce = true;
}
if (!QApplication::platformName().contains("eglfs") && vid_resize != 1) { if (!QApplication::platformName().contains("eglfs") && vid_resize != 1) {
w = (w / (!dpi_scale ? util::screenOfWidget(this)->devicePixelRatio() : 1.)); w = (w / (!dpi_scale ? util::screenOfWidget(this)->devicePixelRatio() : 1.));
@@ -558,7 +561,7 @@ void MainWindow::closeEvent(QCloseEvent *event) {
if (renderers[i]) { if (renderers[i]) {
monitor_settings[i].mon_window_w = renderers[i]->geometry().width(); monitor_settings[i].mon_window_w = renderers[i]->geometry().width();
monitor_settings[i].mon_window_h = renderers[i]->geometry().height(); monitor_settings[i].mon_window_h = renderers[i]->geometry().height();
if (!QApplication::platformName().contains("wayland")) continue; if (QApplication::platformName().contains("wayland")) continue;
monitor_settings[i].mon_window_x = renderers[i]->geometry().x(); monitor_settings[i].mon_window_x = renderers[i]->geometry().x();
monitor_settings[i].mon_window_y = renderers[i]->geometry().y(); monitor_settings[i].mon_window_y = renderers[i]->geometry().y();
} }
@@ -582,7 +585,6 @@ void MainWindow::initRendererMonitorSlot(int monitor_index)
auto& secondaryRenderer = this->renderers[monitor_index]; auto& secondaryRenderer = this->renderers[monitor_index];
secondaryRenderer.reset(new RendererStack(nullptr, monitor_index)); secondaryRenderer.reset(new RendererStack(nullptr, monitor_index));
if (secondaryRenderer) { if (secondaryRenderer) {
connect(this, &MainWindow::pollMouse, secondaryRenderer.get(), &RendererStack::mousePoll, Qt::DirectConnection);
connect(secondaryRenderer.get(), &RendererStack::rendererChanged, this, [this, monitor_index] connect(secondaryRenderer.get(), &RendererStack::rendererChanged, this, [this, monitor_index]
{ {
this->renderers[monitor_index]->show(); this->renderers[monitor_index]->show();

View File

@@ -141,6 +141,7 @@ private:
/* If main window should send keyboard input */ /* If main window should send keyboard input */
bool send_keyboard_input = true; bool send_keyboard_input = true;
bool shownonce = false; bool shownonce = false;
bool resizableonce = false;
friend class SpecifyDimensions; friend class SpecifyDimensions;
friend class ProgSettings; friend class ProgSettings;

View File

@@ -34,6 +34,7 @@
#include "evdev_mouse.hpp" #include "evdev_mouse.hpp"
#include <atomic>
#include <stdexcept> #include <stdexcept>
#include <QScreen> #include <QScreen>
@@ -53,8 +54,8 @@ double mouse_sensitivity = 1.0;
} }
struct mouseinputdata { struct mouseinputdata {
int deltax, deltay, deltaz; atomic_int deltax, deltay, deltaz;
int mousebuttons; atomic_int mousebuttons;
}; };
static mouseinputdata mousedata; static mouseinputdata mousedata;
@@ -145,7 +146,7 @@ int ignoreNextMouseEvent = 1;
void void
RendererStack::mouseReleaseEvent(QMouseEvent *event) RendererStack::mouseReleaseEvent(QMouseEvent *event)
{ {
if (this->geometry().contains(event->pos()) && event->button() == Qt::LeftButton && !mouse_capture && (isMouseDown & 1)) { if (this->geometry().contains(event->pos()) && event->button() == Qt::LeftButton && !mouse_capture && (isMouseDown & 1) && mouse_get_buttons() != 0) {
plat_mouse_capture(1); plat_mouse_capture(1);
this->setCursor(Qt::BlankCursor); this->setCursor(Qt::BlankCursor);
if (!ignoreNextMouseEvent) if (!ignoreNextMouseEvent)
@@ -164,6 +165,7 @@ RendererStack::mouseReleaseEvent(QMouseEvent *event)
} }
isMouseDown &= ~1; isMouseDown &= ~1;
} }
void void
RendererStack::mousePressEvent(QMouseEvent *event) RendererStack::mousePressEvent(QMouseEvent *event)
{ {
@@ -173,6 +175,7 @@ RendererStack::mousePressEvent(QMouseEvent *event)
} }
event->accept(); event->accept();
} }
void void
RendererStack::wheelEvent(QWheelEvent *event) RendererStack::wheelEvent(QWheelEvent *event)
{ {