OS/2, eCS & ArcaOS - Technical > Programming

Qt6 Development

<< < (108/153) > >>

Paul Smedley:
Hi Alex - this is all very helpful, and confirms that my current 'fix' is indeed a workaround. Qt already uses DevQueryCaps (https://github.com/psmedley/qt6-base-os2/blob/main/src/plugins/platforms/os2/qos2screen.cpp#L69), but seems something changed between Qt5 and Qt6 in that that DPI value is now also used for screen scaling, which was causing the menus to be out of position.

So at some point, I need to find the window scaling code, and put in place a better fix for OS/2 so that we don't scale the window, but we do scale the fonts!

Paul Smedley:
Font scaling should be fixed with https://github.com/psmedley/qt6-base-os2/commit/e54d5f1f160f9d5798f2e483ea8f8e7e9014df77 - new qos2.dll link is in the testing thread.

I got lucky with browsing github during my lunch break today, and found https://github.com/psmedley/qt6-base-os2/blob/main/src/gui/kernel/qhighdpiscaling.cpp - searching for references to this led me to a commit which added logicalBaseDPI on other platforms - and voila ;) seems logicalBaseDPI defaulted to 96,96 is not set - which was different to the screen/font dpi of 120,120 - so windows got scaled (which we didn't wnat/need).

Lars:

--- Quote from: Paul Smedley on January 30, 2023, 08:45:36 am ---Font scaling should be fixed with https://github.com/psmedley/qt6-base-os2/commit/e54d5f1f160f9d5798f2e483ea8f8e7e9014df77 - new qos2.dll link is in the testing thread.

I got lucky with browsing github during my lunch break today, and found https://github.com/psmedley/qt6-base-os2/blob/main/src/gui/kernel/qhighdpiscaling.cpp - searching for references to this led me to a commit which added logicalBaseDPI on other platforms - and voila ;) seems logicalBaseDPI defaulted to 96,96 is not set - which was different to the screen/font dpi of 120,120 - so windows got scaled (which we didn't wnat/need).

--- End quote ---

I don't get your explanation. From what I can see, QPlatformScreen::logicalDpi is not properly implemented in your github repo. It just returns QPlatfromScreen::logicalBaseDpi and therefore a 1:1 scaling between "logical" and "physical" for x and also y coordinates.
The BWW repo has an implementation for QPlatformScreen::logicalDpi that is more complex and will lead to a different scaling, at least under certain conditions.
Additionally: Looks like you can fumble around with environment var: QT_FONT_DPI to set your logical DPI. Maybe you can try "set QT_FONT_DPI=120" and see if that makes a difference. At least you can experiment with it ...

And I think it seconds what Alex said: QScreen:: is about Windows scaling and QPlatformScreen:: seems to center around font scaling, at least according to the comments in file qplatformscreen.cpp, at least the BWW repo has this:


--- Code: ---/*!
    Reimplement this function in subclass to return the logical horizontal
    and vertical dots per inch metrics of the screen.
    The logical dots per inch metrics are used by QFont to convert point sizes
    to pixel sizes.
    The default implementation uses the screen pixel size and physical size to
    compute the metrics.
    \sa physicalSize
*/
QDpi QPlatformScreen::logicalDpi() const
{
    QSizeF ps = physicalSize();
    QSize s = geometry().size();

    if (qFuzzyIsNull(ps.width()) || qFuzzyIsNull(ps.height()))
        return QDpi(96, 96);
    return QDpi(25.4 * s.width() / ps.width(),
                25.4 * s.height() / ps.height());
}

--- End code ---

Paul Smedley:
This commit is what have me the idea... https://codereview.qt-project.org/c/qt/qtbase/+/157174/

This bug report also pretty much reflects what we were seeing  https://bugreports.qt.io/plugins/servlet/mobile#issue/QTBUG-87035

Lars:
But does the change go against QScreen or against QPlatformscreen?
I have to admit that I got lost. They are inventing 2 different functions "logicalBaseDPI" and "logicalDPI" that return the exact same value (and sorry, yes, that seemingly changed from QT5 to QT6) and then they introduce them in two different classes. It's also unclear what is now physical and what is virtual. How could you compute a physical DPI value without the ability to query the screen size as physical horizontal and vertical lengths?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version