Details
-
Suggestion
-
Resolution: Incomplete
-
Not Evaluated
-
None
-
5.11.2
-
None
Description
I develop a screen capturing application (SimpleScreenRecorder) which allows the user to select a rectangular capture region using the mouse. Originally I did this using the standard Qt functions: QMouseEvent::globalX/Y to get the global mouse position, and QWidget::setGeometry to place a selection rectangle at the correct position on screen (like QRubberBand).
Users have reported that this approach is completely broken on high-DPI environments with Qt5, because obviously the scaled coordinates that Qt provides don't match the coordinates of the native X11 screen capturing API.
I have tried to write workarounds to basically revert the transformations that Qt is applying, but I have not been able to find a reliable method that produces the correct result in all situations, in particular when dealing with multi-monitor setups with different scale factors per monitor, and when the selection rectangle overlaps the boundary between two monitors. The way Qt handles this is undocumented and in some cases buggy (see QTBUG-71302).
I would like to request a window flag/attribute that disables the Qt high DPI system on a per-window basis. Basically something which sets the devicePixelRatio to 1 for a single window without affecting the other ones. I think this would eliminate all of these issues.
Without such an option, my only alternative is to forcibly disable high DPI support completely by overriding the corresponding environment variables (which users won't like), or revert to native X11 calls to create and draw the selection rectangle window manually (which is a huge pain).