summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qhighdpiscaling.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Don’t warn on QT_AUTO_SCREEN_SCALE_FACTOR usageMorten Johan Sørvig2019-11-201-6/+3
| | | | | | | | | | | | | This warning turned out to be spammy, since the env. variable may be set by KDE, in which case there is nothing the user or app developer can do to fix the situation. QT_AUTO_SCREEN_SCALE_FACTOR is now Done on X11, and remains Deprecated on all other platforms. Change-Id: I9d372655624b0e0b822f0a70e9aec4b18ab98630 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* QHighDpiScaling: impove readability of screenSubfactor methodVitaly Fanaskov2019-11-071-10/+11
| | | | | | Task-number: QTBUG-53022 Change-Id: Idae4379dd78d3125c375fad37a5a3af5bbcdc51e Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* QHighDpiScaling: fix potential null pointer dereferenceVitaly Fanaskov2019-11-071-1/+2
| | | | | | | | | | It's not guaranteed that QPlatformScreen::screen should always return a valid pointer. Furthermore, you can run into this situation with, for example, two screens setup. Task-number: QTBUG-53022 Change-Id: Ic23bb2c30b1245f98a793a44cc5e0b39f9afac4b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Merge remote-tracking branch 'origin/5.13' into 5.14Joerg Bornemann2019-09-201-1/+3
|\ | | | | | | | | | | | | | | Conflicts: qmake/generators/makefile.cpp qmake/generators/makefile.h Change-Id: I4c2deac4f6376c85f5e4fe7fb0ccc9ab9a013cd7
| * QHighDPI: Fix wrong conversion for native child windowsFriedemann Kleint2019-09-181-1/+3
| | | | | | | | | | | | | | | | Do not try to find a screen for native child coordinates. Fixes: QTBUG-78158 Change-Id: I78ba814929f4db3dfd7dd43c09f7c7642222f4fb Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* | QDpi: divide the forced DPI by the scaling factor, as Qt 5.13 didDavid Faure2019-09-131-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | When setting a DPI in xrdb, it should have the same effect on apps that enable scaling and apps that don't (including Qt4 and GTK applications). That's what happened in Qt 5.13, while the recent changes removed that division, and as a result the fonts were huge in Qt5 apps compared to Qt4/GTK/kwin/plasmashell/krunner (which don't scale, but do honor the font DPI). Change-Id: Icd7be2d15a9b50982ae624e41bd9e546f315d58b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* | Dpi settings: QT_SCREEN_SCALE_FACTORS enables scaling againDavid Faure2019-09-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | commit 900f2cb6f7070 removed this from the condition, which breaks the (common) case of having QT_AUTO_SCREEN_SCALE_FACTOR=0 and QT_SCREEN_SCALE_FACTORS set. This used to obey the screen scale factors, so it should still do so (despite the deprecation warning). This is what the Plasma `kcmshell5 kscreen` module actually sets (via startkde). Change-Id: I5f4efed11b937498049ebf1b107954721cf54147 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* | QtGui: Refactor parsing of the High DPI scaling env variablesFriedemann Kleint2019-09-031-9/+10
| | | | | | | | | | | | | | | | | | Use qEnvironmentVariable() where applicable and refactor the parsing of QT_SCREEN_SCALE_FACTORS to use QStringRef. Task-number: QTBUG-53022 Change-Id: I8956c6cecd7b634679eb5e66d2a87cccaf9e7936 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* | Add high-DPI scale factor rounding policy C++ APIMorten Johan Sørvig2019-08-231-21/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This API enables tuning of how Qt rounds fractional scale factors, and corresponds to the QT_SCALE_FACTOR_ROUNDING_POLICY environment variable New API: Qt::HighDPiScaleFactorRoundingPolicy QGuiApplication::setHighDpiScaleFactorRoundingPolicy() QGuiApplication::highDpiScaleFactorRoundingPolicy() Done-with: Friedemann Kleint <Friedemann.Kleint@qt.io> Task-number: QTBUG-53022 Change-Id: Ic360f26a173caa757e4ebde35ce08a6b74290b7d Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Deprecate QT_AUTO_SCREEN_SCALE_FACTORMorten Johan Sørvig2019-08-231-6/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace by QT_ENABLE_HIGHDPI_SCALING. QT_AUTO_SCREEN_SCALE_FACTOR has the usability problem that it mixes enabling the high-DPI scaling mode with the method of getting screen scale factors (“auto”). Due to this, it ends up with a slightly strange name. QT_ENABLE_HIGHDPI_SCALING matches the C++ option (Qt::AA_EnableHighDPiScaling), and leaves the scale factor acquisition method unspecified, possibly to be set by some other means (like QT_SCREEN_SCALE_FACTORS). Done-with: Friedemann Kleint <Friedemann.Kleint@qt.io> Task-number: QTBUG-53022 Change-Id: I30033d91175a00db7837efc9c48c33396f5f0449 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Update QT_SCREEN_SCALE_FACTORSFriedemann Kleint2019-08-231-16/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Store name->factor associations in a global QHash instead of on the QScreen object, making them survive QScreen object deletion, for example on disconnect/ connect cycles. Make factors set with QT_SCREEN_SCALE_FACTORS override the screen factors computed from platform plugin DPI values. This matches the use case for QT_SCREEN_SCALE_FACTORS (but not the general scale factors combine by multiplication”principle) Done-with: Friedemann Kleint <Friedemann.Kleint@qt.io> Task-number: QTBUG-53022 Change-Id: I12771249314ab0c073e609d62f57ac0d18d3b6ce Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Move QT_FONT_DPI to cross-platform codeMorten Johan Sørvig2019-08-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes it possible to test the effects of setting Qt::AA_HighDpiScaling/QT_AUTO_SCREEN_SCALE_FACTOR, with different DPI values on all platforms. This also makes it possible to access the actual DPI values reported by the OS/WS via the QPlatformScreen API. A drawback is that there is no single place to check the environment variable; currently done in three places. This may be further simplified later on. Done-with: Friedemann Kleint <Friedemann.Kleint@qt.io> Task-number: QTBUG-53022 Change-Id: Idd6463219d3ae58fe0ab72c17686cce2eb9dbadd Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Update Dpi and scale factor computationMorten Johan Sørvig2019-08-231-24/+210
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove pixelScale() in favor of logicalBaseDpi(). Compute scale factor based on logical DPI and logical base DPI, or optionally based on the physical DPI. Add policies for running the scale factor and adjusting the logical DPI reported to the application. The policies are set via environment variables: QT_SCALE_FACTOR_ROUNDING_POLICY=Round|Ceil|Floor|RoundPreferFloor|PassThrough QT_DPI_ADJUSTMENT_POLICY=AdjustDpi|DontAdjustDpi|AdjustUpOnly QT_USE_PHYSICAL_DPI=0|1 Done-with: Friedemann Kleint <Friedemann.Kleint@qt.io> Task-number: QTBUG-53022 Change-Id: I4846f223186df665eb0a9c827eaef0a96d1f458f Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Compute logical DPI on a per-screen basisMorten Johan Sørvig2019-08-231-11/+9
|/ | | | | | | | | | | | | | | The logical DPI reported to applications is the platform screen logical DPI divided by the platform screen scale factor. Use the screen in question when calculating the DPI instead of the values from the main screen. QHighDpiScaling::logicalDpi now takes a QScreen pointer. Done-with: Friedemann Kleint <Friedemann.Kleint@qt.io> Task-number: QTBUG-53022 Change-Id: I0f62b5878c37e3488e9a8cc48aef183ff822d0c4 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Add nullptr guard to QHighDScaling::scaleAndOrigin(QPlatformScreen *)Morten Johan Sørvig2019-08-111-0/+2
| | | | | | | | | Commit b6ded193 added an unconditional dereference of the platformScreen pointer, for calls where nativePostion is non-nullptr. Change-Id: I4a6fbbd0337f91d4fcb76c17b4dc60e1b9ad10ed Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QHighDpi::fromNativePixels: use correct screenMorten Johan Sørvig2019-06-191-36/+14
| | | | | | | | | | | | | | | | Calls like QHighDpi::fromNativePixels(point, window) would return device independent coordinates outside any screen in cases where the window is spanning multiple screens and the native point was not on the main screen. Correct this by looking up the correct screen and use its scale factor and origin when scaling coordinates. Task-number: QTBUG-73231 Change-Id: I01a3a42f42121b8d9f4ced2bb0fb023d6ae6bfe7 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* High DPI: Fix crash in QWindow::mapFromGlobal()Friedemann Kleint2019-06-191-1/+1
| | | | | | | | | | | With Web Engine, QQuickWidget or similar, the code can hit on the offscreen window, when its handle is null. Add a check. Amends 3af7b279177f7fb092f0e0fb9ffc8e8d846ed774. Fixes: QTBUG-76440 Change-Id: I123633d18386efd3dbfb22aad6072e4f0877a62e Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QHighDpi: Simplify top-level window handling codeMorten Johan Sørvig2019-05-141-0/+8
| | | | | | | | | | | | | Introduce origin(QWindow *), which returns the point around which coordinates should be scaled: the screen origin for top-level windows, and (0, 0) for child windows. The code paths for top-level and child windows can then be combined. Change-Id: I6b9cdbd9e7c2d9406e9137e325c4eb5c79e3ac9a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix QWindow::mapToGlobal()/mapFromGlobal() for multi-screen windowsMorten Johan Sørvig2019-05-131-0/+42
| | | | | | | | | | | | | | | | | | Make these functions handle the case where a window spans multiple screens, and high-DPI scaling is enabled, and the local position (in the window) is not on the window primary screen (as returned by QWindow::screen()). This is done by detecting the case, and then calculating the correct position using the native coordinate system. [ChangeLog][QtGui] QWindow::mapToGlobal()/mapFromGlobal() now handle windows spanning screens correctly. Done-with: Friedemann Kleint<Friedemann.Kleint@qt.io> Task-number: QTBUG-73231 Change-Id: I3c31b741344d9e85e4f5d9e60bae75acce2db741 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* fix crash if no screens are availableRolf Eike Beer2019-01-211-3/+6
| | | | | | Fixes: QTBUG-73166 Change-Id: I936672b7a09a540d21e6dcd371f5ffe1e5536b85 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QByteArray: add compare() with case sensitivity optionsThiago Macieira2018-06-221-1/+2
| | | | | | | | | | | | | Need to do the same for startsWith() and endsWith(). indexOf() is a lot harder. [ChangeLog][QtCore][QByteArray] Added compare(), which takes Qt::CaseSensitivity as one of the parameters. This function is more efficient than using toLower() or toUpper() and then comparing. Change-Id: Ib48364abee9f464c96c6fffd152e69bde4194df7 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Merge remote-tracking branch 'origin/5.10' into devLars Knoll2018-01-021-2/+16
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf sc/corelib/io/qfsfileengine_p.h src/corelib/io/qstorageinfo_unix.cpp src/platformsupport/eglconvenience/qeglpbuffer_p.h src/platformsupport/input/libinput/qlibinputkeyboard.cpp src/platformsupport/input/libinput/qlibinputpointer.cpp src/plugins/platforms/cocoa/qcocoamenu.mm src/plugins/platforms/ios/qiosscreen.h src/plugins/platforms/ios/qioswindow.h src/plugins/platforms/ios/quiview.mm src/printsupport/dialogs/qpagesetupdialog_unix_p.h src/printsupport/dialogs/qprintpreviewdialog.cpp src/printsupport/widgets/qcupsjobwidget_p.h src/widgets/widgets/qmenu.cpp tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp Change-Id: Iecb4883122efe97ef0ed850271e6c51bab568e9c
| * Adjust screen scale factor for certain screen configurationsVictor-Andrei Variu2017-11-171-2/+16
| | | | | | | | | | | | | | | | | | | | | | Pixel density reported by the screen is sometimes not precise enough, so recalculate it: divide px (physical pixels) by dp (device-independent pixels) for both width and height, and then use the average if it is different from the one initially reported by the screen Task-number: QTBUG-62191 Change-Id: Ia2f485c7ce8849db6e7c1d2ac08f5e008aea2ff8 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* | Fix spelling issues in qhighdpiscaling.cppTor Arne Vestbø2017-11-131-3/+3
|/ | | | | Change-Id: I4ca5a2e79ff88a664505273d2a9f38b1b499076c Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Merge remote-tracking branch 'origin/5.7' into 5.8Liang Qi2016-11-161-2/+4
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: mkspecs/common/linux-android.conf src/gui/opengl/qopengl.h src/network/socket/qnativesocketengine_winrt.cpp src/network/socket/qnativesocketengine_winrt_p.h src/plugins/platforms/cocoa/qcocoawindow.mm src/plugins/platforms/eglfs/api/qeglfsintegration.cpp src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp sync.profile Change-Id: If70aaf2c49df91157b864cf0d7d9513546c9bec4
| * Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-11-151-2/+4
| |\ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: configure src/plugins/platforms/eglfs/qeglfsintegration.cpp src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp Change-Id: Id2da7c775439adb62646d5b741ee7c638042b34b
| | * Only turn off font hinting when scale is != 1Paul Olav Tvete2016-11-081-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | KDE will set the screen scale factors to 1 by default. Make sure we don't turn off font hinting in that case. Task-number: QTBUG-56797 Change-Id: Ieab18a7cfe4c1cb7087caab4d881932a4a991bc8 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* | | Merge remote-tracking branch 'origin/5.7' into 5.8Liang Qi2016-09-211-4/+4
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 5971b88e is not needed in new configure. This merge also reverts "fix QMAKE_DEFAULT_*DIRS resolution with apple SDK", 2c9d15d7, because it breaks iOS build with new configure system. Conflicts: mkspecs/features/default_pre.prf mkspecs/features/mac/toolchain.prf mkspecs/features/toolchain.prf src/dbus/qdbusconnection.cpp src/plugins/sqldrivers/mysql/qsql_mysql.cpp src/sql/drivers/mysql/qsql_mysql.cpp src/widgets/widgets/qmenubar.cpp src/widgets/widgets/qmenubar_p.h tools/configure/configureapp.cpp tools/configure/environment.cpp tools/configure/environment.h Change-Id: I995533dd334211ebd25912db05b639d6f908aaec
| * | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-09-161-4/+4
| |\| | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp Change-Id: I0af32ee55936d523cbd259b6fe82eb9c409f9074
| | * Fix typos in highdpi docsFrederik Gladhorn2016-09-151-4/+4
| | | | | | | | | | | | | | | | | | Change-Id: I15fd6859ff777388a229e3cb10de45886fe543fb Reviewed-by: Nico Vertriest <nico.vertriest@theqtcompany.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* | | Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-08-161-1/+1
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: qmake/doc/src/qmake-manual.qdoc src/corelib/global/qglobal.cpp src/corelib/tools/qstring.cpp src/network/socket/qabstractsocket.cpp src/network/socket/qnativesocketengine_unix.cpp src/plugins/platforms/eglfs/api/qeglfsglobal.h Change-Id: Id5dfdbd30fa996f9b4b66a0b030b7d3b8c0ef288
| * | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-08-131-1/+1
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/qglobal.cpp src/corelib/io/qsettings.cpp src/corelib/itemmodels/qstringlistmodel.cpp tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp Change-Id: I1c6c306ef42c3c0234b19907914b19da706b4a03
| | * Doc: Change instances of '(Mac) OS X' to 'macOS'Topi Reinio2016-08-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As of version 10.12 (Sierra), the name of Apple's desktop operating system will be macOS. Change the occurrences where the Mac platform is discussed to use a macro \macos, which expands to 'macOS'. This helps with adapting to future renaming. Update the instructions on mac-specific Q_OS_* macro usage. Add a \target for the old 'Qt for OS X' topic to keep links working for other documentation modules that try to link with the old name. Change-Id: Id33fb0cd985df702a4ae4efb4c5fd428e77d9b85 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* | | QtBase: use printf-style qWarning/qDebug where possible (II)Marc Mutz2016-05-031-4/+5
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The printf-style version of QDebug expands to a lot less code than the std::ostream-style version. Of course, you pay in type safety (but compilers warn about it these days), you cannot stream complex Qt types and streaming QStrings is awkward, but in many cases you actually improve on readability. But the main reason is that something that's not supposed to be executed under normal operation has no business bloating executable code size. This is not an attempt at converting all qWarnings() to printf-style, only the low-hanging fruit. In this second part, replace qWarning() << "" << non-QString with qWarning("..%.", non-QString). QString (and QUrl etc) have special escaping handling when streamed into QDebug, so leave those alone. They also seem to expand to less code than the qPrintable() alternative, so there's no reason to replace them. Saves 2KiB, 3.4KiB, ~750b and ~450b in text size in QtCore, Gui, Network and Widgets, resp., on optimized GCC 5.3 AMD64 builds. Change-Id: Iae6823e543544347e628ca1060d6d51e3b04d3f4 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* | QtGui: eradicate Q_FOREACH loops [rvalues]Marc Mutz2016-02-111-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | ... by replacing them with C++11 range-for loops. This is the simplest of the patch series: Q_FOREACH took a copy, so we do, too. Except we don't, since we're just catching the return value that comes out of the function (RVO). We can't feed the rvalues into range-for, because they are non-const and would thus detach. Change-Id: I457942159015ff153bdfc6d5f031a3f0a0f6e9ac Reviewed-by: Gunnar Sletta <gunnar@sletta.org> Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | Updated license headersJani Heikkinen2016-01-151-14/+20
|/ | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* doc: correct documentation of QT_AUTO_SCREEN_SCALE_FACTOR env varShawn Rutledge2016-01-071-1/+1
| | | | | Change-Id: I4fa57279b23911893a615fe8a3ce9854d0fec971 Reviewed-by: Topi Reiniö <topi.reinio@theqtcompany.com>
* Update QHighDpiScaling internal documentationMorten Johan Sørvig2015-12-021-24/+113
| | | | | | | | | | | Expand section on coordinate systems. Document the AA_EnableHighDpiScaling / AA_DisableHighDpiScaling flags added in commit add58ed. Add some notes for platform plugin work. Change-Id: Ie6fe2d818a88ba784c0ee675fabbd3fc04d64bf1 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
* QtBase: remove explicit function info from qWarning() etcMarc Mutz2015-11-281-1/+1
| | | | | | | | | | | This information is already registered by the QMessageLogger ctor. Where, by dropping the << Q_FUNC_INFO in ostream-style qDebug(), only a string literal remained, converted to printf-style qDebug() on the go. Change-Id: I3f261c98fd7bcfa1fead381a75a82713bb75e6f3 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Update high-DPI scaling enablers.Morten Johan Sørvig2015-11-041-12/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Make it possible to enable and disable both at the environment variable level and at the source code level. This applies to scaling done by Qt using display density information provided by the operating system. Disabling is done with a 'veto' system: both the environment and source code my prevent the other for enabling scaling. This covers use cases of 'my system does not provide correct display metrics' and 'my application needs access to display pixels', respectively. On the environment, scaling is now enabled with QT_AUTO_SCREEN_SCALE_FACTOR=1 and disabled with QT_AUTO_SCREEN_SCALE_FACTOR=0. In source code the corresponding application attributes are AA_EnableHighDpiScaling and AA_DisapleHighDpiScaling. Not setting any of these indicates 'no preference'. The global scale factor set by QT_SCALE_FACTOR is not affected by any if the disablers. Task-number: QTBUG-46615 Change-Id: If18607d4b56ace1914a710e5aa60b2f0968e0010 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com> Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
* Print one warning for the new high DPI variables, not fourThiago Macieira2015-09-241-4/+4
| | | | | | | | | | | | | | | | | | | | | For people with non-empty QT_MESSAGE_PATTERNS, the multiple lines would be unreadable. This is what it showed for me when starting Qt Creator: [1442136.587] qtcreator(82762 82762)(?libQt5Gui.so.5?|QGuiApplicationPrivate::createPlatformIntegration|QGuiApplicationPrivate::createEventDispatcher|QCoreApplication::init|QCoreApplication::QCoreApplication|QGuiApplication::QGuiApplication|QApplication::QApplication|?qtcreator?|?qtcreator?|__libc_start_main): Warning: QT_DEVICE_PIXEL_RATIO is deprecated. Instead use: [1442136.592] qtcreator(82762 82762)(?libQt5Gui.so.5?|QGuiApplicationPrivate::createPlatformIntegration|QGuiApplicationPrivate::createEventDispatcher|QCoreApplication::init|QCoreApplication::QCoreApplication|QGuiApplication::QGuiApplication|QApplication::QApplication|?qtcreator?|?qtcreator?|__libc_start_main): QT_AUTO_SCREEN_SCALE_FACTOR to enable platform plugin controlled per-screen factors. [1442136.592] qtcreator(82762 82762)(?libQt5Gui.so.5?|QGuiApplicationPrivate::createPlatformIntegration|QGuiApplicationPrivate::createEventDispatcher|QCoreApplication::init|QCoreApplication::QCoreApplication|QGuiApplication::QGuiApplication|QApplication::QApplication|?qtcreator?|?qtcreator?|__libc_start_main): QT_SCREEN_SCALE_FACTORS to set per-screen factors. [1442136.593] qtcreator(82762 82762)(?libQt5Gui.so.5?|QGuiApplicationPrivate::createPlatformIntegration|QGuiApplicationPrivate::createEventDispatcher|QCoreApplication::init|QCoreApplication::QCoreApplication|QGuiApplication::QGuiApplication|QApplication::QApplication|?qtcreator?|?qtcreator?|__libc_start_main): QT_SCALE_FACTOR to set the application global scale factor. (and imagine it line-broken in a terminal 140 columns wide) Change-Id: I42e7ef1a481840699a8dffff1406f73dc4d44a41 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
* Compile-time option for disabling high-DPI scalingPaul Olav Tvete2015-08-061-0/+2
| | | | | | | | | | | | Even if QHighDpiScaling::isActive() returns false, there is a small overhead from calling functions and multiplying with 1.0. This change adds a QT_NO_HIGHDPISCALING #ifdef that replaces all conversion functions with empty inline functions. Task-number: QTBUG-46615 Change-Id: Idf85e1700e3adf7f7174c6fa3f5e1d006d74c826 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
* Introduce cross platform high-dpi scalingMorten Johan Sørvig2015-07-301-0/+320
Add a coordinate scaling layer to QtGui, which supports 'devicePixelRatio' type high-dpi on all platforms, in production and also for development and testing purposes. High-DPI scaling is opt-in, by setting environment variables: QT_SCALE_FACTOR - sets a global scale factor QT_AUTO_SCREEN_SCALE_FACTOR - sets per-screen scale factors, where the scale factors are provided by the platform plugin. This QtGui scaling can be used instead of or in addition to scaling done by the window system. This distinction is not visible to applications [when they use Qt API], which will see a change in the value returned by the devicePixelRatio() accessors as usual. Introduce a new (private to Qt) coordinate system: native pixels. The coordinate system stack now looks like: device-independent pixels (app, upper parts of Qt) native pixels (lower parts of Qt Gui, platform plugins) device pixels (backing stores and OpenGL) Add private QHighDpi namespace with scaling functions that convert between device-independent pixels and native pixels: T toNativePixels(T, QWindow *); T fromNativePixels(T, QWindow *); Add scaling calls the QWindow (and friends) cross-platform implementation, around the calls to QPlatformWindow functions. QPlatformWindow now uses native coordinates - platform code remains largely unchanged since native coordinates are window system coordinates. QWindow now uses (possibly) scaled coordinates. This means that platform plugins no longer can rely on QWindow::geometry() and related functions. QPlatformWindow::windowGeometry() and other convenience functions have been added for use when the platform plugin needs to convert scaled geometry to native geometry. Add Qt::AA_NoHighDpiScaling, which can be use to disable any scaling in QtGui, effectively ignoring the environment variables. (Note that this does not disable any scaling done by the window system.) Contributions from Friedemann and Paul. Task-number: QTBUG-46615 Change-Id: I673bbd69c130e73b13cce83be11bfb28f580bf60 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>