Skip to content
Permalink
Browse files

fix mouse selection for high DPI screens

  • Loading branch information
wwmayer committed Mar 14, 2019
1 parent 2f2d505 commit bb6e4e6ad44aa59d8d7c0de865b41df3febea0d2
Showing with 18 additions and 0 deletions.
  1. +18 −0 src/Gui/MouseSelection.cpp
@@ -390,7 +390,16 @@ int PolyPickerSelection::locationEvent(const SoLocation2Event* const, const QPoi

if (polyline.isWorking()) {
// check the position
#if QT_VERSION >= 0x050000
qreal dpr = _pcView3D->getGLWidget()->devicePixelRatioF();
#else
qreal dpr = 1.0;
#endif

This comment has been minimized.

Copy link
@f3nix

f3nix Mar 16, 2019

Contributor

Hi @wwmayer !
Would it make sense to use this:

/*!
The ratio between logical and physical pixel sizes -- obtained from the window that
the widget is located within, and updated whenever any change occurs, emitting a devicePixelRatioChanged signal. Only available for version Qt 5.6 and above (will be 1.0 for all previous versions)
*/
qreal
QuarterWidget::devicePixelRatio(void) const
{
return PRIVATE(this)->device_pixel_ratio;
}

instead?

This comment has been minimized.

Copy link
@wwmayer

wwmayer Mar 17, 2019

Author Contributor

I wasn't aware of this function. Yes, it makes sense to use it as it simplifies the code a bit.

QRect r = _pcView3D->getGLWidget()->rect();
if (dpr != 1.0) {
r.setHeight(r.height()*dpr);
r.setWidth(r.width()*dpr);
}

if (!r.contains(clPoint)) {
if (clPoint.x() < r.left())
@@ -599,7 +608,16 @@ int FreehandSelection::locationEvent(const SoLocation2Event* const e, const QPoi

if (polyline.isWorking()) {
// check the position
#if QT_VERSION >= 0x050000
qreal dpr = _pcView3D->getGLWidget()->devicePixelRatioF();
#else
qreal dpr = 1.0;
#endif
QRect r = _pcView3D->getGLWidget()->rect();
if (dpr != 1.0) {
r.setHeight(r.height()*dpr);
r.setWidth(r.width()*dpr);
}

if (!r.contains(clPoint)) {
if (clPoint.x() < r.left())

0 comments on commit bb6e4e6

Please sign in to comment.
You can’t perform that action at this time.