Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hidpi black screen issue #58

Merged
merged 1 commit into from
Mar 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/Inventor/Qt/SoQtGLWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,11 +522,13 @@ SoQtGLWidget::setGLSize(const SbVec2s size)
PRIVATE(this)->glSizeUnscaled = size;
#endif
if (PRIVATE(this)->currentglwidget) {
#if QT_VERSION >= 0x050000
#if QT_VERSION >= 0x050600
PRIVATE(this)->glSize = PRIVATE(this)->glSizeUnscaled * PRIVATE(this)->currentglwidget->devicePixelRatioF();
#elif QT_VERSION >= 0x050000
PRIVATE(this)->glSize = PRIVATE(this)->glSizeUnscaled * PRIVATE(this)->currentglwidget->devicePixelRatio();
#endif
int frame = this->isBorder() ? PRIVATE(this)->borderthickness : 0;
PRIVATE(this)->currentglwidget->setGeometry(QRect(frame, frame, PRIVATE(this)->glSize[0], PRIVATE(this)->glSize[1]));
PRIVATE(this)->currentglwidget->setGeometry(QRect(frame, frame, PRIVATE(this)->glSizeUnscaled[0], PRIVATE(this)->glSizeUnscaled[1]));
}

// Due to an internal hack in Qt/Mac 3.1.x, sometimes the OpenGL context
Expand Down Expand Up @@ -790,10 +792,14 @@ SoQtGLWidgetP::gl_changed(void)

#if QT_VERSION >= 0x050000
if (this->currentglwidget) {
#if QT_VERSION >= 0x050600
SbVec2s glSize = this->glSizeUnscaled * this->currentglwidget->devicePixelRatioF();
#else
SbVec2s glSize = this->glSizeUnscaled * this->currentglwidget->devicePixelRatio();
#endif
if (glSize != this->glSize) {
this->glSize = glSize;
this->wasresized = true;
PUBLIC(this)->setSize(PUBLIC(this)->getSize());
}
}
#endif
Expand Down
6 changes: 5 additions & 1 deletion src/Inventor/Qt/devices/SoQtMouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,13 @@ SoQtMouse::translateEvent(QEvent * event)
conv->setCtrlDown(mouseevent->state() & Qt::ControlButton);
conv->setAltDown(mouseevent->state() & Qt::AltButton);
#endif
#if (QT_VERSION >= 0x050000)
#if QT_VERSION >= 0x050000
QWidget* widget = QApplication::widgetAt(mouseevent->globalPos());
#if QT_VERSION >= 0x050600
qreal devicePixelRatio = NULL != widget ? widget->devicePixelRatioF() : qreal(1);
#else
qreal devicePixelRatio = NULL != widget ? widget->devicePixelRatio() : qreal(1);
#endif
this->setEventPosition(conv, mouseevent->x() * devicePixelRatio, mouseevent->y() * devicePixelRatio);
#else
this->setEventPosition(conv, mouseevent->x(), mouseevent->y());
Expand Down