diff options
author | Ken Moore <ken@ixsystems.com> | 2017-05-03 09:30:19 -0400 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2017-05-03 09:30:19 -0400 |
commit | bd5105d652b0bea53da267297bfb5500c57a7e52 (patch) | |
tree | e832e88ce8e9332b81316ee1b03a448c9eea178b | |
parent | Merge branch 'master' of github.com:trueos/lumina (diff) | |
download | lumina-bd5105d652b0bea53da267297bfb5500c57a7e52.tar.gz lumina-bd5105d652b0bea53da267297bfb5500c57a7e52.tar.bz2 lumina-bd5105d652b0bea53da267297bfb5500c57a7e52.zip |
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.
-rw-r--r-- | src-qt5/core/lumina-desktop/LSession.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
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<QScreen*> scrns = QApplication::screens(); + for(int i=0; i<scrns.length(); i++){ + qDebug() << "Check Screen DPI:" << scrns[i]->name(); + 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(){ |