fix(gtk4): derive the device-pixel factor from GTK's two sizes, and four more review fixes
The factor both the viewport and every forwarded input coordinate use came from `gtk_widget_get_scale_factor()`, which GTK documents as "the next higher integer value" under fractional scaling. It is now derived by `DeviceMapping::from_sizes()` from the widget's logical allocation and the device size `GtkGLArea::resize` reports -- the viewport that signal's default handler sets with `glViewport(0, 0, w, h)` -- so the viewport, the renderer and input are one value by construction. The public `int scale_factor()` became `f32 device_scale()`. `kSurfacePixelsPerNotch` is now 100.0 and documented as a *calibration* with a stated assumption, not a unit conversion attributed to axis_value120/Qt. `::unrealize` releases the renderer unconditionally, after making the context current: the error it used to check says nothing about whether GL names exist (creation failure is the path that returns before a renderer is built), and skipping the release left the deletes to the wrapper's destructor, with no context. The drag anchor caches its press point and offsets in logical pixels and scales the difference by the factor in force now, so a scale change mid-drag cannot become a phantom pan. The demo stops its producer in `on_teardown`, before destroying the window whose renderer the stream feeds.
This commit is contained in:
1 parent
36cd3421f3
commit
0445a1861b
6 files changed
+417
-137
No files matched your search
@@ -57,9 +57,11 @@ endif()
|
||||
# to exist for it to compile.
|
||||
target_sources(plot_tests PRIVATE test_qt_pointer.cpp)
|
||||
|
||||
# Same for the GTK adapter's input conversion (see adapters/gtk4/gtk_input.hpp):
|
||||
# the wheel's unit and sign and the modifier mask are this project's logic, and a
|
||||
# headless X server can only deliver the discrete-wheel branch of it.
|
||||
# Same for the GTK adapter's input translation (see adapters/gtk4/gtk_input.hpp):
|
||||
# the device-pixel mapping it derives from GTK's two sizes, the pixel space its drag
|
||||
# anchor is kept in, the wheel's unit and sign and the modifier mask are this
|
||||
# project's logic, and a headless X server at an integer scale can exercise only
|
||||
# part of it.
|
||||
target_sources(plot_tests PRIVATE test_gtk_input.cpp)
|
||||
target_include_directories(plot_tests PRIVATE "${CMAKE_SOURCE_DIR}/adapters")
|
||||
|
||||
|
||||
Reference in new issue
Block a user