From bd5105d652b0bea53da267297bfb5500c57a7e52 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 3 May 2017 09:30:19 -0400 Subject: Clean up how the high-DPI settings for lumina are detected/enabled. Now whenever a screen is added/changed it will print out the physical/logical DPI values into the log, and if a logicalDPI (X or Y) is greater than 110 it will enabled the Qt5 auto-scale functionality. Note: My 1080p laptop monitor has a logical DPI of ~96, but a physical DPI of ~150 and the Qt5 auto-scale stuff is based on physical DPI (so things got massive on a normal-res screen). I am leaving the DPI print-out in the logs for now so that if we run into any other monitors where the logicalDPI>110 rule is invalid we can view/tweak the rule really easily. --- src-qt5/core/lumina-desktop/LSession.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src-qt5/core/lumina-desktop/LSession.cpp') diff --git a/src-qt5/core/lumina-desktop/LSession.cpp b/src-qt5/core/lumina-desktop/LSession.cpp index bdc4f4d3..12dd059f 100644 --- a/src-qt5/core/lumina-desktop/LSession.cpp +++ b/src-qt5/core/lumina-desktop/LSession.cpp @@ -168,7 +168,6 @@ void LSession::setupSession(){ connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(watcherChange(QString)) ); connect(this, SIGNAL(aboutToQuit()), this, SLOT(SessionEnding()) ); if(DEBUG){ qDebug() << " - Init Finished:" << timer->elapsed(); delete timer;} - setenv("QT_AUTO_SCREEN_SCALE_FACTOR","1",true); //Enable the automatic Qt5 DPI scaling for apps for(int i=0; i<4; i++){ LSession::processEvents(); } //Again, just a few event loops here so thing can settle before we close the splash screen //launchStartupApps(); QTimer::singleShot(500, this, SLOT(launchStartupApps()) ); @@ -449,6 +448,19 @@ void LSession::updateDesktops(){ //Make sure all the background windows are registered on the system as virtual roots QTimer::singleShot(100,this, SLOT(registerDesktopWindows())); + //Determine if any High-DPI screens are available and enable auto-scaling as needed + QList scrns = QApplication::screens(); + for(int i=0; iname(); + qDebug() << " -- Physical DPI:" << scrns[i]->physicalDotsPerInchX() << "x" << scrns[i]->physicalDotsPerInchY(); + qDebug() << " -- Logical DPI:" << scrns[i]->logicalDotsPerInchX() << "x" << scrns[i]->logicalDotsPerInchY(); + if(scrns[i]->logicalDotsPerInchX() > 110 || scrns[i]->logicalDotsPerInchY()>110){ //4K is ~196, 3K is ~150 + setenv("QT_AUTO_SCREEN_SCALE_FACTOR","1",true); //Enable the automatic Qt5 DPI scaling for apps + break; + }else if(i==(scrns.length()-1)){ + unsetenv("QT_AUTO_SCREEN_SCALE_FACTOR"); + } + } } void LSession::registerDesktopWindows(){ -- cgit